Index: /trunk/include/VBox/Graphics/HGSMIBuffers.h
===================================================================
--- /trunk/include/VBox/Graphics/HGSMIBuffers.h	(revision 66685)
+++ /trunk/include/VBox/Graphics/HGSMIBuffers.h	(revision 66685)
@@ -0,0 +1,122 @@
+/** @file
+ * VBox Host Guest Shared Memory Interface (HGSMI) buffer management.
+ */
+
+/*
+ * Copyright (C) 2006-2017 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.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+#ifndef ___VBox_Graphics_HGSMIBuffers_h___
+#define ___VBox_Graphics_HGSMIBuffers_h___
+
+#include <HGSMI.h>
+#include <HGSMIChSetup.h>
+#include <VBoxVideoIPRT.h>
+
+#ifdef VBOX_WDDM_MINIPORT
+# include "wddm/VBoxMPShgsmi.h"
+ typedef VBOXSHGSMI HGSMIGUESTCMDHEAP;
+# define HGSMIGUESTCMDHEAP_GET(_p) (&(_p)->Heap)
+#else
+ typedef HGSMIHEAP HGSMIGUESTCMDHEAP;
+# define HGSMIGUESTCMDHEAP_GET(_p) (_p)
+#endif
+
+RT_C_DECLS_BEGIN
+
+/**
+ * Structure grouping the context needed for submitting commands to the host
+ * via HGSMI
+ */
+typedef struct HGSMIGUESTCOMMANDCONTEXT
+{
+    /** Information about the memory heap located in VRAM from which data
+     * structures to be sent to the host are allocated. */
+    HGSMIGUESTCMDHEAP heapCtx;
+    /** The I/O port used for submitting commands to the host by writing their
+     * offsets into the heap. */
+    RTIOPORT port;
+} HGSMIGUESTCOMMANDCONTEXT, *PHGSMIGUESTCOMMANDCONTEXT;
+
+
+/**
+ * Structure grouping the context needed for receiving commands from the host
+ * via HGSMI
+ */
+typedef struct HGSMIHOSTCOMMANDCONTEXT
+{
+    /** Information about the memory area located in VRAM in which the host
+     * places data structures to be read by the guest. */
+    HGSMIAREA areaCtx;
+    /** Convenience structure used for matching host commands to handlers. */
+    /** @todo handlers are registered individually in code rather than just
+     * passing a static structure in order to gain extra flexibility.  There is
+     * currently no expected usage case for this though.  Is the additional
+     * complexity really justified? */
+    HGSMICHANNELINFO channels;
+    /** Flag to indicate that one thread is currently processing the command
+     * queue. */
+    volatile bool fHostCmdProcessing;
+    /* Pointer to the VRAM location where the HGSMI host flags are kept. */
+    volatile HGSMIHOSTFLAGS *pfHostFlags;
+    /** The I/O port used for receiving commands from the host as offsets into
+     * the memory area and sending back confirmations (command completion,
+     * IRQ acknowlegement). */
+    RTIOPORT port;
+} HGSMIHOSTCOMMANDCONTEXT, *PHGSMIHOSTCOMMANDCONTEXT;
+
+/** @name Base HGSMI Buffer APIs
+ * @{ */
+
+/** Acknowlege an IRQ. */
+DECLINLINE(void) VBoxHGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx)
+{
+    VBVO_PORT_WRITE_U32(pCtx->port, HGSMIOFFSET_VOID);
+}
+
+DECLHIDDEN(void)     VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
+                                               void *pvBaseMapping,
+                                               uint32_t offHostFlags,
+                                               void *pvHostAreaMapping,
+                                               uint32_t offVRAMHostArea,
+                                               uint32_t cbHostArea);
+DECLHIDDEN(void)     VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx,
+                                              void *pvMem);
+DECLHIDDEN(void)     VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx);
+/** @todo we should provide a cleanup function too as part of the API */
+DECLHIDDEN(int)      VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
+                                                void *pvGuestHeapMemory,
+                                                uint32_t cbGuestHeapMemory,
+                                                uint32_t offVRAMGuestHeapMemory,
+                                                const HGSMIENV *pEnv);
+DECLHIDDEN(void *)   VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,
+                                          HGSMISIZE cbData,
+                                          uint8_t u8Ch,
+                                          uint16_t u16Op);
+DECLHIDDEN(void)     VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx,
+                                         void *pvBuffer);
+DECLHIDDEN(int)      VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx,
+                                           void *pvBuffer);
+/** @}  */
+
+RT_C_DECLS_END
+
+#endif
Index: /trunk/include/VBox/Graphics/VBoxVideoGuest.h
===================================================================
--- /trunk/include/VBox/Graphics/VBoxVideoGuest.h	(revision 66684)
+++ /trunk/include/VBox/Graphics/VBoxVideoGuest.h	(revision 66685)
@@ -30,61 +30,9 @@
 #define ___VBox_Graphics_VBoxVideoGuest_h___
 
-#include <HGSMI.h>
-#include <HGSMIChSetup.h>
+#include <HGSMIBuffers.h>
 #include <VBoxVideo.h>
 #include <VBoxVideoIPRT.h>
 
