2 * Copyright (C) 2006-2017 Oracle Corporation
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use,
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
27 #ifndef ___VBox_Graphics_HGSMIContext_h___
28 #define ___VBox_Graphics_HGSMIContext_h___
31 #include "hgsmi_ch_setup.h"
34 #ifdef VBOX_WDDM_MINIPORT
35 # include "wddm/VBoxMPShgsmi.h"
36 typedef VBOXSHGSMI HGSMIGUESTCMDHEAP
;
37 # define HGSMIGUESTCMDHEAP_GET(_p) (&(_p)->Heap)
39 typedef HGSMIHEAP HGSMIGUESTCMDHEAP
;
40 # define HGSMIGUESTCMDHEAP_GET(_p) (_p)
45 * Structure grouping the context needed for submitting commands to the host
48 typedef struct HGSMIGUESTCOMMANDCONTEXT
{
49 /** Information about the memory heap located in VRAM from which data
50 * structures to be sent to the host are allocated. */
51 HGSMIGUESTCMDHEAP heapCtx
;
52 /** The I/O port used for submitting commands to the host by writing their
53 * offsets into the heap. */
55 } HGSMIGUESTCOMMANDCONTEXT
, *PHGSMIGUESTCOMMANDCONTEXT
;
59 * Structure grouping the context needed for receiving commands from the host
62 typedef struct HGSMIHOSTCOMMANDCONTEXT
{
63 /** Information about the memory area located in VRAM in which the host
64 * places data structures to be read by the guest. */
66 /** Convenience structure used for matching host commands to handlers. */
67 /** @todo handlers are registered individually in code rather than just
68 * passing a static structure in order to gain extra flexibility. There is
69 * currently no expected usage case for this though. Is the additional
70 * complexity really justified? */
71 HGSMICHANNELINFO channels
;
72 /** Flag to indicate that one thread is currently processing the command
74 volatile bool fHostCmdProcessing
;
75 /* Pointer to the VRAM location where the HGSMI host flags are kept. */
76 volatile struct hgsmi_host_flags
*pfHostFlags
;
77 /** The I/O port used for receiving commands from the host as offsets into
78 * the memory area and sending back confirmations (command completion,
79 * IRQ acknowlegement). */
81 } HGSMIHOSTCOMMANDCONTEXT
, *PHGSMIHOSTCOMMANDCONTEXT
;
83 /** @name HGSMI context initialisation APIs.
86 /** @todo we should provide a cleanup function too as part of the API */
87 int VBoxHGSMISetupGuestContext(struct gen_pool
* ctx
,
88 void *pvGuestHeapMemory
,
89 u32 cbGuestHeapMemory
,
90 u32 offVRAMGuestHeapMemory
,
91 const HGSMIENV
*pEnv
);
92 void VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT ctx
,
95 void *pvHostAreaMapping
,