HGSMIContext.h revision e07dc26b
1/*
2 * Copyright (C) 2006-2017 Oracle Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23
24#ifndef ___VBox_Graphics_HGSMIContext_h___
25#define ___VBox_Graphics_HGSMIContext_h___
26
27#include "HGSMI.h"
28#include "HGSMIChSetup.h"
29#include "VBoxVideoIPRT.h"
30
31#ifdef VBOX_WDDM_MINIPORT
32# include "wddm/VBoxMPShgsmi.h"
33 typedef VBOXSHGSMI HGSMIGUESTCMDHEAP;
34# define HGSMIGUESTCMDHEAP_GET(_p) (&(_p)->Heap)
35#else
36 typedef HGSMIHEAP HGSMIGUESTCMDHEAP;
37# define HGSMIGUESTCMDHEAP_GET(_p) (_p)
38#endif
39
40RT_C_DECLS_BEGIN
41
42/**
43 * Structure grouping the context needed for submitting commands to the host
44 * via HGSMI
45 */
46typedef struct HGSMIGUESTCOMMANDCONTEXT
47{
48    /** Information about the memory heap located in VRAM from which data
49     * structures to be sent to the host are allocated. */
50    HGSMIGUESTCMDHEAP heapCtx;
51    /** The I/O port used for submitting commands to the host by writing their
52     * offsets into the heap. */
53    RTIOPORT port;
54} HGSMIGUESTCOMMANDCONTEXT, *PHGSMIGUESTCOMMANDCONTEXT;
55
56
57/**
58 * Structure grouping the context needed for receiving commands from the host
59 * via HGSMI
60 */
61typedef struct HGSMIHOSTCOMMANDCONTEXT
62{
63    /** Information about the memory area located in VRAM in which the host
64     * places data structures to be read by the guest. */
65    HGSMIAREA areaCtx;
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
73     * queue. */
74    volatile bool fHostCmdProcessing;
75    /* Pointer to the VRAM location where the HGSMI host flags are kept. */
76    volatile HGSMIHOSTFLAGS *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). */
80    RTIOPORT port;
81} HGSMIHOSTCOMMANDCONTEXT, *PHGSMIHOSTCOMMANDCONTEXT;
82
83/** @name HGSMI context initialisation APIs.
84 * @{ */
85
86/** @todo we should provide a cleanup function too as part of the API */
87DECLHIDDEN(int)      VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
88                                                void *pvGuestHeapMemory,
89                                                uint32_t cbGuestHeapMemory,
90                                                uint32_t offVRAMGuestHeapMemory,
91                                                const HGSMIENV *pEnv);
92DECLHIDDEN(void)     VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
93                                               void *pvBaseMapping,
94                                               uint32_t offHostFlags,
95                                               void *pvHostAreaMapping,
96                                               uint32_t offVRAMHostArea,
97                                               uint32_t cbHostArea);
98
99/** @}  */
100
101RT_C_DECLS_END
102
103#endif
104
105