1 | /* $Rev: 21069 $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuest - Inter Driver Communcation, unix implementation.
|
---|
4 | *
|
---|
5 | * This file is included by the platform specific source file.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2009 Sun Microsystems, Inc.
|
---|
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 | *
|
---|
19 | * The contents of this file may alternatively be used under the terms
|
---|
20 | * of the Common Development and Distribution License Version 1.0
|
---|
21 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
22 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
23 | * CDDL are applicable instead of those of the GPL.
|
---|
24 | *
|
---|
25 | * You may elect to license modified versions of this file under the
|
---|
26 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
27 | *
|
---|
28 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
29 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
30 | * additional information or have any questions.
|
---|
31 | * Some lines of code to disable the local APIC on x86_64 machines taken
|
---|
32 | * from a Mandriva patch by Gwenole Beauchesne <[email protected]>.
|
---|
33 | */
|
---|
34 |
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Open a new IDC connection.
|
---|
38 | *
|
---|
39 | * @returns Opaque pointer to session object.
|
---|
40 | * @param pu32Version Where to store VMMDev version.
|
---|
41 | */
|
---|
42 | DECLVBGL(void *) VBoxGuestIDCOpen(uint32_t *pu32Version)
|
---|
43 | {
|
---|
44 | PVBOXGUESTSESSION pSession;
|
---|
45 | int rc;
|
---|
46 | LogFlow(("VBoxGuestIDCOpen: Version=%#x\n", pu32Version ? *pu32Version : 0));
|
---|
47 |
|
---|
48 | AssertPtrReturn(pu32Version, NULL);
|
---|
49 | rc = VBoxGuestCreateKernelSession(&g_DevExt, &pSession);
|
---|
50 | if (RT_SUCCESS(rc))
|
---|
51 | {
|
---|
52 | *pu32Version = VMMDEV_VERSION;
|
---|
53 | return pSession;
|
---|
54 | }
|
---|
55 | LogRel(("VBoxGuestIDCOpen: VBoxGuestCreateKernelSession failed. rc=%d\n", rc));
|
---|
56 | return NULL;
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Close an IDC connection.
|
---|
62 | *
|
---|
63 | * @returns VBox error code.
|
---|
64 | * @param pvState Opaque pointer to the session object.
|
---|
65 | */
|
---|
66 | DECLVBGL(int) VBoxGuestIDCClose(void *pvSession)
|
---|
67 | {
|
---|
68 | PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
|
---|
69 | LogFlow(("VBoxGuestIDCClose:\n"));
|
---|
70 |
|
---|
71 | AssertPtrReturn(pSession, VERR_INVALID_POINTER);
|
---|
72 | VBoxGuestCloseSession(&g_DevExt, pSession);
|
---|
73 | return VINF_SUCCESS;
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Perform an IDC call.
|
---|
79 | *
|
---|
80 | * @returns VBox error code.
|
---|
81 | * @param pvSession Opaque pointer to the session.
|
---|
82 | * @param iCmd Requested function.
|
---|
83 | * @param pvData IO data buffer.
|
---|
84 | * @param cbData Size of the data buffer.
|
---|
85 | * @param pcbDataReturned Where to store the amount of returned data.
|
---|
86 | */
|
---|
87 | DECLVBGL(int) VBoxGuestIDCCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned)
|
---|
88 | {
|
---|
89 | PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
|
---|
90 | LogFlow(("VBoxGuestIDCCall: %pvSesssion=%p Cmd=%u pvData=%p cbData=%d\n", pvSession, iCmd, pvData, cbData));
|
---|
91 |
|
---|
92 | AssertPtrReturn(pSession, VERR_INVALID_POINTER);
|
---|
93 | AssertMsgReturn(pSession->pDevExt == &g_DevExt,
|
---|
94 | ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE);
|
---|
95 |
|
---|
96 | return VBoxGuestCommonIOCtl(iCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned);
|
---|
97 | }
|
---|
98 |
|
---|
99 |
|
---|