VirtualBox

Changeset 58818 in vbox for trunk/src/VBox/Devices/PC/BIOS


Ignore:
Timestamp:
Nov 23, 2015 12:13:00 PM (9 years ago)
Author:
vboxsync
Message:

BIOS: Reduced read path stack usage for ATA/AHCI.

Location:
trunk/src/VBox/Devices/PC/BIOS
Files:
2 edited

Legend:

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

    r58724 r58818  
    235235    parm [ax] modify nomemory;
    236236
    237 void high_bits_save(ahci_t __far *ahci)
     237void inline high_bits_save(ahci_t __far *ahci)
    238238{
    239239    ahci->saved_eax_hi = eax_hi_rd();
    240240}
    241241
    242 void high_bits_restore(ahci_t __far *ahci)
     242void inline high_bits_restore(ahci_t __far *ahci)
    243243{
    244244    eax_hi_wr(ahci->saved_eax_hi);
     
    248248 * Sets a given set of bits in a register.
    249249 */
    250 static void ahci_ctrl_set_bits(uint16_t iobase, uint16_t reg, uint32_t mask)
     250static void inline ahci_ctrl_set_bits(uint16_t iobase, uint16_t reg, uint32_t mask)
    251251{
    252252    outpd(iobase + AHCI_REG_IDX, reg);
     
    257257 * Clears a given set of bits in a register.
    258258 */
    259 static void ahci_ctrl_clear_bits(uint16_t iobase, uint16_t reg, uint32_t mask)
     259static void inline ahci_ctrl_clear_bits(uint16_t iobase, uint16_t reg, uint32_t mask)
    260260{
    261261    outpd(iobase + AHCI_REG_IDX, reg);
     
    267267 * for a register.
    268268 */
    269 static uint8_t ahci_ctrl_is_bit_set(uint16_t iobase, uint16_t reg, uint32_t mask)
     269static uint8_t inline ahci_ctrl_is_bit_set(uint16_t iobase, uint16_t reg, uint32_t mask)
    270270{
    271271    outpd(iobase + AHCI_REG_IDX, reg);
     
    343343    uint16_t        n_sect = bios_dsk->drqp.nsect;
    344344    uint16_t        sectsz = bios_dsk->drqp.sect_sz;
    345     uint16_t        prdt_idx;
    346345    fis_d2h __far   *d2h;
    347346
     
    373372    vds_build_sg_list(&ahci->edds, bios_dsk->drqp.buffer, (uint32_t)n_sect * sectsz);
    374373
    375     prdt_idx = ahci->cur_prd;
    376 
    377374    /* Set up the PRDT. */
    378     ahci->aPrdt[prdt_idx].len       = ahci->edds.u.sg[0].size - 1;
    379     ahci->aPrdt[prdt_idx].phys_addr = ahci->edds.u.sg[0].phys_addr;
    380     ++prdt_idx;
     375    ahci->aPrdt[ahci->cur_prd].len       = ahci->edds.u.sg[0].size - 1;
     376    ahci->aPrdt[ahci->cur_prd].phys_addr = ahci->edds.u.sg[0].phys_addr;
     377    ++ahci->cur_prd;
    381378
    382379    if (bios_dsk->drqp.skip_a) {
    383         ahci->aPrdt[prdt_idx].len       = bios_dsk->drqp.skip_a - 1;
    384         ahci->aPrdt[prdt_idx].phys_addr = ahci->sink_buf_phys;
    385         ++prdt_idx;
    386     }
    387 
    388     ahci->cur_prd = prdt_idx;
    389 
    390 #ifdef DEBUG_AHCI
    391     for (prdt_idx = 0; prdt_idx < ahci->cur_prd; ++prdt_idx) {
    392         DBG_AHCI("S/G entry %u: %5lu bytes @ %08lX\n", prdt_idx,
    393                  ahci->aPrdt[prdt_idx].len + 1, ahci->aPrdt[prdt_idx].phys_addr);
     380        ahci->aPrdt[ahci->cur_prd].len       = bios_dsk->drqp.skip_a - 1;
     381        ahci->aPrdt[ahci->cur_prd].phys_addr = ahci->sink_buf_phys;
     382        ++ahci->cur_prd;
     383    }
     384
     385#if DEBUG_AHCI
     386    {
     387        uint16_t     prdt_idx;
     388
     389        for (prdt_idx = 0; prdt_idx < ahci->cur_prd; ++prdt_idx) {
     390            DBG_AHCI("S/G entry %u: %5lu bytes @ %08lX\n", prdt_idx,
     391                     ahci->aPrdt[prdt_idx].len + 1, ahci->aPrdt[prdt_idx].phys_addr);
     392        }
    394393    }
    395394#endif
  • trunk/src/VBox/Devices/PC/BIOS/ata.c

    r58724 r58818  
    207207uint16_t ata_cmd_data_in(bio_dsk_t __far *bios_dsk, uint16_t command, uint16_t count)
    208208{
    209     uint64_t        lba;
    210209    uint16_t        iobase1, iobase2, blksize, mult_blk_cnt;
    211210    uint16_t        cylinder;
    212     uint16_t        head;
    213     uint16_t        sector;
    214     uint16_t        device;
    215     uint8_t         channel, slave;
     211    uint8_t         head;
     212    uint8_t         sector;
     213    uint8_t         device;
    216214    uint8_t         status, mode;
    217215    char __far      *buffer;
    218216
    219217    device  = bios_dsk->drqp.dev_id;
    220     channel = device / 2;
    221     slave   = device % 2;
    222 
    223     iobase1 = bios_dsk->channels[channel].iobase1;
    224     iobase2 = bios_dsk->channels[channel].iobase2;
     218
     219    iobase1 = bios_dsk->channels[device / 2].iobase1;
     220    iobase2 = bios_dsk->channels[device / 2].iobase2;
    225221    mode    = bios_dsk->devices[device].mode;
    226222    blksize = bios_dsk->devices[device].blksize;
     
    246242    }
    247243
    248     lba      = bios_dsk->drqp.lba;
    249244    buffer   = bios_dsk->drqp.buffer;
    250245    sector   = bios_dsk->drqp.sector;
     
    254249    // sector will be 0 only on lba access. Convert to lba-chs
    255250    if (sector == 0) {
    256         if (lba + count >= 268435456)
     251        if (bios_dsk->drqp.lba + count >= 268435456)
    257252        {
    258             sector = (lba >> 24) & 0x00ff;
    259             cylinder = (lba >> 32) & 0xffff;
     253            sector = (bios_dsk->drqp.lba >> 24) & 0x00ff;
     254            cylinder = (bios_dsk->drqp.lba >> 32) & 0xffff;
    260255            outb(iobase1 + ATA_CB_SC, (count & 0xff00) >> 8);
    261256            outb(iobase1 + ATA_CB_SN, sector);
     
    264259            /* Leave the bottom 24 bits as is, they are treated correctly by the
    265260            * LBA28 code path. */
    266             lba &= 0xffffff;
    267         }
    268         sector = (uint16_t) (lba & 0x000000ffL);
    269         lba >>= 8;
    270         cylinder = (uint16_t) (lba & 0x0000ffffL);
    271         lba >>= 16;
    272         head = ((uint16_t) (lba & 0x0000000fL)) | 0x40;
     261        }
     262        sector   = bios_dsk->drqp.lba & 0x000000ffL;
     263        cylinder = (bios_dsk->drqp.lba >> 8) & 0x0000ffffL;
     264        head     = ((bios_dsk->drqp.lba >> 24) & 0x0000000fL) | 0x40;
    273265    }
    274266
     
    279271    outb(iobase1 + ATA_CB_CL, cylinder & 0x00ff);
    280272    outb(iobase1 + ATA_CB_CH, cylinder >> 8);
    281     outb(iobase1 + ATA_CB_DH, (slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0) | (uint8_t) head );
     273    outb(iobase1 + ATA_CB_DH, ((device & 1) ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0) | head );
    282274    outb(iobase1 + ATA_CB_CMD, command);
    283275
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