VirtualBox

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

Last change on this file since 28800 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • 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 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * VirtualBox Support Driver - IDC Client Lib, Stubs for SUPR0 APIs.
4 */
5
6/*
7 * Copyright (C) 2008 Oracle Corporation
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
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#include "SUPR0IdcClientInternal.h"
31#include <VBox/err.h>
32
33
34/**
35 * Resolves a symbol.
36 *
37 * @returns Pointer to the symbol on success, NULL on failure.
38 *
39 * @param pHandle The IDC handle.
40 * @param pszName The name of the symbol.
41 */
42static void supR0IdcGetSymbol(PSUPDRVIDCHANDLE pHandle, PFNRT *ppfn, const char *pszName)
43{
44 SUPDRVIDCREQGETSYM Req;
45 int rc;
46
47 /*
48 * Create and send a get symbol request.
49 */
50 Req.Hdr.cb = sizeof(Req);
51 Req.Hdr.rc = VERR_WRONG_ORDER;
52 Req.Hdr.pSession = pHandle->s.pSession;
53 Req.u.In.pszSymbol = pszName;
54 Req.u.In.pszModule = NULL;
55 rc = supR0IdcNativeCall(pHandle, SUPDRV_IDC_REQ_GET_SYMBOL, &Req.Hdr);
56 if (RT_SUCCESS(rc))
57 ASMAtomicWritePtr((void * volatile *)ppfn, Req.u.Out.pfnSymbol);
58}
59
60
61/**
62 * Resolves a symbol.
63 *
64 * @returns Pointer to the symbol on success, NULL on failure.
65 *
66 * @param pHandle The IDC handle.
67 * @param pszName The name of the symbol.
68 */
69static void supR0IdcGetSymbolBySession(PSUPDRVSESSION pSession, PFNRT *ppfn, const char *pszName)
70{
71 PSUPDRVIDCHANDLE pHandle = supR0IdcGetHandleFromSession(pSession);
72 if (pHandle)
73 supR0IdcGetSymbol(pHandle, ppfn, pszName);
74}
75
76
77SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2)
78{
79 static DECLCALLBACKPTR(void *, s_pfn)(PSUPDRVSESSION /* pSession */, SUPDRVOBJTYPE /* enmType */, PFNSUPDRVDESTRUCTOR /* pfnDestructor */, void * /* pvUser1 */, void * /* pvUser2 */);
80 DECLCALLBACKPTR(void *, pfn)(PSUPDRVSESSION /* pSession */, SUPDRVOBJTYPE /* enmType */, PFNSUPDRVDESTRUCTOR /* pfnDestructor */, void * /* pvUser1 */, void * /* pvUser2 */);
81 pfn = s_pfn;
82 if (!pfn)
83 {
84 supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjRegister");
85 pfn = s_pfn;
86 if (!pfn)
87 return NULL;
88 }
89
90 return pfn(pSession, enmType, pfnDestructor, pvUser1, pvUser2);
91}
92
93
94SUPR0DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession)
95{
96 static DECLCALLBACKPTR(int, s_pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */);
97 DECLCALLBACKPTR(int, pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */);
98 pfn = s_pfn;
99 if (!pfn)
100 {
101 supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjAddRef");
102 pfn = s_pfn;
103 if (!pfn)
104 return VERR_NOT_SUPPORTED;
105 }
106
107 return pfn(pvObj, pSession);
108}
109
110
111SUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession)
112{
113 static DECLCALLBACKPTR(int, s_pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */);
114 DECLCALLBACKPTR(int, pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */);
115 pfn = s_pfn;
116 if (!pfn)
117 {
118 supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjRelease");
119 pfn = s_pfn;
120 if (!pfn)
121 return VERR_NOT_SUPPORTED;
122 }
123
124 return pfn(pvObj, pSession);
125}
126
127
128SUPR0DECL(int) SUPR0ObjVerifyAccess(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName)
129{
130 static DECLCALLBACKPTR(int, s_pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */, const char * /* pszObjName */);
131 DECLCALLBACKPTR(int, pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */, const char * /* pszObjName */);
132 pfn = s_pfn;
133 if (!pfn)
134 {
135 supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjVerifyAccess");
136 pfn = s_pfn;
137 if (!pfn)
138 return VERR_NOT_SUPPORTED;
139 }
140
141 return pfn(pvObj, pSession, pszObjName);
142}
143
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