VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPR0IdcClientStubs.c@ 19890

Last change on this file since 19890 was 10258, checked in by vboxsync, 16 years ago

Inter-Driver Communication (IDC) interface for the support driver. The client end (SUPR0IdcClient).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: SUPR0IdcClientStubs.c 10258 2008-07-04 23:31:26Z vboxsync $ */
2/** @file
3 * VirtualBox Support Driver - IDC Client Lib, Stubs for SUPR0 APIs.
4 */
5
6/*
7 * Copyright (C) 2008 Sun Microsystems, Inc.
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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31/*******************************************************************************
32* Header Files *
33*******************************************************************************/
34#include "SUPR0IdcClientInternal.h"
35#include <VBox/err.h>
36
37
38/**
39 * Resolves a symbol.
40 *
41 * @returns Pointer to the symbol on success, NULL on failure.
42 *
43 * @param pHandle The IDC handle.
44 * @param pszName The name of the symbol.
45 */
46static void supR0IdcGetSymbol(PSUPDRVIDCHANDLE pHandle, PFNRT *ppfn, const char *pszName)
47{
48 SUPDRVIDCREQGETSYM Req;
49 int rc;
50
51 /*
52 * Create and send a get symbol request.
53 */
54 Req.Hdr.cb = sizeof(Req);
55 Req.Hdr.rc = VERR_WRONG_ORDER;
56 Req.Hdr.pSession = pHandle->s.pSession;
57 Req.u.In.pszSymbol = pszName;
58 Req.u.In.pszModule = NULL;
59 rc = supR0IdcNativeCall(pHandle, SUPDRV_IDC_REQ_GET_SYMBOL, &Req.Hdr);
60 if (RT_SUCCESS(rc))
61 ASMAtomicWritePtr((void * volatile *)ppfn, Req.u.Out.pfnSymbol);
62}
63
64
65/**
66 * Resolves a symbol.
67 *
68 * @returns Pointer to the symbol on success, NULL on failure.
69 *
70 * @param pHandle The IDC handle.
71 * @param pszName The name of the symbol.
72 */
73static void supR0IdcGetSymbolBySession(PSUPDRVSESSION pSession, PFNRT *ppfn, const char *pszName)
74{
75 PSUPDRVIDCHANDLE pHandle = supR0IdcGetHandleFromSession(pSession);
76 if (pHandle)
77 supR0IdcGetSymbol(pHandle, ppfn, pszName);
78}
79
80
81SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2)
82{
83 static DECLCALLBACKPTR(void *, s_pfn)(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2);
84 DECLCALLBACKPTR(void *, pfn)(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2);
85 pfn = s_pfn;
86 if (!pfn)
87 {
88 supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjRegister");
89 pfn = s_pfn;
90 if (!pfn)
91 return NULL;
92 }
93
94 return pfn(pSession, enmType, pfnDestructor, pvUser1, pvUser2);
95}
96
97
98SUPR0DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession)
99{
100 static DECLCALLBACKPTR(int, s_pfn)(void *pvObj, PSUPDRVSESSION pSession);
101 DECLCALLBACKPTR(int, pfn)(void *pvObj, PSUPDRVSESSION pSession);
102 pfn = s_pfn;
103 if (!pfn)
104 {
105 supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjAddRef");
106 pfn = s_pfn;
107 if (!pfn)
108 return VERR_NOT_SUPPORTED;
109 }
110
111 return pfn(pvObj, pSession);
112}
113
114
115SUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession)
116{
117 static DECLCALLBACKPTR(int, s_pfn)(void *pvObj, PSUPDRVSESSION pSession);
118 DECLCALLBACKPTR(int, pfn)(void *pvObj, PSUPDRVSESSION pSession);
119 pfn = s_pfn;
120 if (!pfn)
121 {
122 supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjRelease");
123 pfn = s_pfn;
124 if (!pfn)
125 return VERR_NOT_SUPPORTED;
126 }
127
128 return pfn(pvObj, pSession);
129}
130
131
132SUPR0DECL(int) SUPR0ObjVerifyAccess(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName)
133{
134 static DECLCALLBACKPTR(int, s_pfn)(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName);
135 DECLCALLBACKPTR(int, pfn)(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName);
136 pfn = s_pfn;
137 if (!pfn)
138 {
139 supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjVerifyAccess");
140 pfn = s_pfn;
141 if (!pfn)
142 return VERR_NOT_SUPPORTED;
143 }
144
145 return pfn(pvObj, pSession, pszObjName);
146}
147
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette