1 | /*
|
---|
2 | * Copyright (C) 2010 Sun Microsystems, Inc.
|
---|
3 | *
|
---|
4 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
5 | * available from http://www.virtualbox.org. This file is free software;
|
---|
6 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
7 | * General Public License (GPL) as published by the Free Software
|
---|
8 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
9 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
10 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
11 | *
|
---|
12 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
13 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
14 | * additional information or have any questions.
|
---|
15 | */
|
---|
16 | #include "SHGSMIHost.h"
|
---|
17 | #include <VBox/VBoxVideo.h>
|
---|
18 |
|
---|
19 | /*
|
---|
20 | * VBOXSHGSMI made on top HGSMI and allows receiving notifications
|
---|
21 | * about G->H command completion
|
---|
22 | */
|
---|
23 | static bool vboxSHGSMICommandCanCompleteSynch (PVBOXSHGSMIHEADER pHdr)
|
---|
24 | {
|
---|
25 | return !(pHdr->fFlags & VBOXSHGSMI_FLAG_GH_ASYNCH_FORCE);
|
---|
26 | }
|
---|
27 |
|
---|
28 | static int vboxSHGSMICommandCompleteAsynch (PHGSMIINSTANCE pIns, PVBOXSHGSMIHEADER pHdr)
|
---|
29 | {
|
---|
30 | bool bDoIrq = !!(pHdr->fFlags & VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ)
|
---|
31 | || !!(pHdr->fFlags & VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ_FORCE);
|
---|
32 | return HGSMICompleteGuestCommand(pIns, pHdr, bDoIrq);
|
---|
33 | }
|
---|
34 |
|
---|
35 | void VBoxSHGSMICommandMarkAsynchCompletion (void *pvData)
|
---|
36 | {
|
---|
37 | PVBOXSHGSMIHEADER pHdr = VBoxSHGSMIBufferHeader (pvData);
|
---|
38 | Assert(!(pHdr->fFlags & VBOXSHGSMI_FLAG_HG_ASYNCH));
|
---|
39 | pHdr->fFlags |= VBOXSHGSMI_FLAG_HG_ASYNCH;
|
---|
40 | }
|
---|
41 |
|
---|
42 | int VBoxSHGSMICommandCompleteAsynch (PHGSMIINSTANCE pIns, void *pvData)
|
---|
43 | {
|
---|
44 | PVBOXSHGSMIHEADER pHdr = VBoxSHGSMIBufferHeader (pvData);
|
---|
45 | Assert(!!(pHdr->fFlags & VBOXSHGSMI_FLAG_HG_ASYNCH));
|
---|
46 | return vboxSHGSMICommandCompleteAsynch (pIns, pHdr);
|
---|
47 | }
|
---|
48 |
|
---|
49 | int VBoxSHGSMICommandCompleteSynch (PHGSMIINSTANCE pIns, void *pvData)
|
---|
50 | {
|
---|
51 | PVBOXSHGSMIHEADER pHdr = VBoxSHGSMIBufferHeader (pvData);
|
---|
52 | Assert(!(pHdr->fFlags & VBOXSHGSMI_FLAG_HG_ASYNCH));
|
---|
53 | if (vboxSHGSMICommandCanCompleteSynch(pHdr))
|
---|
54 | return VINF_SUCCESS;
|
---|
55 | pHdr->fFlags |= VBOXSHGSMI_FLAG_HG_ASYNCH;
|
---|
56 | return vboxSHGSMICommandCompleteAsynch(pIns, pHdr);
|
---|
57 | }
|
---|