1 | /* $Id: solaris.h 41212 2012-05-08 15:55:06Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuest - Guest Additions Driver for Solaris - testcase stubs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011 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 ddi_info_cmd_tcomes 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 |
|
---|
18 | #ifndef ___VBoxGuestTestCaseSolaris_h
|
---|
19 | #define ___VBoxGuestTestCaseSolaris_h
|
---|
20 |
|
---|
21 | #include <iprt/assert.h>
|
---|
22 | #include <iprt/string.h> /* RT_ZERO */
|
---|
23 | #ifdef RT_OS_WINDOWS
|
---|
24 | # include <WinSock2.h> /* struct timeval */
|
---|
25 | #endif
|
---|
26 | #include <errno.h>
|
---|
27 | #include <time.h> /* struct timeval */
|
---|
28 |
|
---|
29 | /* Overrides */
|
---|
30 | #define dev_t unsigned
|
---|
31 |
|
---|
32 | /* Constants */
|
---|
33 | #define DDI_FAILURE (-1)
|
---|
34 | #define DDI_SUCCESS (0)
|
---|
35 |
|
---|
36 | #define MODMAXNAMELEN 32
|
---|
37 | #define MODMAXLINKINFOLEN 32
|
---|
38 | #define MODMAXLINK 10
|
---|
39 |
|
---|
40 | #define MOD_NOAUTOUNLOAD 0x1
|
---|
41 |
|
---|
42 | #define M_DATA 0x00
|
---|
43 | #define M_BREAK 0x08
|
---|
44 | #define M_PASSFP 0x09
|
---|
45 | #define M_EVENT 0x0a
|
---|
46 | #define M_SIG 0x0b
|
---|
47 | #define M_DELAY 0x0c
|
---|
48 | #define M_CTL 0x0d
|
---|
49 | #define M_IOCTL 0x0e
|
---|
50 | #define M_SETOPTS 0x10
|
---|
51 | #define M_RSE 0x11
|
---|
52 |
|
---|
53 | #define M_IOCACK 0x81
|
---|
54 | #define M_IOCNAK 0x82
|
---|
55 | #define M_PCPROTO 0x83
|
---|
56 | #define M_PCSIG 0x84
|
---|
57 | #define M_READ 0x85
|
---|
58 | #define M_FLUSH 0x86
|
---|
59 | #define M_STOP 0x87
|
---|
60 | #define M_START 0x88
|
---|
61 | #define M_HANGUP 0x89
|
---|
62 | #define M_ERROR 0x8a
|
---|
63 | #define M_COPYIN 0x8b
|
---|
64 | #define M_COPYOUT 0x8c
|
---|
65 | #define M_IOCDATA 0x8d
|
---|
66 | #define M_PCRSE 0x8e
|
---|
67 | #define M_STOPI 0x8f
|
---|
68 | #define M_STARTI 0x90
|
---|
69 | #define M_PCEVENT 0x91
|
---|
70 | #define M_UNHANGUP 0x92
|
---|
71 | #define M_CMD 0x93
|
---|
72 |
|
---|
73 | #define BPRI_LO 1
|
---|
74 | #define BPRI_MED 2
|
---|
75 | #define BPRI_HI 3
|
---|
76 |
|
---|
77 | #define FLUSHALL 1
|
---|
78 | #define FLUSHDATA 0
|
---|
79 |
|
---|
80 | #define TRANSPARENT (unsigned int)(-1)
|
---|
81 |
|
---|
82 | #define FLUSHR 0x01
|
---|
83 | #define FLUSHW 0x02
|
---|
84 |
|
---|
85 | #define MSIOC ('m'<<8)
|
---|
86 | #define MSIOGETPARMS (MSIOC|1)
|
---|
87 | #define MSIOSETPARMS (MSIOC|2)
|
---|
88 | #define MSIOBUTTONS (MSIOC|3)
|
---|
89 | #define MSIOSRESOLUTION (MSIOC|4)
|
---|
90 |
|
---|
91 | #define VUIOC ('v'<<8)
|
---|
92 | #define VUIDSFORMAT (VUIOC|1)
|
---|
93 | #define VUIDGFORMAT (VUIOC|2)
|
---|
94 | #define VUID_NATIVE 0
|
---|
95 | #define VUID_FIRM_EVENT 1
|
---|
96 |
|
---|
97 | #define VUIDSADDR (VUIOC|3)
|
---|
98 | #define VUIDGADDR (VUIOC|4)
|
---|
99 |
|
---|
100 | #define VUID_WHEEL_MAX_COUNT 256
|
---|
101 | #define VUIDGWHEELCOUNT (VUIOC|15)
|
---|
102 | #define VUIDGWHEELINFO (VUIOC|16)
|
---|
103 | #define VUIDGWHEELSTATE (VUIOC|17)
|
---|
104 | #define VUIDSWHEELSTATE (VUIOC|18)
|
---|
105 |
|
---|
106 | #define DDI_DEVICE_ATTR_V0 0x0001
|
---|
107 | #define DDI_DEVICE_ATTR_V1 0x0002
|
---|
108 |
|
---|
109 | #define DDI_NEVERSWAP_ACC 0x00
|
---|
110 | #define DDI_STRUCTURE_LE_ACC 0x01
|
---|
111 | #define DDI_STRUCTURE_BE_ACC 0x02
|
---|
112 |
|
---|
113 | #define DDI_STRICTORDER_ACC 0x00
|
---|
114 | #define DDI_UNORDERED_OK_ACC 0x01
|
---|
115 | #define DDI_MERGING_OK_ACC 0x02
|
---|
116 | #define DDI_LOADCACHING_OK_ACC 0x03
|
---|
117 | #define DDI_STORECACHING_OK_ACC 0x04
|
---|
118 |
|
---|
119 | /** @todo fix this */
|
---|
120 | #define DDI_DEFAULT_ACC DDI_STRICTORDER_ACC
|
---|
121 |
|
---|
122 | #define DDI_INTR_CLAIMED 1
|
---|
123 | #define DDI_INTR_UNCLAIMED 0
|
---|
124 |
|
---|
125 | #define DDI_INTR_TYPE_FIXED 0x1
|
---|
126 | #define DDI_INTR_TYPE_MSI 0x2
|
---|
127 | #define DDI_INTR_TYPE_MSIX 0x4
|
---|
128 |
|
---|
129 | #define LOC_FIRST_DELTA 32640
|
---|
130 | #define LOC_X_DELTA 32640
|
---|
131 | #define LOC_Y_DELTA 32641
|
---|
132 | #define LOC_LAST_DELTA 32641
|
---|
133 | #define LOC_FIRST_ABSOLUTE 32642
|
---|
134 | #define LOC_X_ABSOLUTE 32642
|
---|
135 | #define LOC_Y_ABSOLUTE 32643
|
---|
136 | #define LOC_LAST_ABSOLUTE 32643
|
---|
137 |
|
---|
138 | #define FE_PAIR_NONE 0
|
---|
139 | #define FE_PAIR_SET 1
|
---|
140 | #define FE_PAIR_DELTA 2
|
---|
141 | #define FE_PAIR_ABSOLUTE 3
|
---|
142 |
|
---|
143 | typedef struct __ldi_handle *ldi_handle_t;
|
---|
144 |
|
---|
145 | typedef enum
|
---|
146 | {
|
---|
147 | DDI_INFO_DEVT2DEVINFO = 0,
|
---|
148 | DDI_INFO_DEVT2INSTANCE = 1
|
---|
149 | } ddi_info_cmd_t;
|
---|
150 |
|
---|
151 | typedef enum
|
---|
152 | {
|
---|
153 | DDI_ATTACH = 0,
|
---|
154 | DDI_RESUME = 1,
|
---|
155 | DDI_PM_RESUME = 2
|
---|
156 | } ddi_attach_cmd_t;
|
---|
157 |
|
---|
158 | typedef enum
|
---|
159 | {
|
---|
160 | DDI_DETACH = 0,
|
---|
161 | DDI_SUSPEND = 1,
|
---|
162 | DDI_PM_SUSPEND = 2,
|
---|
163 | DDI_HOTPLUG_DETACH = 3
|
---|
164 | } ddi_detach_cmd_t;
|
---|
165 |
|
---|
166 | /* Simple types */
|
---|
167 |
|
---|
168 | typedef struct cred *cred_t;
|
---|
169 | typedef struct dev_info *dev_info_t;
|
---|
170 | typedef struct __ddi_acc_handle * ddi_acc_handle_t;
|
---|
171 | typedef struct __ddi_intr_handle *ddi_intr_handle_t;
|
---|
172 | typedef struct mutex *kmutex_t;
|
---|
173 | typedef unsigned int uint_t;
|
---|
174 | typedef unsigned short ushort_t;
|
---|
175 | typedef unsigned char uchar_t;
|
---|
176 |
|
---|
177 | /* Structures */
|
---|
178 |
|
---|
179 | struct modspecific_info {
|
---|
180 | char msi_linkinfo[MODMAXLINKINFOLEN];
|
---|
181 | int msi_p0;
|
---|
182 | };
|
---|
183 |
|
---|
184 | struct modinfo {
|
---|
185 | int mi_info;
|
---|
186 | int mi_state;
|
---|
187 | int mi_id;
|
---|
188 | int mi_nextid;
|
---|
189 | char *mi_base; /* Was caddr_t. */
|
---|
190 | size_t mi_size;
|
---|
191 | int mi_rev;
|
---|
192 | int mi_loadcnt;
|
---|
193 | char mi_name[MODMAXNAMELEN];
|
---|
194 | struct modspecific_info mi_msinfo[MODMAXLINK];
|
---|
195 | };
|
---|
196 |
|
---|
197 | typedef struct queue
|
---|
198 | {
|
---|
199 | struct qinit *q_qinfo;
|
---|
200 | struct msgb *q_first;
|
---|
201 | struct msgb *q_last;
|
---|
202 | struct queue *q_next;
|
---|
203 | void *q_ptr;
|
---|
204 | size_t q_count;
|
---|
205 | uint_t q_flag;
|
---|
206 | ssize_t q_minpsz;
|
---|
207 | ssize_t q_maxpsz;
|
---|
208 | size_t q_hiwat;
|
---|
209 | size_t q_lowat;
|
---|
210 | } queue_t;
|
---|
211 |
|
---|
212 | typedef struct msgb
|
---|
213 | {
|
---|
214 | struct msgb *b_next;
|
---|
215 | struct msgb *b_prev;
|
---|
216 | struct msgb *b_cont;
|
---|
217 | unsigned char *b_rptr;
|
---|
218 | unsigned char *b_wptr;
|
---|
219 | struct datab *b_datap;
|
---|
220 | unsigned char b_band;
|
---|
221 | unsigned short b_flag;
|
---|
222 | } mblk_t;
|
---|
223 |
|
---|
224 | typedef struct datab
|
---|
225 | {
|
---|
226 | unsigned char *db_base;
|
---|
227 | unsigned char *db_lim;
|
---|
228 | unsigned char db_ref;
|
---|
229 | unsigned char db_type;
|
---|
230 | } dblk_t;
|
---|
231 |
|
---|
232 | struct iocblk
|
---|
233 | {
|
---|
234 | int ioc_cmd;
|
---|
235 | cred_t *ioc_cr;
|
---|
236 | uint_t ioc_id;
|
---|
237 | uint_t ioc_flag;
|
---|
238 | size_t ioc_count;
|
---|
239 | int ioc_rval;
|
---|
240 | int ioc_error;
|
---|
241 | #if defined(RT_ARCH_AMD64) /* Actually this should be LP64. */
|
---|
242 | int dummy; /* For simplicity, to ensure the structure size matches
|
---|
243 | struct copyreq. */
|
---|
244 | #endif
|
---|
245 | };
|
---|
246 |
|
---|
247 | struct copyreq
|
---|
248 | {
|
---|
249 | int cq_cmd;
|
---|
250 | cred_t *cq_cr;
|
---|
251 | uint_t cq_id;
|
---|
252 | uint_t cq_flag;
|
---|
253 | mblk_t *cq_private;
|
---|
254 | char *cq_addr; /* Was caddr_t. */
|
---|
255 | size_t cq_size;
|
---|
256 | };
|
---|
257 |
|
---|
258 | struct copyresp
|
---|
259 | {
|
---|
260 | int cp_cmd;
|
---|
261 | cred_t *cp_cr;
|
---|
262 | uint_t cp_id;
|
---|
263 | uint_t cp_flag;
|
---|
264 | mblk_t *cp_private;
|
---|
265 | char *cp_rval; /* Was caddr_t. */
|
---|
266 | };
|
---|
267 |
|
---|
268 | typedef struct modctl
|
---|
269 | {
|
---|
270 | /* ... */
|
---|
271 | char mod_loadflags;
|
---|
272 | /* ... */
|
---|
273 | } modctl_t;
|
---|
274 |
|
---|
275 | typedef struct {
|
---|
276 | int jitter_thresh;
|
---|
277 | int speed_law;
|
---|
278 | int speed_limit;
|
---|
279 | } Ms_parms;
|
---|
280 |
|
---|
281 | typedef struct {
|
---|
282 | int height;
|
---|
283 | int width;
|
---|
284 | } Ms_screen_resolution;
|
---|
285 |
|
---|
286 | typedef struct vuid_addr_probe {
|
---|
287 | short base;
|
---|
288 | union
|
---|
289 | {
|
---|
290 | short next;
|
---|
291 | short current;
|
---|
292 | } data;
|
---|
293 | } Vuid_addr_probe;
|
---|
294 |
|
---|
295 | typedef struct ddi_device_acc_attr
|
---|
296 | {
|
---|
297 | ushort_t devacc_attr_version;
|
---|
298 | uchar_t devacc_attr_endian_flags;
|
---|
299 | uchar_t devacc_attr_dataorder;
|
---|
300 | uchar_t devacc_attr_access;
|
---|
301 | } ddi_device_acc_attr_t;
|
---|
302 |
|
---|
303 | typedef struct firm_event
|
---|
304 | {
|
---|
305 | ushort_t id;
|
---|
306 | uchar_t pair_type;
|
---|
307 | uchar_t pair;
|
---|
308 | int value;
|
---|
309 | struct timeval time;
|
---|
310 | } Firm_event;
|
---|
311 |
|
---|
312 | /* Prototypes */
|
---|
313 |
|
---|
314 | #define _init vboxguestSolarisInit
|
---|
315 | extern int vboxguestSolarisInit(void);
|
---|
316 | #define _fini vboxguestSolarisFini
|
---|
317 | extern int vboxguestSolarisFini(void);
|
---|
318 | #define _info vboxguestSolarisInfo
|
---|
319 | extern int vboxguestSolarisInfo(struct modinfo *pModInfo);
|
---|
320 |
|
---|
321 | /* Simple API stubs */
|
---|
322 |
|
---|
323 | #define cmn_err(...) do {} while(0)
|
---|
324 | #define mod_remove(...) 0
|
---|
325 | #define mod_info(...) 0
|
---|
326 | #define RTR0Init(...) VINF_SUCCESS
|
---|
327 | #define RTR0Term(...) do {} while(0)
|
---|
328 | #define RTLogCreate(...) VINF_SUCCESS
|
---|
329 | #define RTLogRelSetDefaultInstance(...) do {} while(0)
|
---|
330 | #define RTLogDestroy(...) do {} while(0)
|
---|
331 | #define VBoxGuestCreateKernelSession(...) VINF_SUCCESS
|
---|
332 | #define VBoxGuestCreateUserSession(...) VINF_SUCCESS
|
---|
333 | #define VBoxGuestCloseSession(...) do {} while(0)
|
---|
334 | #define VBoxGuestInitDevExt(...) VINF_SUCCESS
|
---|
335 | #define VBoxGuestDeleteDevExt(...) do {} while(0)
|
---|
336 | #define VBoxGuestCommonIOCtl(...) VINF_SUCCESS
|
---|
337 | #define VBoxGuestCommonISR(...) true
|
---|
338 | #define VbglGRAlloc(...) VINF_SUCCESS
|
---|
339 | #define VbglGRPerform(...) VINF_SUCCESS
|
---|
340 | #define VbglGRFree(...) do {} while(0)
|
---|
341 | #define qprocson(...) do {} while(0)
|
---|
342 | #define qprocsoff(...) do {} while(0)
|
---|
343 | #define flushq(...) do {} while(0)
|
---|
344 | #define putnext(...) do {} while(0)
|
---|
345 | #define ddi_get_instance(...) 0
|
---|
346 | #define pci_config_setup(...) DDI_SUCCESS
|
---|
347 | #define pci_config_teardown(...) do {} while(0)
|
---|
348 | #define ddi_regs_map_setup(...) DDI_SUCCESS
|
---|
349 | #define ddi_regs_map_free(...) do {} while(0)
|
---|
350 | #define ddi_dev_regsize(...) DDI_SUCCESS
|
---|
351 | #define ddi_create_minor_node(...) DDI_SUCCESS
|
---|
352 | #define ddi_remove_minor_node(...) do {} while(0)
|
---|
353 | #define ddi_intr_get_supported_types(...) DDI_SUCCESS
|
---|
354 | #define ddi_intr_get_nintrs(...) DDI_SUCCESS
|
---|
355 | #define ddi_intr_get_navail(...) DDI_SUCCESS
|
---|
356 | #define ddi_intr_alloc(...) DDI_SUCCESS
|
---|
357 | #define ddi_intr_free(...) do {} while(0)
|
---|
358 | #define ddi_intr_get_pri(...) DDI_SUCCESS
|
---|
359 | #define ddi_intr_enable(...) DDI_SUCCESS
|
---|
360 | #define ddi_intr_disable(...) DDI_SUCCESS
|
---|
361 | #define ddi_intr_add_handler(...) DDI_SUCCESS
|
---|
362 | #define ddi_intr_remove_handler(...) DDI_SUCCESS
|
---|
363 | #define mutex_init(...) do {} while(0)
|
---|
364 | #define mutex_destroy(...) do {} while(0)
|
---|
365 | #define mutex_enter(...) do {} while(0)
|
---|
366 | #define mutex_exit(...) do {} while(0)
|
---|
367 | #define uniqtime32(...) do {} while(0)
|
---|
368 | #define canput(...) true
|
---|
369 | #define putbq(...) do {} while(0)
|
---|
370 |
|
---|
371 | /* Externally defined helpers. */
|
---|
372 |
|
---|
373 | /** Flags set in the struct mblk b_flag member for verification purposes.
|
---|
374 | * @{ */
|
---|
375 | /** miocpullup was called for this message. */
|
---|
376 | #define F_TEST_PULLUP 1
|
---|
377 | /** @} */
|
---|
378 |
|
---|
379 | extern void miocack(queue_t *pWriteQueue, mblk_t *pMBlk, int cbData, int rc);
|
---|
380 | extern void miocnak(queue_t *pWriteQueue, mblk_t *pMBlk, int cbData, int iErr);
|
---|
381 | extern int miocpullup(mblk_t *pMBlk, size_t cbMsg);
|
---|
382 | extern void mcopyin(mblk_t *pMBlk, void *pvState, size_t cbData, void *pvUser);
|
---|
383 | extern void mcopyout(mblk_t *pMBlk, void *pvState, size_t cbData, void *pvUser,
|
---|
384 | mblk_t *pMBlkData);
|
---|
385 | extern void qreply(queue_t *pQueue, mblk_t *pMBlk);
|
---|
386 | extern mblk_t *allocb(size_t cb, uint_t cPrio);
|
---|
387 | extern void freemsg(mblk_t *pMsg);
|
---|
388 |
|
---|
389 | /* API stubs with simple logic */
|
---|
390 |
|
---|
391 | static modctl_t s_ModCtl;
|
---|
392 | static void **s_pvLinkage;
|
---|
393 |
|
---|
394 | static inline modctl_t *mod_getctl(void **linkage)
|
---|
395 | {
|
---|
396 | s_pvLinkage = linkage;
|
---|
397 | return s_pvLinkage ? &s_ModCtl : NULL;
|
---|
398 | }
|
---|
399 |
|
---|
400 | #define mod_install(linkage) (s_pvLinkage && ((linkage) == s_pvLinkage) ? 0 : EINVAL)
|
---|
401 | #define QREADR 0x00000010
|
---|
402 | #define OTHERQ(q) ((q)->q_flag & QREADR ? (q) + 1 : (q) - 1)
|
---|
403 | #define WR(q) ((q)->q_flag & QREADR ? (q) + 1 : (q))
|
---|
404 | #define RD(q) ((q)->q_flag & QREADR ? (q) : (q) - 1)
|
---|
405 |
|
---|
406 |
|
---|
407 | /* Basic initialisation of a queue structure pair for testing. */
|
---|
408 | static inline void doInitQueues(queue_t aQueues[2])
|
---|
409 | {
|
---|
410 | aQueues[0].q_flag = QREADR;
|
---|
411 | }
|
---|
412 |
|
---|
413 | static inline dev_t makedevice(unsigned cMajor, unsigned cMinor)
|
---|
414 | {
|
---|
415 | return cMajor * 4096 + cMinor;
|
---|
416 | }
|
---|
417 |
|
---|
418 | static inline unsigned getmajor(dev_t device)
|
---|
419 | {
|
---|
420 | return device / 4096;
|
---|
421 | }
|
---|
422 |
|
---|
423 | /* API stubs with controllable logic */
|
---|
424 |
|
---|
425 | #endif /* ___VBoxGuestTestCaseSolaris_h */
|
---|