Index: /trunk/src/VBox/Devices/PC/BIOS/ahci.c
===================================================================
--- /trunk/src/VBox/Devices/PC/BIOS/ahci.c	(revision 58817)
+++ /trunk/src/VBox/Devices/PC/BIOS/ahci.c	(revision 58818)
@@ -235,10 +235,10 @@
     parm [ax] modify nomemory;
 
-void high_bits_save(ahci_t __far *ahci)
+void inline high_bits_save(ahci_t __far *ahci)
 {
     ahci->saved_eax_hi = eax_hi_rd();
 }
 
-void high_bits_restore(ahci_t __far *ahci)
+void inline high_bits_restore(ahci_t __far *ahci)
 {
     eax_hi_wr(ahci->saved_eax_hi);
@@ -248,5 +248,5 @@
  * Sets a given set of bits in a register.
  */
-static void ahci_ctrl_set_bits(uint16_t iobase, uint16_t reg, uint32_t mask)
+static void inline ahci_ctrl_set_bits(uint16_t iobase, uint16_t reg, uint32_t mask)
 {
     outpd(iobase + AHCI_REG_IDX, reg);
@@ -257,5 +257,5 @@
  * Clears a given set of bits in a register.
  */
-static void ahci_ctrl_clear_bits(uint16_t iobase, uint16_t reg, uint32_t mask)
+static void inline ahci_ctrl_clear_bits(uint16_t iobase, uint16_t reg, uint32_t mask)
 {
     outpd(iobase + AHCI_REG_IDX, reg);
@@ -267,5 +267,5 @@
  * for a register.
  */
-static uint8_t ahci_ctrl_is_bit_set(uint16_t iobase, uint16_t reg, uint32_t mask)
+static uint8_t inline ahci_ctrl_is_bit_set(uint16_t iobase, uint16_t reg, uint32_t mask)
 {
     outpd(iobase + AHCI_REG_IDX, reg);
@@ -343,5 +343,4 @@
     uint16_t        n_sect = bios_dsk->drqp.nsect;
     uint16_t        sectsz = bios_dsk->drqp.sect_sz;
-    uint16_t        prdt_idx;
     fis_d2h __far   *d2h;
 
@@ -373,23 +372,23 @@
     vds_build_sg_list(&ahci->edds, bios_dsk->drqp.buffer, (uint32_t)n_sect * sectsz);
 
-    prdt_idx = ahci->cur_prd;
-
     /* Set up the PRDT. */
-    ahci->aPrdt[prdt_idx].len       = ahci->edds.u.sg[0].size - 1;
-    ahci->aPrdt[prdt_idx].phys_addr = ahci->edds.u.sg[0].phys_addr;
-    ++prdt_idx;
+    ahci->aPrdt[ahci->cur_prd].len       = ahci->edds.u.sg[0].size - 1;
+    ahci->aPrdt[ahci->cur_prd].phys_addr = ahci->edds.u.sg[0].phys_addr;
+    ++ahci->cur_prd;
 
     if (bios_dsk->drqp.skip_a) {
-        ahci->aPrdt[prdt_idx].len       = bios_dsk->drqp.skip_a - 1;
-        ahci->aPrdt[prdt_idx].phys_addr = ahci->sink_buf_phys;
-        ++prdt_idx;
-    }
-
-    ahci->cur_prd = prdt_idx;
-
-#ifdef DEBUG_AHCI
-    for (prdt_idx = 0; prdt_idx < ahci->cur_prd; ++prdt_idx) {
-        DBG_AHCI("S/G entry %u: %5lu bytes @ %08lX\n", prdt_idx,
-                 ahci->aPrdt[prdt_idx].len + 1, ahci->aPrdt[prdt_idx].phys_addr);
+        ahci->aPrdt[ahci->cur_prd].len       = bios_dsk->drqp.skip_a - 1;
+        ahci->aPrdt[ahci->cur_prd].phys_addr = ahci->sink_buf_phys;
+        ++ahci->cur_prd;
+    }
+
+#if DEBUG_AHCI
+    {
+        uint16_t     prdt_idx;
+
+        for (prdt_idx = 0; prdt_idx < ahci->cur_prd; ++prdt_idx) {
+            DBG_AHCI("S/G entry %u: %5lu bytes @ %08lX\n", prdt_idx,
+                     ahci->aPrdt[prdt_idx].len + 1, ahci->aPrdt[prdt_idx].phys_addr);
+        }
     }
 #endif
Index: /trunk/src/VBox/Devices/PC/BIOS/ata.c
===================================================================
--- /trunk/src/VBox/Devices/PC/BIOS/ata.c	(revision 58817)
+++ /trunk/src/VBox/Devices/PC/BIOS/ata.c	(revision 58818)
@@ -207,20 +207,16 @@
 uint16_t ata_cmd_data_in(bio_dsk_t __far *bios_dsk, uint16_t command, uint16_t count)
 {
-    uint64_t        lba;
     uint16_t        iobase1, iobase2, blksize, mult_blk_cnt;
     uint16_t        cylinder;
-    uint16_t        head;
-    uint16_t        sector;
-    uint16_t        device;
-    uint8_t         channel, slave;
+    uint8_t         head;
+    uint8_t         sector;
+    uint8_t         device;
     uint8_t         status, mode;
     char __far      *buffer;
 
     device  = bios_dsk->drqp.dev_id;
-    channel = device / 2;
-    slave   = device % 2;
-
-    iobase1 = bios_dsk->channels[channel].iobase1;
-    iobase2 = bios_dsk->channels[channel].iobase2;
+
+    iobase1 = bios_dsk->channels[device / 2].iobase1;
+    iobase2 = bios_dsk->channels[device / 2].iobase2;
     mode    = bios_dsk->devices[device].mode;
     blksize = bios_dsk->devices[device].blksize;
@@ -246,5 +242,4 @@
     }
 
-    lba      = bios_dsk->drqp.lba;
     buffer   = bios_dsk->drqp.buffer;
     sector   = bios_dsk->drqp.sector;
@@ -254,8 +249,8 @@
     // sector will be 0 only on lba access. Convert to lba-chs
     if (sector == 0) {
-        if (lba + count >= 268435456)
+        if (bios_dsk->drqp.lba + count >= 268435456)
         {
-            sector = (lba >> 24) & 0x00ff;
-            cylinder = (lba >> 32) & 0xffff;
+            sector = (bios_dsk->drqp.lba >> 24) & 0x00ff;
+            cylinder = (bios_dsk->drqp.lba >> 32) & 0xffff;
             outb(iobase1 + ATA_CB_SC, (count & 0xff00) >> 8);
             outb(iobase1 + ATA_CB_SN, sector);
@@ -264,11 +259,8 @@
             /* Leave the bottom 24 bits as is, they are treated correctly by the
             * LBA28 code path. */
-            lba &= 0xffffff;
-        }
-        sector = (uint16_t) (lba & 0x000000ffL);
-        lba >>= 8;
-        cylinder = (uint16_t) (lba & 0x0000ffffL);
-        lba >>= 16;
-        head = ((uint16_t) (lba & 0x0000000fL)) | 0x40;
+        }
+        sector   = bios_dsk->drqp.lba & 0x000000ffL;
+        cylinder = (bios_dsk->drqp.lba >> 8) & 0x0000ffffL;
+        head     = ((bios_dsk->drqp.lba >> 24) & 0x0000000fL) | 0x40;
     }
 
@@ -279,5 +271,5 @@
     outb(iobase1 + ATA_CB_CL, cylinder & 0x00ff);
     outb(iobase1 + ATA_CB_CH, cylinder >> 8);
-    outb(iobase1 + ATA_CB_DH, (slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0) | (uint8_t) head );
+    outb(iobase1 + ATA_CB_DH, ((device & 1) ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0) | head );
     outb(iobase1 + ATA_CB_CMD, command);
 
