VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPDrvIDC.h@ 97655

Last change on this file since 97655 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.8 KB
Line 
1/* $Id: SUPDrvIDC.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * VirtualBox Support Driver - Inter-Driver Communication (IDC) definitions.
4 */
5
6/*
7 * Copyright (C) 2008-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef VBOX_INCLUDED_SRC_Support_SUPDrvIDC_h
38#define VBOX_INCLUDED_SRC_Support_SUPDrvIDC_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <VBox/types.h>
44
45/** @def SUP_IDC_CODE
46 * Creates IDC function code.
47 *
48 * @param Function The function number to encode, 1..255.
49 *
50 * @remarks We can take a slightly more relaxed attitude wrt to size encoding
51 * here since only windows will use standard I/O control function code.
52 *
53 * @{
54 */
55
56#ifdef RT_OS_WINDOWS
57# define SUP_IDC_CODE(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) + 2542, METHOD_BUFFERED, FILE_WRITE_ACCESS)
58#else
59# define SUP_IDC_CODE(Function) ( UINT32_C(0xc0ffee00) | (uint32_t)(0x000000ff & (Function)) )
60#endif
61
62
63#ifdef RT_ARCH_AMD64
64# pragma pack(8) /* paranoia. */
65#else
66# pragma pack(4) /* paranoia. */
67#endif
68
69
70/**
71 * An IDC request packet header.
72 *
73 * The main purpose of this header is to pass the session handle
74 * and status code in a generic manner in order to make things
75 * easier on the receiving end.
76 */
77typedef struct SUPDRVIDCREQHDR
78{
79 /** IN: The size of the request. */
80 uint32_t cb;
81 /** OUT: Status code of the request. */
82 int32_t rc;
83 /** IN: Pointer to the session handle. */
84 PSUPDRVSESSION pSession;
85#if ARCH_BITS == 32
86 /** Padding the structure to 16-bytes. */
87 uint32_t u32Padding;
88#endif
89} SUPDRVIDCREQHDR;
90/** Pointer to an IDC request packet header. */
91typedef SUPDRVIDCREQHDR *PSUPDRVIDCREQHDR;
92/** Pointer to a const IDC request packet header. */
93typedef SUPDRVIDCREQHDR const *PCSUPDRVIDCREQHDR;
94
95
96/**
97 * SUPDRV IDC: Connect request.
98 * This request takes a SUPDRVIDCREQCONNECT packet.
99 */
100#define SUPDRV_IDC_REQ_CONNECT SUP_IDC_CODE(1)
101/** A SUPDRV IDC connect request packet. */
102typedef struct SUPDRVIDCREQCONNECT
103{
104 /** The request header. */
105 SUPDRVIDCREQHDR Hdr;
106 /** The payload union. */
107 union
108 {
109 /** The input. */
110 struct SUPDRVIDCREQCONNECTIN
111 {
112 /** The magic cookie (SUPDRVIDCREQ_CONNECT_MAGIC_COOKIE). */
113 uint32_t u32MagicCookie;
114 /** The desired version of the IDC interface. */
115 uint32_t uReqVersion;
116 /** The minimum version of the IDC interface. */
117 uint32_t uMinVersion;
118 } In;
119
120 /** The output. */
121 struct SUPDRVIDCREQCONNECTOUT
122 {
123 /** The support driver session. (An opaque.) */
124 PSUPDRVSESSION pSession;
125 /** The version of the IDC interface for this session. */
126 uint32_t uSessionVersion;
127 /** The version of the IDC interface . */
128 uint32_t uDriverVersion;
129 /** The SVN revision of the driver.
130 * This will be set to 0 if not compiled into the driver. */
131 uint32_t uDriverRevision;
132 } Out;
133 } u;
134} SUPDRVIDCREQCONNECT;
135/** Pointer to a SUPDRV IDC connect request. */
136typedef SUPDRVIDCREQCONNECT *PSUPDRVIDCREQCONNECT;
137/** Magic cookie value (SUPDRVIDCREQCONNECT::In.u32MagicCookie). ('tori') */
138#define SUPDRVIDCREQ_CONNECT_MAGIC_COOKIE UINT32_C(0x69726f74)
139
140
141/**
142 * SUPDRV IDC: Disconnect request.
143 * This request only requires a SUPDRVIDCREQHDR.
144 */
145#define SUPDRV_IDC_REQ_DISCONNECT SUP_IDC_CODE(2)
146
147
148/**
149 * SUPDRV IDC: Query a symbol address.
150 * This request takes a SUPDRVIDCREQGETSYM packet.
151 */
152#define SUPDRV_IDC_REQ_GET_SYMBOL SUP_IDC_CODE(3)
153/** A SUPDRV IDC get symbol request packet. */
154typedef struct SUPDRVIDCREQGETSYM
155{
156 /** The request header. */
157 SUPDRVIDCREQHDR Hdr;
158 /** The payload union. */
159 union
160 {
161 /** The input. */
162 struct SUPDRVIDCREQGETSYMIN
163 {
164 /** The module name.
165 * NULL is an alias for the support driver. */
166 const char *pszModule;
167 /** The symbol name. */
168 const char *pszSymbol;
169 } In;
170
171 /** The output. */
172 struct SUPDRVIDCREQGETSYMOUT
173 {
174 /** The symbol address. */
175 PFNRT pfnSymbol;
176 } Out;
177 } u;
178} SUPDRVIDCREQGETSYM;
179/** Pointer to a SUPDRV IDC get symbol request. */
180typedef SUPDRVIDCREQGETSYM *PSUPDRVIDCREQGETSYM;
181
182
183/**
184 * SUPDRV IDC: Request the registration of a component factory.
185 * This request takes a SUPDRVIDCREQCOMPREGFACTORY packet.
186 */
187#define SUPDRV_IDC_REQ_COMPONENT_REGISTER_FACTORY SUP_IDC_CODE(10)
188/** A SUPDRV IDC register component factory request packet. */
189typedef struct SUPDRVIDCREQCOMPREGFACTORY
190{
191 /** The request header. */
192 SUPDRVIDCREQHDR Hdr;
193 /** The payload union. */
194 union
195 {
196 /** The input. */
197 struct SUPDRVIDCREQCOMPREGFACTORYIN
198 {
199 /** Pointer to the factory. */
200 PCSUPDRVFACTORY pFactory;
201 } In;
202 } u;
203} SUPDRVIDCREQCOMPREGFACTORY;
204/** Pointer to a SUPDRV IDC register component factory request. */
205typedef SUPDRVIDCREQCOMPREGFACTORY *PSUPDRVIDCREQCOMPREGFACTORY;
206
207
208/**
209 * SUPDRV IDC: Deregister a component factory.
210 * This request takes a SUPDRVIDCREQCOMPDEREGFACTORY packet.
211 */
212#define SUPDRV_IDC_REQ_COMPONENT_DEREGISTER_FACTORY SUP_IDC_CODE(11)
213/** A SUPDRV IDC deregister component factory request packet. */
214typedef struct SUPDRVIDCREQCOMPDEREGFACTORY
215{
216 /** The request header. */
217 SUPDRVIDCREQHDR Hdr;
218 /** The payload union. */
219 union
220 {
221 /** The input. */
222 struct SUPDRVIDCREQCOMPDEREGFACTORYIN
223 {
224 /** Pointer to the factory. */
225 PCSUPDRVFACTORY pFactory;
226 } In;
227 } u;
228} SUPDRVIDCREQCOMPDEREGFACTORY;
229/** Pointer to a SUPDRV IDC deregister component factory request. */
230typedef SUPDRVIDCREQCOMPDEREGFACTORY *PSUPDRVIDCREQCOMPDEREGFACTORY;
231
232
233/*
234 * The OS specific prototypes.
235 * Most OSes uses
236 */
237RT_C_DECLS_BEGIN
238
239#if defined(RT_OS_DARWIN)
240# ifdef IN_SUP_R0
241extern DECLEXPORT(int) VBOXCALL SUPDrvDarwinIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
242# else
243extern DECLIMPORT(int) VBOXCALL SUPDrvDarwinIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
244# endif
245
246#elif defined(RT_OS_FREEBSD)
247extern int VBOXCALL SUPDrvFreeBSDIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
248
249#elif defined(RT_OS_LINUX)
250extern int VBOXCALL SUPDrvLinuxIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
251
252#elif defined(RT_OS_OS2)
253/** @todo Port to OS/2. */
254
255#elif defined(RT_OS_SOLARIS)
256extern int VBOXCALL SUPDrvSolarisIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
257
258#elif defined(RT_OS_WINDOWS)
259/* Nothing special for windows. */
260
261#else
262/* PORTME: OS specific IDC stuff goes here. */
263#endif
264
265RT_C_DECLS_END
266
267/**
268 * The SUPDRV IDC entry point.
269 *
270 * @returns VBox status code indicating the validity of the session, request and
271 * the return data packet. The status of the request it self is found
272 * in the packet (specific to each request).
273 *
274 * @param pSession The session. (This is NULL for SUPDRV_IDC_REQ_CONNECT.)
275 * @param uReq The request number.
276 * @param pvReq Pointer to the request packet. Optional for some requests.
277 * @param cbReq The size of the request packet.
278 */
279/** @todo move this and change to function proto */
280typedef DECLCALLBACKTYPE(int, FNSUPDRVIDCENTRY,(PSUPDRVSESSION pSession, uint32_t uReq, void *pvReq, uint32_t cbReq));
281
282/** @} */
283
284
285#pragma pack() /* paranoia */
286
287#endif /* !VBOX_INCLUDED_SRC_Support_SUPDrvIDC_h */
288
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