-#ifdef VBOX_WDDM_MINIPORT
-# include "wddm/VBoxMPShgsmi.h"
- typedef VBOXSHGSMI HGSMIGUESTCMDHEAP;
-# define HGSMIGUESTCMDHEAP_GET(_p) (&(_p)->Heap)
-#else
- typedef HGSMIHEAP HGSMIGUESTCMDHEAP;
-# define HGSMIGUESTCMDHEAP_GET(_p) (_p)
-#endif
-
 RT_C_DECLS_BEGIN
-
-/**
- * Structure grouping the context needed for submitting commands to the host
- * via HGSMI
- */
-typedef struct HGSMIGUESTCOMMANDCONTEXT
-{
-    /** Information about the memory heap located in VRAM from which data
-     * structures to be sent to the host are allocated. */
-    HGSMIGUESTCMDHEAP heapCtx;
-    /** The I/O port used for submitting commands to the host by writing their
-     * offsets into the heap. */
-    RTIOPORT port;
-} HGSMIGUESTCOMMANDCONTEXT, *PHGSMIGUESTCOMMANDCONTEXT;
-
-
-/**
- * Structure grouping the context needed for receiving commands from the host
- * via HGSMI
- */
-typedef struct HGSMIHOSTCOMMANDCONTEXT
-{
-    /** Information about the memory area located in VRAM in which the host
-     * places data structures to be read by the guest. */
-    HGSMIAREA areaCtx;
-    /** Convenience structure used for matching host commands to handlers. */
-    /** @todo handlers are registered individually in code rather than just
-     * passing a static structure in order to gain extra flexibility.  There is
-     * currently no expected usage case for this though.  Is the additional
-     * complexity really justified? */
-    HGSMICHANNELINFO channels;
-    /** Flag to indicate that one thread is currently processing the command
-     * queue. */
-    volatile bool fHostCmdProcessing;
-    /* Pointer to the VRAM location where the HGSMI host flags are kept. */
-    volatile HGSMIHOSTFLAGS *pfHostFlags;
-    /** The I/O port used for receiving commands from the host as offsets into
-     * the memory area and sending back confirmations (command completion,
-     * IRQ acknowlegement). */
-    RTIOPORT port;
-} HGSMIHOSTCOMMANDCONTEXT, *PHGSMIHOSTCOMMANDCONTEXT;
-
 
 /**
@@ -112,22 +60,5 @@
  * @{ */
 
-/** Acknowlege an IRQ. */
-DECLINLINE(void) VBoxHGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx)
-{
-    VBVO_PORT_WRITE_U32(pCtx->port, HGSMIOFFSET_VOID);
-}
-
-DECLHIDDEN(void)     VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx,
-                                              void *pvMem);
-DECLHIDDEN(void)     VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx);
 DECLHIDDEN(bool)     VBoxHGSMIIsSupported(void);
-DECLHIDDEN(void *)   VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,
-                                          HGSMISIZE cbData,
-                                          uint8_t u8Ch,
-                                          uint16_t u16Op);
-DECLHIDDEN(void)     VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx,
-                                         void *pvBuffer);
-DECLHIDDEN(int)      VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx,
-                                           void *pvBuffer);
 DECLHIDDEN(void)     VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM,
                                                  uint32_t *poffVRAMBaseMapping,
@@ -140,10 +71,4 @@
 DECLHIDDEN(int)      VBoxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
                                            uint32_t fCaps);
-/** @todo we should provide a cleanup function too as part of the API */
-DECLHIDDEN(int)      VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
-                                                void *pvGuestHeapMemory,
-                                                uint32_t cbGuestHeapMemory,
-                                                uint32_t offVRAMGuestHeapMemory,
-                                                const HGSMIENV *pEnv);
 DECLHIDDEN(void)     VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
                                                  uint32_t cbVRAM,
@@ -151,10 +76,4 @@
                                                  uint32_t *poffVRAMHostArea,
                                                  uint32_t *pcbHostArea);
-DECLHIDDEN(void)     VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
-                                               void *pvBaseMapping,
-                                               uint32_t offHostFlags,
-                                               void *pvHostAreaMapping,
-                                               uint32_t offVRAMHostArea,
-                                               uint32_t cbHostArea);
 DECLHIDDEN(int)      VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
                                               HGSMIOFFSET offVRAMFlagsLocation,
Index: /trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv
===================================================================
--- /trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv	(revision 66684)
+++ /trunk/src/VBox/Additions/linux/drm/files_vboxvideo_drv	(revision 66685)
@@ -29,4 +29,5 @@
     ${PATH_ROOT}/include/VBox/Graphics/VBoxVideoGuest.h=>include/VBoxVideoGuest.h \
     ${PATH_ROOT}/include/VBox/Graphics/HGSMI.h=>include/HGSMI.h \
+    ${PATH_ROOT}/include/VBox/Graphics/HGSMIBuffers.h=>include/HGSMIBuffers.h \
     ${PATH_ROOT}/include/VBox/Graphics/HGSMIChannels.h=>include/HGSMIChannels.h \
     ${PATH_ROOT}/include/VBox/Graphics/HGSMIChSetup.h=>include/HGSMIChSetup.h \
