1 | /* $Id: DevVGA_VBVA.cpp 44876 2013-02-28 20:56:09Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Video Acceleration (VBVA).
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /*******************************************************************************
|
---|
19 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | #define LOG_GROUP LOG_GROUP_DEV_VGA
|
---|
22 | #include <VBox/vmm/pdmifs.h>
|
---|
23 | #include <VBox/vmm/pdmdev.h>
|
---|
24 | #include <VBox/vmm/pgm.h>
|
---|
25 | #include <VBox/vmm/ssm.h>
|
---|
26 | #include <VBox/VMMDev.h>
|
---|
27 | #include <VBox/VBoxVideo.h>
|
---|
28 | #include <iprt/alloc.h>
|
---|
29 | #include <iprt/assert.h>
|
---|
30 | #include <iprt/asm.h>
|
---|
31 | #include <iprt/string.h>
|
---|
32 | #include <iprt/param.h>
|
---|
33 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
34 | #include <iprt/semaphore.h>
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #include "DevVGA.h"
|
---|
38 |
|
---|
39 | /* A very detailed logging. */
|
---|
40 | #if 0 // def DEBUG_sunlover
|
---|
41 | #define LOGVBVABUFFER(a) LogFlow(a)
|
---|
42 | #else
|
---|
43 | #define LOGVBVABUFFER(a) do {} while (0)
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | /*******************************************************************************
|
---|
47 | * Structures and Typedefs *
|
---|
48 | *******************************************************************************/
|
---|
49 | typedef struct VBVAPARTIALRECORD
|
---|
50 | {
|
---|
51 | uint8_t *pu8;
|
---|
52 | uint32_t cb;
|
---|
53 | } VBVAPARTIALRECORD;
|
---|
54 |
|
---|
55 | typedef struct VBVAVIEW
|
---|
56 | {
|
---|
57 | VBVAINFOVIEW view;
|
---|
58 | VBVAINFOSCREEN screen;
|
---|
59 | VBVABUFFER *pVBVA;
|
---|
60 | uint32_t u32VBVAOffset;
|
---|
61 | VBVAPARTIALRECORD partialRecord;
|
---|
62 | } VBVAVIEW;
|
---|
63 |
|
---|
64 | typedef struct VBVAMOUSESHAPEINFO
|
---|
65 | {
|
---|
66 | bool fSet;
|
---|
67 | bool fVisible;
|
---|
68 | bool fAlpha;
|
---|
69 | uint32_t u32HotX;
|
---|
70 | uint32_t u32HotY;
|
---|
71 | uint32_t u32Width;
|
---|
72 | uint32_t u32Height;
|
---|
73 | uint32_t cbShape;
|
---|
74 | uint32_t cbAllocated;
|
---|
75 | uint8_t *pu8Shape;
|
---|
76 | } VBVAMOUSESHAPEINFO;
|
---|
77 |
|
---|
78 | /** @todo saved state: save and restore VBVACONTEXT */
|
---|
79 | typedef struct VBVACONTEXT
|
---|
80 | {
|
---|
81 | uint32_t cViews;
|
---|
82 | VBVAVIEW aViews[64 /* @todo SchemaDefs::MaxGuestMonitors*/];
|
---|
83 | VBVAMOUSESHAPEINFO mouseShapeInfo;
|
---|
84 | } VBVACONTEXT;
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 | /** Copies @a cb bytes from the VBVA ring buffer to the @a pu8Dst.
|
---|
89 | * Used for partial records or for records which cross the ring boundary.
|
---|
90 | */
|
---|
91 | static void vbvaFetchBytes (VBVABUFFER *pVBVA, uint8_t *pu8Dst, uint32_t cb)
|
---|
92 | {
|
---|
93 | /** @todo replace the 'if' with an assert. The caller must ensure this condition. */
|
---|
94 | if (cb >= pVBVA->cbData)
|
---|
95 | {
|
---|
96 | AssertMsgFailed (("cb = 0x%08X, ring buffer size 0x%08X", cb, pVBVA->cbData));
|
---|
97 | return;
|
---|
98 | }
|
---|
99 |
|
---|
100 | const uint32_t u32BytesTillBoundary = pVBVA->cbData - pVBVA->off32Data;
|
---|
101 | const uint8_t *src = &pVBVA->au8Data[pVBVA->off32Data];
|
---|
102 | const int32_t i32Diff = cb - u32BytesTillBoundary;
|
---|
103 |
|
---|
104 | if (i32Diff <= 0)
|
---|
105 | {
|
---|
106 | /* Chunk will not cross buffer boundary. */
|
---|
107 | memcpy (pu8Dst, src, cb);
|
---|
108 | }
|
---|
109 | else
|
---|
110 | {
|
---|
111 | /* Chunk crosses buffer boundary. */
|
---|
112 | memcpy (pu8Dst, src, u32BytesTillBoundary);
|
---|
113 | memcpy (pu8Dst + u32BytesTillBoundary, &pVBVA->au8Data[0], i32Diff);
|
---|
114 | }
|
---|
115 |
|
---|
116 | /* Advance data offset. */
|
---|
117 | pVBVA->off32Data = (pVBVA->off32Data + cb) % pVBVA->cbData;
|
---|
118 |
|
---|
119 | return;
|
---|
120 | }
|
---|
121 |
|
---|
122 |
|
---|
123 | static bool vbvaPartialRead (VBVAPARTIALRECORD *pPartialRecord, uint32_t cbRecord, VBVABUFFER *pVBVA)
|
---|
124 | {
|
---|
125 | uint8_t *pu8New;
|
---|
126 |
|
---|
127 | LOGVBVABUFFER(("vbvaPartialRead: p = %p, cb = %d, cbRecord 0x%08X\n",
|
---|
128 | pPartialRecord->pu8, pPartialRecord->cb, cbRecord));
|
---|
129 |
|
---|
130 | if (pPartialRecord->pu8)
|
---|
131 | {
|
---|
132 | Assert (pPartialRecord->cb);
|
---|
133 | pu8New = (uint8_t *)RTMemRealloc (pPartialRecord->pu8, cbRecord);
|
---|
134 | }
|
---|
135 | else
|
---|
136 | {
|
---|
137 | Assert (!pPartialRecord->cb);
|
---|
138 | pu8New = (uint8_t *)RTMemAlloc (cbRecord);
|
---|
139 | }
|
---|
140 |
|
---|
141 | if (!pu8New)
|
---|
142 | {
|
---|
143 | /* Memory allocation failed, fail the function. */
|
---|
144 | Log(("vbvaPartialRead: failed to (re)alocate memory for partial record!!! cbRecord 0x%08X\n",
|
---|
145 | cbRecord));
|
---|
146 |
|
---|
147 | if (pPartialRecord->pu8)
|
---|
148 | {
|
---|
149 | RTMemFree (pPartialRecord->pu8);
|
---|
150 | }
|
---|
151 |
|
---|
152 | pPartialRecord->pu8 = NULL;
|
---|
153 | pPartialRecord->cb = 0;
|
---|
154 |
|
---|
155 | return false;
|
---|
156 | }
|
---|
157 |
|
---|
158 | /* Fetch data from the ring buffer. */
|
---|
159 | vbvaFetchBytes (pVBVA, pu8New + pPartialRecord->cb, cbRecord - pPartialRecord->cb);
|
---|
160 |
|
---|
161 | pPartialRecord->pu8 = pu8New;
|
---|
162 | pPartialRecord->cb = cbRecord;
|
---|
163 |
|
---|
164 | return true;
|
---|
165 | }
|
---|
166 |
|
---|
167 | /* For contiguous chunks just return the address in the buffer.
|
---|
168 | * For crossing boundary - allocate a buffer from heap.
|
---|
169 | */
|
---|
170 | static bool vbvaFetchCmd (VBVAPARTIALRECORD *pPartialRecord, VBVABUFFER *pVBVA, VBVACMDHDR **ppHdr, uint32_t *pcbCmd)
|
---|
171 | {
|
---|
172 | uint32_t indexRecordFirst = pVBVA->indexRecordFirst;
|
---|
173 | uint32_t indexRecordFree = pVBVA->indexRecordFree;
|
---|
174 |
|
---|
175 | LOGVBVABUFFER(("first = %d, free = %d\n",
|
---|
176 | indexRecordFirst, indexRecordFree));
|
---|
177 |
|
---|
178 | if (indexRecordFirst == indexRecordFree)
|
---|
179 | {
|
---|
180 | /* No records to process. Return without assigning output variables. */
|
---|
181 | return true;
|
---|
182 | }
|
---|
183 |
|
---|
184 | uint32_t cbRecordCurrent = ASMAtomicReadU32(&pVBVA->aRecords[indexRecordFirst].cbRecord);
|
---|
185 |
|
---|
186 | LOGVBVABUFFER(("cbRecord = 0x%08X, pPartialRecord->cb = 0x%08X\n", cbRecordCurrent, pPartialRecord->cb));
|
---|
187 |
|
---|
188 | uint32_t cbRecord = cbRecordCurrent & ~VBVA_F_RECORD_PARTIAL;
|
---|
189 |
|
---|
190 | if (pPartialRecord->cb)
|
---|
191 | {
|
---|
192 | /* There is a partial read in process. Continue with it. */
|
---|
193 | Assert (pPartialRecord->pu8);
|
---|
194 |
|
---|
195 | LOGVBVABUFFER(("continue partial record cb = %d cbRecord 0x%08X, first = %d, free = %d\n",
|
---|
196 | pPartialRecord->cb, cbRecordCurrent, indexRecordFirst, indexRecordFree));
|
---|
197 |
|
---|
198 | if (cbRecord > pPartialRecord->cb)
|
---|
199 | {
|
---|
200 | /* New data has been added to the record. */
|
---|
201 | if (!vbvaPartialRead (pPartialRecord, cbRecord, pVBVA))
|
---|
202 | {
|
---|
203 | return false;
|
---|
204 | }
|
---|
205 | }
|
---|
206 |
|
---|
207 | if (!(cbRecordCurrent & VBVA_F_RECORD_PARTIAL))
|
---|
208 | {
|
---|
209 | /* The record is completed by guest. Return it to the caller. */
|
---|
210 | *ppHdr = (VBVACMDHDR *)pPartialRecord->pu8;
|
---|
211 | *pcbCmd = pPartialRecord->cb;
|
---|
212 |
|
---|
213 | pPartialRecord->pu8 = NULL;
|
---|
214 | pPartialRecord->cb = 0;
|
---|
215 |
|
---|
216 | /* Advance the record index. */
|
---|
217 | pVBVA->indexRecordFirst = (indexRecordFirst + 1) % RT_ELEMENTS(pVBVA->aRecords);
|
---|
218 |
|
---|
219 | LOGVBVABUFFER(("partial done ok, data = %d, free = %d\n",
|
---|
220 | pVBVA->off32Data, pVBVA->off32Free));
|
---|
221 | }
|
---|
222 |
|
---|
223 | return true;
|
---|
224 | }
|
---|
225 |
|
---|
226 | /* A new record need to be processed. */
|
---|
227 | if (cbRecordCurrent & VBVA_F_RECORD_PARTIAL)
|
---|
228 | {
|
---|
229 | /* Current record is being written by guest. '=' is important here,
|
---|
230 | * because the guest will do a FLUSH at this condition.
|
---|
231 | * This partial record is too large for the ring buffer and must
|
---|
232 | * be accumulated in an allocated buffer.
|
---|
233 | */
|
---|
234 | if (cbRecord >= pVBVA->cbData - pVBVA->cbPartialWriteThreshold)
|
---|
235 | {
|
---|
236 | /* Partial read must be started. */
|
---|
237 | if (!vbvaPartialRead (pPartialRecord, cbRecord, pVBVA))
|
---|
238 | {
|
---|
239 | return false;
|
---|
240 | }
|
---|
241 |
|
---|
242 | LOGVBVABUFFER(("started partial record cb = 0x%08X cbRecord 0x%08X, first = %d, free = %d\n",
|
---|
243 | pPartialRecord->cb, cbRecordCurrent, indexRecordFirst, indexRecordFree));
|
---|
244 | }
|
---|
245 |
|
---|
246 | return true;
|
---|
247 | }
|
---|
248 |
|
---|
249 | /* Current record is complete. If it is not empty, process it. */
|
---|
250 | if (cbRecord)
|
---|
251 | {
|
---|
252 | /* The size of largest contiguous chunk in the ring biffer. */
|
---|
253 | uint32_t u32BytesTillBoundary = pVBVA->cbData - pVBVA->off32Data;
|
---|
254 |
|
---|
255 | /* The pointer to data in the ring buffer. */
|
---|
256 | uint8_t *src = &pVBVA->au8Data[pVBVA->off32Data];
|
---|
257 |
|
---|
258 | /* Fetch or point the data. */
|
---|
259 | if (u32BytesTillBoundary >= cbRecord)
|
---|
260 | {
|
---|
261 | /* The command does not cross buffer boundary. Return address in the buffer. */
|
---|
262 | *ppHdr = (VBVACMDHDR *)src;
|
---|
263 |
|
---|
264 | /* Advance data offset. */
|
---|
265 | pVBVA->off32Data = (pVBVA->off32Data + cbRecord) % pVBVA->cbData;
|
---|
266 | }
|
---|
267 | else
|
---|
268 | {
|
---|
269 | /* The command crosses buffer boundary. Rare case, so not optimized. */
|
---|
270 | uint8_t *dst = (uint8_t *)RTMemAlloc (cbRecord);
|
---|
271 |
|
---|
272 | if (!dst)
|
---|
273 | {
|
---|
274 | LogFlowFunc (("could not allocate %d bytes from heap!!!\n", cbRecord));
|
---|
275 | pVBVA->off32Data = (pVBVA->off32Data + cbRecord) % pVBVA->cbData;
|
---|
276 | return false;
|
---|
277 | }
|
---|
278 |
|
---|
279 | vbvaFetchBytes (pVBVA, dst, cbRecord);
|
---|
280 |
|
---|
281 | *ppHdr = (VBVACMDHDR *)dst;
|
---|
282 |
|
---|
283 | LOGVBVABUFFER(("Allocated from heap %p\n", dst));
|
---|
284 | }
|
---|
285 | }
|
---|
286 |
|
---|
287 | *pcbCmd = cbRecord;
|
---|
288 |
|
---|
289 | /* Advance the record index. */
|
---|
290 | pVBVA->indexRecordFirst = (indexRecordFirst + 1) % RT_ELEMENTS(pVBVA->aRecords);
|
---|
291 |
|
---|
292 | LOGVBVABUFFER(("done ok, data = %d, free = %d\n",
|
---|
293 | pVBVA->off32Data, pVBVA->off32Free));
|
---|
294 |
|
---|
295 | return true;
|
---|
296 | }
|
---|
297 |
|
---|
298 | static void vbvaReleaseCmd (VBVAPARTIALRECORD *pPartialRecord, VBVABUFFER *pVBVA, VBVACMDHDR *pHdr, uint32_t cbCmd)
|
---|
299 | {
|
---|
300 | uint8_t *au8RingBuffer = &pVBVA->au8Data[0];
|
---|
301 |
|
---|
302 | if ( (uint8_t *)pHdr >= au8RingBuffer
|
---|
303 | && (uint8_t *)pHdr < &au8RingBuffer[pVBVA->cbData])
|
---|
304 | {
|
---|
305 | /* The pointer is inside ring buffer. Must be continuous chunk. */
|
---|
306 | Assert (pVBVA->cbData - ((uint8_t *)pHdr - au8RingBuffer) >= cbCmd);
|
---|
307 |
|
---|
308 | /* Do nothing. */
|
---|
309 |
|
---|
310 | Assert (!pPartialRecord->pu8 && pPartialRecord->cb == 0);
|
---|
311 | }
|
---|
312 | else
|
---|
313 | {
|
---|
314 | /* The pointer is outside. It is then an allocated copy. */
|
---|
315 | LOGVBVABUFFER(("Free heap %p\n", pHdr));
|
---|
316 |
|
---|
317 | if ((uint8_t *)pHdr == pPartialRecord->pu8)
|
---|
318 | {
|
---|
319 | pPartialRecord->pu8 = NULL;
|
---|
320 | pPartialRecord->cb = 0;
|
---|
321 | }
|
---|
322 | else
|
---|
323 | {
|
---|
324 | Assert (!pPartialRecord->pu8 && pPartialRecord->cb == 0);
|
---|
325 | }
|
---|
326 |
|
---|
327 | RTMemFree (pHdr);
|
---|
328 | }
|
---|
329 |
|
---|
330 | return;
|
---|
331 | }
|
---|
332 |
|
---|
333 | static int vbvaFlushProcess (unsigned uScreenId, PVGASTATE pVGAState, VBVAPARTIALRECORD *pPartialRecord, VBVABUFFER *pVBVA)
|
---|
334 | {
|
---|
335 | LOGVBVABUFFER(("uScreenId %d, indexRecordFirst = %d, indexRecordFree = %d, off32Data = %d, off32Free = %d\n",
|
---|
336 | uScreenId, pVBVA->indexRecordFirst, pVBVA->indexRecordFree, pVBVA->off32Data, pVBVA->off32Free));
|
---|
337 | struct {
|
---|
338 | /* The rectangle that includes all dirty rectangles. */
|
---|
339 | int32_t xLeft;
|
---|
340 | int32_t xRight;
|
---|
341 | int32_t yTop;
|
---|
342 | int32_t yBottom;
|
---|
343 | } dirtyRect;
|
---|
344 | RT_ZERO(dirtyRect);
|
---|
345 |
|
---|
346 | bool fUpdate = false; /* Whether there were any updates. */
|
---|
347 | bool fDirtyEmpty = true;
|
---|
348 |
|
---|
349 | for (;;)
|
---|
350 | {
|
---|
351 | VBVACMDHDR *phdr = NULL;
|
---|
352 | uint32_t cbCmd = ~0;
|
---|
353 |
|
---|
354 | /* Fetch the command data. */
|
---|
355 | if (!vbvaFetchCmd (pPartialRecord, pVBVA, &phdr, &cbCmd))
|
---|
356 | {
|
---|
357 | LogFunc(("unable to fetch command. off32Data = %d, off32Free = %d!!!\n",
|
---|
358 | pVBVA->off32Data, pVBVA->off32Free));
|
---|
359 |
|
---|
360 | /* @todo old code disabled VBVA processing here. */
|
---|
361 | return VERR_NOT_SUPPORTED;
|
---|
362 | }
|
---|
363 |
|
---|
364 | if (cbCmd == uint32_t(~0))
|
---|
365 | {
|
---|
366 | /* No more commands yet in the queue. */
|
---|
367 | break;
|
---|
368 | }
|
---|
369 |
|
---|
370 | if (cbCmd != 0)
|
---|
371 | {
|
---|
372 | if (!fUpdate)
|
---|
373 | {
|
---|
374 | pVGAState->pDrv->pfnVBVAUpdateBegin (pVGAState->pDrv, uScreenId);
|
---|
375 | fUpdate = true;
|
---|
376 | }
|
---|
377 |
|
---|
378 | /* Updates the rectangle and sends the command to the VRDP server. */
|
---|
379 | pVGAState->pDrv->pfnVBVAUpdateProcess (pVGAState->pDrv, uScreenId, phdr, cbCmd);
|
---|
380 |
|
---|
381 | int32_t xRight = phdr->x + phdr->w;
|
---|
382 | int32_t yBottom = phdr->y + phdr->h;
|
---|
383 |
|
---|
384 | /* These are global coords, relative to the primary screen. */
|
---|
385 |
|
---|
386 | LOGVBVABUFFER(("cbCmd = %d, x=%d, y=%d, w=%d, h=%d\n",
|
---|
387 | cbCmd, phdr->x, phdr->y, phdr->w, phdr->h));
|
---|
388 | LogRel3(("%s: update command cbCmd = %d, x=%d, y=%d, w=%d, h=%d\n",
|
---|
389 | __PRETTY_FUNCTION__, cbCmd, phdr->x, phdr->y, phdr->w,
|
---|
390 | phdr->h));
|
---|
391 |
|
---|
392 | /* Collect all rects into one. */
|
---|
393 | if (fDirtyEmpty)
|
---|
394 | {
|
---|
395 | /* This is the first rectangle to be added. */
|
---|
396 | dirtyRect.xLeft = phdr->x;
|
---|
397 | dirtyRect.yTop = phdr->y;
|
---|
398 | dirtyRect.xRight = xRight;
|
---|
399 | dirtyRect.yBottom = yBottom;
|
---|
400 | fDirtyEmpty = false;
|
---|
401 | }
|
---|
402 | else
|
---|
403 | {
|
---|
404 | /* Adjust region coordinates. */
|
---|
405 | if (dirtyRect.xLeft > phdr->x)
|
---|
406 | {
|
---|
407 | dirtyRect.xLeft = phdr->x;
|
---|
408 | }
|
---|
409 |
|
---|
410 | if (dirtyRect.yTop > phdr->y)
|
---|
411 | {
|
---|
412 | dirtyRect.yTop = phdr->y;
|
---|
413 | }
|
---|
414 |
|
---|
415 | if (dirtyRect.xRight < xRight)
|
---|
416 | {
|
---|
417 | dirtyRect.xRight = xRight;
|
---|
418 | }
|
---|
419 |
|
---|
420 | if (dirtyRect.yBottom < yBottom)
|
---|
421 | {
|
---|
422 | dirtyRect.yBottom = yBottom;
|
---|
423 | }
|
---|
424 | }
|
---|
425 | }
|
---|
426 |
|
---|
427 | vbvaReleaseCmd (pPartialRecord, pVBVA, phdr, cbCmd);
|
---|
428 | }
|
---|
429 |
|
---|
430 | if (fUpdate)
|
---|
431 | {
|
---|
432 | if (dirtyRect.xRight - dirtyRect.xLeft)
|
---|
433 | {
|
---|
434 | LogRel3(("%s: sending update screen=%d, x=%d, y=%d, w=%d, h=%d\n",
|
---|
435 | __PRETTY_FUNCTION__, uScreenId, dirtyRect.xLeft,
|
---|
436 | dirtyRect.yTop, dirtyRect.xRight - dirtyRect.xLeft,
|
---|
437 | dirtyRect.yBottom - dirtyRect.yTop));
|
---|
438 | pVGAState->pDrv->pfnVBVAUpdateEnd (pVGAState->pDrv, uScreenId, dirtyRect.xLeft, dirtyRect.yTop,
|
---|
439 | dirtyRect.xRight - dirtyRect.xLeft, dirtyRect.yBottom - dirtyRect.yTop);
|
---|
440 | }
|
---|
441 | else
|
---|
442 | {
|
---|
443 | pVGAState->pDrv->pfnVBVAUpdateEnd (pVGAState->pDrv, uScreenId, 0, 0, 0, 0);
|
---|
444 | }
|
---|
445 | }
|
---|
446 |
|
---|
447 | return VINF_SUCCESS;
|
---|
448 | }
|
---|
449 |
|
---|
450 | static int vbvaFlush (PVGASTATE pVGAState, VBVACONTEXT *pCtx)
|
---|
451 | {
|
---|
452 | unsigned uScreenId;
|
---|
453 |
|
---|
454 | for (uScreenId = 0; uScreenId < pCtx->cViews; uScreenId++)
|
---|
455 | {
|
---|
456 | VBVAPARTIALRECORD *pPartialRecord = &pCtx->aViews[uScreenId].partialRecord;
|
---|
457 | VBVABUFFER *pVBVA = pCtx->aViews[uScreenId].pVBVA;
|
---|
458 |
|
---|
459 | if (pVBVA)
|
---|
460 | {
|
---|
461 | vbvaFlushProcess (uScreenId, pVGAState, pPartialRecord, pVBVA);
|
---|
462 | }
|
---|
463 | }
|
---|
464 |
|
---|
465 | /* @todo rc */
|
---|
466 | return VINF_SUCCESS;
|
---|
467 | }
|
---|
468 |
|
---|
469 | static int vbvaResize (PVGASTATE pVGAState, VBVAVIEW *pView, const VBVAINFOSCREEN *pNewScreen)
|
---|
470 | {
|
---|
471 | /* Verify pNewScreen. */
|
---|
472 | /* @todo */
|
---|
473 |
|
---|
474 | /* Apply these changes. */
|
---|
475 | pView->screen = *pNewScreen;
|
---|
476 |
|
---|
477 | uint8_t *pu8VRAM = pVGAState->vram_ptrR3 + pView->view.u32ViewOffset;
|
---|
478 |
|
---|
479 | int rc = pVGAState->pDrv->pfnVBVAResize (pVGAState->pDrv, &pView->view, &pView->screen, pu8VRAM);
|
---|
480 |
|
---|
481 | /* @todo process VINF_VGA_RESIZE_IN_PROGRESS? */
|
---|
482 |
|
---|
483 | return rc;
|
---|
484 | }
|
---|
485 |
|
---|
486 | static int vbvaEnable (unsigned uScreenId, PVGASTATE pVGAState, VBVACONTEXT *pCtx, VBVABUFFER *pVBVA, uint32_t u32Offset, bool fRestored)
|
---|
487 | {
|
---|
488 | /* @todo old code did a UpdateDisplayAll at this place. */
|
---|
489 |
|
---|
490 | int rc;
|
---|
491 |
|
---|
492 | if (pVGAState->pDrv->pfnVBVAEnable)
|
---|
493 | {
|
---|
494 | pVBVA->hostFlags.u32HostEvents = 0;
|
---|
495 | pVBVA->hostFlags.u32SupportedOrders = 0;
|
---|
496 |
|
---|
497 | rc = pVGAState->pDrv->pfnVBVAEnable (pVGAState->pDrv, uScreenId, &pVBVA->hostFlags);
|
---|
498 | }
|
---|
499 | else
|
---|
500 | {
|
---|
501 | rc = VERR_NOT_SUPPORTED;
|
---|
502 | }
|
---|
503 |
|
---|
504 | if (RT_SUCCESS (rc))
|
---|
505 | {
|
---|
506 | /* pVBVA->hostFlags has been set up by pfnVBVAEnable. */
|
---|
507 | LogFlowFunc(("u32HostEvents 0x%08X, u32SupportedOrders 0x%08X\n",
|
---|
508 | pVBVA->hostFlags.u32HostEvents, pVBVA->hostFlags.u32SupportedOrders));
|
---|
509 |
|
---|
510 | if (!fRestored)
|
---|
511 | {
|
---|
512 | /* @todo Actually this function must not touch the partialRecord structure at all,
|
---|
513 | * because initially it is a zero and when VBVA is disabled this should be set to zero.
|
---|
514 | * But I'm not sure that no code depends on zeroing partialRecord here.
|
---|
515 | * So for now (a quick fix for 4.1) just do not do this if the VM was restored,
|
---|
516 | * when partialRecord might be loaded already from the saved state.
|
---|
517 | */
|
---|
518 | pCtx->aViews[uScreenId].partialRecord.pu8 = NULL;
|
---|
519 | pCtx->aViews[uScreenId].partialRecord.cb = 0;
|
---|
520 | }
|
---|
521 |
|
---|
522 | pCtx->aViews[uScreenId].pVBVA = pVBVA;
|
---|
523 | pCtx->aViews[uScreenId].u32VBVAOffset = u32Offset;
|
---|
524 | }
|
---|
525 |
|
---|
526 | return rc;
|
---|
527 | }
|
---|
528 |
|
---|
529 | static int vbvaDisable (unsigned uScreenId, PVGASTATE pVGAState, VBVACONTEXT *pCtx)
|
---|
530 | {
|
---|
531 | /* Process any pending orders and empty the VBVA ring buffer. */
|
---|
532 | vbvaFlush (pVGAState, pCtx);
|
---|
533 |
|
---|
534 | VBVAVIEW *pView = &pCtx->aViews[uScreenId];
|
---|
535 |
|
---|
536 | if (pView->pVBVA)
|
---|
537 | {
|
---|
538 | pView->pVBVA->hostFlags.u32HostEvents = 0;
|
---|
539 | pView->pVBVA->hostFlags.u32SupportedOrders = 0;
|
---|
540 |
|
---|
541 | pView->partialRecord.pu8 = NULL;
|
---|
542 | pView->partialRecord.cb = 0;
|
---|
543 |
|
---|
544 | pView->pVBVA = NULL;
|
---|
545 | pView->u32VBVAOffset = HGSMIOFFSET_VOID;
|
---|
546 | }
|
---|
547 |
|
---|
548 | pVGAState->pDrv->pfnVBVADisable (pVGAState->pDrv, uScreenId);
|
---|
549 | return VINF_SUCCESS;
|
---|
550 | }
|
---|
551 |
|
---|
552 | bool VBVAIsEnabled(PVGASTATE pVGAState)
|
---|
553 | {
|
---|
554 | PHGSMIINSTANCE pHGSMI = pVGAState->pHGSMI;
|
---|
555 | if (pHGSMI)
|
---|
556 | {
|
---|
557 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pHGSMI);
|
---|
558 | if (pCtx)
|
---|
559 | {
|
---|
560 | if (pCtx->cViews)
|
---|
561 | {
|
---|
562 | VBVAVIEW * pView = &pCtx->aViews[0];
|
---|
563 | if (pView->pVBVA)
|
---|
564 | return true;
|
---|
565 | }
|
---|
566 | }
|
---|
567 | }
|
---|
568 | return false;
|
---|
569 | }
|
---|
570 |
|
---|
571 | #ifdef DEBUG_sunlover
|
---|
572 | void dumpMouseShapeInfo(const VBVAMOUSESHAPEINFO *pMouseShapeInfo)
|
---|
573 | {
|
---|
574 | LogFlow(("fSet = %d, fVisible %d, fAlpha %d, @%d,%d %dx%d (%p, %d/%d)\n",
|
---|
575 | pMouseShapeInfo->fSet,
|
---|
576 | pMouseShapeInfo->fVisible,
|
---|
577 | pMouseShapeInfo->fAlpha,
|
---|
578 | pMouseShapeInfo->u32HotX,
|
---|
579 | pMouseShapeInfo->u32HotY,
|
---|
580 | pMouseShapeInfo->u32Width,
|
---|
581 | pMouseShapeInfo->u32Height,
|
---|
582 | pMouseShapeInfo->pu8Shape,
|
---|
583 | pMouseShapeInfo->cbShape,
|
---|
584 | pMouseShapeInfo->cbAllocated
|
---|
585 | ));
|
---|
586 | }
|
---|
587 | #endif
|
---|
588 |
|
---|
589 | static int vbvaUpdateMousePointerShape(PVGASTATE pVGAState, VBVAMOUSESHAPEINFO *pMouseShapeInfo, bool fShape, const uint8_t *pu8Shape)
|
---|
590 | {
|
---|
591 | int rc;
|
---|
592 | LogFlowFunc(("pVGAState %p, pMouseShapeInfo %p, fShape %d, pu8Shape %p\n",
|
---|
593 | pVGAState, pMouseShapeInfo, fShape, pu8Shape));
|
---|
594 | #ifdef DEBUG_sunlover
|
---|
595 | dumpMouseShapeInfo(pMouseShapeInfo);
|
---|
596 | #endif
|
---|
597 |
|
---|
598 | if (fShape && pu8Shape != NULL)
|
---|
599 | {
|
---|
600 | rc = pVGAState->pDrv->pfnVBVAMousePointerShape (pVGAState->pDrv,
|
---|
601 | pMouseShapeInfo->fVisible,
|
---|
602 | pMouseShapeInfo->fAlpha,
|
---|
603 | pMouseShapeInfo->u32HotX,
|
---|
604 | pMouseShapeInfo->u32HotY,
|
---|
605 | pMouseShapeInfo->u32Width,
|
---|
606 | pMouseShapeInfo->u32Height,
|
---|
607 | pu8Shape);
|
---|
608 | }
|
---|
609 | else
|
---|
610 | {
|
---|
611 | rc = pVGAState->pDrv->pfnVBVAMousePointerShape (pVGAState->pDrv,
|
---|
612 | pMouseShapeInfo->fVisible,
|
---|
613 | false,
|
---|
614 | 0, 0,
|
---|
615 | 0, 0,
|
---|
616 | NULL);
|
---|
617 | }
|
---|
618 |
|
---|
619 | return rc;
|
---|
620 | }
|
---|
621 |
|
---|
622 | static int vbvaMousePointerShape (PVGASTATE pVGAState, VBVACONTEXT *pCtx, const VBVAMOUSEPOINTERSHAPE *pShape, HGSMISIZE cbShape)
|
---|
623 | {
|
---|
624 | bool fVisible = (pShape->fu32Flags & VBOX_MOUSE_POINTER_VISIBLE) != 0;
|
---|
625 | bool fAlpha = (pShape->fu32Flags & VBOX_MOUSE_POINTER_ALPHA) != 0;
|
---|
626 | bool fShape = (pShape->fu32Flags & VBOX_MOUSE_POINTER_SHAPE) != 0;
|
---|
627 |
|
---|
628 | HGSMISIZE cbPointerData = 0;
|
---|
629 |
|
---|
630 | if (fShape)
|
---|
631 | {
|
---|
632 | cbPointerData = ((((pShape->u32Width + 7) / 8) * pShape->u32Height + 3) & ~3)
|
---|
633 | + pShape->u32Width * 4 * pShape->u32Height;
|
---|
634 | }
|
---|
635 |
|
---|
636 | if (cbPointerData > cbShape - RT_OFFSETOF(VBVAMOUSEPOINTERSHAPE, au8Data))
|
---|
637 | {
|
---|
638 | Log(("vbvaMousePointerShape: calculated pointer data size is too big (%d bytes, limit %d)\n",
|
---|
639 | cbPointerData, cbShape - RT_OFFSETOF(VBVAMOUSEPOINTERSHAPE, au8Data)));
|
---|
640 | return VERR_INVALID_PARAMETER;
|
---|
641 | }
|
---|
642 |
|
---|
643 | /* Save mouse info it will be used to restore mouse pointer after restoring saved state. */
|
---|
644 | pCtx->mouseShapeInfo.fSet = true;
|
---|
645 | pCtx->mouseShapeInfo.fVisible = fVisible;
|
---|
646 | pCtx->mouseShapeInfo.fAlpha = fAlpha;
|
---|
647 | if (fShape)
|
---|
648 | {
|
---|
649 | /* Data related to shape. */
|
---|
650 | pCtx->mouseShapeInfo.u32HotX = pShape->u32HotX;
|
---|
651 | pCtx->mouseShapeInfo.u32HotY = pShape->u32HotY;
|
---|
652 | pCtx->mouseShapeInfo.u32Width = pShape->u32Width;
|
---|
653 | pCtx->mouseShapeInfo.u32Height = pShape->u32Height;
|
---|
654 |
|
---|
655 | /* Reallocate memory buffer if necessary. */
|
---|
656 | if (cbPointerData > pCtx->mouseShapeInfo.cbAllocated)
|
---|
657 | {
|
---|
658 | RTMemFree (pCtx->mouseShapeInfo.pu8Shape);
|
---|
659 | pCtx->mouseShapeInfo.pu8Shape = NULL;
|
---|
660 | pCtx->mouseShapeInfo.cbShape = 0;
|
---|
661 |
|
---|
662 | uint8_t *pu8Shape = (uint8_t *)RTMemAlloc (cbPointerData);
|
---|
663 | if (pu8Shape)
|
---|
664 | {
|
---|
665 | pCtx->mouseShapeInfo.pu8Shape = pu8Shape;
|
---|
666 | pCtx->mouseShapeInfo.cbAllocated = cbPointerData;
|
---|
667 | }
|
---|
668 | }
|
---|
669 |
|
---|
670 | /* Copy shape bitmaps. */
|
---|
671 | if (pCtx->mouseShapeInfo.pu8Shape)
|
---|
672 | {
|
---|
673 | memcpy (pCtx->mouseShapeInfo.pu8Shape, &pShape->au8Data[0], cbPointerData);
|
---|
674 | pCtx->mouseShapeInfo.cbShape = cbPointerData;
|
---|
675 | }
|
---|
676 | }
|
---|
677 |
|
---|
678 | if (pVGAState->pDrv->pfnVBVAMousePointerShape == NULL)
|
---|
679 | {
|
---|
680 | return VERR_NOT_SUPPORTED;
|
---|
681 | }
|
---|
682 |
|
---|
683 | int rc = vbvaUpdateMousePointerShape(pVGAState, &pCtx->mouseShapeInfo, fShape, &pShape->au8Data[0]);
|
---|
684 |
|
---|
685 | return rc;
|
---|
686 | }
|
---|
687 |
|
---|
688 | static unsigned vbvaViewFromOffset (PHGSMIINSTANCE pIns, VBVACONTEXT *pCtx, const void *pvBuffer)
|
---|
689 | {
|
---|
690 | /* Check which view contains the buffer. */
|
---|
691 | HGSMIOFFSET offBuffer = HGSMIPointerToOffsetHost (pIns, pvBuffer);
|
---|
692 |
|
---|
693 | if (offBuffer != HGSMIOFFSET_VOID)
|
---|
694 | {
|
---|
695 | unsigned uScreenId;
|
---|
696 |
|
---|
697 | for (uScreenId = 0; uScreenId < pCtx->cViews; uScreenId++)
|
---|
698 | {
|
---|
699 | VBVAINFOVIEW *pView = &pCtx->aViews[uScreenId].view;
|
---|
700 |
|
---|
701 | if ( pView->u32ViewSize > 0
|
---|
702 | && pView->u32ViewOffset <= offBuffer
|
---|
703 | && offBuffer <= pView->u32ViewOffset + pView->u32ViewSize - 1)
|
---|
704 | {
|
---|
705 | return pView->u32ViewIndex;
|
---|
706 | }
|
---|
707 | }
|
---|
708 | }
|
---|
709 |
|
---|
710 | return ~0U;
|
---|
711 | }
|
---|
712 |
|
---|
713 | #ifdef DEBUG_sunlover
|
---|
714 | static void dumpctx(const VBVACONTEXT *pCtx)
|
---|
715 | {
|
---|
716 | Log(("VBVACONTEXT dump: cViews %d\n", pCtx->cViews));
|
---|
717 |
|
---|
718 | uint32_t iView;
|
---|
719 | for (iView = 0; iView < pCtx->cViews; iView++)
|
---|
720 | {
|
---|
721 | const VBVAVIEW *pView = &pCtx->aViews[iView];
|
---|
722 |
|
---|
723 | Log((" view %d o 0x%x s 0x%x m 0x%x\n",
|
---|
724 | pView->view.u32ViewIndex,
|
---|
725 | pView->view.u32ViewOffset,
|
---|
726 | pView->view.u32ViewSize,
|
---|
727 | pView->view.u32MaxScreenSize));
|
---|
728 |
|
---|
729 | Log((" screen %d @%d,%d s 0x%x l 0x%x %dx%d bpp %d f 0x%x\n",
|
---|
730 | pView->screen.u32ViewIndex,
|
---|
731 | pView->screen.i32OriginX,
|
---|
732 | pView->screen.i32OriginY,
|
---|
733 | pView->screen.u32StartOffset,
|
---|
734 | pView->screen.u32LineSize,
|
---|
735 | pView->screen.u32Width,
|
---|
736 | pView->screen.u32Height,
|
---|
737 | pView->screen.u16BitsPerPixel,
|
---|
738 | pView->screen.u16Flags));
|
---|
739 |
|
---|
740 | Log((" VBVA o 0x%x p %p\n",
|
---|
741 | pView->u32VBVAOffset,
|
---|
742 | pView->pVBVA));
|
---|
743 |
|
---|
744 | Log((" PR cb 0x%x p %p\n",
|
---|
745 | pView->partialRecord.cb,
|
---|
746 | pView->partialRecord.pu8));
|
---|
747 | }
|
---|
748 |
|
---|
749 | dumpMouseShapeInfo(&pCtx->mouseShapeInfo);
|
---|
750 | }
|
---|
751 | #endif /* DEBUG_sunlover */
|
---|
752 |
|
---|
753 | #define VBOXVBVASAVEDSTATE_VHWAAVAILABLE_MAGIC 0x12345678
|
---|
754 | #define VBOXVBVASAVEDSTATE_VHWAUNAVAILABLE_MAGIC 0x9abcdef0
|
---|
755 |
|
---|
756 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
757 | static void vbvaVHWAHHCommandReinit(VBOXVHWACMD* pHdr, VBOXVHWACMD_TYPE enmCmd, int32_t iDisplay)
|
---|
758 | {
|
---|
759 | memset(pHdr, 0, VBOXVHWACMD_HEADSIZE());
|
---|
760 | pHdr->cRefs = 1;
|
---|
761 | pHdr->iDisplay = iDisplay;
|
---|
762 | pHdr->rc = VERR_NOT_IMPLEMENTED;
|
---|
763 | pHdr->enmCmd = enmCmd;
|
---|
764 | pHdr->Flags = VBOXVHWACMD_FLAG_HH_CMD;
|
---|
765 | }
|
---|
766 |
|
---|
767 | static VBOXVHWACMD* vbvaVHWAHHCommandCreate (PVGASTATE pVGAState, VBOXVHWACMD_TYPE enmCmd, int32_t iDisplay, VBOXVHWACMD_LENGTH cbCmd)
|
---|
768 | {
|
---|
769 | VBOXVHWACMD* pHdr = (VBOXVHWACMD*)RTMemAlloc(cbCmd + VBOXVHWACMD_HEADSIZE());
|
---|
770 | Assert(pHdr);
|
---|
771 | if (pHdr)
|
---|
772 | vbvaVHWAHHCommandReinit(pHdr, enmCmd, iDisplay);
|
---|
773 |
|
---|
774 | return pHdr;
|
---|
775 | }
|
---|
776 |
|
---|
777 | DECLINLINE(void) vbvaVHWAHHCommandRelease (VBOXVHWACMD* pCmd)
|
---|
778 | {
|
---|
779 | uint32_t cRefs = ASMAtomicDecU32(&pCmd->cRefs);
|
---|
780 | if(!cRefs)
|
---|
781 | {
|
---|
782 | RTMemFree(pCmd);
|
---|
783 | }
|
---|
784 | }
|
---|
785 |
|
---|
786 | DECLINLINE(void) vbvaVHWAHHCommandRetain (VBOXVHWACMD* pCmd)
|
---|
787 | {
|
---|
788 | ASMAtomicIncU32(&pCmd->cRefs);
|
---|
789 | }
|
---|
790 |
|
---|
791 | static unsigned vbvaVHWAHandleCommand (PVGASTATE pVGAState, VBVACONTEXT *pCtx, PVBOXVHWACMD pCmd)
|
---|
792 | {
|
---|
793 | if (pVGAState->pDrv->pfnVHWACommandProcess)
|
---|
794 | pVGAState->pDrv->pfnVHWACommandProcess(pVGAState->pDrv, pCmd);
|
---|
795 | #ifdef DEBUG_misha
|
---|
796 | else
|
---|
797 | AssertFailed();
|
---|
798 | #endif
|
---|
799 | return 0;
|
---|
800 | }
|
---|
801 |
|
---|
802 | static DECLCALLBACK(void) vbvaVHWAHHCommandSetEventCallback(void * pContext)
|
---|
803 | {
|
---|
804 | RTSemEventSignal((RTSEMEVENT)pContext);
|
---|
805 | }
|
---|
806 |
|
---|
807 | static int vbvaVHWAHHCommandPost(PVGASTATE pVGAState, VBOXVHWACMD* pCmd)
|
---|
808 | {
|
---|
809 | RTSEMEVENT hComplEvent;
|
---|
810 | int rc = RTSemEventCreate(&hComplEvent);
|
---|
811 | AssertRC(rc);
|
---|
812 | if(RT_SUCCESS(rc))
|
---|
813 | {
|
---|
814 | /* ensure the cmd is not deleted until we process it */
|
---|
815 | vbvaVHWAHHCommandRetain (pCmd);
|
---|
816 | VBOXVHWA_HH_CALLBACK_SET(pCmd, vbvaVHWAHHCommandSetEventCallback, (void*)hComplEvent);
|
---|
817 | vbvaVHWAHandleCommand(pVGAState, NULL, pCmd);
|
---|
818 | if((ASMAtomicReadU32((volatile uint32_t *)&pCmd->Flags) & VBOXVHWACMD_FLAG_HG_ASYNCH) != 0)
|
---|
819 | {
|
---|
820 | rc = RTSemEventWaitNoResume(hComplEvent, RT_INDEFINITE_WAIT);
|
---|
821 | }
|
---|
822 | else
|
---|
823 | {
|
---|
824 | /* the command is completed */
|
---|
825 | }
|
---|
826 |
|
---|
827 | AssertRC(rc);
|
---|
828 | if(RT_SUCCESS(rc))
|
---|
829 | {
|
---|
830 | RTSemEventDestroy(hComplEvent);
|
---|
831 | }
|
---|
832 | vbvaVHWAHHCommandRelease(pCmd);
|
---|
833 | }
|
---|
834 | return rc;
|
---|
835 | }
|
---|
836 |
|
---|
837 | int vbvaVHWAConstruct (PVGASTATE pVGAState)
|
---|
838 | {
|
---|
839 | VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(pVGAState, VBOXVHWACMD_TYPE_HH_CONSTRUCT, 0, sizeof(VBOXVHWACMD_HH_CONSTRUCT));
|
---|
840 | Assert(pCmd);
|
---|
841 | if(pCmd)
|
---|
842 | {
|
---|
843 | uint32_t iDisplay = 0;
|
---|
844 | int rc = VINF_SUCCESS;
|
---|
845 | VBOXVHWACMD_HH_CONSTRUCT * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_HH_CONSTRUCT);
|
---|
846 |
|
---|
847 | do
|
---|
848 | {
|
---|
849 | memset(pBody, 0, sizeof(VBOXVHWACMD_HH_CONSTRUCT));
|
---|
850 |
|
---|
851 | PPDMDEVINS pDevIns = pVGAState->pDevInsR3;
|
---|
852 | PVM pVM = PDMDevHlpGetVM(pDevIns);
|
---|
853 |
|
---|
854 | pBody->pVM = pVM;
|
---|
855 | pBody->pvVRAM = pVGAState->vram_ptrR3;
|
---|
856 | pBody->cbVRAM = pVGAState->vram_size;
|
---|
857 |
|
---|
858 | rc = vbvaVHWAHHCommandPost(pVGAState, pCmd);
|
---|
859 | AssertRC(rc);
|
---|
860 | if(RT_SUCCESS(rc))
|
---|
861 | {
|
---|
862 | rc = pCmd->rc;
|
---|
863 | AssertMsg(RT_SUCCESS(rc) || rc == VERR_NOT_IMPLEMENTED, ("%Rrc\n", rc));
|
---|
864 | if(rc == VERR_NOT_IMPLEMENTED)
|
---|
865 | {
|
---|
866 | /* @todo: set some flag in pVGAState indicating VHWA is not supported */
|
---|
867 | /* VERR_NOT_IMPLEMENTED is not a failure, we just do not support it */
|
---|
868 | rc = VINF_SUCCESS;
|
---|
869 | }
|
---|
870 |
|
---|
871 | if (!RT_SUCCESS(rc))
|
---|
872 | break;
|
---|
873 | }
|
---|
874 | else
|
---|
875 | break;
|
---|
876 |
|
---|
877 | ++iDisplay;
|
---|
878 | if (iDisplay >= pVGAState->cMonitors)
|
---|
879 | break;
|
---|
880 | vbvaVHWAHHCommandReinit(pCmd, VBOXVHWACMD_TYPE_HH_CONSTRUCT, (int32_t)iDisplay);
|
---|
881 | } while (true);
|
---|
882 |
|
---|
883 | vbvaVHWAHHCommandRelease(pCmd);
|
---|
884 |
|
---|
885 | return rc;
|
---|
886 | }
|
---|
887 | return VERR_OUT_OF_RESOURCES;
|
---|
888 | }
|
---|
889 |
|
---|
890 | int vbvaVHWAReset (PVGASTATE pVGAState)
|
---|
891 | {
|
---|
892 | /* ensure we have all pending cmds processed and h->g cmds disabled */
|
---|
893 | VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(pVGAState, VBOXVHWACMD_TYPE_HH_RESET, 0, 0);
|
---|
894 | Assert(pCmd);
|
---|
895 | if(pCmd)
|
---|
896 | {
|
---|
897 | int rc = VINF_SUCCESS;
|
---|
898 | uint32_t iDisplay = 0;
|
---|
899 |
|
---|
900 | do
|
---|
901 | {
|
---|
902 | rc =vbvaVHWAHHCommandPost(pVGAState, pCmd);
|
---|
903 | AssertRC(rc);
|
---|
904 | if(RT_SUCCESS(rc))
|
---|
905 | {
|
---|
906 | rc = pCmd->rc;
|
---|
907 | AssertMsg(RT_SUCCESS(rc) || rc == VERR_NOT_IMPLEMENTED, ("%Rrc\n", rc));
|
---|
908 | if (rc == VERR_NOT_IMPLEMENTED)
|
---|
909 | rc = VINF_SUCCESS;
|
---|
910 | }
|
---|
911 |
|
---|
912 | if (!RT_SUCCESS(rc))
|
---|
913 | break;
|
---|
914 |
|
---|
915 | ++iDisplay;
|
---|
916 | if (iDisplay >= pVGAState->cMonitors)
|
---|
917 | break;
|
---|
918 | vbvaVHWAHHCommandReinit(pCmd, VBOXVHWACMD_TYPE_HH_RESET, (int32_t)iDisplay);
|
---|
919 |
|
---|
920 | } while (true);
|
---|
921 |
|
---|
922 | vbvaVHWAHHCommandRelease(pCmd);
|
---|
923 |
|
---|
924 | return rc;
|
---|
925 | }
|
---|
926 | return VERR_OUT_OF_RESOURCES;
|
---|
927 | }
|
---|
928 |
|
---|
929 | typedef DECLCALLBACK(bool) FNVBOXVHWAHHCMDPRECB(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext);
|
---|
930 | typedef FNVBOXVHWAHHCMDPRECB *PFNVBOXVHWAHHCMDPRECB;
|
---|
931 |
|
---|
932 | typedef DECLCALLBACK(bool) FNVBOXVHWAHHCMDPOSTCB(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, int rc, void *pvContext);
|
---|
933 | typedef FNVBOXVHWAHHCMDPOSTCB *PFNVBOXVHWAHHCMDPOSTCB;
|
---|
934 |
|
---|
935 | int vbvaVHWAHHPost(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, PFNVBOXVHWAHHCMDPRECB pfnPre, PFNVBOXVHWAHHCMDPOSTCB pfnPost, void *pvContext)
|
---|
936 | {
|
---|
937 | const VBOXVHWACMD_TYPE enmType = pCmd->enmCmd;
|
---|
938 | int rc = VINF_SUCCESS;
|
---|
939 | uint32_t iDisplay = 0;
|
---|
940 |
|
---|
941 | do
|
---|
942 | {
|
---|
943 | if (!pfnPre || pfnPre(pVGAState, pCmd, iDisplay, pvContext))
|
---|
944 | {
|
---|
945 | rc = vbvaVHWAHHCommandPost(pVGAState, pCmd);
|
---|
946 | AssertRC(rc);
|
---|
947 | if (pfnPost)
|
---|
948 | {
|
---|
949 | if (!pfnPost(pVGAState, pCmd, iDisplay, rc, pvContext))
|
---|
950 | {
|
---|
951 | rc = VINF_SUCCESS;
|
---|
952 | break;
|
---|
953 | }
|
---|
954 | rc = VINF_SUCCESS;
|
---|
955 | }
|
---|
956 | else if(RT_SUCCESS(rc))
|
---|
957 | {
|
---|
958 | rc = pCmd->rc;
|
---|
959 | AssertMsg(RT_SUCCESS(rc) || rc == VERR_NOT_IMPLEMENTED, ("%Rrc\n", rc));
|
---|
960 | if(rc == VERR_NOT_IMPLEMENTED)
|
---|
961 | {
|
---|
962 | rc = VINF_SUCCESS;
|
---|
963 | }
|
---|
964 | }
|
---|
965 |
|
---|
966 | if (!RT_SUCCESS(rc))
|
---|
967 | break;
|
---|
968 | }
|
---|
969 |
|
---|
970 | ++iDisplay;
|
---|
971 | if (iDisplay >= pVGAState->cMonitors)
|
---|
972 | break;
|
---|
973 | vbvaVHWAHHCommandReinit(pCmd, enmType, (int32_t)iDisplay);
|
---|
974 | } while (true);
|
---|
975 |
|
---|
976 | return rc;
|
---|
977 | }
|
---|
978 |
|
---|
979 | /* @todo call this also on reset? */
|
---|
980 | int vbvaVHWAEnable (PVGASTATE pVGAState, bool bEnable)
|
---|
981 | {
|
---|
982 | const VBOXVHWACMD_TYPE enmType = bEnable ? VBOXVHWACMD_TYPE_HH_ENABLE : VBOXVHWACMD_TYPE_HH_DISABLE;
|
---|
983 | VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(pVGAState,
|
---|
984 | enmType,
|
---|
985 | 0, 0);
|
---|
986 | Assert(pCmd);
|
---|
987 | if(pCmd)
|
---|
988 | {
|
---|
989 | int rc = vbvaVHWAHHPost (pVGAState, pCmd, NULL, NULL, NULL);
|
---|
990 | vbvaVHWAHHCommandRelease(pCmd);
|
---|
991 | return rc;
|
---|
992 | }
|
---|
993 | return VERR_OUT_OF_RESOURCES;
|
---|
994 | }
|
---|
995 |
|
---|
996 | int vboxVBVASaveStatePrep (PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
997 | {
|
---|
998 | /* ensure we have no pending commands */
|
---|
999 | return vbvaVHWAEnable(PDMINS_2_DATA(pDevIns, PVGASTATE), false);
|
---|
1000 | }
|
---|
1001 |
|
---|
1002 | int vboxVBVASaveStateDone (PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
1003 | {
|
---|
1004 | /* ensure we have no pending commands */
|
---|
1005 | return vbvaVHWAEnable(PDMINS_2_DATA(pDevIns, PVGASTATE), true);
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | int vbvaVHWACommandCompleteAsynch(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd)
|
---|
1009 | {
|
---|
1010 | int rc;
|
---|
1011 | if((pCmd->Flags & VBOXVHWACMD_FLAG_HH_CMD) == 0)
|
---|
1012 | {
|
---|
1013 | PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface);
|
---|
1014 | PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
|
---|
1015 |
|
---|
1016 | Assert(pCmd->Flags & VBOXVHWACMD_FLAG_HG_ASYNCH);
|
---|
1017 | #ifdef VBOX_WITH_WDDM
|
---|
1018 | if (pVGAState->fGuestCaps & VBVACAPS_COMPLETEGCMD_BY_IOREAD)
|
---|
1019 | {
|
---|
1020 | rc = HGSMICompleteGuestCommand(pIns, pCmd, !!(pCmd->Flags & VBOXVHWACMD_FLAG_GH_ASYNCH_IRQ));
|
---|
1021 | AssertRC(rc);
|
---|
1022 | }
|
---|
1023 | else
|
---|
1024 | #endif
|
---|
1025 | {
|
---|
1026 | VBVAHOSTCMD *pHostCmd;
|
---|
1027 | int32_t iDisplay = pCmd->iDisplay;
|
---|
1028 |
|
---|
1029 | if(pCmd->Flags & VBOXVHWACMD_FLAG_GH_ASYNCH_EVENT)
|
---|
1030 | {
|
---|
1031 | rc = HGSMIHostCommandAlloc (pIns,
|
---|
1032 | (void**)&pHostCmd,
|
---|
1033 | VBVAHOSTCMD_SIZE(sizeof(VBVAHOSTCMDEVENT)),
|
---|
1034 | HGSMI_CH_VBVA,
|
---|
1035 | VBVAHG_EVENT);
|
---|
1036 | AssertRC(rc);
|
---|
1037 | if(RT_SUCCESS(rc))
|
---|
1038 | {
|
---|
1039 | memset(pHostCmd, 0 , VBVAHOSTCMD_SIZE(sizeof(VBVAHOSTCMDEVENT)));
|
---|
1040 | pHostCmd->iDstID = pCmd->iDisplay;
|
---|
1041 | pHostCmd->customOpCode = 0;
|
---|
1042 | VBVAHOSTCMDEVENT *pBody = VBVAHOSTCMD_BODY(pHostCmd, VBVAHOSTCMDEVENT);
|
---|
1043 | pBody->pEvent = pCmd->GuestVBVAReserved1;
|
---|
1044 | }
|
---|
1045 | }
|
---|
1046 | else
|
---|
1047 | {
|
---|
1048 | HGSMIOFFSET offCmd = HGSMIPointerToOffsetHost (pIns, pCmd);
|
---|
1049 | Assert(offCmd != HGSMIOFFSET_VOID);
|
---|
1050 | if(offCmd != HGSMIOFFSET_VOID)
|
---|
1051 | {
|
---|
1052 | rc = HGSMIHostCommandAlloc (pIns,
|
---|
1053 | (void**)&pHostCmd,
|
---|
1054 | VBVAHOSTCMD_SIZE(sizeof(VBVAHOSTCMDVHWACMDCOMPLETE)),
|
---|
1055 | HGSMI_CH_VBVA,
|
---|
1056 | VBVAHG_DISPLAY_CUSTOM);
|
---|
1057 | AssertRC(rc);
|
---|
1058 | if(RT_SUCCESS(rc))
|
---|
1059 | {
|
---|
1060 | memset(pHostCmd, 0 , VBVAHOSTCMD_SIZE(sizeof(VBVAHOSTCMDVHWACMDCOMPLETE)));
|
---|
1061 | pHostCmd->iDstID = pCmd->iDisplay;
|
---|
1062 | pHostCmd->customOpCode = VBVAHG_DCUSTOM_VHWA_CMDCOMPLETE;
|
---|
1063 | VBVAHOSTCMDVHWACMDCOMPLETE *pBody = VBVAHOSTCMD_BODY(pHostCmd, VBVAHOSTCMDVHWACMDCOMPLETE);
|
---|
1064 | pBody->offCmd = offCmd;
|
---|
1065 | }
|
---|
1066 | }
|
---|
1067 | else
|
---|
1068 | {
|
---|
1069 | rc = VERR_INVALID_PARAMETER;
|
---|
1070 | }
|
---|
1071 | }
|
---|
1072 |
|
---|
1073 | if(RT_SUCCESS(rc))
|
---|
1074 | {
|
---|
1075 | rc = HGSMIHostCommandProcessAndFreeAsynch(pIns, pHostCmd, (pCmd->Flags & VBOXVHWACMD_FLAG_GH_ASYNCH_IRQ) != 0);
|
---|
1076 | AssertRC(rc);
|
---|
1077 | if(RT_SUCCESS(rc))
|
---|
1078 | {
|
---|
1079 | return rc;
|
---|
1080 | }
|
---|
1081 | HGSMIHostCommandFree (pIns, pHostCmd);
|
---|
1082 | }
|
---|
1083 | }
|
---|
1084 | }
|
---|
1085 | else
|
---|
1086 | {
|
---|
1087 | PFNVBOXVHWA_HH_CALLBACK pfn = VBOXVHWA_HH_CALLBACK_GET(pCmd);
|
---|
1088 | if(pfn)
|
---|
1089 | {
|
---|
1090 | pfn(VBOXVHWA_HH_CALLBACK_GET_ARG(pCmd));
|
---|
1091 | }
|
---|
1092 | rc = VINF_SUCCESS;
|
---|
1093 | }
|
---|
1094 | return rc;
|
---|
1095 | }
|
---|
1096 |
|
---|
1097 | typedef struct VBOXVBVASAVEDSTATECBDATA
|
---|
1098 | {
|
---|
1099 | PSSMHANDLE pSSM;
|
---|
1100 | int rc;
|
---|
1101 | bool ab2DOn[VBOX_VIDEO_MAX_SCREENS];
|
---|
1102 | } VBOXVBVASAVEDSTATECBDATA, *PVBOXVBVASAVEDSTATECBDATA;
|
---|
1103 |
|
---|
1104 | static DECLCALLBACK(bool) vboxVBVASaveStateBeginPostCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, int rc, void *pvContext)
|
---|
1105 | {
|
---|
1106 | PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
|
---|
1107 | if (RT_FAILURE(pData->rc))
|
---|
1108 | return false;
|
---|
1109 | if (RT_FAILURE(rc))
|
---|
1110 | {
|
---|
1111 | pData->rc = rc;
|
---|
1112 | return false;
|
---|
1113 | }
|
---|
1114 |
|
---|
1115 | Assert(iDisplay < RT_ELEMENTS(pData->ab2DOn));
|
---|
1116 | if (iDisplay >= RT_ELEMENTS(pData->ab2DOn))
|
---|
1117 | {
|
---|
1118 | pData->rc = VERR_INVALID_PARAMETER;
|
---|
1119 | return false;
|
---|
1120 | }
|
---|
1121 |
|
---|
1122 | Assert(RT_SUCCESS(pCmd->rc) || pCmd->rc == VERR_NOT_IMPLEMENTED);
|
---|
1123 | if (RT_SUCCESS(pCmd->rc))
|
---|
1124 | {
|
---|
1125 | pData->ab2DOn[iDisplay] = true;
|
---|
1126 | }
|
---|
1127 | else if (pCmd->rc != VERR_NOT_IMPLEMENTED)
|
---|
1128 | {
|
---|
1129 | pData->rc = pCmd->rc;
|
---|
1130 | return false;
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | return true;
|
---|
1134 | }
|
---|
1135 |
|
---|
1136 | static DECLCALLBACK(bool) vboxVBVASaveStatePerformPreCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
|
---|
1137 | {
|
---|
1138 | PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
|
---|
1139 | if (RT_FAILURE(pData->rc))
|
---|
1140 | return false;
|
---|
1141 |
|
---|
1142 | Assert(iDisplay < RT_ELEMENTS(pData->ab2DOn));
|
---|
1143 | if (iDisplay >= RT_ELEMENTS(pData->ab2DOn))
|
---|
1144 | {
|
---|
1145 | pData->rc = VERR_INVALID_PARAMETER;
|
---|
1146 | return false;
|
---|
1147 | }
|
---|
1148 |
|
---|
1149 | int rc;
|
---|
1150 |
|
---|
1151 | if (pData->ab2DOn[iDisplay])
|
---|
1152 | {
|
---|
1153 | rc = SSMR3PutU32 (pData->pSSM, VBOXVBVASAVEDSTATE_VHWAAVAILABLE_MAGIC); AssertRC(rc);
|
---|
1154 | if (RT_FAILURE(rc))
|
---|
1155 | {
|
---|
1156 | pData->rc = rc;
|
---|
1157 | return false;
|
---|
1158 | }
|
---|
1159 | return true;
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 | rc = SSMR3PutU32 (pData->pSSM, VBOXVBVASAVEDSTATE_VHWAUNAVAILABLE_MAGIC); AssertRC(rc);
|
---|
1163 | if (RT_FAILURE(rc))
|
---|
1164 | {
|
---|
1165 | pData->rc = rc;
|
---|
1166 | return false;
|
---|
1167 | }
|
---|
1168 |
|
---|
1169 | return false;
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | static DECLCALLBACK(bool) vboxVBVASaveStateEndPreCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
|
---|
1173 | {
|
---|
1174 | PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
|
---|
1175 | Assert(iDisplay < RT_ELEMENTS(pData->ab2DOn));
|
---|
1176 | if (pData->ab2DOn[iDisplay])
|
---|
1177 | {
|
---|
1178 | return true;
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | return false;
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 | static DECLCALLBACK(bool) vboxVBVALoadStatePerformPostCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, int rc, void *pvContext)
|
---|
1185 | {
|
---|
1186 | PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
|
---|
1187 | if (RT_FAILURE(pData->rc))
|
---|
1188 | return false;
|
---|
1189 | if (RT_FAILURE(rc))
|
---|
1190 | {
|
---|
1191 | pData->rc = rc;
|
---|
1192 | return false;
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 | Assert(iDisplay < RT_ELEMENTS(pData->ab2DOn));
|
---|
1196 | if (iDisplay >= RT_ELEMENTS(pData->ab2DOn))
|
---|
1197 | {
|
---|
1198 | pData->rc = VERR_INVALID_PARAMETER;
|
---|
1199 | return false;
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | Assert(RT_SUCCESS(pCmd->rc) || pCmd->rc == VERR_NOT_IMPLEMENTED);
|
---|
1203 | if (pCmd->rc == VERR_NOT_IMPLEMENTED)
|
---|
1204 | {
|
---|
1205 | pData->rc = SSMR3SkipToEndOfUnit(pData->pSSM);
|
---|
1206 | AssertRC(pData->rc);
|
---|
1207 | return false;
|
---|
1208 | }
|
---|
1209 | if (RT_FAILURE(pCmd->rc))
|
---|
1210 | {
|
---|
1211 | pData->rc = pCmd->rc;
|
---|
1212 | return false;
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | return true;
|
---|
1216 | }
|
---|
1217 |
|
---|
1218 | static DECLCALLBACK(bool) vboxVBVALoadStatePerformPreCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
|
---|
1219 | {
|
---|
1220 | PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
|
---|
1221 | if (RT_FAILURE(pData->rc))
|
---|
1222 | return false;
|
---|
1223 |
|
---|
1224 | Assert(iDisplay < RT_ELEMENTS(pData->ab2DOn));
|
---|
1225 | if (iDisplay >= RT_ELEMENTS(pData->ab2DOn))
|
---|
1226 | {
|
---|
1227 | pData->rc = VERR_INVALID_PARAMETER;
|
---|
1228 | return false;
|
---|
1229 | }
|
---|
1230 |
|
---|
1231 | int rc;
|
---|
1232 | uint32_t u32;
|
---|
1233 | rc = SSMR3GetU32(pData->pSSM, &u32); AssertRC(rc);
|
---|
1234 | if (RT_FAILURE(rc))
|
---|
1235 | {
|
---|
1236 | pData->rc = rc;
|
---|
1237 | return false;
|
---|
1238 | }
|
---|
1239 |
|
---|
1240 | switch (u32)
|
---|
1241 | {
|
---|
1242 | case VBOXVBVASAVEDSTATE_VHWAAVAILABLE_MAGIC:
|
---|
1243 | return true;
|
---|
1244 | case VBOXVBVASAVEDSTATE_VHWAUNAVAILABLE_MAGIC:
|
---|
1245 | return false;
|
---|
1246 | default:
|
---|
1247 | pData->rc = VERR_INVALID_STATE;
|
---|
1248 | return false;
|
---|
1249 | }
|
---|
1250 | }
|
---|
1251 | #endif /* #ifdef VBOX_WITH_VIDEOHWACCEL */
|
---|
1252 |
|
---|
1253 | int vboxVBVASaveDevStateExec (PVGASTATE pVGAState, PSSMHANDLE pSSM)
|
---|
1254 | {
|
---|
1255 | PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
|
---|
1256 | int rc = HGSMIHostSaveStateExec (pIns, pSSM);
|
---|
1257 | if (RT_SUCCESS(rc))
|
---|
1258 | {
|
---|
1259 | /* Save VBVACONTEXT. */
|
---|
1260 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pIns);
|
---|
1261 |
|
---|
1262 | if (!pCtx)
|
---|
1263 | {
|
---|
1264 | AssertFailed();
|
---|
1265 |
|
---|
1266 | /* Still write a valid value to the SSM. */
|
---|
1267 | rc = SSMR3PutU32 (pSSM, 0);
|
---|
1268 | AssertRCReturn(rc, rc);
|
---|
1269 | }
|
---|
1270 | else
|
---|
1271 | {
|
---|
1272 | #ifdef DEBUG_sunlover
|
---|
1273 | dumpctx(pCtx);
|
---|
1274 | #endif
|
---|
1275 |
|
---|
1276 | rc = SSMR3PutU32 (pSSM, pCtx->cViews);
|
---|
1277 | AssertRCReturn(rc, rc);
|
---|
1278 |
|
---|
1279 | uint32_t iView;
|
---|
1280 | for (iView = 0; iView < pCtx->cViews; iView++)
|
---|
1281 | {
|
---|
1282 | VBVAVIEW *pView = &pCtx->aViews[iView];
|
---|
1283 |
|
---|
1284 | rc = SSMR3PutU32 (pSSM, pView->view.u32ViewIndex);
|
---|
1285 | AssertRCReturn(rc, rc);
|
---|
1286 | rc = SSMR3PutU32 (pSSM, pView->view.u32ViewOffset);
|
---|
1287 | AssertRCReturn(rc, rc);
|
---|
1288 | rc = SSMR3PutU32 (pSSM, pView->view.u32ViewSize);
|
---|
1289 | AssertRCReturn(rc, rc);
|
---|
1290 | rc = SSMR3PutU32 (pSSM, pView->view.u32MaxScreenSize);
|
---|
1291 | AssertRCReturn(rc, rc);
|
---|
1292 |
|
---|
1293 | rc = SSMR3PutU32 (pSSM, pView->screen.u32ViewIndex);
|
---|
1294 | AssertRCReturn(rc, rc);
|
---|
1295 | rc = SSMR3PutS32 (pSSM, pView->screen.i32OriginX);
|
---|
1296 | AssertRCReturn(rc, rc);
|
---|
1297 | rc = SSMR3PutS32 (pSSM, pView->screen.i32OriginY);
|
---|
1298 | AssertRCReturn(rc, rc);
|
---|
1299 | rc = SSMR3PutU32 (pSSM, pView->screen.u32StartOffset);
|
---|
1300 | AssertRCReturn(rc, rc);
|
---|
1301 | rc = SSMR3PutU32 (pSSM, pView->screen.u32LineSize);
|
---|
1302 | AssertRCReturn(rc, rc);
|
---|
1303 | rc = SSMR3PutU32 (pSSM, pView->screen.u32Width);
|
---|
1304 | AssertRCReturn(rc, rc);
|
---|
1305 | rc = SSMR3PutU32 (pSSM, pView->screen.u32Height);
|
---|
1306 | AssertRCReturn(rc, rc);
|
---|
1307 | rc = SSMR3PutU16 (pSSM, pView->screen.u16BitsPerPixel);
|
---|
1308 | AssertRCReturn(rc, rc);
|
---|
1309 | rc = SSMR3PutU16 (pSSM, pView->screen.u16Flags);
|
---|
1310 | AssertRCReturn(rc, rc);
|
---|
1311 |
|
---|
1312 | rc = SSMR3PutU32 (pSSM, pView->pVBVA? pView->u32VBVAOffset: HGSMIOFFSET_VOID);
|
---|
1313 | AssertRCReturn(rc, rc);
|
---|
1314 |
|
---|
1315 | rc = SSMR3PutU32 (pSSM, pView->partialRecord.cb);
|
---|
1316 | AssertRCReturn(rc, rc);
|
---|
1317 |
|
---|
1318 | if (pView->partialRecord.cb > 0)
|
---|
1319 | {
|
---|
1320 | rc = SSMR3PutMem (pSSM, pView->partialRecord.pu8, pView->partialRecord.cb);
|
---|
1321 | AssertRCReturn(rc, rc);
|
---|
1322 | }
|
---|
1323 | }
|
---|
1324 |
|
---|
1325 | /* Save mouse pointer shape information. */
|
---|
1326 | rc = SSMR3PutBool (pSSM, pCtx->mouseShapeInfo.fSet);
|
---|
1327 | AssertRCReturn(rc, rc);
|
---|
1328 | rc = SSMR3PutBool (pSSM, pCtx->mouseShapeInfo.fVisible);
|
---|
1329 | AssertRCReturn(rc, rc);
|
---|
1330 | rc = SSMR3PutBool (pSSM, pCtx->mouseShapeInfo.fAlpha);
|
---|
1331 | AssertRCReturn(rc, rc);
|
---|
1332 | rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.u32HotX);
|
---|
1333 | AssertRCReturn(rc, rc);
|
---|
1334 | rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.u32HotY);
|
---|
1335 | AssertRCReturn(rc, rc);
|
---|
1336 | rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.u32Width);
|
---|
1337 | AssertRCReturn(rc, rc);
|
---|
1338 | rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.u32Height);
|
---|
1339 | AssertRCReturn(rc, rc);
|
---|
1340 | rc = SSMR3PutU32 (pSSM, pCtx->mouseShapeInfo.cbShape);
|
---|
1341 | AssertRCReturn(rc, rc);
|
---|
1342 | if (pCtx->mouseShapeInfo.cbShape)
|
---|
1343 | {
|
---|
1344 | rc = SSMR3PutMem (pSSM, pCtx->mouseShapeInfo.pu8Shape, pCtx->mouseShapeInfo.cbShape);
|
---|
1345 | AssertRCReturn(rc, rc);
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | #ifdef VBOX_WITH_WDDM
|
---|
1349 | /* Size of some additional data. For future extensions. */
|
---|
1350 | rc = SSMR3PutU32 (pSSM, 4);
|
---|
1351 | AssertRCReturn(rc, rc);
|
---|
1352 | rc = SSMR3PutU32 (pSSM, pVGAState->fGuestCaps);
|
---|
1353 | AssertRCReturn(rc, rc);
|
---|
1354 | #else
|
---|
1355 | /* Size of some additional data. For future extensions. */
|
---|
1356 | rc = SSMR3PutU32 (pSSM, 0);
|
---|
1357 | AssertRCReturn(rc, rc);
|
---|
1358 | #endif
|
---|
1359 | }
|
---|
1360 | }
|
---|
1361 |
|
---|
1362 | return rc;
|
---|
1363 | }
|
---|
1364 |
|
---|
1365 | int vboxVBVASaveStateExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
1366 | {
|
---|
1367 | PVGASTATE pVGAState = PDMINS_2_DATA(pDevIns, PVGASTATE);
|
---|
1368 | int rc;
|
---|
1369 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
1370 | VBOXVBVASAVEDSTATECBDATA VhwaData = {0};
|
---|
1371 | VhwaData.pSSM = pSSM;
|
---|
1372 | uint32_t cbCmd = sizeof (VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM); /* maximum cmd size */
|
---|
1373 | VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(pVGAState, VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEBEGIN, 0, cbCmd);
|
---|
1374 | Assert(pCmd);
|
---|
1375 | if(pCmd)
|
---|
1376 | {
|
---|
1377 | vbvaVHWAHHPost (pVGAState, pCmd, NULL, vboxVBVASaveStateBeginPostCb, &VhwaData);
|
---|
1378 | rc = VhwaData.rc;
|
---|
1379 | AssertRC(rc);
|
---|
1380 | if (RT_SUCCESS(rc))
|
---|
1381 | {
|
---|
1382 | #endif
|
---|
1383 | rc = vboxVBVASaveDevStateExec (pVGAState, pSSM);
|
---|
1384 | AssertRC(rc);
|
---|
1385 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
1386 | if (RT_SUCCESS(rc))
|
---|
1387 | {
|
---|
1388 | vbvaVHWAHHCommandReinit(pCmd, VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEPERFORM, 0);
|
---|
1389 | VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM *pSave = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM);
|
---|
1390 | pSave->pSSM = pSSM;
|
---|
1391 | vbvaVHWAHHPost (pVGAState, pCmd, vboxVBVASaveStatePerformPreCb, NULL, &VhwaData);
|
---|
1392 | rc = VhwaData.rc;
|
---|
1393 | AssertRC(rc);
|
---|
1394 | if (RT_SUCCESS(rc))
|
---|
1395 | {
|
---|
1396 | vbvaVHWAHHCommandReinit(pCmd, VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEEND, 0);
|
---|
1397 | vbvaVHWAHHPost (pVGAState, pCmd, vboxVBVASaveStateEndPreCb, NULL, &VhwaData);
|
---|
1398 | rc = VhwaData.rc;
|
---|
1399 | AssertRC(rc);
|
---|
1400 | }
|
---|
1401 | }
|
---|
1402 | }
|
---|
1403 |
|
---|
1404 | vbvaVHWAHHCommandRelease(pCmd);
|
---|
1405 | }
|
---|
1406 | else
|
---|
1407 | rc = VERR_OUT_OF_RESOURCES;
|
---|
1408 | #else
|
---|
1409 | if (RT_SUCCESS(rc))
|
---|
1410 | {
|
---|
1411 | for (uint32_t i = 0; i < pVGAState->cMonitors; ++i)
|
---|
1412 | {
|
---|
1413 | rc = SSMR3PutU32 (pSSM, VBOXVBVASAVEDSTATE_VHWAUNAVAILABLE_MAGIC);
|
---|
1414 | AssertRCReturn(rc, rc);
|
---|
1415 | }
|
---|
1416 | }
|
---|
1417 | #endif
|
---|
1418 | return rc;
|
---|
1419 | }
|
---|
1420 |
|
---|
1421 | int vboxVBVALoadStateExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version)
|
---|
1422 | {
|
---|
1423 | if (u32Version < VGA_SAVEDSTATE_VERSION_HGSMI)
|
---|
1424 | {
|
---|
1425 | /* Nothing was saved. */
|
---|
1426 | return VINF_SUCCESS;
|
---|
1427 | }
|
---|
1428 |
|
---|
1429 | PVGASTATE pVGAState = PDMINS_2_DATA(pDevIns, PVGASTATE);
|
---|
1430 | PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
|
---|
1431 | int rc = HGSMIHostLoadStateExec (pIns, pSSM, u32Version);
|
---|
1432 | if (RT_SUCCESS(rc))
|
---|
1433 | {
|
---|
1434 | /* Load VBVACONTEXT. */
|
---|
1435 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pIns);
|
---|
1436 |
|
---|
1437 | if (!pCtx)
|
---|
1438 | {
|
---|
1439 | /* This should not happen. */
|
---|
1440 | AssertFailed();
|
---|
1441 | rc = VERR_INVALID_PARAMETER;
|
---|
1442 | }
|
---|
1443 | else
|
---|
1444 | {
|
---|
1445 | uint32_t cViews = 0;
|
---|
1446 | rc = SSMR3GetU32 (pSSM, &cViews);
|
---|
1447 | AssertRCReturn(rc, rc);
|
---|
1448 |
|
---|
1449 | uint32_t iView;
|
---|
1450 | for (iView = 0; iView < cViews; iView++)
|
---|
1451 | {
|
---|
1452 | VBVAVIEW *pView = &pCtx->aViews[iView];
|
---|
1453 |
|
---|
1454 | rc = SSMR3GetU32 (pSSM, &pView->view.u32ViewIndex);
|
---|
1455 | AssertRCReturn(rc, rc);
|
---|
1456 | rc = SSMR3GetU32 (pSSM, &pView->view.u32ViewOffset);
|
---|
1457 | AssertRCReturn(rc, rc);
|
---|
1458 | rc = SSMR3GetU32 (pSSM, &pView->view.u32ViewSize);
|
---|
1459 | AssertRCReturn(rc, rc);
|
---|
1460 | rc = SSMR3GetU32 (pSSM, &pView->view.u32MaxScreenSize);
|
---|
1461 | AssertRCReturn(rc, rc);
|
---|
1462 |
|
---|
1463 | rc = SSMR3GetU32 (pSSM, &pView->screen.u32ViewIndex);
|
---|
1464 | AssertRCReturn(rc, rc);
|
---|
1465 | rc = SSMR3GetS32 (pSSM, &pView->screen.i32OriginX);
|
---|
1466 | AssertRCReturn(rc, rc);
|
---|
1467 | rc = SSMR3GetS32 (pSSM, &pView->screen.i32OriginY);
|
---|
1468 | AssertRCReturn(rc, rc);
|
---|
1469 | rc = SSMR3GetU32 (pSSM, &pView->screen.u32StartOffset);
|
---|
1470 | AssertRCReturn(rc, rc);
|
---|
1471 | rc = SSMR3GetU32 (pSSM, &pView->screen.u32LineSize);
|
---|
1472 | AssertRCReturn(rc, rc);
|
---|
1473 | rc = SSMR3GetU32 (pSSM, &pView->screen.u32Width);
|
---|
1474 | AssertRCReturn(rc, rc);
|
---|
1475 | rc = SSMR3GetU32 (pSSM, &pView->screen.u32Height);
|
---|
1476 | AssertRCReturn(rc, rc);
|
---|
1477 | rc = SSMR3GetU16 (pSSM, &pView->screen.u16BitsPerPixel);
|
---|
1478 | AssertRCReturn(rc, rc);
|
---|
1479 | rc = SSMR3GetU16 (pSSM, &pView->screen.u16Flags);
|
---|
1480 | AssertRCReturn(rc, rc);
|
---|
1481 |
|
---|
1482 | rc = SSMR3GetU32 (pSSM, &pView->u32VBVAOffset);
|
---|
1483 | AssertRCReturn(rc, rc);
|
---|
1484 |
|
---|
1485 | rc = SSMR3GetU32 (pSSM, &pView->partialRecord.cb);
|
---|
1486 | AssertRCReturn(rc, rc);
|
---|
1487 |
|
---|
1488 | if (pView->partialRecord.cb == 0)
|
---|
1489 | {
|
---|
1490 | pView->partialRecord.pu8 = NULL;
|
---|
1491 | }
|
---|
1492 | else
|
---|
1493 | {
|
---|
1494 | Assert(pView->partialRecord.pu8 == NULL); /* Should be it. */
|
---|
1495 |
|
---|
1496 | uint8_t *pu8 = (uint8_t *)RTMemAlloc (pView->partialRecord.cb);
|
---|
1497 |
|
---|
1498 | if (!pu8)
|
---|
1499 | {
|
---|
1500 | return VERR_NO_MEMORY;
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | pView->partialRecord.pu8 = pu8;
|
---|
1504 |
|
---|
1505 | rc = SSMR3GetMem (pSSM, pView->partialRecord.pu8, pView->partialRecord.cb);
|
---|
1506 | AssertRCReturn(rc, rc);
|
---|
1507 | }
|
---|
1508 |
|
---|
1509 | if ( pView->u32VBVAOffset == HGSMIOFFSET_VOID
|
---|
1510 | || pView->screen.u32LineSize == 0) /* Earlier broken saved states. */
|
---|
1511 | {
|
---|
1512 | pView->pVBVA = NULL;
|
---|
1513 | }
|
---|
1514 | else
|
---|
1515 | {
|
---|
1516 | pView->pVBVA = (VBVABUFFER *)HGSMIOffsetToPointerHost (pIns, pView->u32VBVAOffset);
|
---|
1517 | }
|
---|
1518 | }
|
---|
1519 |
|
---|
1520 | if (u32Version > VGA_SAVEDSTATE_VERSION_WITH_CONFIG)
|
---|
1521 | {
|
---|
1522 | /* Read mouse pointer shape information. */
|
---|
1523 | rc = SSMR3GetBool (pSSM, &pCtx->mouseShapeInfo.fSet);
|
---|
1524 | AssertRCReturn(rc, rc);
|
---|
1525 | rc = SSMR3GetBool (pSSM, &pCtx->mouseShapeInfo.fVisible);
|
---|
1526 | AssertRCReturn(rc, rc);
|
---|
1527 | rc = SSMR3GetBool (pSSM, &pCtx->mouseShapeInfo.fAlpha);
|
---|
1528 | AssertRCReturn(rc, rc);
|
---|
1529 | rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.u32HotX);
|
---|
1530 | AssertRCReturn(rc, rc);
|
---|
1531 | rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.u32HotY);
|
---|
1532 | AssertRCReturn(rc, rc);
|
---|
1533 | rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.u32Width);
|
---|
1534 | AssertRCReturn(rc, rc);
|
---|
1535 | rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.u32Height);
|
---|
1536 | AssertRCReturn(rc, rc);
|
---|
1537 | rc = SSMR3GetU32 (pSSM, &pCtx->mouseShapeInfo.cbShape);
|
---|
1538 | AssertRCReturn(rc, rc);
|
---|
1539 | if (pCtx->mouseShapeInfo.cbShape)
|
---|
1540 | {
|
---|
1541 | pCtx->mouseShapeInfo.pu8Shape = (uint8_t *)RTMemAlloc(pCtx->mouseShapeInfo.cbShape);
|
---|
1542 | if (pCtx->mouseShapeInfo.pu8Shape == NULL)
|
---|
1543 | {
|
---|
1544 | return VERR_NO_MEMORY;
|
---|
1545 | }
|
---|
1546 | pCtx->mouseShapeInfo.cbAllocated = pCtx->mouseShapeInfo.cbShape;
|
---|
1547 | rc = SSMR3GetMem (pSSM, pCtx->mouseShapeInfo.pu8Shape, pCtx->mouseShapeInfo.cbShape);
|
---|
1548 | AssertRCReturn(rc, rc);
|
---|
1549 | }
|
---|
1550 | else
|
---|
1551 | {
|
---|
1552 | pCtx->mouseShapeInfo.pu8Shape = NULL;
|
---|
1553 | }
|
---|
1554 |
|
---|
1555 | /* Size of some additional data. For future extensions. */
|
---|
1556 | uint32_t cbExtra = 0;
|
---|
1557 | rc = SSMR3GetU32 (pSSM, &cbExtra);
|
---|
1558 | AssertRCReturn(rc, rc);
|
---|
1559 | #ifdef VBOX_WITH_WDDM
|
---|
1560 | if (cbExtra >= 4)
|
---|
1561 | {
|
---|
1562 | rc = SSMR3GetU32 (pSSM, &pVGAState->fGuestCaps);
|
---|
1563 | AssertRCReturn(rc, rc);
|
---|
1564 | cbExtra -= 4;
|
---|
1565 | }
|
---|
1566 | #endif
|
---|
1567 | if (cbExtra > 0)
|
---|
1568 | {
|
---|
1569 | rc = SSMR3Skip(pSSM, cbExtra);
|
---|
1570 | AssertRCReturn(rc, rc);
|
---|
1571 | }
|
---|
1572 | }
|
---|
1573 |
|
---|
1574 | pCtx->cViews = iView;
|
---|
1575 | LogFlowFunc(("%d views loaded\n", pCtx->cViews));
|
---|
1576 |
|
---|
1577 | if (u32Version > VGA_SAVEDSTATE_VERSION_WDDM)
|
---|
1578 | {
|
---|
1579 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
1580 | uint32_t cbCmd = sizeof (VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM); /* maximum cmd size */
|
---|
1581 | VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(pVGAState, VBOXVHWACMD_TYPE_HH_SAVESTATE_LOADPERFORM, 0, cbCmd);
|
---|
1582 | Assert(pCmd);
|
---|
1583 | if(pCmd)
|
---|
1584 | {
|
---|
1585 | VBOXVBVASAVEDSTATECBDATA VhwaData = {0};
|
---|
1586 | VhwaData.pSSM = pSSM;
|
---|
1587 | VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM *pLoad = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM);
|
---|
1588 | pLoad->pSSM = pSSM;
|
---|
1589 | vbvaVHWAHHPost (pVGAState, pCmd, vboxVBVALoadStatePerformPreCb, vboxVBVALoadStatePerformPostCb, &VhwaData);
|
---|
1590 | rc = VhwaData.rc;
|
---|
1591 | AssertRC(rc);
|
---|
1592 | vbvaVHWAHHCommandRelease(pCmd);
|
---|
1593 | }
|
---|
1594 | else
|
---|
1595 | {
|
---|
1596 | rc = VERR_OUT_OF_RESOURCES;
|
---|
1597 | }
|
---|
1598 | #else
|
---|
1599 | rc = SSMR3SkipToEndOfUnit(pSSM);
|
---|
1600 | AssertRCReturn(rc, rc);
|
---|
1601 | #endif
|
---|
1602 | }
|
---|
1603 |
|
---|
1604 | #ifdef DEBUG_sunlover
|
---|
1605 | dumpctx(pCtx);
|
---|
1606 | #endif
|
---|
1607 | }
|
---|
1608 | }
|
---|
1609 |
|
---|
1610 | return rc;
|
---|
1611 | }
|
---|
1612 |
|
---|
1613 | int vboxVBVALoadStateDone (PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
1614 | {
|
---|
1615 | PVGASTATE pVGAState = PDMINS_2_DATA(pDevIns, PVGASTATE);
|
---|
1616 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI);
|
---|
1617 |
|
---|
1618 | if (pCtx)
|
---|
1619 | {
|
---|
1620 | uint32_t iView;
|
---|
1621 | for (iView = 0; iView < pCtx->cViews; iView++)
|
---|
1622 | {
|
---|
1623 | VBVAVIEW *pView = &pCtx->aViews[iView];
|
---|
1624 |
|
---|
1625 | if (pView->pVBVA)
|
---|
1626 | {
|
---|
1627 | vbvaEnable (iView, pVGAState, pCtx, pView->pVBVA, pView->u32VBVAOffset, true /* fRestored */);
|
---|
1628 | vbvaResize (pVGAState, pView, &pView->screen);
|
---|
1629 | }
|
---|
1630 | }
|
---|
1631 |
|
---|
1632 | if (pCtx->mouseShapeInfo.fSet)
|
---|
1633 | {
|
---|
1634 | vbvaUpdateMousePointerShape(pVGAState, &pCtx->mouseShapeInfo, true, pCtx->mouseShapeInfo.pu8Shape);
|
---|
1635 | }
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 | return VINF_SUCCESS;
|
---|
1639 | }
|
---|
1640 |
|
---|
1641 | void VBVARaiseIrq (PVGASTATE pVGAState, uint32_t fFlags)
|
---|
1642 | {
|
---|
1643 | PPDMDEVINS pDevIns = pVGAState->pDevInsR3;
|
---|
1644 | PDMCritSectEnter(&pVGAState->CritSect, VERR_SEM_BUSY);
|
---|
1645 |
|
---|
1646 | HGSMISetHostGuestFlags(pVGAState->pHGSMI, HGSMIHOSTFLAGS_IRQ | fFlags);
|
---|
1647 | PDMDevHlpPCISetIrq(pDevIns, 0, PDM_IRQ_LEVEL_HIGH);
|
---|
1648 |
|
---|
1649 | PDMCritSectLeave(&pVGAState->CritSect);
|
---|
1650 | }
|
---|
1651 |
|
---|
1652 | /*
|
---|
1653 | *
|
---|
1654 | * New VBVA uses a new interface id: #define VBE_DISPI_ID_VBOX_VIDEO 0xBE01
|
---|
1655 | *
|
---|
1656 | * VBVA uses two 32 bits IO ports to write VRAM offsets of shared memory blocks for commands.
|
---|
1657 | * Read Write
|
---|
1658 | * Host port 0x3b0 to process completed
|
---|
1659 | * Guest port 0x3d0 control value? to process
|
---|
1660 | *
|
---|
1661 | */
|
---|
1662 |
|
---|
1663 | static DECLCALLBACK(void) vbvaNotifyGuest (void *pvCallback)
|
---|
1664 | {
|
---|
1665 | #if defined(VBOX_WITH_HGSMI) && (defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_VDMA) || defined(VBOX_WITH_WDDM))
|
---|
1666 | PVGASTATE pVGAState = (PVGASTATE)pvCallback;
|
---|
1667 | VBVARaiseIrq (pVGAState, 0);
|
---|
1668 | #else
|
---|
1669 | NOREF(pvCallback);
|
---|
1670 | /* Do nothing. Later the VMMDev/VGA IRQ can be used for the notification. */
|
---|
1671 | #endif
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | /* The guest submitted a buffer. @todo Verify all guest data. */
|
---|
1675 | static DECLCALLBACK(int) vbvaChannelHandler (void *pvHandler, uint16_t u16ChannelInfo, void *pvBuffer, HGSMISIZE cbBuffer)
|
---|
1676 | {
|
---|
1677 | int rc = VINF_SUCCESS;
|
---|
1678 |
|
---|
1679 | LogFlowFunc(("pvHandler %p, u16ChannelInfo %d, pvBuffer %p, cbBuffer %u\n",
|
---|
1680 | pvHandler, u16ChannelInfo, pvBuffer, cbBuffer));
|
---|
1681 |
|
---|
1682 | PVGASTATE pVGAState = (PVGASTATE)pvHandler;
|
---|
1683 | PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
|
---|
1684 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pIns);
|
---|
1685 |
|
---|
1686 | switch (u16ChannelInfo)
|
---|
1687 | {
|
---|
1688 | #ifdef VBOX_WITH_VDMA
|
---|
1689 | case VBVA_VDMA_CMD:
|
---|
1690 | {
|
---|
1691 | if (cbBuffer < VBoxSHGSMIBufferHeaderSize() + sizeof (VBOXVDMACBUF_DR))
|
---|
1692 | {
|
---|
1693 | rc = VERR_INVALID_PARAMETER;
|
---|
1694 | break;
|
---|
1695 | }
|
---|
1696 | PVBOXVDMACBUF_DR pCmd = (PVBOXVDMACBUF_DR)VBoxSHGSMIBufferData ((PVBOXSHGSMIHEADER)pvBuffer);
|
---|
1697 | vboxVDMACommand(pVGAState->pVdma, pCmd, cbBuffer - VBoxSHGSMIBufferHeaderSize());
|
---|
1698 | rc = VINF_SUCCESS;
|
---|
1699 | break;
|
---|
1700 | }
|
---|
1701 | case VBVA_VDMA_CTL:
|
---|
1702 | {
|
---|
1703 | if (cbBuffer < VBoxSHGSMIBufferHeaderSize() + sizeof (VBOXVDMA_CTL))
|
---|
1704 | {
|
---|
1705 | rc = VERR_INVALID_PARAMETER;
|
---|
1706 | break;
|
---|
1707 | }
|
---|
1708 | PVBOXVDMA_CTL pCmd = (PVBOXVDMA_CTL)VBoxSHGSMIBufferData ((PVBOXSHGSMIHEADER)pvBuffer);
|
---|
1709 | vboxVDMAControl(pVGAState->pVdma, pCmd, cbBuffer - VBoxSHGSMIBufferHeaderSize());
|
---|
1710 | rc = VINF_SUCCESS;
|
---|
1711 | break;
|
---|
1712 | }
|
---|
1713 | #endif
|
---|
1714 | case VBVA_QUERY_CONF32:
|
---|
1715 | {
|
---|
1716 | if (cbBuffer < sizeof (VBVACONF32))
|
---|
1717 | {
|
---|
1718 | rc = VERR_INVALID_PARAMETER;
|
---|
1719 | break;
|
---|
1720 | }
|
---|
1721 |
|
---|
1722 | VBVACONF32 *pConf32 = (VBVACONF32 *)pvBuffer;
|
---|
1723 | LogFlowFunc(("VBVA_QUERY_CONF32: u32Index %d, u32Value 0x%x\n",
|
---|
1724 | pConf32->u32Index, pConf32->u32Value));
|
---|
1725 |
|
---|
1726 | if (pConf32->u32Index == VBOX_VBVA_CONF32_MONITOR_COUNT)
|
---|
1727 | {
|
---|
1728 | pConf32->u32Value = pCtx->cViews;
|
---|
1729 | }
|
---|
1730 | else if (pConf32->u32Index == VBOX_VBVA_CONF32_HOST_HEAP_SIZE)
|
---|
1731 | {
|
---|
1732 | /* @todo a value calculated from the vram size */
|
---|
1733 | pConf32->u32Value = 64*_1K;
|
---|
1734 | }
|
---|
1735 | else
|
---|
1736 | {
|
---|
1737 | Log(("Unsupported VBVA_QUERY_CONF32 index %d!!!\n",
|
---|
1738 | pConf32->u32Index));
|
---|
1739 | rc = VERR_INVALID_PARAMETER;
|
---|
1740 | }
|
---|
1741 | } break;
|
---|
1742 |
|
---|
1743 | case VBVA_SET_CONF32:
|
---|
1744 | {
|
---|
1745 | if (cbBuffer < sizeof (VBVACONF32))
|
---|
1746 | {
|
---|
1747 | rc = VERR_INVALID_PARAMETER;
|
---|
1748 | break;
|
---|
1749 | }
|
---|
1750 |
|
---|
1751 | VBVACONF32 *pConf32 = (VBVACONF32 *)pvBuffer;
|
---|
1752 | LogFlowFunc(("VBVA_SET_CONF32: u32Index %d, u32Value 0x%x\n",
|
---|
1753 | pConf32->u32Index, pConf32->u32Value));
|
---|
1754 |
|
---|
1755 | if (pConf32->u32Index == VBOX_VBVA_CONF32_MONITOR_COUNT)
|
---|
1756 | {
|
---|
1757 | /* do nothing. this is a const. */
|
---|
1758 | }
|
---|
1759 | else if (pConf32->u32Index == VBOX_VBVA_CONF32_HOST_HEAP_SIZE)
|
---|
1760 | {
|
---|
1761 | /* do nothing. this is a const. */
|
---|
1762 | }
|
---|
1763 | else
|
---|
1764 | {
|
---|
1765 | Log(("Unsupported VBVA_SET_CONF32 index %d!!!\n",
|
---|
1766 | pConf32->u32Index));
|
---|
1767 | rc = VERR_INVALID_PARAMETER;
|
---|
1768 | }
|
---|
1769 | } break;
|
---|
1770 |
|
---|
1771 | case VBVA_INFO_VIEW:
|
---|
1772 | {
|
---|
1773 | if (cbBuffer < sizeof (VBVAINFOVIEW))
|
---|
1774 | {
|
---|
1775 | rc = VERR_INVALID_PARAMETER;
|
---|
1776 | break;
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | /* Guest submits an array of VBVAINFOVIEW structures. */
|
---|
1780 | VBVAINFOVIEW *pView = (VBVAINFOVIEW *)pvBuffer;
|
---|
1781 |
|
---|
1782 | for (;
|
---|
1783 | cbBuffer >= sizeof (VBVAINFOVIEW);
|
---|
1784 | pView++, cbBuffer -= sizeof (VBVAINFOVIEW))
|
---|
1785 | {
|
---|
1786 | LogFlowFunc(("VBVA_INFO_VIEW: index %d, offset 0x%x, size 0x%x, max screen size 0x%x\n",
|
---|
1787 | pView->u32ViewIndex, pView->u32ViewOffset, pView->u32ViewSize, pView->u32MaxScreenSize));
|
---|
1788 |
|
---|
1789 | /* @todo verify view data. */
|
---|
1790 | if (pView->u32ViewIndex >= pCtx->cViews)
|
---|
1791 | {
|
---|
1792 | Log(("View index too large %d!!!\n",
|
---|
1793 | pView->u32ViewIndex));
|
---|
1794 | rc = VERR_INVALID_PARAMETER;
|
---|
1795 | break;
|
---|
1796 | }
|
---|
1797 |
|
---|
1798 | pCtx->aViews[pView->u32ViewIndex].view = *pView;
|
---|
1799 | }
|
---|
1800 | } break;
|
---|
1801 |
|
---|
1802 | case VBVA_INFO_HEAP:
|
---|
1803 | {
|
---|
1804 | if (cbBuffer < sizeof (VBVAINFOHEAP))
|
---|
1805 | {
|
---|
1806 | rc = VERR_INVALID_PARAMETER;
|
---|
1807 | break;
|
---|
1808 | }
|
---|
1809 |
|
---|
1810 | VBVAINFOHEAP *pHeap = (VBVAINFOHEAP *)pvBuffer;
|
---|
1811 | LogFlowFunc(("VBVA_INFO_HEAP: offset 0x%x, size 0x%x\n",
|
---|
1812 | pHeap->u32HeapOffset, pHeap->u32HeapSize));
|
---|
1813 |
|
---|
1814 | rc = HGSMISetupHostHeap (pIns, pHeap->u32HeapOffset, pHeap->u32HeapSize);
|
---|
1815 | } break;
|
---|
1816 |
|
---|
1817 | case VBVA_FLUSH:
|
---|
1818 | {
|
---|
1819 | if (cbBuffer < sizeof (VBVAFLUSH))
|
---|
1820 | {
|
---|
1821 | rc = VERR_INVALID_PARAMETER;
|
---|
1822 | break;
|
---|
1823 | }
|
---|
1824 |
|
---|
1825 | VBVAFLUSH *pFlush = (VBVAFLUSH *)pvBuffer;
|
---|
1826 | LogFlowFunc(("VBVA_FLUSH: u32Reserved 0x%x\n",
|
---|
1827 | pFlush->u32Reserved));
|
---|
1828 |
|
---|
1829 | rc = vbvaFlush (pVGAState, pCtx);
|
---|
1830 | } break;
|
---|
1831 |
|
---|
1832 | case VBVA_INFO_SCREEN:
|
---|
1833 | {
|
---|
1834 | if (cbBuffer < sizeof (VBVAINFOSCREEN))
|
---|
1835 | {
|
---|
1836 | rc = VERR_INVALID_PARAMETER;
|
---|
1837 | break;
|
---|
1838 | }
|
---|
1839 |
|
---|
1840 | VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)pvBuffer;
|
---|
1841 | VBVAINFOVIEW *pView = &pCtx->aViews[pScreen->u32ViewIndex].view;
|
---|
1842 | /* Calculate the offset of the end of the screen so we can make
|
---|
1843 | * sure it is inside the view. I assume that screen rollover is not
|
---|
1844 | * implemented. */
|
---|
1845 | int64_t offEnd = (int64_t)pScreen->u32Height * pScreen->u32LineSize
|
---|
1846 | + pScreen->u32Width + pScreen->u32StartOffset;
|
---|
1847 | LogRelFlowFunc(("VBVA_INFO_SCREEN: [%d] @%d,%d %dx%d, line 0x%x, BPP %d, flags 0x%x\n",
|
---|
1848 | pScreen->u32ViewIndex, pScreen->i32OriginX, pScreen->i32OriginY,
|
---|
1849 | pScreen->u32Width, pScreen->u32Height,
|
---|
1850 | pScreen->u32LineSize, pScreen->u16BitsPerPixel, pScreen->u16Flags));
|
---|
1851 |
|
---|
1852 | if ( pScreen->u32ViewIndex < RT_ELEMENTS (pCtx->aViews)
|
---|
1853 | && pScreen->u16BitsPerPixel <= 32
|
---|
1854 | && pScreen->u32Width <= UINT16_MAX
|
---|
1855 | && pScreen->u32Height <= UINT16_MAX
|
---|
1856 | && pScreen->u32LineSize <= UINT16_MAX * 4
|
---|
1857 | && offEnd < pView->u32MaxScreenSize)
|
---|
1858 | {
|
---|
1859 | vbvaResize (pVGAState, &pCtx->aViews[pScreen->u32ViewIndex], pScreen);
|
---|
1860 | }
|
---|
1861 | else
|
---|
1862 | {
|
---|
1863 | LogRelFlow(("VBVA_INFO_SCREEN [%lu]: bad data: %lux%lu, line 0x%lx, BPP %u, start offset %lu, max screen size %lu\n",
|
---|
1864 | (unsigned long)pScreen->u32ViewIndex,
|
---|
1865 | (unsigned long)pScreen->u32Width,
|
---|
1866 | (unsigned long)pScreen->u32Height,
|
---|
1867 | (unsigned long)pScreen->u32LineSize,
|
---|
1868 | (unsigned long)pScreen->u16BitsPerPixel,
|
---|
1869 | (unsigned long)pScreen->u32StartOffset,
|
---|
1870 | (unsigned long)pView->u32MaxScreenSize));
|
---|
1871 | rc = VERR_INVALID_PARAMETER;
|
---|
1872 | }
|
---|
1873 | } break;
|
---|
1874 |
|
---|
1875 | case VBVA_ENABLE:
|
---|
1876 | {
|
---|
1877 | if (cbBuffer < sizeof (VBVAENABLE))
|
---|
1878 | {
|
---|
1879 | rc = VERR_INVALID_PARAMETER;
|
---|
1880 | break;
|
---|
1881 | }
|
---|
1882 |
|
---|
1883 | VBVAENABLE *pEnable = (VBVAENABLE *)pvBuffer;
|
---|
1884 | unsigned uScreenId;
|
---|
1885 | if (pEnable->u32Flags & VBVA_F_EXTENDED)
|
---|
1886 | {
|
---|
1887 | if (cbBuffer < sizeof (VBVAENABLE_EX))
|
---|
1888 | {
|
---|
1889 | rc = VERR_INVALID_PARAMETER;
|
---|
1890 | break;
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 | VBVAENABLE_EX *pEnableEx = (VBVAENABLE_EX *)pvBuffer;
|
---|
1894 | uScreenId = pEnableEx->u32ScreenId;
|
---|
1895 | }
|
---|
1896 | else
|
---|
1897 | {
|
---|
1898 | uScreenId = vbvaViewFromOffset (pIns, pCtx, pvBuffer);
|
---|
1899 | }
|
---|
1900 |
|
---|
1901 | if (uScreenId == ~0U)
|
---|
1902 | {
|
---|
1903 | rc = VERR_INVALID_PARAMETER;
|
---|
1904 | break;
|
---|
1905 | }
|
---|
1906 |
|
---|
1907 | LogFlowFunc(("VBVA_ENABLE[%d]: u32Flags 0x%x u32Offset 0x%x\n",
|
---|
1908 | uScreenId, pEnable->u32Flags, pEnable->u32Offset));
|
---|
1909 |
|
---|
1910 | if ((pEnable->u32Flags & (VBVA_F_ENABLE | VBVA_F_DISABLE)) == VBVA_F_ENABLE)
|
---|
1911 | {
|
---|
1912 | /* Guest reported offset relative to view. */
|
---|
1913 | uint32_t u32Offset = pEnable->u32Offset;
|
---|
1914 | if (!(pEnable->u32Flags & VBVA_F_ABSOFFSET))
|
---|
1915 | {
|
---|
1916 | u32Offset += pCtx->aViews[uScreenId].view.u32ViewOffset;
|
---|
1917 | }
|
---|
1918 |
|
---|
1919 | VBVABUFFER *pVBVA = (VBVABUFFER *)HGSMIOffsetToPointerHost (pIns, u32Offset);
|
---|
1920 |
|
---|
1921 | if (pVBVA)
|
---|
1922 | {
|
---|
1923 | /* Process any pending orders and empty the VBVA ring buffer. */
|
---|
1924 | vbvaFlush (pVGAState, pCtx);
|
---|
1925 |
|
---|
1926 | rc = vbvaEnable (uScreenId, pVGAState, pCtx, pVBVA, u32Offset, false /* fRestored */);
|
---|
1927 | }
|
---|
1928 | else
|
---|
1929 | {
|
---|
1930 | Log(("Invalid VBVABUFFER offset 0x%x!!!\n",
|
---|
1931 | pEnable->u32Offset));
|
---|
1932 | rc = VERR_INVALID_PARAMETER;
|
---|
1933 | }
|
---|
1934 | }
|
---|
1935 | else if ((pEnable->u32Flags & (VBVA_F_ENABLE | VBVA_F_DISABLE)) == VBVA_F_DISABLE)
|
---|
1936 | {
|
---|
1937 | rc = vbvaDisable (uScreenId, pVGAState, pCtx);
|
---|
1938 | }
|
---|
1939 | else
|
---|
1940 | {
|
---|
1941 | Log(("Invalid VBVA_ENABLE flags 0x%x!!!\n",
|
---|
1942 | pEnable->u32Flags));
|
---|
1943 | rc = VERR_INVALID_PARAMETER;
|
---|
1944 | }
|
---|
1945 |
|
---|
1946 | pEnable->i32Result = rc;
|
---|
1947 | } break;
|
---|
1948 |
|
---|
1949 | case VBVA_MOUSE_POINTER_SHAPE:
|
---|
1950 | {
|
---|
1951 | if (cbBuffer < sizeof (VBVAMOUSEPOINTERSHAPE))
|
---|
1952 | {
|
---|
1953 | rc = VERR_INVALID_PARAMETER;
|
---|
1954 | break;
|
---|
1955 | }
|
---|
1956 |
|
---|
1957 | VBVAMOUSEPOINTERSHAPE *pShape = (VBVAMOUSEPOINTERSHAPE *)pvBuffer;
|
---|
1958 |
|
---|
1959 | LogFlowFunc(("VBVA_MOUSE_POINTER_SHAPE: i32Result 0x%x, fu32Flags 0x%x, hot spot %d,%d, size %dx%d\n",
|
---|
1960 | pShape->i32Result,
|
---|
1961 | pShape->fu32Flags,
|
---|
1962 | pShape->u32HotX,
|
---|
1963 | pShape->u32HotY,
|
---|
1964 | pShape->u32Width,
|
---|
1965 | pShape->u32Height));
|
---|
1966 |
|
---|
1967 | rc = vbvaMousePointerShape (pVGAState, pCtx, pShape, cbBuffer);
|
---|
1968 |
|
---|
1969 | pShape->i32Result = rc;
|
---|
1970 | } break;
|
---|
1971 |
|
---|
1972 |
|
---|
1973 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
1974 | case VBVA_VHWA_CMD:
|
---|
1975 | {
|
---|
1976 | rc = vbvaVHWAHandleCommand (pVGAState, pCtx, (PVBOXVHWACMD)pvBuffer);
|
---|
1977 | } break;
|
---|
1978 | #endif
|
---|
1979 |
|
---|
1980 | #ifdef VBOX_WITH_WDDM
|
---|
1981 | case VBVA_INFO_CAPS:
|
---|
1982 | {
|
---|
1983 | if (cbBuffer < sizeof (VBVACAPS))
|
---|
1984 | {
|
---|
1985 | rc = VERR_INVALID_PARAMETER;
|
---|
1986 | break;
|
---|
1987 | }
|
---|
1988 |
|
---|
1989 | VBVACAPS *pCaps = (VBVACAPS*)pvBuffer;
|
---|
1990 | pVGAState->fGuestCaps = pCaps->fCaps;
|
---|
1991 | pCaps->rc = VINF_SUCCESS;
|
---|
1992 | } break;
|
---|
1993 | #endif
|
---|
1994 | case VBVA_SCANLINE_CFG:
|
---|
1995 | {
|
---|
1996 | if (cbBuffer < sizeof (VBVASCANLINECFG))
|
---|
1997 | {
|
---|
1998 | rc = VERR_INVALID_PARAMETER;
|
---|
1999 | break;
|
---|
2000 | }
|
---|
2001 |
|
---|
2002 | VBVASCANLINECFG *pCfg = (VBVASCANLINECFG*)pvBuffer;
|
---|
2003 | pVGAState->fScanLineCfg = pCfg->fFlags;
|
---|
2004 | pCfg->rc = VINF_SUCCESS;
|
---|
2005 | } break;
|
---|
2006 | default:
|
---|
2007 | Log(("Unsupported VBVA guest command %d!!!\n",
|
---|
2008 | u16ChannelInfo));
|
---|
2009 | break;
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | return rc;
|
---|
2013 | }
|
---|
2014 |
|
---|
2015 | void VBVAReset (PVGASTATE pVGAState)
|
---|
2016 | {
|
---|
2017 | if (!pVGAState || !pVGAState->pHGSMI)
|
---|
2018 | {
|
---|
2019 | return;
|
---|
2020 | }
|
---|
2021 |
|
---|
2022 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI);
|
---|
2023 |
|
---|
2024 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
2025 | vbvaVHWAReset (pVGAState);
|
---|
2026 | #endif
|
---|
2027 |
|
---|
2028 | uint32_t HgFlags = HGSMIReset (pVGAState->pHGSMI);
|
---|
2029 | if(HgFlags & HGSMIHOSTFLAGS_IRQ)
|
---|
2030 | {
|
---|
2031 | /* this means the IRQ is LEVEL_HIGH, need to reset it */
|
---|
2032 | PDMDevHlpPCISetIrq(pVGAState->pDevInsR3, 0, PDM_IRQ_LEVEL_LOW);
|
---|
2033 | }
|
---|
2034 |
|
---|
2035 | if (pCtx)
|
---|
2036 | {
|
---|
2037 | vbvaFlush (pVGAState, pCtx);
|
---|
2038 |
|
---|
2039 | unsigned uScreenId;
|
---|
2040 |
|
---|
2041 | for (uScreenId = 0; uScreenId < pCtx->cViews; uScreenId++)
|
---|
2042 | {
|
---|
2043 | vbvaDisable (uScreenId, pVGAState, pCtx);
|
---|
2044 | }
|
---|
2045 |
|
---|
2046 | pCtx->mouseShapeInfo.fSet = false;
|
---|
2047 | RTMemFree(pCtx->mouseShapeInfo.pu8Shape);
|
---|
2048 | pCtx->mouseShapeInfo.pu8Shape = NULL;
|
---|
2049 | pCtx->mouseShapeInfo.cbAllocated = 0;
|
---|
2050 | pCtx->mouseShapeInfo.cbShape = 0;
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | }
|
---|
2054 |
|
---|
2055 | int VBVAUpdateDisplay (PVGASTATE pVGAState)
|
---|
2056 | {
|
---|
2057 | int rc = VERR_NOT_SUPPORTED; /* Assuming that the VGA device will have to do updates. */
|
---|
2058 |
|
---|
2059 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI);
|
---|
2060 |
|
---|
2061 | if (pCtx)
|
---|
2062 | {
|
---|
2063 | rc = vbvaFlush (pVGAState, pCtx);
|
---|
2064 |
|
---|
2065 | if (RT_SUCCESS (rc))
|
---|
2066 | {
|
---|
2067 | if (!pCtx->aViews[0].pVBVA)
|
---|
2068 | {
|
---|
2069 | /* VBVA is not enabled for the first view, so VGA device must do updates. */
|
---|
2070 | rc = VERR_NOT_SUPPORTED;
|
---|
2071 | }
|
---|
2072 | }
|
---|
2073 | }
|
---|
2074 |
|
---|
2075 | return rc;
|
---|
2076 | }
|
---|
2077 |
|
---|
2078 | static HGSMICHANNELHANDLER sOldChannelHandler;
|
---|
2079 |
|
---|
2080 | int VBVAInit (PVGASTATE pVGAState)
|
---|
2081 | {
|
---|
2082 | PPDMDEVINS pDevIns = pVGAState->pDevInsR3;
|
---|
2083 |
|
---|
2084 | PVM pVM = PDMDevHlpGetVM(pDevIns);
|
---|
2085 |
|
---|
2086 | int rc = HGSMICreate (&pVGAState->pHGSMI,
|
---|
2087 | pVM,
|
---|
2088 | "VBVA",
|
---|
2089 | 0,
|
---|
2090 | pVGAState->vram_ptrR3,
|
---|
2091 | pVGAState->vram_size,
|
---|
2092 | vbvaNotifyGuest,
|
---|
2093 | pVGAState,
|
---|
2094 | sizeof (VBVACONTEXT));
|
---|
2095 |
|
---|
2096 | if (RT_SUCCESS (rc))
|
---|
2097 | {
|
---|
2098 | rc = HGSMIHostChannelRegister (pVGAState->pHGSMI,
|
---|
2099 | HGSMI_CH_VBVA,
|
---|
2100 | vbvaChannelHandler,
|
---|
2101 | pVGAState,
|
---|
2102 | &sOldChannelHandler);
|
---|
2103 | if (RT_SUCCESS (rc))
|
---|
2104 | {
|
---|
2105 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI);
|
---|
2106 | pCtx->cViews = pVGAState->cMonitors;
|
---|
2107 | }
|
---|
2108 | }
|
---|
2109 |
|
---|
2110 | return rc;
|
---|
2111 |
|
---|
2112 | }
|
---|
2113 |
|
---|
2114 | void VBVADestroy (PVGASTATE pVGAState)
|
---|
2115 | {
|
---|
2116 | VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI);
|
---|
2117 |
|
---|
2118 | if (pCtx)
|
---|
2119 | {
|
---|
2120 | pCtx->mouseShapeInfo.fSet = false;
|
---|
2121 | RTMemFree(pCtx->mouseShapeInfo.pu8Shape);
|
---|
2122 | pCtx->mouseShapeInfo.pu8Shape = NULL;
|
---|
2123 | pCtx->mouseShapeInfo.cbAllocated = 0;
|
---|
2124 | pCtx->mouseShapeInfo.cbShape = 0;
|
---|
2125 | }
|
---|
2126 |
|
---|
2127 | HGSMIDestroy (pVGAState->pHGSMI);
|
---|
2128 | pVGAState->pHGSMI = NULL;
|
---|
2129 | }
|
---|