1 | /* $Rev: 33595 $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuest - Inter Driver Communication, unix implementation.
|
---|
4 | *
|
---|
5 | * This file is included by the platform specific source file.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2009 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | * Some lines of code to disable the local APIC on x86_64 machines taken
|
---|
19 | * from a Mandriva patch by Gwenole Beauchesne <[email protected]>.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | /** @todo Use some header that we have in common with VBoxGuestLib.h... */
|
---|
24 | DECLVBGL(void *) VBoxGuestIDCOpen(uint32_t *pu32Version);
|
---|
25 | DECLVBGL(int) VBoxGuestIDCClose(void *pvSession);
|
---|
26 | DECLVBGL(int) VBoxGuestIDCCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned);
|
---|
27 |
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Open a new IDC connection.
|
---|
31 | *
|
---|
32 | * @returns Opaque pointer to session object.
|
---|
33 | * @param pu32Version Where to store VMMDev version.
|
---|
34 | */
|
---|
35 | DECLVBGL(void *) VBoxGuestIDCOpen(uint32_t *pu32Version)
|
---|
36 | {
|
---|
37 | PVBOXGUESTSESSION pSession;
|
---|
38 | int rc;
|
---|
39 | LogFlow(("VBoxGuestIDCOpen: Version=%#x\n", pu32Version ? *pu32Version : 0));
|
---|
40 |
|
---|
41 | AssertPtrReturn(pu32Version, NULL);
|
---|
42 | rc = VBoxGuestCreateKernelSession(&g_DevExt, &pSession);
|
---|
43 | if (RT_SUCCESS(rc))
|
---|
44 | {
|
---|
45 | *pu32Version = VMMDEV_VERSION;
|
---|
46 | return pSession;
|
---|
47 | }
|
---|
48 | LogRel(("VBoxGuestIDCOpen: VBoxGuestCreateKernelSession failed. rc=%d\n", rc));
|
---|
49 | return NULL;
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Close an IDC connection.
|
---|
55 | *
|
---|
56 | * @returns VBox error code.
|
---|
57 | * @param pvState Opaque pointer to the session object.
|
---|
58 | */
|
---|
59 | DECLVBGL(int) VBoxGuestIDCClose(void *pvSession)
|
---|
60 | {
|
---|
61 | PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
|
---|
62 | LogFlow(("VBoxGuestIDCClose:\n"));
|
---|
63 |
|
---|
64 | AssertPtrReturn(pSession, VERR_INVALID_POINTER);
|
---|
65 | VBoxGuestCloseSession(&g_DevExt, pSession);
|
---|
66 | return VINF_SUCCESS;
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Perform an IDC call.
|
---|
72 | *
|
---|
73 | * @returns VBox error code.
|
---|
74 | * @param pvSession Opaque pointer to the session.
|
---|
75 | * @param iCmd Requested function.
|
---|
76 | * @param pvData IO data buffer.
|
---|
77 | * @param cbData Size of the data buffer.
|
---|
78 | * @param pcbDataReturned Where to store the amount of returned data.
|
---|
79 | */
|
---|
80 | DECLVBGL(int) VBoxGuestIDCCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned)
|
---|
81 | {
|
---|
82 | PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
|
---|
83 | LogFlow(("VBoxGuestIDCCall: %pvSession=%p Cmd=%u pvData=%p cbData=%d\n", pvSession, iCmd, pvData, cbData));
|
---|
84 |
|
---|
85 | AssertPtrReturn(pSession, VERR_INVALID_POINTER);
|
---|
86 | AssertMsgReturn(pSession->pDevExt == &g_DevExt,
|
---|
87 | ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE);
|
---|
88 |
|
---|
89 | return VBoxGuestCommonIOCtl(iCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned);
|
---|
90 | }
|
---|
91 |
|
---|