VirtualBox

忽略:
時間撮記:
2011-11-17 下午02:31:57 (13 年 以前)
作者:
vboxsync
訊息:

More merging of BIOS disk structures.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/PC/BIOS-new/disk.c

    r39340 r39346  
    7373    uint16_t            count;
    7474    uint8_t             device, status;
    75     uint8_t             scsi_device;
    7675    ebda_data_t __far   *ebda_data;
    7776
     
    132131        }
    133132
    134 #ifdef VBOX_WITH_SCSI
    135         if (!VBOX_IS_SCSI_DEVICE(device))
    136 #endif
    137         {
    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;
    141         }
    142 #ifdef VBOX_WITH_SCSI
    143         else {
    144             scsi_device = VBOX_GET_SCSI_DEVICE(device);
    145    
    146             nlc   = ebda_data->scsi.devices[scsi_device].device_info.lchs.cylinders;
    147             nlh   = ebda_data->scsi.devices[scsi_device].device_info.lchs.heads;
    148             nlspt = ebda_data->scsi.devices[scsi_device].device_info.lchs.spt;
    149         }
    150 #endif
    151 
    152         // sanity check on cyl heads, sec
     133        /* Get the logical CHS geometry. */
     134        nlc   = ebda_data->bdisk.devices[device].lchs.cylinders;
     135        nlh   = ebda_data->bdisk.devices[device].lchs.heads;
     136        nlspt = ebda_data->bdisk.devices[device].lchs.spt;
     137
     138        /* Sanity check the geometry. */
    153139        if( (cylinder >= nlc) || (head >= nlh) || (sector > nlspt )) {
    154140            BX_INFO("%s: function %02x, disk %02x, parameters out of range %04x/%04x/%04x!\n", __func__, GET_AH(), GET_DL(), cylinder, head, sector);
     
    160146            goto int13_success;
    161147
    162 #ifdef VBOX_WITH_SCSI
    163         if (!VBOX_IS_SCSI_DEVICE(device))
    164 #endif
    165         {
    166             nph   = ebda_data->bdisk.devices[device].pchs.heads;
    167             npspt = ebda_data->bdisk.devices[device].pchs.spt;
    168         }
    169 #ifdef VBOX_WITH_SCSI
    170         else {
    171             scsi_device = VBOX_GET_SCSI_DEVICE(device);
    172             nph   = ebda_data->scsi.devices[scsi_device].device_info.pchs.heads;
    173             npspt = ebda_data->scsi.devices[scsi_device].device_info.pchs.spt;
    174         }
    175 #endif
    176 
    177         // if needed, translate lchs to lba, and execute command
    178 #ifdef VBOX_WITH_SCSI
     148        /* Now get relevant the physical geometry information. */
     149        nph   = ebda_data->bdisk.devices[device].pchs.heads;
     150        npspt = ebda_data->bdisk.devices[device].pchs.spt;
     151
     152        /* If required, translate LCHS to LBA and execute command. */
     153        //@todo: The IS_SCSI_DEVICE check should be redundant...
    179154        if (( (nph != nlh) || (npspt != nlspt)) || VBOX_IS_SCSI_DEVICE(device)) {
    180155            lba = ((((uint32_t)cylinder * (uint32_t)nlh) + (uint32_t)head) * (uint32_t)nlspt) + (uint32_t)sector - 1;
    181156            sector = 0; // this forces the command to be lba
    182157        }
    183 #else
    184         if (( (nph != nlh) || (npspt != nlspt)) ) {
    185             lba = ((((uint32_t)cylinder * (uint32_t)nlh) + (uint32_t)head) * (uint32_t)nlspt) + (uint32_t)sector - 1;
    186             sector = 0; // this forces the command to be lba
    187         }
    188 #endif
    189158
    190159        if ( GET_AH() == 0x02 )
     
    229198    case 0x08: /* read disk drive parameters */
    230199
    231         // Get logical geometry from table
    232 #ifdef VBOX_WITH_SCSI
    233         if (!VBOX_IS_SCSI_DEVICE(device))
    234 #endif
    235         {
    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;
    239         }
    240 #ifdef VBOX_WITH_SCSI
    241         else {
    242             scsi_device = VBOX_GET_SCSI_DEVICE(device);
    243             nlc   = ebda_data->scsi.devices[scsi_device].device_info.lchs.cylinders;
    244             nlh   = ebda_data->scsi.devices[scsi_device].device_info.lchs.heads;
    245             nlspt = ebda_data->scsi.devices[scsi_device].device_info.lchs.spt;
    246         }
    247 #endif
     200        /* Get the logical geometry from internal table. */
     201        nlc   = ebda_data->bdisk.devices[device].lchs.cylinders;
     202        nlh   = ebda_data->bdisk.devices[device].lchs.heads;
     203        nlspt = ebda_data->bdisk.devices[device].lchs.spt;
    248204
    249205        count = ebda_data->bdisk.hdcount;
     
    277233    case 0x15: /* read disk drive size */
    278234
    279       // Get physical geometry from table
    280 #ifdef VBOX_WITH_SCSI
    281         if (!VBOX_IS_SCSI_DEVICE(device))
    282 #endif
    283         {
    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;
    287         }
    288 #ifdef VBOX_WITH_SCSI
    289         else {
    290             scsi_device = VBOX_GET_SCSI_DEVICE(device);
    291             npc   = ebda_data->scsi.devices[scsi_device].device_info.pchs.cylinders;
    292             nph   = ebda_data->scsi.devices[scsi_device].device_info.pchs.heads;
    293             npspt = ebda_data->scsi.devices[scsi_device].device_info.pchs.spt;
    294         }
    295 #endif
    296 
    297         // Compute sector count seen by int13
     235        /* Get the physical geometry from internal table. */
     236        npc   = ebda_data->bdisk.devices[device].pchs.cylinders;
     237        nph   = ebda_data->bdisk.devices[device].pchs.heads;
     238        npspt = ebda_data->bdisk.devices[device].pchs.spt;
     239
     240        /* Calculate sector count seen by old style INT 13h. */
    298241        lba = (uint32_t)npc * (uint32_t)nph * (uint32_t)npspt;
    299242        CX = lba >> 16;
     
    346289    uint16_t            size, count;
    347290    uint8_t             device, status;
    348     uint8_t             scsi_device;
    349291    ebda_data_t __far   *ebda_data;
    350292    int13ext_t __far    *i13_ext;
     
    402344        lba = i13_ext->lba1;
    403345
    404 #ifdef VBOX_WITH_SCSI
    405         if (VBOX_IS_SCSI_DEVICE(device))
    406         {
    407             if (lba >= ebda_data->scsi.devices[VBOX_GET_SCSI_DEVICE(device)].device_info.sectors ) {
    408                 BX_INFO("%s: function %02x. LBA out of range\n", __func__, GET_AH());
    409                 goto int13x_fail;
    410             }
    411         }
    412         else
    413 #endif
    414346        if (lba >= ebda_data->bdisk.devices[device].sectors) {
    415347              BX_INFO("%s: function %02x. LBA out of range\n", __func__, GET_AH());
     
    475407        size = dpt->size;
    476408
    477         // Buffer is too small
    478         if(size < 0x1a)
     409        /* Check if buffer is large enough. */
     410        if (size < 0x1a)
    479411            goto int13x_fail;
    480412       
    481         // EDD 1.x
    482         if(size >= 0x1a) {
     413        /* Fill in EDD 1.x table. */
     414        if (size >= 0x1a) {
    483415            uint16_t   blksize;
    484416
    485 #ifdef VBOX_WITH_SCSI
    486             if (!VBOX_IS_SCSI_DEVICE(device))
    487 #endif
    488             {
    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;
    494             }
    495 #ifdef VBOX_WITH_SCSI
    496             else {
    497                 scsi_device = VBOX_GET_SCSI_DEVICE(device);
    498                 npc     = ebda_data->scsi.devices[scsi_device].device_info.pchs.cylinders;
    499                 nph     = ebda_data->scsi.devices[scsi_device].device_info.pchs.heads;
    500                 npspt   = ebda_data->scsi.devices[scsi_device].device_info.pchs.spt;
    501                 lba     = ebda_data->scsi.devices[scsi_device].device_info.sectors;
    502                 blksize = ebda_data->scsi.devices[scsi_device].device_info.blksize;
    503             }
    504 #endif
     417            npc     = ebda_data->bdisk.devices[device].pchs.cylinders;
     418            nph     = ebda_data->bdisk.devices[device].pchs.heads;
     419            npspt   = ebda_data->bdisk.devices[device].pchs.spt;
     420            lba     = ebda_data->bdisk.devices[device].sectors;
     421            blksize = ebda_data->bdisk.devices[device].blksize;
     422
    505423            dpt->size      = 0x1a;
    506424            dpt->infos     = 0x02;  // geometry is valid
     
    513431        }
    514432
    515         // EDD 2.x
    516         if(size >= 0x1e) {
     433        /* Fill in EDD 2.x table. */
     434        if (size >= 0x1e) {
    517435            uint8_t     channel, irq, mode, checksum, i, translation;
    518436            uint16_t    iobase1, iobase2, options;
     
    555473        }
    556474
    557         // EDD 3.x
     475        /* Fill in EDD 3.x table. */
    558476        if(size >= 0x42) {
    559477            uint8_t     channel, iface, checksum, i;
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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