VirtualBox

Ignore:
Timestamp:
Sep 9, 2011 12:56:49 PM (13 years ago)
Author:
vboxsync
Message:

Reduced read_word/write_word usage.

File:
1 edited

Legend:

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

    r38699 r38706  
    6868void BIOSCALL int13_harddisk(disk_regs_t r)
    6969{
    70     uint32_t    lba;
    71     uint16_t    ebda_seg=read_word(0x0040,0x000E);
    72     uint16_t    cylinder, head, sector;
    73     uint16_t    npc, nph, npspt, nlc, nlh, nlspt;
    74     uint16_t    count;
    75     uint8_t     device, status;
    76     uint8_t     scsi_device;
     70    uint32_t            lba;
     71    uint16_t            cylinder, head, sector;
     72    uint16_t            npc, nph, npspt, nlc, nlh, nlspt;
     73    uint16_t            count;
     74    uint8_t             device, status;
     75    uint8_t             scsi_device;
     76    ebda_data_t __far   *ebda_data;
    7777
    7878    BX_DEBUG_INT13_HD("%s: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", __func__, AX, BX, CX, DX, ES);
    79    
     79
     80    ebda_data = read_word(0x0040,0x000E) :> 0;
    8081    write_byte(0x0040, 0x008e, 0);  // clear completion flag
    8182   
     
    8788   
    8889    // Get the ata channel
    89     device=read_byte(ebda_seg,(uint16_t)&EbdaData->ata.hdidmap[GET_ELDL()-0x80]);
     90    device = ebda_data->ata.hdidmap[GET_ELDL()-0x80];
    9091   
    9192    // basic check : device has to be valid
     
    135136#endif
    136137        {
    137             nlc   = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].lchs.cylinders);
    138             nlh   = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].lchs.heads);
    139             nlspt = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].lchs.spt);
     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;
    140141        }
    141142#ifdef VBOX_WITH_SCSI
     
    143144            scsi_device = VBOX_GET_SCSI_DEVICE(device);
    144145   
    145             nlc   = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.lchs.cylinders);
    146             nlh   = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.lchs.heads);
    147             nlspt = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.lchs.spt);
     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;
    148149        }
    149150#endif
     
    163164#endif
    164165        {
    165             nph   = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].pchs.heads);
    166             npspt = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].pchs.spt);
     166            nph   = ebda_data->ata.devices[device].pchs.heads;
     167            npspt = ebda_data->ata.devices[device].pchs.spt;
    167168        }
    168169#ifdef VBOX_WITH_SCSI
    169170        else {
    170171            scsi_device = VBOX_GET_SCSI_DEVICE(device);
    171             nph   = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.pchs.heads);
    172             npspt = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.pchs.spt);
     172            nph   = ebda_data->scsi.devices[scsi_device].device_info.pchs.heads;
     173            npspt = ebda_data->scsi.devices[scsi_device].device_info.pchs.spt;
    173174        }
    174175#endif
     
    195196#endif
    196197            {
    197                 write_word(ebda_seg,(uint16_t)&EbdaData->ata.devices[device].blksize,count * 0x200);
     198                ebda_data->ata.devices[device].blksize = count * 0x200;
    198199                status=ata_cmd_data_in(device, ATA_CMD_READ_MULTIPLE, count, cylinder, head, sector, lba, MK_FP(ES, BX));
    199                 write_word(ebda_seg,(uint16_t)&EbdaData->ata.devices[device].blksize,0x200);
     200                ebda_data->ata.devices[device].blksize = 0x200;
    200201            }
    201202        } else {
     
    209210
    210211        // Set nb of sector transferred
    211         SET_AL(read_word(ebda_seg, (uint16_t)&EbdaData->ata.trsfsectors));
     212        SET_AL(ebda_data->ata.trsfsectors);
    212213       
    213214        if (status != 0) {
     
    233234#endif
    234235        {
    235             nlc   = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].lchs.cylinders);
    236             nlh   = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].lchs.heads);
    237             nlspt = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].lchs.spt);
     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;
    238239        }
    239240#ifdef VBOX_WITH_SCSI
    240241        else {
    241242            scsi_device = VBOX_GET_SCSI_DEVICE(device);
    242             nlc   = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.lchs.cylinders);
    243             nlh   = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.lchs.heads);
    244             nlspt = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.lchs.spt);
    245         }
    246 #endif
    247 
    248         count = read_byte(ebda_seg, (uint16_t)&EbdaData->ata.hdcount);
     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
     248
     249        count = ebda_data->ata.hdcount;
    249250        /* Maximum cylinder number is just one less than the number of cylinders. */
    250251        nlc = nlc - 1; /* 0 based , last sector not used */
     
    265266
    266267        // Read the status from controller
    267         status = inb(read_word(ebda_seg, (uint16_t)&EbdaData->ata.channels[device/2].iobase1) + ATA_CB_STAT);
     268        status = inb(ebda_data->ata.channels[device/2].iobase1 + ATA_CB_STAT);
    268269        if ( (status & ( ATA_CB_STAT_BSY | ATA_CB_STAT_RDY )) == ATA_CB_STAT_RDY ) {
    269270            goto int13_success;
     
    281282#endif
    282283        {
    283             npc   = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].pchs.cylinders);
    284             nph   = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].pchs.heads);
    285             npspt = read_word(ebda_seg, (uint16_t)&EbdaData->ata.devices[device].pchs.spt);
     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;
    286287        }
    287288#ifdef VBOX_WITH_SCSI
    288289        else {
    289290            scsi_device = VBOX_GET_SCSI_DEVICE(device);
    290             npc   = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.pchs.cylinders);
    291             nph   = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.pchs.heads);
    292             npspt = read_word(ebda_seg, (uint16_t)&EbdaData->scsi.devices[scsi_device].device_info.pchs.spt);
     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;
    293294        }
    294295#endif
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