Index: trunk/src/VBox/Devices/PC/DevACPI.cpp
===================================================================
--- trunk/src/VBox/Devices/PC/DevACPI.cpp	(revision 44625)
+++ trunk/src/VBox/Devices/PC/DevACPI.cpp	(revision 44626)
@@ -1720,5 +1720,5 @@
     R(PM1a_EVT_OFFSET,   1, acpiR3PM1aStsWrite,      acpiR3Pm1aStsRead,     "ACPI PM1a Status");
     R(PM1a_CTL_OFFSET,   1, acpiR3PM1aCtlWrite,      acpiR3Pm1aCtlRead,     "ACPI PM1a Control");
-    R(PM_TMR_OFFSET,     1, NULL,                  acpiPMTmrRead,       "ACPI PM Timer");
+    R(PM_TMR_OFFSET,     1, NULL,                    acpiPMTmrRead,         "ACPI PM Timer");
     R(GPE0_OFFSET + L,   L, acpiR3Gpe0EnWrite,       acpiR3Gpe0EnRead,      "ACPI GPE0 Enable");
     R(GPE0_OFFSET,       L, acpiR3Gpe0StsWrite,      acpiR3Gpe0StsRead,     "ACPI GPE0 Status");
Index: trunk/src/VBox/Devices/PC/DevAPIC.cpp
===================================================================
--- trunk/src/VBox/Devices/PC/DevAPIC.cpp	(revision 44625)
+++ trunk/src/VBox/Devices/PC/DevAPIC.cpp	(revision 44626)
@@ -1812,5 +1812,6 @@
     APICState *pApic = apicGetStateByCurEmt(pDev);
 
-    Log(("CPU%d: apicMMIORead at %llx\n", pApic->phys_id,  (uint64_t)GCPhysAddr));
+    Log(("CPU%d: apicMMIORead at %RGp\n", pApic->phys_id, GCPhysAddr));
+    Assert(cb == 4);
 
     /** @todo add LAPIC range validity checks (different LAPICs can
@@ -1818,50 +1819,27 @@
 
     STAM_COUNTER_INC(&CTXSUFF(pDev->StatMMIORead));
-    switch (cb)
-    {
-        case 1:
-            /** @todo this is not how recent APIC behave!  We will fix
-             *        this via the IOM. */
-            *(uint8_t *)pv = 0;
-            break;
-
-        case 2:
-            /** @todo this is not how recent APIC behave! */
-            *(uint16_t *)pv = 0;
-            break;
-
-        case 4:
-        {
 #if 0 /* Note! experimental */
 #ifndef IN_RING3
-            uint32_t index = (GCPhysAddr >> 4) & 0xff;
-
-            if (    index == 0x08 /* TPR */
-                &&  ++pApic->cTPRPatchAttempts < APIC_MAX_PATCH_ATTEMPTS)
-            {
-#ifdef IN_RC
-                pDevIns->pDevHlpGC->pfnPATMSetMMIOPatchInfo(pDevIns, GCPhysAddr, &pApic->tpr);
-#else
-                RTGCPTR pDevInsGC = PDMINS2DATA_GCPTR(pDevIns);
-                pDevIns->pHlpR0->pfnPATMSetMMIOPatchInfo(pDevIns, GCPhysAddr, pDevIns + RT_OFFSETOF(APICState, tpr));
-#endif
-                return VINF_PATM_HC_MMIO_PATCH_READ;
-            }
+    uint32_t index = (GCPhysAddr >> 4) & 0xff;
+
+    if (    index == 0x08 /* TPR */
+        &&  ++pApic->cTPRPatchAttempts < APIC_MAX_PATCH_ATTEMPTS)
+    {
+# ifdef IN_RC
+        pDevIns->pDevHlpGC->pfnPATMSetMMIOPatchInfo(pDevIns, GCPhysAddr, &pApic->tpr);
+# else
+        RTGCPTR pDevInsGC = PDMINS2DATA_GCPTR(pDevIns);
+        pDevIns->pHlpR0->pfnPATMSetMMIOPatchInfo(pDevIns, GCPhysAddr, pDevIns + RT_OFFSETOF(APICState, tpr));
+# endif
+        return VINF_PATM_HC_MMIO_PATCH_READ;
+    }
 #endif
 #endif /* experimental */
 
-            /* It does its own locking. */
-            uint64_t u64Value = 0;
-            int rc = apicReadRegister(pDev, pApic, (GCPhysAddr >> 4) & 0xff, &u64Value,
-                                      VINF_IOM_R3_MMIO_READ, false /*fMsr*/);
-            *(uint32_t *)pv = (uint32_t)u64Value;
-            return rc;
-        }
-
-        default:
-            AssertReleaseMsgFailed(("cb=%d\n", cb)); /* for now we assume simple accesses. */
-            return VERR_INTERNAL_ERROR;
-    }
-    return VINF_SUCCESS;
+    /* Note! apicReadRegister does its own locking. */
+    uint64_t u64Value = 0;
+    int rc = apicReadRegister(pDev, pApic, (GCPhysAddr >> 4) & 0xff, &u64Value, VINF_IOM_R3_MMIO_READ, false /*fMsr*/);
+    *(uint32_t *)pv = (uint32_t)u64Value;
+    return rc;
 }
 
@@ -1871,5 +1849,6 @@
     APICState *pApic = apicGetStateByCurEmt(pDev);
 
-    Log(("CPU%d: apicMMIOWrite at %llx\n", pApic->phys_id, (uint64_t)GCPhysAddr));
+    Log(("CPU%d: apicMMIOWrite at %RGp\n", pApic->phys_id, GCPhysAddr));
+    Assert(cb == 4);
 
     /** @todo: add LAPIC range validity checks (multiple LAPICs can theoretically have
@@ -1877,21 +1856,7 @@
 
     STAM_COUNTER_INC(&CTXSUFF(pDev->StatMMIOWrite));
-    switch (cb)
-    {
-        case 1:
-        case 2:
-            /* ignore */
-            break;
-
-        case 4:
-            /* It does its own locking. */
-            return apicWriteRegister(pDev, pApic, (GCPhysAddr >> 4) & 0xff, *(uint32_t const *)pv,
-                                     VINF_IOM_R3_MMIO_WRITE, false /*fMsr*/);
-
-        default:
-            AssertReleaseMsgFailed(("cb=%d\n", cb)); /* for now we assume simple accesses. */
-            return VERR_INTERNAL_ERROR;
-    }
-    return VINF_SUCCESS;
+    /* Note! It does its own locking. */
+    return apicWriteRegister(pDev, pApic, (GCPhysAddr >> 4) & 0xff, *(uint32_t const *)pv,
+                             VINF_IOM_R3_MMIO_WRITE, false /*fMsr*/);
 }
 
@@ -2381,5 +2346,5 @@
     uint32_t ApicBase = pDev->paLapicsR3[0].apicbase & ~0xfff;
     rc = PDMDevHlpMMIORegister(pDevIns, ApicBase, 0x1000, pDev,
-                               IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
+                               IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_ONLY_DWORD,
                                apicMMIOWrite, apicMMIORead, "APIC Memory");
     if (RT_FAILURE(rc))
Index: trunk/src/VBox/ExtPacks/BusMouseSample/BusMouse.cpp
===================================================================
--- trunk/src/VBox/ExtPacks/BusMouseSample/BusMouse.cpp	(revision 44625)
+++ trunk/src/VBox/ExtPacks/BusMouseSample/BusMouse.cpp	(revision 44626)
@@ -124,5 +124,6 @@
 typedef struct MouState
 {
-    /* 8255A state */
+    /** @name 8255A state
+     * @{ */
     uint8_t         port_a;
     uint8_t         port_b;
@@ -138,5 +139,8 @@
     /** Timer period in milliseconds. */
     uint32_t        cTimerPeriodMs;
-    /* mouse state */
+    /** @} */
+
+    /** @name mouse state
+     * @{ */
     int32_t         disable_counter;
     uint8_t         mouse_enabled;
@@ -145,4 +149,5 @@
     uint8_t         mouse_buttons;
     uint8_t         mouse_buttons_reported;
+    /** @}  */
 
     /** Pointer to the device instance - RC. */
@@ -348,72 +353,74 @@
 }
 
-static int bms_write_port(MouState *pThis, uint32_t addr, uint32_t val)
+static int bms_write_port(MouState *pThis, uint32_t offPort, uint32_t uValue)
 {
     int rc = VINF_SUCCESS;
 
-    LogRel3(("%s: write port %d: 0x%02x\n", __PRETTY_FUNCTION__, addr, val));
-
-    switch(addr) {
-    case BMS_PORT_SIG:
-        /* Update port B. */
-        pThis->port_b = val;
-        break;
-    case BMS_PORT_DATA:
-        /* Do nothing, port A is not writable. */
-        break;
-    case BMS_PORT_INIT:
-        pThis->ctrl_port = val;
-        break;
-    case BMS_PORT_CTRL:
-        /* Update the high nibble of port C. */
-        pThis->port_c = (val & 0xF0) | (pThis->port_c & 0x0F);
-        bms_update_ctrl(pThis);
-        break;
-    default:
-        AssertMsgFailed(("invalid port %#x\n", addr));
-        break;
+    LogRel3(("%s: write port %d: 0x%02x\n", __PRETTY_FUNCTION__, offPort, uValue));
+
+    switch (offPort)
+    {
+        case BMS_PORT_SIG:
+            /* Update port B. */
+            pThis->port_b = uValue;
+            break;
+        case BMS_PORT_DATA:
+            /* Do nothing, port A is not writable. */
+            break;
+        case BMS_PORT_INIT:
+            pThis->ctrl_port = uValue;
+            break;
+        case BMS_PORT_CTRL:
+            /* Update the high nibble of port C. */
+            pThis->port_c = (uValue & 0xF0) | (pThis->port_c & 0x0F);
+            bms_update_ctrl(pThis);
+            break;
+        default:
+            AssertMsgFailed(("invalid port %#x\n", offPort));
+            break;
     }
     return rc;
 }
 
-static uint32_t bms_read_port(MouState *pThis, uint32_t addr)
-{
-    uint32_t val;
-
-    switch(addr) {
-    case BMS_PORT_DATA:
-        /* Read port A. */
-        val = pThis->port_a;
-        break;
-    case BMS_PORT_SIG:
-        /* Read port B. */
-        val = pThis->port_b;
-        break;
-    case BMS_PORT_CTRL:
-        /* Read port C. */
-        val = pThis->port_c;
-        /* Some Microsoft driver code reads the control port 10,000 times when
-         * determining the IRQ level. This can occur faster than the IRQ line
-         * transitions and the detection fails. To work around this, we force
-         * the IRQ bit to toggle every once in a while.
-         */
-        if (pThis->irq_toggle_counter)
-            pThis->irq_toggle_counter--;
-        else
-        {
-            pThis->irq_toggle_counter = 1000;
-            val ^= BMS_IRQ_BIT(pThis->irq);
-        }
-        break;
-    case BMS_PORT_INIT:
-        /* Read the 8255A control port. */
-        val = pThis->ctrl_port;
-        break;
-    default:
-        AssertMsgFailed(("invalid port %#x\n", addr));
-        break;
-    }
-    LogRel3(("%s: read port %d: 0x%02x\n", __PRETTY_FUNCTION__, addr, val));
-    return val;
+static uint32_t bms_read_port(MouState *pThis, uint32_t offPort)
+{
+    uint32_t uValue;
+
+    switch (offPort)
+    {
+        case BMS_PORT_DATA:
+            /* Read port A. */
+            uValue = pThis->port_a;
+            break;
+        case BMS_PORT_SIG:
+            /* Read port B. */
+            uValue = pThis->port_b;
+            break;
+        case BMS_PORT_CTRL:
+            /* Read port C. */
+            uValue = pThis->port_c;
+            /* Some Microsoft driver code reads the control port 10,000 times when
+             * determining the IRQ level. This can occur faster than the IRQ line
+             * transitions and the detection fails. To work around this, we force
+             * the IRQ bit to toggle every once in a while.
+             */
+            if (pThis->irq_toggle_counter)
+                pThis->irq_toggle_counter--;
+            else
+            {
+                pThis->irq_toggle_counter = 1000;
+                uValue ^= BMS_IRQ_BIT(pThis->irq);
+            }
+            break;
+        case BMS_PORT_INIT:
+            /* Read the 8255A control port. */
+            uValue = pThis->ctrl_port;
+            break;
+        default:
+            AssertMsgFailed(("invalid port %#x\n", offPort));
+            break;
+    }
+    LogRel3(("%s: read port %d: 0x%02x\n", __PRETTY_FUNCTION__, offPort, uValue));
+    return uValue;
 }
 
