Index: /trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp	(revision 50549)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp	(revision 50550)
@@ -24,5 +24,4 @@
 #include "DevVGA.h"
 #include "HGSMI/SHGSMIHost.h"
-#include "HGSMI/HGSMIHostHlp.h"
 
 #include <VBox/VBoxVideo3D.h>
Index: /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp	(revision 50549)
+++ /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp	(revision 50550)
@@ -61,7 +61,7 @@
 #include <iprt/critsect.h>
 #include <iprt/heap.h>
+#include <iprt/list.h>
 #include <iprt/semaphore.h>
 #include <iprt/string.h>
-#include <iprt/asm.h>
 
 #include <VBox/err.h>
@@ -74,5 +74,4 @@
 #include <VBox/HGSMI/HGSMIChSetup.h>
 
-#include "HGSMIHostHlp.h"
 #include "../DevVGASavedState.h"
 
@@ -133,5 +132,5 @@
 
 
-typedef struct _HGSMIINSTANCE
+typedef struct HGSMIINSTANCE
 {
     PVM pVM;                           /* The VM. */
@@ -145,22 +144,22 @@
     RTCRITSECT    hostHeapCritSect;    /* Heap serialization lock. */
 
-    HGSMILIST hostFIFO;                /* Pending host buffers. */
-    HGSMILIST hostFIFORead;            /* Host buffers read by the guest. */
-    HGSMILIST hostFIFOProcessed;       /* Processed by the guest. */
-    HGSMILIST hostFIFOFree;            /* Buffers for reuse. */
+    RTLISTANCHOR hostFIFO;             /* Pending host buffers. */
+    RTLISTANCHOR hostFIFORead;         /* Host buffers read by the guest. */
+    RTLISTANCHOR hostFIFOProcessed;    /* Processed by the guest. */
+    RTLISTANCHOR hostFIFOFree;         /* Buffers for reuse. */
 #ifdef VBOX_WITH_WDDM
-    HGSMILIST guestCmdCompleted;       /* list of completed guest commands to be returned to the guest*/
-#endif
-    RTCRITSECT    hostFIFOCritSect;    /* FIFO serialization lock. */
+    RTLISTANCHOR guestCmdCompleted;    /* list of completed guest commands to be returned to the guest*/
+#endif
+    RTCRITSECT hostFIFOCritSect;       /* FIFO serialization lock. */
 
     PFNHGSMINOTIFYGUEST pfnNotifyGuest; /* Guest notification callback. */
-    void *pvNotifyGuest;               /* Guest notification callback context. */
-
-    volatile HGSMIHOSTFLAGS * pHGFlags;
+    void *pvNotifyGuest;                /* Guest notification callback context. */
+
+    volatile HGSMIHOSTFLAGS *pHGFlags;
 
     HGSMICHANNELINFO channelInfo;      /* Channel handlers indexed by the channel id.
-                                                      * The array is accessed under the instance lock.
-                                                      */
- }  HGSMIINSTANCE;
+                                        * The array is accessed under the instance lock.
+                                        */
+} HGSMIINSTANCE;
 
 
@@ -168,11 +167,9 @@
 typedef FNHGSMIHOSTFIFOCALLBACK *PFNHGSMIHOSTFIFOCALLBACK;
 
