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