VirtualBox

Changeset 39340 in vbox


Ignore:
Timestamp:
Nov 16, 2011 5:59:23 PM (13 years ago)
Author:
vboxsync
Message:

Started refactoring disk support.

Location:
trunk/src/VBox/Devices/PC/BIOS-new
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS-new/ahci.c

    r38997 r39340  
    2929#include "vds.h"
    3030
    31 #define VBOX_AHCI_DEBUG         0
     31#define VBOX_AHCI_DEBUG         1
    3232#define VBOX_AHCI_INT13_DEBUG   0
    3333
     
    672672
    673673    ebda_seg  = read_word(0x0040, 0x000E);
    674     ahci_seg   = read_word(ebda_seg, (uint16_t)&EbdaData->ahci_seg);
     674    ahci_seg  = read_word(ebda_seg, (uint16_t)&EbdaData->ahci_seg);
    675675    u16IoBase = read_word(ahci_seg, (uint16_t)&AhciData->iobase);
    676676    old_disks = read_byte(ahci_seg, (uint16_t)&AhciData->cHardDisksOld);
     
    766766
    767767            // Set nb of sector transferred
    768             SET_AL(read_word(ebda_seg, (uint16_t)&EbdaData->ata.trsfsectors));
     768            SET_AL(read_word(ebda_seg, (uint16_t)&EbdaData->bdisk.trsfsectors));
    769769
    770770            if (status != 0)
     
    869869                else
    870870                {
    871                     write_word(ebda_seg,&EbdaData->ata.devices[device].blksize,count * 0x200);
     871                    write_word(ebda_seg,&EbdaData->bdisk.devices[device].blksize,count * 0x200);
    872872                    status=ata_cmd_data_in(device, ATA_CMD_READ_MULTIPLE, count, 0, 0, 0, lba, segment, offset);
    873                     write_word(ebda_seg,&EbdaData->ata.devices[device].blksize,0x200);
     873                    write_word(ebda_seg,&EbdaData->bdisk.devices[device].blksize,0x200);
    874874                }
    875875            }
     
    882882            }
    883883
    884             count=read_word(ebda_seg, &EbdaData->ata.trsfsectors);
     884            count=read_word(ebda_seg, &EbdaData->bdisk.trsfsectors);
    885885            write_word(DS, SI+(uint16_t)&Int13Ext->count, count);
    886886
     
    943943
    944944                write_word(DS, SI+(uint16_t)&Int13DPT->dpte_segment, ebda_seg);
    945                 write_word(DS, SI+(uint16_t)&Int13DPT->dpte_offset, &EbdaData->ata.dpte);
     945                write_word(DS, SI+(uint16_t)&Int13DPT->dpte_offset, &EbdaData->bdisk.dpte);
    946946
    947947                // Fill in dpte
    948948                channel = device / 2;
    949                 iobase1 = read_word(ebda_seg, &EbdaData->ata.channels[channel].iobase1);
    950                 iobase2 = read_word(ebda_seg, &EbdaData->ata.channels[channel].iobase2);
    951                 irq = read_byte(ebda_seg, &EbdaData->ata.channels[channel].irq);
    952                 mode = read_byte(ebda_seg, &EbdaData->ata.devices[device].mode);
    953                 translation = read_byte(ebda_seg, &EbdaData->ata.devices[device].translation);
     949                iobase1 = read_word(ebda_seg, &EbdaData->bdisk.channels[channel].iobase1);
     950                iobase2 = read_word(ebda_seg, &EbdaData->bdisk.channels[channel].iobase2);
     951                irq = read_byte(ebda_seg, &EbdaData->bdisk.channels[channel].irq);
     952                mode = read_byte(ebda_seg, &EbdaData->bdisk.devices[device].mode);
     953                translation = read_byte(ebda_seg, &EbdaData->bdisk.devices[device].translation);
    954954
    955955                options  = (translation==ATA_TRANSLATION_NONE?0:1<<3); // chs translation
     
    959959                options |= (translation==ATA_TRANSLATION_RECHS?3:0<<9);
    960960
    961                 write_word(ebda_seg, &EbdaData->ata.dpte.iobase1, iobase1);
    962                 write_word(ebda_seg, &EbdaData->ata.dpte.iobase2, iobase2);
    963                 //write_byte(ebda_seg, &EbdaData->ata.dpte.prefix, (0xe | /*(device % 2))<<4*/ );
    964                 write_byte(ebda_seg, &EbdaData->ata.dpte.unused, 0xcb );
    965                 write_byte(ebda_seg, &EbdaData->ata.dpte.irq, irq );
    966                 write_byte(ebda_seg, &EbdaData->ata.dpte.blkcount, 1 );
    967                 write_byte(ebda_seg, &EbdaData->ata.dpte.dma, 0 );
    968                 write_byte(ebda_seg, &EbdaData->ata.dpte.pio, 0 );
    969                 write_word(ebda_seg, &EbdaData->ata.dpte.options, options);
    970                 write_word(ebda_seg, &EbdaData->ata.dpte.reserved, 0);
    971                 write_byte(ebda_seg, &EbdaData->ata.dpte.revision, 0x11);
     961                write_word(ebda_seg, &EbdaData->bdisk.dpte.iobase1, iobase1);
     962                write_word(ebda_seg, &EbdaData->bdisk.dpte.iobase2, iobase2);
     963                //write_byte(ebda_seg, &EbdaData->bdisk.dpte.prefix, (0xe | /*(device % 2))<<4*/ );
     964                write_byte(ebda_seg, &EbdaData->bdisk.dpte.unused, 0xcb );
     965                write_byte(ebda_seg, &EbdaData->bdisk.dpte.irq, irq );
     966                write_byte(ebda_seg, &EbdaData->bdisk.dpte.blkcount, 1 );
     967                write_byte(ebda_seg, &EbdaData->bdisk.dpte.dma, 0 );
     968                write_byte(ebda_seg, &EbdaData->bdisk.dpte.pio, 0 );
     969                write_word(ebda_seg, &EbdaData->bdisk.dpte.options, options);
     970                write_word(ebda_seg, &EbdaData->bdisk.dpte.reserved, 0);
     971                write_byte(ebda_seg, &EbdaData->bdisk.dpte.revision, 0x11);
    972972
    973973                checksum=0;
    974974                for (i=0; i<15; i++)
    975                     checksum+=read_byte(ebda_seg, (&EbdaData->ata.dpte) + i);
     975                    checksum+=read_byte(ebda_seg, (&EbdaData->bdisk.dpte) + i);
    976976
    977977                checksum = -checksum;
    978                 write_byte(ebda_seg, &EbdaData->ata.dpte.checksum, checksum);
     978                write_byte(ebda_seg, &EbdaData->bdisk.dpte.checksum, checksum);
    979979            }
    980980
     
    986986
    987987                channel = device / 2;
    988                 iface = read_byte(ebda_seg, &EbdaData->ata.channels[channel].iface);
    989                 iobase1 = read_word(ebda_seg, &EbdaData->ata.channels[channel].iobase1);
     988                iface = read_byte(ebda_seg, &EbdaData->bdisk.channels[channel].iface);
     989                iobase1 = read_word(ebda_seg, &EbdaData->bdisk.channels[channel].iobase1);
    990990
    991991                write_word(DS, SI+(uint16_t)&Int13DPT->size, 0x42);
  • trunk/src/VBox/Devices/PC/BIOS-new/ata.c

    r38848 r39340  
    8383    uint16_t        ebda_seg=read_word(0x0040,0x000E);
    8484    uint8_t         channel, device;
    85     ata_t __far    *AtaData;
    86    
    87     AtaData = ebda_seg :> &EbdaData->ata;
     85    bio_dsk_t __far *AtaData;
     86   
     87    AtaData = ebda_seg :> &EbdaData->bdisk;
    8888   
    8989    // Channels info init.
     
    136136    uint16_t        max;
    137137    uint16_t        pdelay;
    138     ata_t __far    *AtaData;
    139    
    140     AtaData = ebda_seg :> &EbdaData->ata;
     138    bio_dsk_t __far *AtaData;
     139   
     140    AtaData = ebda_seg :> &EbdaData->bdisk;
    141141    channel = device / 2;
    142142    slave = device % 2;
     
    214214    uint8_t         channel, slave;
    215215    uint8_t         status, current, mode;
    216     ata_t __far    *AtaData;
    217    
    218     AtaData = ebda_seg :> &EbdaData->ata;
     216    bio_dsk_t __far *AtaData;
     217   
     218    AtaData = ebda_seg :> &EbdaData->bdisk;
    219219   
    220220    channel = device / 2;
     
    364364    uint8_t         hdcount, cdcount, device, type;
    365365    uint8_t         buffer[0x0200];
    366     ata_t __far    *AtaData;
    367    
    368     AtaData = ebda_seg :> &EbdaData->ata;
     366    bio_dsk_t __far *AtaData;
     367   
     368    AtaData = ebda_seg :> &EbdaData->bdisk;
    369369
    370370#if BX_MAX_ATA_INTERFACES > 0
     
    697697                          uint16_t head, uint16_t sector, uint32_t lba, char __far *buffer)
    698698{
    699     uint16_t    ebda_seg = read_word(0x0040,0x000E);
    700     uint16_t    iobase1, iobase2, blksize;
    701     uint8_t     channel, slave;
    702     uint8_t     status, current, mode;
    703     ata_t __far *AtaData;
    704    
    705     AtaData = ebda_seg :> &EbdaData->ata;
     699    uint16_t        ebda_seg = read_word(0x0040,0x000E);
     700    uint16_t        iobase1, iobase2, blksize;
     701    uint8_t         channel, slave;
     702    uint8_t         status, current, mode;
     703    bio_dsk_t __far *AtaData;
     704   
     705    AtaData = ebda_seg :> &EbdaData->bdisk;
    706706   
    707707    channel = device / 2;
     
    840840                        uint16_t header, uint32_t length, uint8_t inout, char __far *buffer)
    841841{
    842     uint16_t    ebda_seg = read_word(0x0040,0x000E);
    843     uint16_t    iobase1, iobase2;
    844     uint16_t    lcount, lbefore, lafter, count;
    845     uint8_t     channel, slave;
    846     uint8_t     status, mode, lmode;
    847     uint32_t    transfer;
    848     ata_t __far *AtaData;
    849 
    850     AtaData = ebda_seg :> &EbdaData->ata;
     842    uint16_t        ebda_seg = read_word(0x0040,0x000E);
     843    uint16_t        iobase1, iobase2;
     844    uint16_t        lcount, lbefore, lafter, count;
     845    uint8_t         channel, slave;
     846    uint8_t         status, mode, lmode;
     847    uint32_t        transfer;
     848    bio_dsk_t __far *AtaData;
     849
     850    AtaData = ebda_seg :> &EbdaData->bdisk;
    851851
    852852    channel = device / 2;
     
    10651065{
    10661066    uint16_t        ebda_seg = read_word(0x0040,0x000E);
    1067     ata_t __far    *AtaData;
    1068    
    1069     AtaData = ebda_seg :> &EbdaData->ata;
     1067    bio_dsk_t __far *AtaData;
     1068   
     1069    AtaData = ebda_seg :> &EbdaData->bdisk;
    10701070   
    10711071    if (device >= BX_MAX_ATA_DEVICES)
  • trunk/src/VBox/Devices/PC/BIOS-new/biosint.h

    r38997 r39340  
    3939 */
    4040
     41
     42/* Compile-time assertion macro. */
     43#define ct_assert(a)    extern int ct_ass_arr[!!(a) == 1];
    4144
    4245/* For functions called from assembly code. */
  • trunk/src/VBox/Devices/PC/BIOS-new/disk.c

    r38808 r39340  
    8888   
    8989    // Get the ata channel
    90     device = ebda_data->ata.hdidmap[GET_ELDL()-0x80];
     90    device = ebda_data->bdisk.hdidmap[GET_ELDL()-0x80];
    9191   
    9292    // basic check : device has to be valid
     
    136136#endif
    137137        {
    138             nlc   = ebda_data->ata.devices[device].lchs.cylinders;
    139             nlh   = ebda_data->ata.devices[device].lchs.heads;
    140             nlspt = ebda_data->ata.devices[device].lchs.spt;
     138            nlc   = ebda_data->bdisk.devices[device].lchs.cylinders;
     139            nlh   = ebda_data->bdisk.devices[device].lchs.heads;
     140            nlspt = ebda_data->bdisk.devices[device].lchs.spt;
    141141        }
    142142#ifdef VBOX_WITH_SCSI
     
    164164#endif
    165165        {
    166             nph   = ebda_data->ata.devices[device].pchs.heads;
    167             npspt = ebda_data->ata.devices[device].pchs.spt;
     166            nph   = ebda_data->bdisk.devices[device].pchs.heads;
     167            npspt = ebda_data->bdisk.devices[device].pchs.spt;
    168168        }
    169169#ifdef VBOX_WITH_SCSI
     
    196196#endif
    197197            {
    198                 ebda_data->ata.devices[device].blksize = count * 0x200;
     198                ebda_data->bdisk.devices[device].blksize = count * 0x200;
    199199                status=ata_cmd_data_in(device, ATA_CMD_READ_MULTIPLE, count, cylinder, head, sector, lba, MK_FP(ES, BX));
    200                 ebda_data->ata.devices[device].blksize = 0x200;
     200                ebda_data->bdisk.devices[device].blksize = 0x200;
    201201            }
    202202        } else {
     
    210210
    211211        // Set nb of sector transferred
    212         SET_AL(ebda_data->ata.trsfsectors);
     212        SET_AL(ebda_data->bdisk.trsfsectors);
    213213       
    214214        if (status != 0) {
     
    234234#endif
    235235        {
    236             nlc   = ebda_data->ata.devices[device].lchs.cylinders;
    237             nlh   = ebda_data->ata.devices[device].lchs.heads;
    238             nlspt = ebda_data->ata.devices[device].lchs.spt;
     236            nlc   = ebda_data->bdisk.devices[device].lchs.cylinders;
     237            nlh   = ebda_data->bdisk.devices[device].lchs.heads;
     238            nlspt = ebda_data->bdisk.devices[device].lchs.spt;
    239239        }
    240240#ifdef VBOX_WITH_SCSI
     
    247247#endif
    248248
    249         count = ebda_data->ata.hdcount;
     249        count = ebda_data->bdisk.hdcount;
    250250        /* Maximum cylinder number is just one less than the number of cylinders. */
    251251        nlc = nlc - 1; /* 0 based , last sector not used */
     
    266266
    267267        // Read the status from controller
    268         status = inb(ebda_data->ata.channels[device/2].iobase1 + ATA_CB_STAT);
     268        status = inb(ebda_data->bdisk.channels[device/2].iobase1 + ATA_CB_STAT);
    269269        if ( (status & ( ATA_CB_STAT_BSY | ATA_CB_STAT_RDY )) == ATA_CB_STAT_RDY ) {
    270270            goto int13_success;
     
    282282#endif
    283283        {
    284             npc   = ebda_data->ata.devices[device].pchs.cylinders;
    285             nph   = ebda_data->ata.devices[device].pchs.heads;
    286             npspt = ebda_data->ata.devices[device].pchs.spt;
     284            npc   = ebda_data->bdisk.devices[device].pchs.cylinders;
     285            nph   = ebda_data->bdisk.devices[device].pchs.heads;
     286            npspt = ebda_data->bdisk.devices[device].pchs.spt;
    287287        }
    288288#ifdef VBOX_WITH_SCSI
     
    364364   
    365365    // Get the ata channel
    366     device = ebda_data->ata.hdidmap[GET_ELDL()-0x80];
     366    device = ebda_data->bdisk.hdidmap[GET_ELDL()-0x80];
    367367   
    368368    // basic check : device has to be valid
     
    412412        else
    413413#endif
    414         if (lba >= ebda_data->ata.devices[device].sectors) {
     414        if (lba >= ebda_data->bdisk.devices[device].sectors) {
    415415              BX_INFO("%s: function %02x. LBA out of range\n", __func__, GET_AH());
    416416              goto int13x_fail;
     
    431431                    status=ata_cmd_data_in(device, ATA_CMD_READ_SECTORS_EXT, count, 0, 0, 0, lba, MK_FP(segment, offset));
    432432                else {
    433                     ebda_data->ata.devices[device].blksize = count * 0x200;
     433                    ebda_data->bdisk.devices[device].blksize = count * 0x200;
    434434                    status=ata_cmd_data_in(device, ATA_CMD_READ_MULTIPLE, count, 0, 0, 0, lba, MK_FP(segment, offset));
    435                     ebda_data->ata.devices[device].blksize = 0x200;
     435                    ebda_data->bdisk.devices[device].blksize = 0x200;
    436436                }
    437437            }
     
    449449        }
    450450
    451         count = ebda_data->ata.trsfsectors;
     451        count = ebda_data->bdisk.trsfsectors;
    452452        i13_ext->count = count;
    453453       
     
    487487#endif
    488488            {
    489                 npc     = ebda_data->ata.devices[device].pchs.cylinders;
    490                 nph     = ebda_data->ata.devices[device].pchs.heads;
    491                 npspt   = ebda_data->ata.devices[device].pchs.spt;
    492                 lba     = ebda_data->ata.devices[device].sectors;
    493                 blksize = ebda_data->ata.devices[device].blksize;
     489                npc     = ebda_data->bdisk.devices[device].pchs.cylinders;
     490                nph     = ebda_data->bdisk.devices[device].pchs.heads;
     491                npspt   = ebda_data->bdisk.devices[device].pchs.spt;
     492                lba     = ebda_data->bdisk.devices[device].sectors;
     493                blksize = ebda_data->bdisk.devices[device].blksize;
    494494            }
    495495#ifdef VBOX_WITH_SCSI
     
    520520            dpt->size = 0x1e;
    521521            dpt->dpte_segment = ebda_seg;
    522             dpt->dpte_offset  = (uint16_t)&EbdaData->ata.dpte;
     522            dpt->dpte_offset  = (uint16_t)&EbdaData->bdisk.dpte;
    523523           
    524524            // Fill in dpte
    525525            channel = device / 2;
    526             iobase1 = ebda_data->ata.channels[channel].iobase1;
    527             iobase2 = ebda_data->ata.channels[channel].iobase2;
    528             irq     = ebda_data->ata.channels[channel].irq;
    529             mode    = ebda_data->ata.devices[device].mode;
    530             translation = ebda_data->ata.devices[device].translation;
     526            iobase1 = ebda_data->bdisk.channels[channel].iobase1;
     527            iobase2 = ebda_data->bdisk.channels[channel].iobase2;
     528            irq     = ebda_data->bdisk.channels[channel].irq;
     529            mode    = ebda_data->bdisk.devices[device].mode;
     530            translation = ebda_data->bdisk.devices[device].translation;
    531531           
    532532            options  = (translation == ATA_TRANSLATION_NONE ? 0 : 1 << 3);  // chs translation
     
    536536            options |= (translation==ATA_TRANSLATION_RECHS ? 3 : 0 << 9);
    537537           
    538             ebda_data->ata.dpte.iobase1  = iobase1;
    539             ebda_data->ata.dpte.iobase2  = iobase2;
    540             ebda_data->ata.dpte.prefix   = (0xe | (device % 2)) << 4;
    541             ebda_data->ata.dpte.unused   = 0xcb;
    542             ebda_data->ata.dpte.irq      = irq;
    543             ebda_data->ata.dpte.blkcount = 1;
    544             ebda_data->ata.dpte.dma      = 0;
    545             ebda_data->ata.dpte.pio      = 0;
    546             ebda_data->ata.dpte.options  = options;
    547             ebda_data->ata.dpte.reserved = 0;
    548             ebda_data->ata.dpte.revision = 0x11;
     538            ebda_data->bdisk.dpte.iobase1  = iobase1;
     539            ebda_data->bdisk.dpte.iobase2  = iobase2;
     540            ebda_data->bdisk.dpte.prefix   = (0xe | (device % 2)) << 4;
     541            ebda_data->bdisk.dpte.unused   = 0xcb;
     542            ebda_data->bdisk.dpte.irq      = irq;
     543            ebda_data->bdisk.dpte.blkcount = 1;
     544            ebda_data->bdisk.dpte.dma      = 0;
     545            ebda_data->bdisk.dpte.pio      = 0;
     546            ebda_data->bdisk.dpte.options  = options;
     547            ebda_data->bdisk.dpte.reserved = 0;
     548            ebda_data->bdisk.dpte.revision = 0x11;
    549549           
    550550            checksum = 0;
    551551            for (i=0; i<15; i++)
    552                 checksum += read_byte(ebda_seg, (uint16_t)&EbdaData->ata.dpte + i);
     552                checksum += read_byte(ebda_seg, (uint16_t)&EbdaData->bdisk.dpte + i);
    553553            checksum = -checksum;
    554             ebda_data->ata.dpte.checksum = checksum;
     554            ebda_data->bdisk.dpte.checksum = checksum;
    555555        }
    556556
     
    561561
    562562            channel = device / 2;
    563             iface   = ebda_data->ata.channels[channel].iface;
    564             iobase1 = ebda_data->ata.channels[channel].iobase1;
     563            iface   = ebda_data->bdisk.channels[channel].iface;
     564            iobase1 = ebda_data->bdisk.channels[channel].iobase1;
    565565           
    566566            dpt->size       = 0x42;
  • trunk/src/VBox/Devices/PC/BIOS-new/ebda.h

    r38848 r39340  
    6363
    6464/* Generic storage device types. Bit of a misnomer! */
    65 #define ATA_TYPE_NONE     0x00
    66 #define ATA_TYPE_UNKNOWN  0x01
    67 #define ATA_TYPE_ATA      0x02
    68 #define ATA_TYPE_ATAPI    0x03
    69 #define ATA_TYPE_SCSI     0x04 // SCSI disk
    70 
    71 #define ATA_DEVICE_NONE  0x00
    72 #define ATA_DEVICE_HD    0xFF
    73 #define ATA_DEVICE_CDROM 0x05
     65#define ATA_TYPE_NONE       0x00
     66#define ATA_TYPE_UNKNOWN    0x01
     67#define ATA_TYPE_ATA        0x02
     68#define ATA_TYPE_ATAPI      0x03
     69#define ATA_TYPE_SCSI       0x04 // SCSI disk
     70
     71#define ATA_DEVICE_NONE     0x00
     72#define ATA_DEVICE_HD       0xFF
     73#define ATA_DEVICE_CDROM    0x05
    7474
    7575
    7676#if 1 //BX_USE_ATADRV
    7777
    78 //@todo: does the struct really have to be misaligned?
    79 #pragma pack(0)
    80 
    81 typedef struct {
    82     uint16_t    heads;      // # heads
    83     uint16_t    cylinders;  // # cylinders
    84     uint16_t    spt;        // # sectors / track
    85 } chs_t;
    86 
    87   // DPTE definition
     78/* Note: The DPTE and FDPT structures are industry standards and
     79 * may not be modified. The other disk-related structures are
     80 * internal to the BIOS.
     81 */
     82
     83/* Translated DPT (Device Parameter Table). */
    8884typedef struct {
    8985    uint16_t    iobase1;
     
    10197} dpte_t;
    10298
    103 typedef struct {
    104     uint8_t     iface;        // ISA or PCI
    105     uint16_t    iobase1;      // IO Base 1
    106     uint16_t    iobase2;      // IO Base 2
    107     uint8_t     irq;          // IRQ
    108 } ata_channel_t;
    109 
    110 typedef struct {
    111     uint8_t     type;         // Detected type of ata (ata/atapi/none/unknown/scsi)
    112     uint8_t     device;       // Detected type of attached devices (hd/cd/none)
    113     uint8_t     removable;    // Removable device flag
    114     uint8_t     lock;         // Locks for removable devices
    115     uint8_t     mode;         // transfer mode : PIO 16/32 bits - IRQ - ISADMA - PCIDMA
    116     uint16_t    blksize;      // block size
    117 
    118     uint8_t     translation;  // type of translation
    119     chs_t       lchs;         // Logical CHS
    120     chs_t       pchs;         // Physical CHS
    121 
    122     uint32_t    sectors;      // Total sectors count
    123 } ata_device_t;
    124 
    125 typedef struct {
    126     // ATA channels info
    127     ata_channel_t channels[BX_MAX_ATA_INTERFACES];
    128 
    129     // ATA devices info
    130     ata_device_t  devices[BX_MAX_ATA_DEVICES];
    131     //
    132     // map between (bios hd id - 0x80) and ata channels and scsi disks.
    133     uint8_t     hdcount, hdidmap[BX_MAX_STORAGE_DEVICES];
    134 
    135     // map between (bios cd id - 0xE0) and ata channels
    136     uint8_t     cdcount, cdidmap[BX_MAX_STORAGE_DEVICES];
    137 
    138     // Buffer for DPTE table
    139     dpte_t      dpte;
    140 
    141     // Count of transferred sectors and bytes
    142     uint16_t    trsfsectors;
    143     uint32_t    trsfbytes;
    144 } ata_t;
    145 
    146 #if BX_ELTORITO_BOOT
    147   // ElTorito Device Emulation data
    148 typedef struct {
    149     uint8_t     active;
    150     uint8_t     media;
    151     uint8_t     emulated_drive;
    152     uint8_t     controller_index;
    153     uint16_t    device_spec;
    154     uint32_t    ilba;
    155     uint16_t    buffer_segment;
    156     uint16_t    load_segment;
    157     uint16_t    sector_count;
    158 
    159     // Virtual device
    160     chs_t       vdevice;
    161 } cdemu_t;
    162 #endif // BX_ELTORITO_BOOT
    163 
    164 #ifdef VBOX_WITH_SCSI
    165 typedef struct {
    166     // I/O port this device is attached to.
    167     uint16_t        io_base;
    168     // Target Id.
    169     uint8_t         target_id;
    170     // SCSI devices info
    171     ata_device_t    device_info;
    172 } scsi_device_t;
    173 
    174 typedef struct {
    175     // SCSI device info
    176     scsi_device_t   devices[BX_MAX_SCSI_DEVICES];
    177     // Number of scsi disks.
    178     uint8_t         hdcount;
    179 } scsi_t;
    180 #endif
    181 
    182 #ifdef VBOX_WITH_BIOS_AHCI
    183 //typedef struct {
    184 //    uint16_t    iobase;
    185 //} ahci_t;
    186 #endif
    187 
     99ct_assert(sizeof(dpte_t) == 16);    /* Ensure correct size. */
     100
     101#pragma pack(0)
     102
     103/* FDPT - Fixed Disk Parameter Table. PC/AT compatible; note
     104 * that this structure is slightly misaligned.
     105 */
    188106typedef struct {
    189107    uint16_t    lcyl;
     
    199117} fdpt_t;
    200118
     119#pragma pack()
     120
     121ct_assert(sizeof(fdpt_t) == 16);    /* Ensure correct size. */
     122
     123
     124/* C/H/S geometry information. */
     125typedef struct {
     126    uint16_t    heads;      /* Number of heads. */
     127    uint16_t    cylinders;  /* Number of cylinders. */
     128    uint16_t    spt;        /* Number of sectors per track. */
     129} chs_t;
     130
     131typedef struct {
     132    uint8_t     iface;        // ISA or PCI
     133    uint8_t     irq;          // IRQ
     134    uint16_t    iobase1;      // IO Base 1
     135    uint16_t    iobase2;      // IO Base 2
     136} ata_chan_t;
     137
     138typedef struct {
     139    uint8_t     type;         // Detected type of disk (ata/atapi/none/unknown/scsi)
     140    uint8_t     device;       // Detected type of attached devices (hd/cd/none)
     141    uint8_t     removable;    // Removable device flag
     142    uint8_t     lock;         // Locks for removable devices
     143    uint8_t     mode;         // transfer mode : PIO 16/32 bits - IRQ - ISADMA - PCIDMA
     144    uint8_t     translation;  // type of translation
     145    uint16_t    blksize;      // block size
     146    chs_t       lchs;         // Logical CHS
     147    chs_t       pchs;         // Physical CHS
     148    uint32_t    sectors;      // Total sectors count
     149} ata_dev_t;
     150
     151typedef struct {
     152    // ATA channels info
     153    ata_chan_t  channels[BX_MAX_ATA_INTERFACES];
     154
     155    // ATA devices info
     156    ata_dev_t   devices[BX_MAX_ATA_DEVICES];
     157    //
     158    // map between (bios hd id - 0x80) and ata channels and scsi disks.
     159    uint8_t     hdcount, hdidmap[BX_MAX_STORAGE_DEVICES];
     160
     161    // map between (bios cd id - 0xE0) and ata channels
     162    uint8_t     cdcount, cdidmap[BX_MAX_STORAGE_DEVICES];
     163
     164    // Buffer for DPTE table
     165    dpte_t      dpte;
     166
     167    // Count of transferred sectors and bytes
     168    uint16_t    trsfsectors;
     169    uint32_t    trsfbytes;
     170} bio_dsk_t;
     171
     172#if BX_ELTORITO_BOOT
     173  // ElTorito Device Emulation data
     174typedef struct {
     175    uint8_t     active;
     176    uint8_t     media;
     177    uint8_t     emulated_drive;
     178    uint8_t     controller_index;
     179    uint16_t    device_spec;
     180    uint16_t    buffer_segment;
     181    uint32_t    ilba;
     182    uint16_t    load_segment;
     183    uint16_t    sector_count;
     184    chs_t       vdevice;    /* Virtual device geometry. */
     185} cdemu_t;
     186#endif
     187
     188#ifdef VBOX_WITH_SCSI
     189typedef struct {
     190    // I/O port this device is attached to.
     191    uint16_t    io_base;
     192    // Target Id.
     193    uint8_t     target_id;
     194    // SCSI devices info
     195    ata_dev_t   device_info;
     196} scsi_dev_t;
     197
     198typedef struct {
     199    // SCSI device info
     200    scsi_dev_t  devices[BX_MAX_SCSI_DEVICES];
     201    // Number of scsi disks.
     202    uint8_t     hdcount;
     203} scsi_t;
     204#endif
     205
    201206// for access to EBDA area
    202207//     The EBDA structure should conform to
    203208//     http://www.frontiernet.net/~fys/rombios.htm document
    204209//     I made the ata and cdemu structs begin at 0x121 in the EBDA seg
    205 /* MS-DOS KEYB.COM may overwrite the word at offset 0x117 in the EBDA. */
     210/* MS-DOS KEYB.COM may overwrite the word at offset 0x117 in the EBDA
     211 * which contains the keyboard ID for PS/2 BIOSes.
     212 */
    206213typedef struct {
    207214    unsigned char filler1[0x3D];
     
    218225#endif
    219226
    220     // ATA Driver data
    221     ata_t       ata;
     227    bio_dsk_t   bdisk;      /* Disk driver data (ATA/SCSI/AHCI). */
    222228
    223229#if BX_ELTORITO_BOOT
    224     // El Torito Emulation data
    225     cdemu_t     cdemu;
    226 #endif // BX_ELTORITO_BOOT
     230    cdemu_t     cdemu;      /* El Torito floppy/HD emulation data. */
     231#endif
    227232
    228233#ifdef VBOX_WITH_SCSI
    229234    // SCSI Driver data
    230235    scsi_t      scsi;
    231 # endif
     236#endif
    232237
    233238#ifdef VBOX_WITH_BIOS_AHCI
     
    240245} ebda_data_t;
    241246
    242 #pragma pack()
     247ct_assert(sizeof(ebda_data_t) < 0x400);     /* Must be under 1K in size. */
    243248
    244249// the last 16 bytes of the EBDA segment are used for the MPS floating
  • trunk/src/VBox/Devices/PC/BIOS-new/eltorito.c

    r38699 r39340  
    346346            write_byte(0x40,0x10,read_byte(0x40,0x10)|0x41);
    347347        else
    348             write_byte(ebda_seg,(uint16_t)&EbdaData->ata.hdcount, read_byte(ebda_seg, (uint16_t)&EbdaData->ata.hdcount) + 1);
     348            write_byte(ebda_seg,(uint16_t)&EbdaData->bdisk.hdcount, read_byte(ebda_seg, (uint16_t)&EbdaData->bdisk.hdcount) + 1);
    349349    }
    350350   
     
    572572    uint32_t        lba;
    573573    uint16_t        count, segment, offset, size;
    574     ata_t __far    *ata;
    575 
    576     ata = ebda_seg :> &EbdaData->ata;
     574    bio_dsk_t __far *ata;
     575
     576    ata = ebda_seg :> &EbdaData->bdisk;
    577577
    578578   
     
    780780
    781781        write_word(DS, SI+(uint16_t)&Int13DPT->dpte_segment, ebda_seg);
    782         write_word(DS, SI+(uint16_t)&Int13DPT->dpte_offset, (uint16_t)&EbdaData->ata.dpte);
     782        write_word(DS, SI+(uint16_t)&Int13DPT->dpte_offset, (uint16_t)&EbdaData->bdisk.dpte);
    783783
    784784        // Fill in dpte
     
    808808
    809809        checksum=0;
    810         for (i=0; i<15; i++) checksum += read_byte(ebda_seg, (uint16_t)&EbdaData->ata.dpte + i);
     810        for (i=0; i<15; i++)
     811            checksum += read_byte(ebda_seg, (uint16_t)&EbdaData->bdisk.dpte + i);
    811812        checksum = -checksum;
    812813        ata->dpte.checksum = checksum;
  • trunk/src/VBox/Devices/PC/BIOS-new/notes.txt

    r38899 r39340  
    2929  horribly. DOS 6.x with EMM386 is a good testcase (esp. loading drivers
    3030  into UMBs).
     31
     32- Many older OSes (especially UNIX based) require the FDPT to contain
     33  physical ATA disk geometry; for that reason, disks smaller than ~500MB are
     34  easiest to use. Otherwise a "large" BIOS disk option would be required.
     35
     36- Some really old OSes (Xenix circa 1986-7) do not understand the EBDA idea
     37  and clear the memory. For those, the FDPT must be in the BIOS ROM area, or
     38  the OS will destroy it (even when it's at 0:300 in the IVT).
    3139
    3240
  • trunk/src/VBox/Devices/PC/BIOS-new/scsi.c

    r38699 r39340  
    158158
    159159    // Reset count of transferred data
    160     ebda_data->ata.trsfsectors = 0;
    161     ebda_data->ata.trsfbytes   = 0;
     160    ebda_data->bdisk.trsfsectors = 0;
     161    ebda_data->bdisk.trsfbytes   = 0;
    162162
    163163    /* Prepare CDB */
     
    181181    if (!rc)
    182182    {
    183         ebda_data->ata.trsfsectors = count;
    184         ebda_data->ata.trsfbytes   = count * 512;
     183        ebda_data->bdisk.trsfsectors = count;
     184        ebda_data->bdisk.trsfbytes   = count * 512;
    185185    }
    186186
     
    212212
    213213    // Reset count of transferred data
    214     ebda_data->ata.trsfsectors = 0;
    215     ebda_data->ata.trsfbytes   = 0;
     214    ebda_data->bdisk.trsfsectors = 0;
     215    ebda_data->bdisk.trsfbytes   = 0;
    216216
    217217    /* Prepare CDB */
     
    235235    if (!rc)
    236236    {
    237         ebda_data->ata.trsfsectors = count;
    238         ebda_data->ata.trsfbytes   = (count * 512);
     237        ebda_data->bdisk.trsfsectors = count;
     238        ebda_data->bdisk.trsfbytes   = (count * 512);
    239239    }
    240240
     
    366366
    367367                /* Store the id of the disk in the ata hdidmap. */
    368                 hdcount = ebda_data->ata.hdcount;
    369                 ebda_data->ata.hdidmap[hdcount] = hdcount_scsi + BX_MAX_ATA_DEVICES;
     368                hdcount = ebda_data->bdisk.hdcount;
     369                ebda_data->bdisk.hdidmap[hdcount] = hdcount_scsi + BX_MAX_ATA_DEVICES;
    370370                hdcount++;
    371                 ebda_data->ata.hdcount = hdcount;
     371                ebda_data->bdisk.hdcount = hdcount;
    372372
    373373                /* Update hdcount in the BDA. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette