Index: trunk/src/VBox/Devices/PC/DevPit-i8254.cpp
===================================================================
--- trunk/src/VBox/Devices/PC/DevPit-i8254.cpp	(revision 11249)
+++ trunk/src/VBox/Devices/PC/DevPit-i8254.cpp	(revision 11250)
@@ -1,5 +1,5 @@
 /** $Id$ */
 /** @file
- * Intel 8254 Programmable Interval Timer (PIT) And Dummy Speaker Device.
+ * DevPIT-i8254 - Intel 8254 Programmable Interval Timer (PIT) And Dummy Speaker Device.
  */
 
@@ -44,5 +44,4 @@
  * THE SOFTWARE.
  */
-
 
 /*******************************************************************************
@@ -56,5 +55,6 @@
 #include <iprt/asm.h>
 
-#include "Builtins.h"
+#include "../Builtins.h"
+
 
 /*******************************************************************************
@@ -77,4 +77,5 @@
 //#define FAKE_REFRESH_CLOCK
 
+
 /*******************************************************************************
 *   Structures and Typedefs                                                    *
@@ -82,12 +83,16 @@
 typedef struct PITChannelState
 {
-    /** Pointer to the instance data - HCPtr. */
-    R3R0PTRTYPE(struct PITState *)  pPitHC;
-    /** The timer - HCPtr. */
-    R3R0PTRTYPE(PTMTIMER)           pTimerHC;
-    /** Pointer to the instance data - GCPtr. */
-    RCPTRTYPE(struct PITState *)    pPitGC;
-    /** The timer - HCPtr. */
-    PTMTIMERRC                      pTimerGC;
+    /** Pointer to the instance data - R3 Ptr. */
+    R3PTRTYPE(struct PITState *)    pPitR3;
+    /** The timer - R3 Ptr. */
+    PTMTIMERR3                      pTimerR3;
+    /** Pointer to the instance data - R0 Ptr. */
+    R0PTRTYPE(struct PITState *)    pPitR0;
+    /** The timer - R0 Ptr. */
+    PTMTIMERR0                      pTimerR0;
+    /** Pointer to the instance data - RC Ptr. */
+    RCPTRTYPE(struct PITState *)    pPitRC;
+    /** The timer - RC Ptr. */
+    PTMTIMERRC                      pTimerRC;
     /** The virtual time stamp at the last reload. (only used in mode 2 for now) */
     uint64_t                        u64ReloadTS;
@@ -133,5 +138,5 @@
 #endif
     /** Pointer to the device instance. */
-    R3PTRTYPE(PPDMDEVINS)   pDevIns;
+    PPDMDEVINSR3            pDevIns;
 #if HC_ARCH_BITS == 32
     uint32_t                Alignment0;
@@ -165,18 +170,12 @@
     uint64_t d;
     int counter;
-    PTMTIMER pTimer = s->CTXSUFF(pPit)->channels[0].CTXSUFF(pTimer);
-
-    if (s->mode == 2) /** @todo Implement proper virtual time and get rid of this hack.. */
-    {
-#if 0
-        d = TMTimerGet(pTimer);
-        d -= s->u64ReloadTS;
-        d = ASMMultU64ByU32DivByU32(d, PIT_FREQ, TMTimerGetFreq(pTimer));
-#else /* variable time because of catch up */
+    PTMTIMER pTimer = s->CTX_SUFF(pPit)->channels[0].CTX_SUFF(pTimer);
+
+    if (s->mode == 2)
+    {
         if (s->u64NextTS == UINT64_MAX)
             return 1; /** @todo check this value. */
         d = TMTimerGet(pTimer);
         d = ASMMultU64ByU32DivByU32(d - s->u64ReloadTS, s->count, s->u64NextTS - s->u64ReloadTS);
-#endif
         if (d >= s->count)
             return 1;
@@ -207,5 +206,5 @@
 {
     uint64_t d;
-    PTMTIMER pTimer = s->CTXSUFF(pPit)->channels[0].CTXSUFF(pTimer);
+    PTMTIMER pTimer = s->CTX_SUFF(pPit)->channels[0].CTX_SUFF(pTimer);
     int out;
 
@@ -269,5 +268,5 @@
 {
     PITChannelState *s = &pit->channels[channel];
-    PTMTIMER pTimer = s->CTXSUFF(pPit)->channels[0].CTXSUFF(pTimer);
+    PTMTIMER pTimer = s->CTX_SUFF(pPit)->channels[0].CTX_SUFF(pTimer);
     Assert((val & 1) == val);
 
@@ -299,7 +298,7 @@
 }
 
-static inline void pit_load_count(PITChannelState *s, int val)
-{
-    PTMTIMER pTimer = s->CTXSUFF(pPit)->channels[0].CTXSUFF(pTimer);
+DECLINLINE(void) pit_load_count(PITChannelState *s, int val)
+{
+    PTMTIMER pTimer = s->CTX_SUFF(pPit)->channels[0].CTX_SUFF(pTimer);
     if (val == 0)
         val = 0x10000;
@@ -309,5 +308,5 @@
 
     /* log the new rate (ch 0 only). */
-    if (    s->pTimerHC /* ch 0 */
+    if (    s->pTimerR3 /* ch 0 */
         &&  s->cRelLogEntries++ < 32)
         LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=0)\n",
@@ -319,5 +318,5 @@
                                             uint64_t current_time)
 {
-    PTMTIMER pTimer = s->CTXSUFF(pPit)->channels[0].CTXSUFF(pTimer);
+    PTMTIMER pTimer = s->CTX_SUFF(pPit)->channels[0].CTX_SUFF(pTimer);
     uint64_t d, next_time, base;
     uint32_t period2;
@@ -388,7 +387,7 @@
     int irq_level;
     PPDMDEVINS pDevIns;
-    PTMTIMER pTimer = s->CTXSUFF(pPit)->channels[0].CTXSUFF(pTimer);
-
-    if (!s->CTXSUFF(pTimer))
+    PTMTIMER pTimer = s->CTX_SUFF(pPit)->channels[0].CTX_SUFF(pTimer);
+
+    if (!s->CTX_SUFF(pTimer))
         return;
     expire_time = pit_get_next_transition_time(s, current_time);
@@ -396,5 +395,5 @@
 
     /* We just flip-flop the irq level to save that extra timer call, which isn't generally required (we haven't served it for months). */
-    pDevIns = s->CTXSUFF(pPit)->pDevIns;
+    pDevIns = s->CTX_SUFF(pPit)->pDevIns;
     PDMDevHlpISASetIrq(pDevIns, s->irq, irq_level);
     if (irq_level)
@@ -405,5 +404,5 @@
     {
         s->u64ReloadTS = now;
-        STAM_COUNTER_INC(&s->CTXSUFF(pPit)->StatPITIrq);
+        STAM_COUNTER_INC(&s->CTX_SUFF(pPit)->StatPITIrq);
     }
 
@@ -411,10 +410,10 @@
     {
         s->u64NextTS = expire_time;
-        TMTimerSet(s->CTXSUFF(pTimer), s->u64NextTS);
+        TMTimerSet(s->CTX_SUFF(pTimer), s->u64NextTS);
     }
     else
     {
         LogFlow(("PIT: m=%d count=%#4x irq_level=%#x stopped\n", s->mode, s->count, irq_level));
-        TMTimerStop(s->CTXSUFF(pTimer));
+        TMTimerStop(s->CTX_SUFF(pTimer));
         s->u64NextTS = UINT64_MAX;
     }
@@ -562,5 +561,5 @@
                         /* status latch */
                         /* XXX: add BCD and null count */
-                        PTMTIMER pTimer = s->CTXSUFF(pPit)->channels[0].CTXSUFF(pTimer);
+                        PTMTIMER pTimer = s->CTX_SUFF(pPit)->channels[0].CTX_SUFF(pTimer);
                         s->status = (pit_get_out1(s, TMTimerGet(pTimer)) << 7)
                             | (s->rw_mode << 4)
@@ -640,6 +639,6 @@
     {
         PITState *pData = PDMINS2DATA(pDevIns, PITState *);
-        const uint64_t u64Now = TMTimerGet(pData->channels[0].CTXSUFF(pTimer));
-        Assert(TMTimerGetFreq(pData->channels[0].CTXSUFF(pTimer)) == 1000000000); /* lazy bird. */
+        const uint64_t u64Now = TMTimerGet(pData->channels[0].CTX_SUFF(pTimer));
+        Assert(TMTimerGetFreq(pData->channels[0].CTX_SUFF(pTimer)) == 1000000000); /* lazy bird. */
 
         /* bit 6,7 Parity error stuff. */
@@ -728,6 +727,6 @@
         SSMR3PutU64(pSSMHandle, s->u64ReloadTS);
         SSMR3PutS64(pSSMHandle, s->next_transition_time);
-        if (s->CTXSUFF(pTimer))
-            TMR3TimerSave(s->CTXSUFF(pTimer), pSSMHandle);
+        if (s->CTX_SUFF(pTimer))
+            TMR3TimerSave(s->CTX_SUFF(pTimer), pSSMHandle);
     }
 
@@ -776,7 +775,7 @@
         SSMR3GetU64(pSSMHandle, &s->u64ReloadTS);
         SSMR3GetS64(pSSMHandle, &s->next_transition_time);
-        if (s->CTXSUFF(pTimer))
+        if (s->CTX_SUFF(pTimer))
         {
-            TMR3TimerLoad(s->CTXSUFF(pTimer), pSSMHandle);
+            TMR3TimerLoad(s->CTX_SUFF(pTimer), pSSMHandle);
             LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=%d) (restore)\n",
                     s->mode, s->count, s->count, PIT_FREQ / s->count, (PIT_FREQ * 100 / s->count) % 100, i));
@@ -805,7 +804,7 @@
     PITState *pData = PDMINS2DATA(pDevIns, PITState *);
     PITChannelState *s = &pData->channels[0];
-    STAM_PROFILE_ADV_START(&s->CTXSUFF(pPit)->StatPITHandler, a);
+    STAM_PROFILE_ADV_START(&s->CTX_SUFF(pPit)->StatPITHandler, a);
     pit_irq_timer_update(s, s->next_transition_time);
-    STAM_PROFILE_ADV_STOP(&s->CTXSUFF(pPit)->StatPITHandler, a);
+    STAM_PROFILE_ADV_STOP(&s->CTX_SUFF(pPit)->StatPITHandler, a);
 }
 
@@ -824,10 +823,10 @@
     LogFlow(("pitRelocate: \n"));
 
-    for (i = 0; i < ELEMENTS(pData->channels); i++)
+    for (i = 0; i < RT_ELEMENTS(pData->channels); i++)
     {
         PITChannelState *pCh = &pData->channels[i];
-        if (pCh->pTimerHC)
-            pCh->pTimerGC = TMTimerGCPtr(pCh->pTimerHC);
-        pData->channels[i].pPitGC = PDMINS2DATA_GCPTR(pDevIns);
+        if (pCh->pTimerR3)
+            pCh->pTimerRC = TMTimerRCPtr(pCh->pTimerR3);
+        pData->channels[i].pPitRC = PDMINS_2_DATA_RCPTR(pDevIns);
     }
 }
@@ -983,8 +982,9 @@
     pData->pDevIns = pDevIns;
     pData->channels[0].irq = u8Irq;
-    for (i = 0; i < ELEMENTS(pData->channels); i++)
-    {
-        pData->channels[i].pPitHC = pData;
-        pData->channels[i].pPitGC = PDMINS2DATA_GCPTR(pDevIns);
+    for (i = 0; i < RT_ELEMENTS(pData->channels); i++)
+    {
+        pData->channels[i].pPitR3 = pData;
+        pData->channels[i].pPitR0 = PDMINS_2_DATA_R0PTR(pDevIns);
+        pData->channels[i].pPitRC = PDMINS_2_DATA_RCPTR(pDevIns);
     }
 
@@ -993,5 +993,5 @@
      */
     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, pitTimer, "i8254 Programmable Interval Timer",
-                                &pData->channels[0].CTXSUFF(pTimer));
+                                &pData->channels[0].pTimerR3);
     if (VBOX_FAILURE(rc))
     {
@@ -999,4 +999,6 @@
         return rc;
     }
+    pData->channels[0].pTimerRC = TMTimerRCPtr(pData->channels[0].pTimerR3);
+    pData->channels[0].pTimerR0 = TMTimerR0Ptr(pData->channels[0].pTimerR3);
 
     rc = PDMDevHlpIOPortRegister(pDevIns, u16Base, 4, NULL, pitIOPortWrite, pitIOPortRead, NULL, NULL, "i8254 Programmable Interval Timer");
Index: trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp
===================================================================
--- trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp	(revision 11249)
+++ trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp	(revision 11250)
@@ -465,8 +465,10 @@
     /* PC/DevPit-i8254.cpp */
     GEN_CHECK_SIZE(PITChannelState);
-    GEN_CHECK_OFF(PITChannelState, pPitHC);
-    GEN_CHECK_OFF(PITChannelState, pTimerHC);
-    GEN_CHECK_OFF(PITChannelState, pPitGC);
-    GEN_CHECK_OFF(PITChannelState, pTimerGC);
+    GEN_CHECK_OFF(PITChannelState, pPitR3);
+    GEN_CHECK_OFF(PITChannelState, pTimerR3);
+    GEN_CHECK_OFF(PITChannelState, pPitR0);
+    GEN_CHECK_OFF(PITChannelState, pTimerR0);
+    GEN_CHECK_OFF(PITChannelState, pPitRC);
+    GEN_CHECK_OFF(PITChannelState, pTimerRC);
     GEN_CHECK_OFF(PITChannelState, u64ReloadTS);
     GEN_CHECK_OFF(PITChannelState, u64NextTS);
