Index: trunk/src/VBox/Devices/Storage/DevATA.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 107855)
+++ trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 107856)
@@ -1441,6 +1441,6 @@
     if (s->cTotalSectors <= (1 << 28) - 1)
     {
-        p[60] = RT_H2LE_U16(s->cTotalSectors);
-        p[61] = RT_H2LE_U16(s->cTotalSectors >> 16);
+        p[60] = RT_H2LE_U16(RT_LO_U16(s->cTotalSectors));
+        p[61] = RT_H2LE_U16(RT_HI_U16(s->cTotalSectors));
     }
     else
@@ -1484,8 +1484,8 @@
     if (s->cTotalSectors > (1 << 28) - 1)
     {
-        p[100] = RT_H2LE_U16(s->cTotalSectors);
-        p[101] = RT_H2LE_U16(s->cTotalSectors >> 16);
-        p[102] = RT_H2LE_U16(s->cTotalSectors >> 32);
-        p[103] = RT_H2LE_U16(s->cTotalSectors >> 48);
+        p[100] = RT_H2LE_U16(RT_LO_U16(RT_LO_U32(s->cTotalSectors)));
+        p[101] = RT_H2LE_U16(RT_HI_U16(RT_LO_U32(s->cTotalSectors)));
+        p[102] = RT_H2LE_U16(RT_LO_U16(RT_HI_U32(s->cTotalSectors)));
+        p[103] = RT_H2LE_U16(RT_HI_U16(RT_HI_U32(s->cTotalSectors)));
     }
 
@@ -1495,6 +1495,6 @@
         /* Enable reporting of logical sector size. */
         p[106] |= RT_H2LE_U16(RT_BIT(12) | RT_BIT(14));
-        p[117] = RT_H2LE_U16(cSectorSizeInWords);
-        p[118] = RT_H2LE_U16(cSectorSizeInWords >> 16);
+        p[117] = RT_H2LE_U16(RT_LO_U16(cSectorSizeInWords));
+        p[118] = RT_H2LE_U16(RT_HI_U16(cSectorSizeInWords));
     }
 
@@ -1673,5 +1673,5 @@
         {
             /* LBA */
-            s->uATARegSelect = (s->uATARegSelect & 0xf0) | (iLBA >> 24);
+            s->uATARegSelect = RT_BYTE4(iLBA) | (s->uATARegSelect & 0xf0);
             s->uATARegHCyl   = RT_BYTE3(iLBA);
             s->uATARegLCyl   = RT_BYTE2(iLBA);
@@ -1873,5 +1873,5 @@
     Assert(cSectors);
     iLBA = s->iCurLBA;
-    Log(("%s: %d sectors at LBA %d\n", __FUNCTION__, cSectors, iLBA));
+    Log(("%s: %d sectors at LBA %llu\n", __FUNCTION__, cSectors, iLBA));
     rc = ataR3ReadSectors(pDevIns, pCtl, s, pDevR3, iLBA, s->abIOBuffer, cSectors, &fRedo);
     if (RT_SUCCESS(rc))
@@ -1926,5 +1926,5 @@
     Assert(cSectors);
     iLBA = s->iCurLBA;
-    Log(("%s: %d sectors at LBA %d\n", __FUNCTION__, cSectors, iLBA));
+    Log(("%s: %d sectors at LBA %llu\n", __FUNCTION__, cSectors, iLBA));
     rc = ataR3WriteSectors(pDevIns, pCtl, s, pDevR3, iLBA, s->abIOBuffer, cSectors, &fRedo);
     if (RT_SUCCESS(rc))
@@ -4680,8 +4680,8 @@
  */
 
-static VBOXSTRICTRC ataIOPortWriteU8(PPDMDEVINS pDevIns, PATACONTROLLER pCtl, uint32_t addr, uint32_t val, uintptr_t iCtl)
+static VBOXSTRICTRC ataIOPortWriteU8(PPDMDEVINS pDevIns, PATACONTROLLER pCtl, uint32_t addr, uint8_t val, uintptr_t iCtl)
 {
     RT_NOREF(iCtl);
-    Log2(("%s: LUN#%d write addr=%#x val=%#04x\n", __FUNCTION__, pCtl->aIfs[pCtl->iSelectedIf & ATA_SELECTED_IF_MASK].iLUN, addr, val));
+    Log2(("%s: LUN#%d write addr=%#x val=%#02x\n", __FUNCTION__, pCtl->aIfs[pCtl->iSelectedIf & ATA_SELECTED_IF_MASK].iLUN, addr, val));
     addr &= 7;
     switch (addr)
@@ -4965,5 +4965,5 @@
         }
     }
-    Log2(("%s: LUN#%d addr=%#x val=%#04x\n", __FUNCTION__, s->iLUN, addr, val));
+    Log2(("%s: LUN#%d addr=%#x val=%#02x\n", __FUNCTION__, s->iLUN, addr, val));
     *pu32 = val;
     return VINF_SUCCESS;
@@ -4989,5 +4989,5 @@
 }
 
-static int ataControlWrite(PPDMDEVINS pDevIns, PATACONTROLLER pCtl, uint32_t val, uint32_t uIoPortForLog)
+static int ataControlWrite(PPDMDEVINS pDevIns, PATACONTROLLER pCtl, uint8_t val, uint32_t uIoPortForLog)
 {
     RT_NOREF(uIoPortForLog);
@@ -4997,5 +4997,5 @@
 #endif /* !IN_RING3 */
 
-    Log2(("%s: LUN#%d write addr=%#x val=%#04x\n", __FUNCTION__, pCtl->aIfs[pCtl->iSelectedIf & ATA_SELECTED_IF_MASK].iLUN, uIoPortForLog, val));
+    Log2(("%s: LUN#%d write addr=%#x val=%#02x\n", __FUNCTION__, pCtl->aIfs[pCtl->iSelectedIf & ATA_SELECTED_IF_MASK].iLUN, uIoPortForLog, val));
     /* RESET is common for both drives attached to a controller. */
     if (   !(pCtl->aIfs[0].uATARegDevCtl & ATA_DEVCTL_RESET)
@@ -6740,5 +6740,5 @@
             Log(("ataIOPortWrite1: suspect write to port %x val=%x size=%d\n", offPort, u32, cb));
 
-        rc = ataIOPortWriteU8(pDevIns, pCtl, offPort, u32, iCtl);
+        rc = ataIOPortWriteU8(pDevIns, pCtl, offPort, RT_BYTE1(u32), iCtl);
 
         PDMDevHlpCritSectLeave(pDevIns, &pCtl->lock);
@@ -6805,5 +6805,5 @@
         if (rc == VINF_SUCCESS)
         {
-            rc = ataControlWrite(pDevIns, pCtl, u32, offPort);
+            rc = ataControlWrite(pDevIns, pCtl, RT_BYTE1(u32), offPort);
             PDMDevHlpCritSectLeave(pDevIns, &pCtl->lock);
         }
