1 | /* $Id: SHGSMIHost.cpp 55401 2015-04-23 10:03:17Z vboxsync $ */
|
---|
2 | /*
|
---|
3 | * Copyright (C) 2010 Oracle Corporation
|
---|
4 | *
|
---|
5 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
6 | * available from http://www.virtualbox.org. This file is free software;
|
---|
7 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
8 | * General Public License (GPL) as published by the Free Software
|
---|
9 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
10 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
11 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
12 | */
|
---|
13 | #include "SHGSMIHost.h"
|
---|
14 | #include <VBox/VBoxVideo.h>
|
---|
15 |
|
---|
16 | /*
|
---|
17 | * VBOXSHGSMI made on top HGSMI and allows receiving notifications
|
---|
18 | * about G->H command completion
|
---|
19 | */
|
---|
20 | static bool vboxSHGSMICommandCanCompleteSynch (PVBOXSHGSMIHEADER pHdr)
|
---|
21 | {
|
---|
22 | return !(pHdr->fFlags & VBOXSHGSMI_FLAG_GH_ASYNCH_FORCE);
|
---|
23 | }
|
---|
24 |
|
---|
25 | static int vboxSHGSMICommandCompleteAsynch (PHGSMIINSTANCE pIns, PVBOXSHGSMIHEADER pHdr)
|
---|
26 | {
|
---|
27 | bool bDoIrq = !!(pHdr->fFlags & VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ)
|
---|
28 | || !!(pHdr->fFlags & VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ_FORCE);
|
---|
29 | return HGSMICompleteGuestCommand(pIns, pHdr, bDoIrq);
|
---|
30 | }
|
---|
31 |
|
---|
32 | void VBoxSHGSMICommandMarkAsynchCompletion (void *pvData)
|
---|
33 | {
|
---|
34 | PVBOXSHGSMIHEADER pHdr = VBoxSHGSMIBufferHeader (pvData);
|
---|
35 | Assert(!(pHdr->fFlags & VBOXSHGSMI_FLAG_HG_ASYNCH));
|
---|
36 | pHdr->fFlags |= VBOXSHGSMI_FLAG_HG_ASYNCH;
|
---|
37 | }
|
---|
38 |
|
---|
39 | int VBoxSHGSMICommandComplete (PHGSMIINSTANCE pIns, void *pvData)
|
---|
40 | {
|
---|
41 | PVBOXSHGSMIHEADER pHdr = VBoxSHGSMIBufferHeader (pvData);
|
---|
42 | if (!(pHdr->fFlags & VBOXSHGSMI_FLAG_HG_ASYNCH) /* <- check if synchronous completion */
|
---|
43 | && vboxSHGSMICommandCanCompleteSynch(pHdr)) /* <- check if can complete synchronously */
|
---|
44 | return VINF_SUCCESS;
|
---|
45 | pHdr->fFlags |= VBOXSHGSMI_FLAG_HG_ASYNCH;
|
---|
46 | return vboxSHGSMICommandCompleteAsynch(pIns, pHdr);
|
---|
47 | }
|
---|