-typedef struct _HGSMIHOSTFIFOENTRY
-{
-    /* The list field. Must be the first field. */
-    HGSMILISTENTRY entry;
-
-    /* Backlink to the HGSMI instance. */
-    HGSMIINSTANCE *pIns;
+typedef struct HGSMIHOSTFIFOENTRY
+{
+    RTLISTNODE nodeEntry;
+
+    HGSMIINSTANCE *pIns;               /* Backlink to the HGSMI instance. */
 
 #if 0
@@ -181,9 +178,8 @@
     RTSEMEVENTMULTI hEvent;
 #endif
-    /* Status flags of the entry. */
-    volatile uint32_t fl;
-
-    /* Offset in the memory region of the entry data. */
-    HGSMIOFFSET offBuffer;
+
+    volatile uint32_t fl;              /* Status flags of the entry. */
+
+    HGSMIOFFSET offBuffer;             /* Offset in the memory region of the entry data. */
 
 #if 0
@@ -195,9 +191,4 @@
 
 } HGSMIHOSTFIFOENTRY;
-
-#define HGSMILISTENTRY_2_FIFOENTRY(_pe) \
-    ( (HGSMIHOSTFIFOENTRY*)((uint8_t *)(_pe) - RT_OFFSETOF(HGSMIHOSTFIFOENTRY, entry)) )
-
-//AssertCompile(RT_OFFSETOF(HGSMIHOSTFIFOENTRY, entry) == 0);
 
 
@@ -213,14 +204,10 @@
 #ifdef VBOX_WITH_WDDM
 
-typedef struct _HGSMIGUESTCOMPLENTRY
-{
-    /* The list field. Must be the first field. */
-    HGSMILISTENTRY entry;
-    /* guest command buffer */
-    HGSMIOFFSET offBuffer;
+typedef struct HGSMIGUESTCOMPLENTRY
+{
+    RTLISTNODE nodeEntry;
+    HGSMIOFFSET offBuffer; /* Offset of the guest command buffer. */
 } HGSMIGUESTCOMPLENTRY;
 
-#define HGSMILISTENTRY_2_HGSMIGUESTCOMPLENTRY(_pe) \
-    ( (HGSMIGUESTCOMPLENTRY*)((uint8_t *)(_pe) - RT_OFFSETOF(HGSMIGUESTCOMPLENTRY, entry)) )
 
 static void hgsmiGuestCompletionFIFOFree (HGSMIINSTANCE *pIns, HGSMIGUESTCOMPLENTRY *pEntry)
@@ -376,27 +363,29 @@
     int rc = hgsmiFIFOLock(pIns);
     AssertRC(rc);
-    if(RT_SUCCESS(rc))
-    {
-        /* Get the host FIFO head entry. */
-        HGSMILISTENTRY *pHead = pIns->guestCmdCompleted.pHead;
-        if(pHead)
-            hgsmiListRemove (&pIns->guestCmdCompleted, pHead, NULL);
-
-        if(!pIns->guestCmdCompleted.pHead)
+    if (RT_SUCCESS(rc))
+    {
+        HGSMIGUESTCOMPLENTRY *pEntry = RTListGetFirst(&pIns->guestCmdCompleted, HGSMIGUESTCOMPLENTRY, nodeEntry);
+        if (pEntry)
+        {
+            RTListNodeRemove(&pEntry->nodeEntry);
+        }
+
+        if (RTListIsEmpty(&pIns->guestCmdCompleted))
         {
             if(pIns->pHGFlags)
-                ASMAtomicAndU32(&pIns->pHGFlags->u32HostFlags, (~HGSMIHOSTFLAGS_GCOMMAND_COMPLETED));
+            {
+                ASMAtomicAndU32(&pIns->pHGFlags->u32HostFlags, ~HGSMIHOSTFLAGS_GCOMMAND_COMPLETED);
+            }
         }
 
         hgsmiFIFOUnlock(pIns);
 
-        if (pHead)
-        {
-            HGSMIGUESTCOMPLENTRY *pEntry = HGSMILISTENTRY_2_HGSMIGUESTCOMPLENTRY(pHead);
+        if (pEntry)
+        {
             offCmd = pEntry->offBuffer;
 
             LogFlowFunc(("host FIFO head %p.\n", pEntry));
 
-            hgsmiGuestCompletionFIFOFree (pIns, pEntry);
+            hgsmiGuestCompletionFIFOFree(pIns, pEntry);
         }
     }
@@ -428,7 +417,7 @@
 }
 
-static bool hgsmiProcessHostCmdCompletion (HGSMIINSTANCE *pIns,
-                     HGSMIOFFSET offBuffer,
-                     bool bCompleteFirst)
+static bool hgsmiProcessHostCmdCompletion(HGSMIINSTANCE *pIns,
+                                          HGSMIOFFSET offBuffer,
+                                          bool bCompleteFirst)
 {
     VM_ASSERT_EMT(pIns->pVM);
@@ -437,25 +426,16 @@
     if(RT_SUCCESS(rc))
     {
-        /* Search the Read list for the given buffer offset. Also find the previous entry. */
-        HGSMIHOSTFIFOENTRY *pEntry = HGSMILISTENTRY_2_FIFOENTRY(pIns->hostFIFORead.pHead);
-        HGSMIHOSTFIFOENTRY *pPrev = NULL;
-
-        while (pEntry)
-        {
-            Assert(pEntry->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_READ));
-
-            if (bCompleteFirst || pEntry->offBuffer == offBuffer)
-            {
+        /* Search the Read list for the given buffer offset. */
+        HGSMIHOSTFIFOENTRY *pEntry = NULL;
+
+        HGSMIHOSTFIFOENTRY *pIter;
+        RTListForEach(&pIns->hostFIFORead, pIter, HGSMIHOSTFIFOENTRY, nodeEntry)
+        {
+            Assert(pIter->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_READ));
+            if (bCompleteFirst || pIter->offBuffer == offBuffer)
+            {
+                pEntry = pIter;
                 break;
             }
-
-#ifdef DEBUGVHWASTRICT
-            /* guest usually completes commands in the order it receives it
-             * if we're here this would typically means there is some cmd loss */
-            AssertFailed();
-#endif
-
-            pPrev = pEntry;
-            pEntry = HGSMILISTENTRY_2_FIFOENTRY(pEntry->entry.pNext);
         }
 
@@ -466,12 +446,10 @@
         if (pEntry)
         {
-            /* Exclude from the Read list. */
-            hgsmiListRemove (&pIns->hostFIFORead, &pEntry->entry, pPrev? &pPrev->entry: NULL);
+            RTListNodeRemove(&pEntry->nodeEntry);
 
             pEntry->fl &= ~HGSMI_F_HOST_FIFO_READ;
             pEntry->fl |= HGSMI_F_HOST_FIFO_PROCESSED;
 
-            /* Save in the Processed list. */
-            hgsmiListAppend (&pIns->hostFIFOProcessed, &pEntry->entry);
+            RTListAppend(&pIns->hostFIFOProcessed, &pEntry->nodeEntry);
 
             hgsmiFIFOUnlock(pIns);
@@ -522,5 +500,5 @@
     {
         /* Get the host FIFO head entry. */
-        HGSMIHOSTFIFOENTRY *pEntry = HGSMILISTENTRY_2_FIFOENTRY(pIns->hostFIFO.pHead);
+        HGSMIHOSTFIFOENTRY *pEntry = RTListGetFirst(&pIns->hostFIFO, HGSMIHOSTFIFOENTRY, nodeEntry);
 
         LogFlowFunc(("host FIFO head %p.\n", pEntry));
@@ -530,8 +508,10 @@
             Assert(pEntry->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_QUEUED));
 
-            /* Exclude from the FIFO. */
-            hgsmiListRemove (&pIns->hostFIFO, &pEntry->entry, NULL);
-
-            if(!pIns->hostFIFO.pHead)
+            /*
+             * Move the entry to the Read list.
+             */
+            RTListNodeRemove(&pEntry->nodeEntry);
+
+            if (RTListIsEmpty(&pIns->hostFIFO))
             {
                 ASMAtomicAndU32(&pIns->pHGFlags->u32HostFlags, (~HGSMIHOSTFLAGS_COMMANDS_PENDING));
@@ -541,9 +521,8 @@
             pEntry->fl |= HGSMI_F_HOST_FIFO_READ;
 
-            /* Save in the Read list. */
-            hgsmiListAppend (&pIns->hostFIFORead, &pEntry->entry);
+            RTListAppend(&pIns->hostFIFORead, &pEntry->nodeEntry);
 
             hgsmiFIFOUnlock(pIns);
-            Assert(pEntry->offBuffer != HGSMIOFFSET_VOID);
+
             /* Return the buffer offset of the host FIFO head. */
             return pEntry->offBuffer;
@@ -759,5 +738,5 @@
     if(RT_SUCCESS(rc))
     {
-        hgsmiListRemove (&pIns->hostFIFOProcessed, &pEntry->entry, NULL);
+        RTListNodeRemove(&pEntry->nodeEntry);
         hgsmiFIFOUnlock (pIns);
 
@@ -788,25 +767,22 @@
         if(RT_SUCCESS(rc))
         {
-            /* Search the Processed list for the given offMem. Also find the previous entry. */
-            HGSMIHOSTFIFOENTRY *pEntry = HGSMILISTENTRY_2_FIFOENTRY(pIns->hostFIFOProcessed.pHead);
-            HGSMIHOSTFIFOENTRY *pPrev = NULL;
-
-            while (pEntry)
-            {
-                Assert(pEntry->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_PROCESSED));
-
-                if (pEntry->offBuffer == offMem)
+            /* Search the Processed list for the given offMem. */
+            HGSMIHOSTFIFOENTRY *pEntry = NULL;
+
+            HGSMIHOSTFIFOENTRY *pIter;
+            RTListForEach(&pIns->hostFIFOProcessed, pIter, HGSMIHOSTFIFOENTRY, nodeEntry)
+            {
+                Assert(pIter->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_PROCESSED));
+
+                if (pIter->offBuffer == offMem)
                 {
+                    pEntry = pIter;
                     break;
                 }
-
-                pPrev = pEntry;
-                pEntry = HGSMILISTENTRY_2_FIFOENTRY(pEntry->entry.pNext);
             }
 
             if (pEntry)
             {
-                /* Exclude from the Processed list. */
-                hgsmiListRemove (&pIns->hostFIFOProcessed, &pEntry->entry, &pPrev->entry);
+                RTListNodeRemove(&pEntry->nodeEntry);
             }
             else
@@ -815,5 +791,4 @@
                 AssertFailed ();
             }
-
 
             hgsmiFIFOUnlock (pIns);
@@ -845,10 +820,4 @@
 }
 
-#define HGSMI_SET_COMMAND_PROCESSED_STATE(_pe) \
-{ \
-    Assert((_pe)->entry.pNext == NULL); \
-    Assert((_pe)->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_PROCESSED)); \
-}
-
 #if 0
 static DECLCALLBACK(void) hgsmiHostCommandRaiseEventCallback (void *pvCallback)
@@ -857,5 +826,5 @@
     HGSMIHOSTFIFOENTRY *pEntry = (HGSMIHOSTFIFOENTRY *)pvCallback;
 
-    HGSMI_SET_COMMAND_PROCESSED_STATE(pEntry);
+    Assert(pEntry->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_PROCESSED));
 
     /* This is a simple callback, just signal the event. */
@@ -869,5 +838,5 @@
     HGSMIHOSTFIFOENTRY *pEntry = (HGSMIHOSTFIFOENTRY *)pvCallback;
 
-    HGSMI_SET_COMMAND_PROCESSED_STATE(pEntry);
+    Assert(pEntry->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_PROCESSED));
 
     /* This is a simple callback, just signal the event. */
@@ -900,5 +869,5 @@
         if (RT_SUCCESS (rc))
         {
-            hgsmiListAppend (&pIns->hostFIFO, &pEntry->entry);
+            RTListAppend(&pIns->hostFIFO, &pEntry->nodeEntry);
             ASMAtomicOrU32(&pIns->pHGFlags->u32HostFlags, HGSMIHOSTFLAGS_COMMANDS_PENDING);
 
@@ -1179,24 +1148,28 @@
 }
 
-static int hgsmiHostSaveFifoEntryLocked (HGSMIHOSTFIFOENTRY *pEntry, PSSMHANDLE pSSM)
-{
-    SSMR3PutU32 (pSSM, pEntry->fl);
-    return SSMR3PutU32 (pSSM, pEntry->offBuffer);
-}
-
-static int hgsmiHostSaveFifoLocked (HGSMILIST * pFifo, PSSMHANDLE pSSM)
+static int hgsmiHostSaveFifoLocked(RTLISTANCHOR *pList, PSSMHANDLE pSSM)
 {
     VBOXHGSMI_SAVE_FIFOSTART(pSSM);
-    uint32_t size = 0;
-    for(HGSMILISTENTRY * pEntry = pFifo->pHead; pEntry; pEntry = pEntry->pNext)
-    {
-        ++size;
-    }
-    int rc = SSMR3PutU32 (pSSM, size);
-
-    for(HGSMILISTENTRY * pEntry = pFifo->pHead; pEntry && RT_SUCCESS(rc); pEntry = pEntry->pNext)
-    {
-        HGSMIHOSTFIFOENTRY *pFifoEntry = HGSMILISTENTRY_2_FIFOENTRY(pEntry);
-        rc = hgsmiHostSaveFifoEntryLocked (pFifoEntry, pSSM);
+
+    HGSMIHOSTFIFOENTRY *pIter;
+
+    uint32_t cEntries = 0;
+    RTListForEach(pList, pIter, HGSMIHOSTFIFOENTRY, nodeEntry)
+    {
+        ++cEntries;
+    }
+
+    int rc = SSMR3PutU32(pSSM, cEntries);
+    if (RT_SUCCESS(rc))
+    {
+        RTListForEach(pList, pIter, HGSMIHOSTFIFOENTRY, nodeEntry)
+        {
+            SSMR3PutU32(pSSM, pIter->fl);
+            rc = SSMR3PutU32(pSSM, pIter->offBuffer);
+            if (RT_FAILURE(rc))
+            {
+                break;
+            }
+        }
     }
 
@@ -1206,23 +1179,26 @@
 }
 
-static int hgsmiHostSaveGuestCmdCompletedFifoEntryLocked (HGSMIGUESTCOMPLENTRY *pEntry, PSSMHANDLE pSSM)
-{
-    return SSMR3PutU32 (pSSM, pEntry->offBuffer);
-}
-
-static int hgsmiHostSaveGuestCmdCompletedFifoLocked (HGSMILIST * pFifo, PSSMHANDLE pSSM)
+static int hgsmiHostSaveGuestCmdCompletedFifoLocked(RTLISTANCHOR *pList, PSSMHANDLE pSSM)
 {
     VBOXHGSMI_SAVE_FIFOSTART(pSSM);
-    uint32_t size = 0;
-    for(HGSMILISTENTRY * pEntry = pFifo->pHead; pEntry; pEntry = pEntry->pNext)
-    {
-        ++size;
-    }
-    int rc = SSMR3PutU32 (pSSM, size);
-
-    for(HGSMILISTENTRY * pEntry = pFifo->pHead; pEntry && RT_SUCCESS(rc); pEntry = pEntry->pNext)
-    {
-        HGSMIGUESTCOMPLENTRY *pFifoEntry = HGSMILISTENTRY_2_HGSMIGUESTCOMPLENTRY(pEntry);
-        rc = hgsmiHostSaveGuestCmdCompletedFifoEntryLocked (pFifoEntry, pSSM);
+
+    HGSMIGUESTCOMPLENTRY *pIter;
+
+    uint32_t cEntries = 0;
+    RTListForEach(pList, pIter, HGSMIGUESTCOMPLENTRY, nodeEntry)
+    {
+        ++cEntries;
+    }
+    int rc = SSMR3PutU32(pSSM, cEntries);
+    if (RT_SUCCESS(rc))
+    {
+        RTListForEach(pList, pIter, HGSMIGUESTCOMPLENTRY, nodeEntry)
+        {
+            rc = SSMR3PutU32(pSSM, pIter->offBuffer);
+            if (RT_FAILURE(rc))
+            {
+                break;
+            }
+        }
     }
 
@@ -1252,18 +1228,20 @@
 }
 
-static int hgsmiHostLoadFifoLocked (PHGSMIINSTANCE pIns, HGSMILIST * pFifo, PSSMHANDLE pSSM)
+static int hgsmiHostLoadFifoLocked(PHGSMIINSTANCE pIns, RTLISTANCHOR *pList, PSSMHANDLE pSSM)
 {
     VBOXHGSMI_LOAD_FIFOSTART(pSSM);
 
-    uint32_t size;
-    int rc = SSMR3GetU32 (pSSM, &size); AssertRC(rc);
-    if(RT_SUCCESS(rc) && size)
-    {
-        for(uint32_t i = 0; i < size; ++i)
-        {
-            HGSMIHOSTFIFOENTRY *pFifoEntry = NULL;  /* initialized to shut up gcc */
-            rc = hgsmiHostLoadFifoEntryLocked (pIns, &pFifoEntry, pSSM);
+    uint32_t cEntries = 0;
+    int rc = SSMR3GetU32(pSSM, &cEntries);
+    if (RT_SUCCESS(rc) && cEntries)
+    {
+        uint32_t i;
+        for (i = 0; i < cEntries; ++i)
+        {
+            HGSMIHOSTFIFOENTRY *pEntry = NULL;
+            rc = hgsmiHostLoadFifoEntryLocked(pIns, &pEntry, pSSM);
             AssertRCBreak(rc);
-            hgsmiListAppend (pFifo, &pFifoEntry->entry);
+
+            RTListAppend(pList, &pEntry->nodeEntry);
         }
     }
@@ -1289,20 +1267,23 @@
 }
 
-static int hgsmiHostLoadGuestCmdCompletedFifoLocked (PHGSMIINSTANCE pIns, HGSMILIST * pFifo, PSSMHANDLE pSSM, uint32_t u32Version)
+static int hgsmiHostLoadGuestCmdCompletedFifoLocked(PHGSMIINSTANCE pIns, RTLISTANCHOR *pList, PSSMHANDLE pSSM, uint32_t u32Version)
 {
     VBOXHGSMI_LOAD_FIFOSTART(pSSM);
 
-    uint32_t size;
-    int rc = SSMR3GetU32 (pSSM, &size); AssertRC(rc);
-    if(RT_SUCCESS(rc) && size)
+    uint32_t i;
+
+    uint32_t cEntries = 0;
+    int rc = SSMR3GetU32(pSSM, &cEntries);
+    if (RT_SUCCESS(rc) && cEntries)
     {
         if (u32Version > VGA_SAVEDSTATE_VERSION_INV_GCMDFIFO)
         {
-            for(uint32_t i = 0; i < size; ++i)
-            {
-                HGSMIGUESTCOMPLENTRY *pFifoEntry = NULL;  /* initialized to shut up gcc */
-                rc = hgsmiHostLoadGuestCmdCompletedFifoEntryLocked (pIns, &pFifoEntry, pSSM);
+            for (i = 0; i < cEntries; ++i)
+            {
+                HGSMIGUESTCOMPLENTRY *pEntry = NULL;
+                rc = hgsmiHostLoadGuestCmdCompletedFifoEntryLocked(pIns, &pEntry, pSSM);
                 AssertRCBreak(rc);
-                hgsmiListAppend (pFifo, &pFifoEntry->entry);
+
+                RTListAppend(pList, &pEntry->nodeEntry);
             }
         }
@@ -1311,11 +1292,13 @@
             LogRel(("WARNING: the current saved state version has some 3D support data missing, "
                     "which may lead to some guest applications function improperly"));
-            /* just read out all invalid data and discard it */
-            for(uint32_t i = 0; i < size; ++i)
-            {
-                HGSMIHOSTFIFOENTRY *pFifoEntry = NULL;  /* initialized to shut up gcc */
-                rc = hgsmiHostLoadFifoEntryLocked (pIns, &pFifoEntry, pSSM);
+
+            /* Just read out all invalid data and discard it. */
+            for (i = 0; i < cEntries; ++i)
+            {
+                HGSMIHOSTFIFOENTRY *pEntry = NULL;
+                rc = hgsmiHostLoadFifoEntryLocked(pIns, &pEntry, pSSM);
                 AssertRCBreak(rc);
-                hgsmiHostFIFOFree (pIns, pFifoEntry);
+
+                hgsmiHostFIFOFree(pIns, pEntry);
             }
         }
@@ -1818,4 +1801,10 @@
         pIns->pfnNotifyGuest = pfnNotifyGuest;
         pIns->pvNotifyGuest  = pvNotifyGuest;
+
+        RTListInit(&pIns->hostFIFO);
+        RTListInit(&pIns->hostFIFORead);
+        RTListInit(&pIns->hostFIFOProcessed);
+        RTListInit(&pIns->hostFIFOFree);
+        RTListInit(&pIns->guestCmdCompleted);
     }
 
@@ -1912,5 +1901,5 @@
         if (RT_SUCCESS (rc))
         {
-            hgsmiListAppend (&pIns->guestCmdCompleted, &pEntry->entry);
+            RTListAppend(&pIns->guestCmdCompleted, &pEntry->nodeEntry);
             ASMAtomicOrU32(&pIns->pHGFlags->u32HostFlags, HGSMIHOSTFLAGS_GCOMMAND_COMPLETED);
 
Index: /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.h	(revision 50549)
+++ /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.h	(revision 50550)
@@ -26,6 +26,6 @@
 #include <VBox/HGSMI/HGSMIChSetup.h>
 
-struct _HGSMIINSTANCE;
-typedef struct _HGSMIINSTANCE *PHGSMIINSTANCE;
+struct HGSMIINSTANCE;
+typedef struct HGSMIINSTANCE *PHGSMIINSTANCE;
 
 /* Callback for the guest notification about a new host buffer. */
Index: unk/src/VBox/Devices/Graphics/HGSMI/HGSMIHostHlp.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHostHlp.cpp	(revision 50549)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/** @file
- *
- * VBox Host Guest Shared Memory Interface (HGSMI).
- * Host part helpers.
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-
-#include "HGSMIHostHlp.h"
-
-
-void hgsmiListAppend (HGSMILIST *pList, HGSMILISTENTRY *pEntry)
-{
-    AssertPtr(pEntry);
-    Assert(pEntry->pNext == NULL);
-
-    if (pList->pTail)
-    {
-        Assert (pList->pTail->pNext == NULL);
-        pList->pTail->pNext = pEntry;
-    }
-    else
-    {
-        Assert (pList->pHead == NULL);
-        pList->pHead = pEntry;
-    }
-
-    pList->pTail = pEntry;
-}
-
-
-void hgsmiListRemove (HGSMILIST *pList, HGSMILISTENTRY *pEntry, HGSMILISTENTRY *pPrev)
-{
-    AssertPtr(pEntry);
-
-    if (pEntry->pNext == NULL)
-    {
-        Assert (pList->pTail == pEntry);
-        pList->pTail = pPrev;
-    }
-    else
-    {
-        /* Do nothing. The *pTail is not changed. */
-    }
-
-    if (pPrev == NULL)
-    {
-        Assert (pList->pHead == pEntry);
-        pList->pHead = pEntry->pNext;
-    }
-    else
-    {
-        pPrev->pNext = pEntry->pNext;
-    }
-
-    pEntry->pNext = NULL;
-}
-
-HGSMILISTENTRY * hgsmiListRemoveAll (HGSMILIST *pList, HGSMILISTENTRY ** ppTail /* optional */)
-{
-    HGSMILISTENTRY * pHead = pList->pHead;
-    if (ppTail)
-        *ppTail = pList->pTail;
-
-    hgsmiListInit (pList);
-
-    return pHead;
-}
-
Index: unk/src/VBox/Devices/Graphics/HGSMI/HGSMIHostHlp.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHostHlp.h	(revision 50549)
+++ 	(revision )
@@ -1,112 +1,0 @@
-/** @file
- *
- * VBox Host Guest Shared Memory Interface (HGSMI).
- * Host part helpers.
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-
-#ifndef __HGSMIHostHlp_h__
-#define __HGSMIHostHlp_h__
-
-#include <iprt/assert.h>
-#include <iprt/types.h>
-
-typedef struct _HGSMILISTENTRY
-{
-    struct _HGSMILISTENTRY *pNext;
-} HGSMILISTENTRY;
-
-typedef struct _HGSMILIST
-{
-    HGSMILISTENTRY *pHead;
-    HGSMILISTENTRY *pTail;
-} HGSMILIST;
-
-void hgsmiListAppend (HGSMILIST *pList, HGSMILISTENTRY *pEntry);
-DECLINLINE(void) hgsmiListPrepend (HGSMILIST *pList, HGSMILISTENTRY *pEntry)
-{
-    HGSMILISTENTRY * pHead = pList->pHead;
-    pList->pHead = pEntry;
-    pEntry->pNext = pHead;
-    if (!pHead)
-        pList->pTail = pEntry;
-}
-
-void hgsmiListRemove (HGSMILIST *pList, HGSMILISTENTRY *pEntry, HGSMILISTENTRY *pPrev);
-
-DECLINLINE(HGSMILISTENTRY*) hgsmiListRemoveHead (HGSMILIST *pList)
-{
-    HGSMILISTENTRY *pHead = pList->pHead;
-    if (pHead)
-        hgsmiListRemove (pList, pHead, NULL);
-    return pHead;
-}
-
-DECLINLINE(bool) hgsmiListIsEmpty (HGSMILIST *pList)
-{
-    return !pList->pHead;
-}
-
-DECLINLINE(void) hgsmiListInit (HGSMILIST *pList)
-{
-    pList->pHead = NULL;
-    pList->pTail = NULL;
-}
-
-HGSMILISTENTRY * hgsmiListRemoveAll (HGSMILIST *pList, HGSMILISTENTRY ** ppTail /* optional */);
-
-DECLINLINE(void) hgsmiListAppendAll (HGSMILIST *pList, HGSMILISTENTRY *pHead, HGSMILISTENTRY *pTail)
-{
-    if(hgsmiListIsEmpty (pList))
-    {
-        pList->pHead = pHead;
-        pList->pTail = pTail;
-    }
-    else
-    {
-        pList->pTail->pNext = pHead;
-        pList->pTail = pTail;
-    }
-}
-
-DECLINLINE(void) hgsmiListPrependAll (HGSMILIST *pList, HGSMILISTENTRY *pHead, HGSMILISTENTRY *pTail)
-{
-    HGSMILISTENTRY *pOldHead = pList->pHead;
-    if(!pOldHead)
-    {
-        pList->pHead = pHead;
-        pList->pTail = pTail;
-    }
-    else
-    {
-        pList->pHead = pHead;
-        pTail->pNext = pOldHead;
-    }
-}
-
-DECLINLINE(void) hgsmiListCat (HGSMILIST *pList, HGSMILIST *pList2)
-{
-    hgsmiListAppendAll (pList, pList2->pHead, pList2->pTail);
-    hgsmiListInit (pList2);
-}
-
-DECLINLINE(void) hgsmiListPrepCat (HGSMILIST *pList, HGSMILIST *pList2)
-{
-    hgsmiListPrependAll (pList, pList2->pHead, pList2->pTail);
-    hgsmiListInit (pList2);
-}
-
-
-#endif /* !__HGSMIHostHlp_h__*/
Index: /trunk/src/VBox/Devices/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Devices/Makefile.kmk	(revision 50549)
+++ /trunk/src/VBox/Devices/Makefile.kmk	(revision 50550)
@@ -228,6 +228,5 @@
   VBoxDD_SOURCES        += \
  	Graphics/DevVGA_VBVA.cpp \
- 	Graphics/HGSMI/HGSMIHost.cpp \
- 	Graphics/HGSMI/HGSMIHostHlp.cpp
+ 	Graphics/HGSMI/HGSMIHost.cpp
   VBoxDD_LIBS           += \
  	$(PATH_STAGE_LIB)/HGSMIHostR3Lib$(VBOX_SUFF_LIB)
