1 | /** @file
|
---|
2 | * VirtualBox Video miniport driver
|
---|
3 | *
|
---|
4 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
5 | *
|
---|
6 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
7 | * available from http://www.virtualbox.org. This file is free software;
|
---|
8 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
9 | * General Public License (GPL) as published by the Free Software
|
---|
10 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
11 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
12 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef VBOXVIDEO_H
|
---|
16 | #define VBOXVIDEO_H
|
---|
17 |
|
---|
18 | #include <VBox/cdefs.h>
|
---|
19 | #include <VBox/types.h>
|
---|
20 | #include <iprt/assert.h>
|
---|
21 |
|
---|
22 | //#include <iprt/thread.h>
|
---|
23 |
|
---|
24 | #include <VBox/HGSMI/HGSMI.h>
|
---|
25 | #include <VBox/HGSMI/HGSMIChSetup.h>
|
---|
26 | #include <VBox/VBoxVideo.h>
|
---|
27 | #include "VBoxHGSMI.h"
|
---|
28 |
|
---|
29 | #define VBE_DISPI_IOPORT_INDEX 0x01CE
|
---|
30 | #define VBE_DISPI_IOPORT_DATA 0x01CF
|
---|
31 | #define VBE_DISPI_INDEX_ID 0x0
|
---|
32 | #define VBE_DISPI_INDEX_XRES 0x1
|
---|
33 | #define VBE_DISPI_INDEX_YRES 0x2
|
---|
34 | #define VBE_DISPI_INDEX_BPP 0x3
|
---|
35 | #define VBE_DISPI_INDEX_ENABLE 0x4
|
---|
36 | #define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
|
---|
37 | #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
|
---|
38 | #define VBE_DISPI_INDEX_X_OFFSET 0x8
|
---|
39 | #define VBE_DISPI_INDEX_Y_OFFSET 0x9
|
---|
40 | #define VBE_DISPI_INDEX_VBOX_VIDEO 0xa
|
---|
41 |
|
---|
42 | #define VBE_DISPI_ID2 0xB0C2
|
---|
43 | /* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
|
---|
44 | #define VBE_DISPI_ID_VBOX_VIDEO 0xBE00
|
---|
45 | #define VBE_DISPI_ID_HGSMI 0xBE01
|
---|
46 | #define VBE_DISPI_ID_ANYX 0xBE02
|
---|
47 | #define VBE_DISPI_DISABLED 0x00
|
---|
48 | #define VBE_DISPI_ENABLED 0x01
|
---|
49 | #define VBE_DISPI_LFB_ENABLED 0x40
|
---|
50 | #define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
|
---|
51 | #define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4
|
---|
52 | #define VBE_DISPI_TOTAL_VIDEO_MEMORY_KB (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024)
|
---|
53 | #define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES (VBE_DISPI_TOTAL_VIDEO_MEMORY_KB * 1024)
|
---|
54 |
|
---|
55 | #define VGA_PORT_HGSMI_HOST 0x3b0
|
---|
56 | #define VGA_PORT_HGSMI_GUEST 0x3d0
|
---|
57 |
|
---|
58 | typedef struct VBOXVIDEO_COMMON
|
---|
59 | {
|
---|
60 | int cDisplays; /* Number of displays. */
|
---|
61 |
|
---|
62 | uint32_t cbVRAM; /* The VRAM size. */
|
---|
63 |
|
---|
64 | uint32_t cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
|
---|
65 | * It is at offset:
|
---|
66 | * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
|
---|
67 | */
|
---|
68 | void *pvMiniportHeap; /* The pointer to the miniport heap VRAM.
|
---|
69 | * This is mapped by miniport separately.
|
---|
70 | */
|
---|
71 | volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
|
---|
72 | volatile bool bHostCmdProcessing;
|
---|
73 |
|
---|
74 | void *pvAdapterInformation; /* The pointer to the last 4K of VRAM.
|
---|
75 | * This is mapped by miniport separately.
|
---|
76 | */
|
---|
77 |
|
---|
78 | /** Host HGSMI capabilities the guest can handle */
|
---|
79 | uint32_t fCaps;
|
---|
80 |
|
---|
81 | bool bHGSMI; /* Whether HGSMI is enabled. */
|
---|
82 |
|
---|
83 | HGSMIAREA areaHostHeap; /* Host heap VRAM area. */
|
---|
84 |
|
---|
85 | HGSMICHANNELINFO channels;
|
---|
86 |
|
---|
87 | HGSMIHEAP hgsmiAdapterHeap;
|
---|
88 |
|
---|
89 | /* The IO Port Number for host commands. */
|
---|
90 | RTIOPORT IOPortHost;
|
---|
91 |
|
---|
92 | /* The IO Port Number for guest commands. */
|
---|
93 | RTIOPORT IOPortGuest;
|
---|
94 | } VBOXVIDEO_COMMON, *PVBOXVIDEO_COMMON;
|
---|
95 |
|
---|
96 | extern "C"
|
---|
97 | {
|
---|
98 | /** Signal an event in a guest-OS-specific way. pvEvent will be re-cast to
|
---|
99 | * something OS-specific. */
|
---|
100 | void VBoxVideoCmnSignalEvent(PVBOXVIDEO_COMMON pCommon, uint64_t pvEvent);
|
---|
101 |
|
---|
102 | /** Allocate memory to be used in normal driver operation (dispatch level in
|
---|
103 | * Windows) but not necessarily in IRQ context. */
|
---|
104 | void *VBoxVideoCmnMemAllocDriver(PVBOXVIDEO_COMMON pCommon, size_t cb);
|
---|
105 |
|
---|
106 | /** Free memory allocated by @a VBoxVideoCmnMemAllocDriver */
|
---|
107 | void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv);
|
---|
108 |
|
---|
109 | /** Write an 8-bit value to an I/O port. */
|
---|
110 | void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value);
|
---|
111 |
|
---|
112 | /** Write a 16-bit value to an I/O port. */
|
---|
113 | void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value);
|
---|
114 |
|
---|
115 | /** Write a 32-bit value to an I/O port. */
|
---|
116 | void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value);
|
---|
117 |
|
---|
118 | /** Read an 8-bit value from an I/O port. */
|
---|
119 | uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port);
|
---|
120 |
|
---|
121 | /** Read a 16-bit value from an I/O port. */
|
---|
122 | uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port);
|
---|
123 |
|
---|
124 | /** Read a 32-bit value from an I/O port. */
|
---|
125 | uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port);
|
---|
126 |
|
---|
127 | void* vboxHGSMIBufferAlloc(PVBOXVIDEO_COMMON pCommon,
|
---|
128 | HGSMISIZE cbData,
|
---|
129 | uint8_t u8Ch,
|
---|
130 | uint16_t u16Op);
|
---|
131 | void vboxHGSMIBufferFree (PVBOXVIDEO_COMMON pCommon, void *pvBuffer);
|
---|
132 | int vboxHGSMIBufferSubmit (PVBOXVIDEO_COMMON pCommon, void *pvBuffer);
|
---|
133 |
|
---|
134 | int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon,
|
---|
135 | void **ppv,
|
---|
136 | uint32_t ulOffset,
|
---|
137 | uint32_t ulSize);
|
---|
138 |
|
---|
139 | void VBoxUnmapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv);
|
---|
140 |
|
---|
141 | typedef bool(*PFNVIDEOIRQSYNC)(void *);
|
---|
142 | bool VBoxSyncToVideoIRQ(PVBOXVIDEO_COMMON pCommon, PFNVIDEOIRQSYNC pfnSync,
|
---|
143 | void *pvUser);
|
---|
144 |
|
---|
145 | /*
|
---|
146 | * Host and Guest port IO helpers.
|
---|
147 | */
|
---|
148 | DECLINLINE(void) VBoxHGSMIHostWrite(PVBOXVIDEO_COMMON pCommon, uint32_t data)
|
---|
149 | {
|
---|
150 | VBoxVideoCmnPortWriteUlong(pCommon->IOPortHost, data);
|
---|
151 | }
|
---|
152 |
|
---|
153 | DECLINLINE(uint32_t) VBoxHGSMIHostRead(PVBOXVIDEO_COMMON pCommon)
|
---|
154 | {
|
---|
155 | return VBoxVideoCmnPortReadUlong(pCommon->IOPortHost);
|
---|
156 | }
|
---|
157 |
|
---|
158 | DECLINLINE(void) VBoxHGSMIGuestWrite(PVBOXVIDEO_COMMON pCommon, uint32_t data)
|
---|
159 | {
|
---|
160 | VBoxVideoCmnPortWriteUlong(pCommon->IOPortGuest, data);
|
---|
161 | }
|
---|
162 |
|
---|
163 | DECLINLINE(uint32_t) VBoxHGSMIGuestRead(PVBOXVIDEO_COMMON pCommon)
|
---|
164 | {
|
---|
165 | return VBoxVideoCmnPortReadUlong(pCommon->IOPortGuest);
|
---|
166 | }
|
---|
167 |
|
---|
168 | bool VBoxHGSMIIsSupported (void);
|
---|
169 |
|
---|
170 | typedef int FNHGSMIFILLVIEWINFO (void *pvData, VBVAINFOVIEW *pInfo);
|
---|
171 | typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
|
---|
172 |
|
---|
173 | int VBoxHGSMISendViewInfo(PVBOXVIDEO_COMMON pCommon, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData);
|
---|
174 |
|
---|
175 | void VBoxSetupDisplaysHGSMI (PVBOXVIDEO_COMMON pCommon,
|
---|
176 | uint32_t AdapterMemorySize, uint32_t fCaps);
|
---|
177 |
|
---|
178 | bool vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon,
|
---|
179 | uint32_t fFlags,
|
---|
180 | uint32_t cHotX,
|
---|
181 | uint32_t cHotY,
|
---|
182 | uint32_t cWidth,
|
---|
183 | uint32_t cHeight,
|
---|
184 | uint8_t *pPixels,
|
---|
185 | uint32_t cbLength);
|
---|
186 |
|
---|
187 | void VBoxFreeDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon);
|
---|
188 | #ifndef VBOX_WITH_WDDM
|
---|
189 | DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
|
---|
190 | DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, uint32_t iDisplay, struct _VBVAHOSTCMD ** ppCmd);
|
---|
191 | #endif
|
---|
192 |
|
---|
193 |
|
---|
194 | int vboxVBVAChannelDisplayEnable(PVBOXVIDEO_COMMON pCommon,
|
---|
195 | int iDisplay, /* negative would mean this is a miniport handler */
|
---|
196 | uint8_t u8Channel);
|
---|
197 |
|
---|
198 | void hgsmiProcessHostCommandQueue(PVBOXVIDEO_COMMON pCommon);
|
---|
199 |
|
---|
200 | void HGSMIClearIrq (PVBOXVIDEO_COMMON pCommon);
|
---|
201 |
|
---|
202 | } /* extern "C" */
|
---|
203 |
|
---|
204 | #endif /* VBOXVIDEO_H */
|
---|