VirtualBox

source: vbox/trunk/include/VBox/pdm.h@ 1857

Last change on this file since 1857 was 1550, checked in by vboxsync, 18 years ago

don't include VBoxGuest.h if we don't need to because it drags in ostypes.h and that conflicts with a core darwin type.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 241.4 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager.
3 */
4
5/*
6 * Copyright (C) 2006 InnoTek Systemberatung GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef __VBox_pdm_h__
22#define __VBox_pdm_h__
23
24#include <VBox/cdefs.h>
25#include <VBox/types.h>
26#include <VBox/iom.h>
27#include <VBox/ssm.h>
28#include <VBox/cfgm.h>
29#include <VBox/dbgf.h>
30#include <VBox/err.h>
31#include <VBox/pci.h>
32
33#include <iprt/critsect.h>
34#include <iprt/stdarg.h>
35
36
37__BEGIN_DECLS
38
39/** @defgroup grp_pdm The Pluggable Device Manager API
40 * @{
41 */
42
43/** Source position.
44 * @deprecated Use RT_SRC_POS */
45#define PDM_SRC_POS RT_SRC_POS
46
47/** Source position declaration.
48 * @deprecated Use RT_SRC_POS_DECL */
49#define PDM_SRC_POS_DECL RT_SRC_POS_DECL
50
51/** Source position arguments.
52 * @deprecated Use RT_SRC_POS_ARGS */
53#define PDM_SRC_POS_ARGS RT_SRC_POS_ARGS
54
55
56/** @defgroup grp_pdm_queue The PDM Queue
57 * @ingroup grp_pdm
58 * @{
59 */
60
61/** Pointer to a PDM queue. Also called PDM queue handle. */
62typedef struct PDMQUEUE *PPDMQUEUE;
63
64/** Pointer to a PDM queue item core. */
65typedef struct PDMQUEUEITEMCORE *PPDMQUEUEITEMCORE;
66
67/**
68 * PDM queue item core.
69 */
70typedef struct PDMQUEUEITEMCORE
71{
72 /** Pointer to the next item in the pending list - HC Pointer. */
73 HCPTRTYPE(PPDMQUEUEITEMCORE) pNextHC;
74 /** Pointer to the next item in the pending list - GC Pointer. */
75 GCPTRTYPE(PPDMQUEUEITEMCORE) pNextGC;
76#if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
77 uint32_t Alignment0;
78#endif
79} PDMQUEUEITEMCORE;
80
81
82/**
83 * Queue consumer callback for devices.
84 *
85 * @returns Success indicator.
86 * If false the item will not be removed and the flushing will stop.
87 * @param pDevIns The device instance.
88 * @param pItem The item to consume. Upon return this item will be freed.
89 */
90typedef DECLCALLBACK(bool) FNPDMQUEUEDEV(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem);
91/** Pointer to a FNPDMQUEUEDEV(). */
92typedef FNPDMQUEUEDEV *PFNPDMQUEUEDEV;
93
94/**
95 * Queue consumer callback for drivers.
96 *
97 * @returns Success indicator.
98 * If false the item will not be removed and the flushing will stop.
99 * @param pDrvIns The driver instance.
100 * @param pItem The item to consume. Upon return this item will be freed.
101 */
102typedef DECLCALLBACK(bool) FNPDMQUEUEDRV(PPDMDRVINS pDrvIns, PPDMQUEUEITEMCORE pItem);
103/** Pointer to a FNPDMQUEUEDRV(). */
104typedef FNPDMQUEUEDRV *PFNPDMQUEUEDRV;
105
106/**
107 * Queue consumer callback for internal component.
108 *
109 * @returns Success indicator.
110 * If false the item will not be removed and the flushing will stop.
111 * @param pVM The VM handle.
112 * @param pItem The item to consume. Upon return this item will be freed.
113 */
114typedef DECLCALLBACK(bool) FNPDMQUEUEINT(PVM pVM, PPDMQUEUEITEMCORE pItem);
115/** Pointer to a FNPDMQUEUEINT(). */
116typedef FNPDMQUEUEINT *PFNPDMQUEUEINT;
117
118/**
119 * Queue consumer callback for external component.
120 *
121 * @returns Success indicator.
122 * If false the item will not be removed and the flushing will stop.
123 * @param pvUser User argument.
124 * @param pItem The item to consume. Upon return this item will be freed.
125 */
126typedef DECLCALLBACK(bool) FNPDMQUEUEEXT(void *pvUser, PPDMQUEUEITEMCORE pItem);
127/** Pointer to a FNPDMQUEUEEXT(). */
128typedef FNPDMQUEUEEXT *PFNPDMQUEUEEXT;
129
130/**
131 * Create a queue with a device owner.
132 *
133 * @returns VBox status code.
134 * @param pVM VM handle.
135 * @param pDevIns Device instance.
136 * @param cbItem Size a queue item.
137 * @param cItems Number of items in the queue.
138 * @param cMilliesInterval Number of milliseconds between polling the queue.
139 * If 0 then the emulation thread will be notified whenever an item arrives.
140 * @param pfnCallback The consumer function.
141 * @param fGCEnabled Set if the queue must be usable from GC.
142 * @param ppQueue Where to store the queue handle on success.
143 * @thread Emulation thread only.
144 */
145PDMR3DECL(int) PDMR3QueueCreateDevice(PVM pVM, PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
146 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue);
147
148/**
149 * Create a queue with a driver owner.
150 *
151 * @returns VBox status code.
152 * @param pVM VM handle.
153 * @param pDrvIns Driver instance.
154 * @param cbItem Size a queue item.
155 * @param cItems Number of items in the queue.
156 * @param cMilliesInterval Number of milliseconds between polling the queue.
157 * If 0 then the emulation thread will be notified whenever an item arrives.
158 * @param pfnCallback The consumer function.
159 * @param ppQueue Where to store the queue handle on success.
160 * @thread The emulation thread.
161 */
162PDMR3DECL(int) PDMR3QueueCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
163 PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue);
164
165/**
166 * Create a queue with an internal owner.
167 *
168 * @returns VBox status code.
169 * @param pVM VM handle.
170 * @param cbItem Size a queue item.
171 * @param cItems Number of items in the queue.
172 * @param cMilliesInterval Number of milliseconds between polling the queue.
173 * If 0 then the emulation thread will be notified whenever an item arrives.
174 * @param pfnCallback The consumer function.
175 * @param fGCEnabled Set if the queue must be usable from GC.
176 * @param ppQueue Where to store the queue handle on success.
177 * @thread Emulation thread only.
178 */
179PDMR3DECL(int) PDMR3QueueCreateInternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
180 PFNPDMQUEUEINT pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue);
181
182/**
183 * Create a queue with an external owner.
184 *
185 * @returns VBox status code.
186 * @param pVM VM handle.
187 * @param cbItem Size a queue item.
188 * @param cItems Number of items in the queue.
189 * @param cMilliesInterval Number of milliseconds between polling the queue.
190 * If 0 then the emulation thread will be notified whenever an item arrives.
191 * @param pfnCallback The consumer function.
192 * @param pvUser The user argument to the consumer function.
193 * @param ppQueue Where to store the queue handle on success.
194 * @thread The emulation thread.
195 */
196PDMR3DECL(int) PDMR3QueueCreateExternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
197 PFNPDMQUEUEEXT pfnCallback, void *pvUser, PPDMQUEUE *ppQueue);
198
199/**
200 * Destroy a queue.
201 *
202 * @returns VBox status code.
203 * @param pQueue Queue to destroy.
204 * @thread The emulation thread.
205 */
206PDMR3DECL(int) PDMR3QueueDestroy(PPDMQUEUE pQueue);
207
208/**
209 * Destroy a all queues owned by the specified device.
210 *
211 * @returns VBox status code.
212 * @param pVM VM handle.
213 * @param pDevIns Device instance.
214 * @thread Emulation thread only.
215 */
216PDMR3DECL(int) PDMR3QueueDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
217
218/**
219 * Destroy a all queues owned by the specified driver.
220 *
221 * @returns VBox status code.
222 * @param pVM VM handle.
223 * @param pDrvIns Driver instance.
224 * @thread Emulation thread only.
225 */
226PDMR3DECL(int) PDMR3QueueDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
227
228/**
229 * Flushes pending queues.
230 * This is a forced action callback.
231 *
232 * @param pVM VM handle.
233 * @thread The emulation thread.
234 */
235PDMR3DECL(void) PDMR3QueueFlushAll(PVM pVM);
236
237/**
238 * This is a worker function used by PDMQueueFlush to perform the
239 * flush in ring-3.
240 *
241 * The queue which should be flushed is pointed to by either pQueueFlushGC,
242 * pQueueFlushHC, or pQueueue. This function will flush that queue and
243 * recalc the queue FF.
244 *
245 * @param pVM The VM handle.
246 * @param pQueue The queue to flush. Only used in Ring-3.
247 */
248PDMR3DECL(void) PDMR3QueueFlushWorker(PVM pVM, PPDMQUEUE pQueue);
249
250/**
251 * Flushes a PDM queue.
252 *
253 * @param pQueue The queue handle.
254 */
255PDMDECL(void) PDMQueueFlush(PPDMQUEUE pQueue);
256
257/**
258 * Allocate an item from a queue.
259 * The allocated item must be handed on to PDMQueueInsert() after the
260 * data has been filled in.
261 *
262 * @returns Pointer to allocated queue item.
263 * @returns NULL on failure. The queue is exhausted.
264 * @param pQueue The queue handle.
265 * @thread Any thread.
266 */
267PDMDECL(PPDMQUEUEITEMCORE) PDMQueueAlloc(PPDMQUEUE pQueue);
268
269/**
270 * Queue an item.
271 * The item must have been obtained using PDMQueueAlloc(). Once the item
272 * has been passed to this function it must not be touched!
273 *
274 * @param pQueue The queue handle.
275 * @param pItem The item to insert.
276 * @thread Any thread.
277 */
278PDMDECL(void) PDMQueueInsert(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem);
279
280/**
281 * Queue an item.
282 * The item must have been obtained using PDMQueueAlloc(). Once the item
283 * have been passed to this function it must not be touched!
284 *
285 * @param pQueue The queue handle.
286 * @param pItem The item to insert.
287 * @param NanoMaxDelay The maximum delay before processing the queue, in nanoseconds.
288 * This applies only to GC.
289 * @thread Any thread.
290 */
291PDMDECL(void) PDMQueueInsertEx(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem, uint64_t NanoMaxDelay);
292
293
294/**
295 * Gets the GC pointer for the specified queue.
296 *
297 * @returns The GC address of the queue.
298 * @returns NULL if pQueue is invalid.
299 * @param pQueue The queue handle.
300 */
301PDMDECL(GCPTRTYPE(PPDMQUEUE)) PDMQueueGCPtr(PPDMQUEUE pQueue);
302
303/** @} */
304
305
306
307/** @defgroup grp_pdm_critsect The PDM Critical Section
308 * @ingroup grp_pdm
309 * @{
310 */
311
312/**
313 * A PDM critical section.
314 * Initialize using PDMDRVHLP::pfnCritSectInit().
315 */
316typedef union PDMCRITSECT
317{
318 /** Padding. */
319 uint8_t padding[HC_ARCH_BITS == 64 ? 0xa8 : 0x80];
320#ifdef PDMCRITSECTINT_DECLARED
321 /** The internal structure (not normally visible). */
322 struct PDMCRITSECTINT s;
323#endif
324} PDMCRITSECT;
325/** Pointer to a PDM critical section. */
326typedef PDMCRITSECT *PPDMCRITSECT;
327/** Pointer to a const PDM critical section. */
328typedef const PDMCRITSECT *PCPDMCRITSECT;
329
330/**
331 * Initializes a PDM critical section for internal use.
332 *
333 * The PDM critical sections are derived from the IPRT critical sections, but
334 * works in GC as well.
335 *
336 * @returns VBox status code.
337 * @param pVM The VM handle.
338 * @param pDevIns Device instance.
339 * @param pCritSect Pointer to the critical section.
340 * @param pszName The name of the critical section (for statistics).
341 */
342PDMR3DECL(int) PDMR3CritSectInit(PVM pVM, PPDMCRITSECT pCritSect, const char *pszName);
343
344/**
345 * Leaves a critical section entered with PDMCritSectEnter().
346 *
347 * @returns VINF_SUCCESS if entered successfully.
348 * @returns rcBusy when encountering a busy critical section in GC/R0.
349 * @returns VERR_SEM_DESTROYED if the critical section is dead.
350 *
351 * @param pCritSect The PDM critical section to enter.
352 * @param rcBusy The status code to return when we're in GC or R0
353 * and the section is busy.
354 */
355PDMDECL(int) PDMCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy);
356
357/**
358 * Leaves a critical section entered with PDMCritSectEnter().
359 *
360 * @param pCritSect The PDM critical section to leave.
361 */
362PDMDECL(void) PDMCritSectLeave(PPDMCRITSECT pCritSect);
363
364/**
365 * Checks the caller is the owner of the critical section.
366 *
367 * @returns true if owner.
368 * @returns false if not owner.
369 * @param pCritSect The critical section.
370 */
371PDMDECL(bool) PDMCritSectIsOwner(PCPDMCRITSECT pCritSect);
372
373/**
374 * Try enter a critical section.
375 *
376 * @returns VINF_SUCCESS on success.
377 * @returns VERR_SEM_BUSY if the critsect was owned.
378 * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
379 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
380 * @param pCritSect The critical section.
381 */
382PDMR3DECL(int) PDMR3CritSectTryEnter(PPDMCRITSECT pCritSect);
383
384/**
385 * Deletes the critical section.
386 *
387 * @returns VBox status code.
388 * @param pCritSect The PDM critical section to destroy.
389 */
390PDMR3DECL(int) PDMR3CritSectDelete(PPDMCRITSECT pCritSect);
391
392/**
393 * Deletes all remaining critical sections.
394 *
395 * This is called at the end of the termination process.
396 *
397 * @returns VBox status.
398 * First error code, rest is lost.
399 * @param pVM The VM handle.
400 * @remark Don't confuse this with PDMR3CritSectDelete.
401 */
402PDMDECL(int) PDMR3CritSectTerm(PVM pVM);
403
404/**
405 * Process the critical sections queued for ring-3 'leave'.
406 *
407 * @param pVM The VM handle.
408 */
409PDMR3DECL(void) PDMR3CritSectFF(PVM pVM);
410
411/** @} */
412
413
414
415/** @defgroup grp_pdm_interfaces Interfaces
416 * @ingroup grp_pdm
417 * @{
418 */
419
420/**
421 * Driver interface identficators.
422 */
423typedef enum PDMINTERFACE
424{
425 /** PDMIBASE - The interface everyone supports. */
426 PDMINTERFACE_BASE = 1,
427 /** PDMIMOUSEPORT - The mouse port interface. (Down) Coupled with PDMINTERFACE_MOUSE_CONNECTOR. */
428 PDMINTERFACE_MOUSE_PORT,
429 /** PDMIMOUSECONNECTOR - The mouse connector interface. (Up) Coupled with PDMINTERFACE_MOUSE_PORT. */
430 PDMINTERFACE_MOUSE_CONNECTOR,
431 /** PDMIKEYBOARDPORT - The keyboard port interface. (Down) Coupled with PDMINTERFACE_KEYBOARD_CONNECTOR. */
432 PDMINTERFACE_KEYBOARD_PORT,
433 /** PDMIKEYBOARDCONNECTOR - The keyboard connector interface. (Up) Coupled with PDMINTERFACE_KEYBOARD_PORT. */
434 PDMINTERFACE_KEYBOARD_CONNECTOR,
435 /** PDMIDISPLAYPORT - The display port interface. (Down) Coupled with PDMINTERFACE_DISPLAY_CONNECTOR. */
436 PDMINTERFACE_DISPLAY_PORT,
437 /** PDMIDISPLAYCONNECTOR - The display connector interface. (Up) Coupled with PDMINTERFACE_DISPLAY_PORT. */
438 PDMINTERFACE_DISPLAY_CONNECTOR,
439 /** PDMICHARPORT - The char notify interface. (Down) Coupled with PDMINTERFACE_CHAR. */
440 PDMINTERFACE_CHAR_PORT,
441 /** PDMICHAR - The char driver interface. (Up) Coupled with PDMINTERFACE_CHAR_PORT. */
442 PDMINTERFACE_CHAR,
443 /** PDMISTREAM - The stream driver interface (Up) No coupling.
444 * Used by a char driver to implement PDMINTERFACE_CHAR. */
445 PDMINTERFACE_STREAM,
446 /** PDMIBLOCKPORT - The block notify interface (Down) Coupled with PDMINTERFACE_BLOCK. */
447 PDMINTERFACE_BLOCK_PORT,
448 /** PDMIBLOCK - The block driver interface (Up) Coupled with PDMINTERFACE_BLOCK_PORT. */
449 PDMINTERFACE_BLOCK,
450 /** PDMIBLOCKBIOS - The block bios interface. (External) */
451 PDMINTERFACE_BLOCK_BIOS,
452 /** PDMIMOUNTNOTIFY - The mountable notification interface. (Down) Coupled with PDMINTERFACE_MOUNT. */
453 PDMINTERFACE_MOUNT_NOTIFY,
454 /** PDMIMOUNT - The mountable interface. (Up) Coupled with PDMINTERFACE_MOUNT_NOTIFY. */
455 PDMINTERFACE_MOUNT,
456 /** PDMIMEDIA - The media interface. (Up) No coupling.
457 * Used by a block unit driver to implement PDMINTERFACE_BLOCK and PDMINTERFACE_BLOCK_BIOS. */
458 PDMINTERFACE_MEDIA,
459 /** PDMIISCSITRANSPORT - The iSCSI transport interface (Up) No coupling.
460 * used by the iSCSI media driver. */
461 PDMINTERFACE_ISCSITRANSPORT,
462
463 /** PDMINETWORKPORT - The network port interface. (Down) Coupled with PDMINTERFACE_NETWORK_CONNECTOR. */
464 PDMINTERFACE_NETWORK_PORT,
465 /** PDMINETWORKPORT - The network connector interface. (Up) Coupled with PDMINTERFACE_NETWORK_PORT. */
466 PDMINTERFACE_NETWORK_CONNECTOR,
467 /** PDMINETWORKCONFIG - The network configuartion interface. (Main) Used by the managment api. */
468 PDMINTERFACE_NETWORK_CONFIG,
469
470 /** PDMIAUDIOCONNECTOR - The audio driver interface. (Up) No coupling. */
471 PDMINTERFACE_AUDIO_CONNECTOR,
472
473 /** PDMIAUDIOSNIFFERPORT - The Audio Sniffer Device port interface. */
474 PDMINTERFACE_AUDIO_SNIFFER_PORT,
475 /** PDMIAUDIOSNIFFERCONNECTOR - The Audio Sniffer Driver connector interface. */
476 PDMINTERFACE_AUDIO_SNIFFER_CONNECTOR,
477
478 /** PDMIVMMDEVPORT - The VMM Device port interface. */
479 PDMINTERFACE_VMMDEV_PORT,
480 /** PDMIVMMDEVCONNECTOR - The VMM Device connector interface. */
481 PDMINTERFACE_VMMDEV_CONNECTOR,
482
483 /** PDMILEDPORTS - The generic LED port interface. (Down) Coupled with PDMINTERFACE_LED_CONNECTORS. */
484 PDMINTERFACE_LED_PORTS,
485 /** PDMILEDCONNECTORS - The generic LED connector interface. (Up) Coupled with PDMINTERFACE_LED_PORTS. */
486 PDMINTERFACE_LED_CONNECTORS,
487
488 /** PDMIACPIPORT - ACPI port interface. (Down) Coupled with PDMINTERFACE_ACPI_CONNECTOR. */
489 PDMINTERFACE_ACPI_PORT,
490 /** PDMIACPICONNECTOR - ACPI connector interface. (Up) Coupled with PDMINTERFACE_ACPI_PORT. */
491 PDMINTERFACE_ACPI_CONNECTOR,
492
493 /** PDMIHGCMPORT - The Host-Guest communication manager port interface. Normally implemented by VMMDev. */
494 PDMINTERFACE_HGCM_PORT,
495 /** PDMIHGCMCONNECTOR - The Host-Guest communication manager connector interface. Normally implemented by Main::VMMDevInterface. */
496 PDMINTERFACE_HGCM_CONNECTOR,
497
498 /** VUSBIROOTHUBPORT - VUSB RootHub port interface. (Down) Coupled with PDMINTERFACE_USB_RH_CONNECTOR. */
499 PDMINTERFACE_VUSB_RH_PORT,
500 /** VUSBIROOTHUBCONNECTOR - VUSB RootHub connector interface. (Up) Coupled with PDMINTERFACE_USB_RH_PORT. */
501 PDMINTERFACE_VUSB_RH_CONNECTOR,
502 /** VUSBIROOTHUBCONNECTOR - VUSB RootHub configuration interface. (Main) Used by the managment api. */
503 PDMINTERFACE_VUSB_RH_CONFIG,
504
505 /** VUSBROOTHUBCONNECTOR - VUSB Device interface. (Up) No coupling. */
506 PDMINTERFACE_VUSB_DEVICE,
507
508 /** Maximum interface number. */
509 PDMINTERFACE_MAX
510} PDMINTERFACE;
511
512
513/**
514 * PDM Driver Base Interface.
515 */
516typedef struct PDMIBASE
517{
518 /**
519 * Queries an interface to the driver.
520 *
521 * @returns Pointer to interface.
522 * @returns NULL if the interface was not supported by the driver.
523 * @param pInterface Pointer to this interface structure.
524 * @param enmInterface The requested interface identification.
525 * @thread Any thread.
526 */
527 DECLR3CALLBACKMEMBER(void *, pfnQueryInterface,(struct PDMIBASE *pInterface, PDMINTERFACE enmInterface));
528} PDMIBASE;
529/** Pointer to a PDM Driver Base Interface. */
530typedef PDMIBASE *PPDMIBASE;
531
532
533/**
534 * Dummy interface.
535 *
536 * This is used to typedef other dummy interfaces. The purpose of a dummy
537 * interface is to validate the logical function of a driver/device and
538 * full a natural interface pair.
539 */
540typedef struct PDMIDUMMY
541{
542 RTHCPTR pvDummy;
543} PDMIDUMMY;
544
545
546/** Pointer to a mouse port interface. */
547typedef struct PDMIMOUSEPORT *PPDMIMOUSEPORT;
548/**
549 * Mouse port interface.
550 * Pair with PDMIMOUSECONNECTOR.
551 */
552typedef struct PDMIMOUSEPORT
553{
554 /**
555 * Puts a mouse event.
556 * This is called by the source of mouse events. The event will be passed up until the
557 * topmost driver, which then calls the registered event handler.
558 *
559 * @returns VBox status code.
560 * @param pInterface Pointer to this interface structure.
561 * @param i32DeltaX The X delta.
562 * @param i32DeltaY The Y delta.
563 * @param i32DeltaZ The Z delta.
564 * @param fButtonStates The button states, see the PDMIMOUSEPORT_BUTTON_* \#defines.
565 * @thread The emulation thread.
566 */
567 DECLR3CALLBACKMEMBER(int, pfnPutEvent,(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, uint32_t fButtonStates));
568} PDMIMOUSEPORT;
569
570/** Mouse button defines for PDMIMOUSEPORT::pfnPutEvent.
571 * @{ */
572#define PDMIMOUSEPORT_BUTTON_LEFT BIT(0)
573#define PDMIMOUSEPORT_BUTTON_RIGHT BIT(1)
574#define PDMIMOUSEPORT_BUTTON_MIDDLE BIT(2)
575/** @} */
576
577
578/**
579 * Mouse connector interface.
580 * Pair with PDMIMOUSEPORT.
581 */
582typedef PDMIDUMMY PDMIMOUSECONNECTOR;
583 /** Pointer to a mouse connector interface. */
584typedef PDMIMOUSECONNECTOR *PPDMIMOUSECONNECTOR;
585
586
587/** Pointer to a keyboard port interface. */
588typedef struct PDMIKEYBOARDPORT *PPDMIKEYBOARDPORT;
589/**
590 * Keyboard port interface.
591 * Pair with PDMIKEYBOARDCONNECTOR.
592 */
593typedef struct PDMIKEYBOARDPORT
594{
595 /**
596 * Puts a keyboard event.
597 * This is called by the source of keyboard events. The event will be passed up until the
598 * topmost driver, which then calls the registered event handler.
599 *
600 * @returns VBox status code.
601 * @param pInterface Pointer to this interface structure.
602 * @param u8KeyCode The keycode to queue.
603 * @thread The emulation thread.
604 */
605 DECLR3CALLBACKMEMBER(int, pfnPutEvent,(PPDMIKEYBOARDPORT pInterface, uint8_t u8KeyCode));
606} PDMIKEYBOARDPORT;
607
608/**
609 * Keyboard LEDs.
610 */
611typedef enum PDMKEYBLEDS
612{
613 /** Num Lock */
614 PDMKEYBLEDS_NUMLOCK = 0x0001,
615 /** Caps Lock */
616 PDMKEYBLEDS_CAPSLOCK = 0x0002,
617 /** Scroll Lock */
618 PDMKEYBLEDS_SCROLLLOCK = 0x0004
619} PDMKEYBLEDS;
620
621/** Pointer to keyboard connector interface. */
622typedef struct PDMIKEYBOARDCONNECTOR *PPDMIKEYBOARDCONNECTOR;
623
624
625/**
626 * Keyboard connector interface.
627 * Pair with PDMIKEYBOARDPORT
628 */
629typedef struct PDMIKEYBOARDCONNECTOR
630{
631 /**
632 * Notifies the the downstream driver about an LED change initiated by the guest.
633 *
634 * @param pInterface Pointer to the this interface.
635 * @param enmLeds The new led mask.
636 */
637 DECLR3CALLBACKMEMBER(void, pfnLedStatusChange,(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds));
638
639} PDMIKEYBOARDCONNECTOR;
640
641
642/** Pointer to a display port interface. */
643typedef struct PDMIDISPLAYPORT *PPDMIDISPLAYPORT;
644/**
645 * Display port interface.
646 * Pair with PDMIDISPLAYCONNECTOR.
647 */
648typedef struct PDMIDISPLAYPORT
649{
650 /**
651 * Update the display with any changed regions.
652 *
653 * Flushes any display changes to the memory pointed to by the
654 * PDMIDISPLAYCONNECTOR interface and calles PDMIDISPLAYCONNECTOR::pfnUpdateRect()
655 * while doing so.
656 *
657 * @param pInterface Pointer to this interface.
658 * @thread The emulation thread.
659 */
660 DECLR3CALLBACKMEMBER(void, pfnUpdateDisplay,(PPDMIDISPLAYPORT pInterface));
661
662 /**
663 * Update the entire display.
664 *
665 * Flushes the entire display content to the memory pointed to by the
666 * PDMIDISPLAYCONNECTOR interface and calles PDMIDISPLAYCONNECTOR::pfnUpdateRect().
667 *
668 * @param pInterface Pointer to this interface.
669 * @thread The emulation thread.
670 */
671 DECLR3CALLBACKMEMBER(void, pfnUpdateDisplayAll,(PPDMIDISPLAYPORT pInterface));
672
673 /**
674 * Return the current guest color depth in bits per pixel (bpp).
675 *
676 * As the graphics card is able to provide display updates with the bpp
677 * requested by the host, this method can be used to query the actual
678 * guest color depth.
679 *
680 * @returns VBox status code.
681 * @param pInterface Pointer to this interface.
682 * @param pcBits Where to store the current guest color depth.
683 * @thread Any thread.
684 */
685 DECLR3CALLBACKMEMBER(int, pfnQueryColorDepth,(PPDMIDISPLAYPORT pInterface, uint32_t *pcBits));
686
687 /**
688 * Sets the refresh rate and restart the timer.
689 * The rate is defined as the minimum interval between the return of
690 * one PDMIDISPLAYPORT::pfnRefresh() call to the next one.
691 *
692 * The interval timer will be restarted by this call. So at VM startup
693 * this function must be called to start the refresh cycle. The refresh
694 * rate is not saved, but have to be when resuming a loaded VM state.
695 *
696 * @returns VBox status code.
697 * @param pInterface Pointer to this interface.
698 * @param cMilliesInterval Number of millies between two refreshes.
699 * @thread Any thread.
700 */
701 DECLR3CALLBACKMEMBER(int, pfnSetRefreshRate,(PPDMIDISPLAYPORT pInterface, uint32_t cMilliesInterval));
702
703 /**
704 * Create a 32-bbp snapshot of the display.
705 *
706 * This will create a 32-bbp bitmap with dword aligned scanline length. Because
707 * of a wish for no locks in the graphics device, this must be called from the
708 * emulation thread.
709 *
710 * @param pInterface Pointer to this interface.
711 * @param pvData Pointer the buffer to copy the bits to.
712 * @param cbData Size of the buffer.
713 * @param pcx Where to store the width of the bitmap. (optional)
714 * @param pcy Where to store the height of the bitmap. (optional)
715 * @param pcbData Where to store the actual size of the bitmap. (optional)
716 * @thread The emulation thread.
717 */
718 DECLR3CALLBACKMEMBER(int, pfnSnapshot,(PPDMIDISPLAYPORT pInterface, void *pvData, size_t cbData, uint32_t *pcx, uint32_t *pcy, size_t *pcbData));
719
720 /**
721 * Copy bitmap to the display.
722 *
723 * This will convert and copy a 32-bbp bitmap (with dword aligned scanline length) to
724 * the memory pointed to by the PDMIDISPLAYCONNECTOR interface.
725 *
726 * @param pInterface Pointer to this interface.
727 * @param pvData Pointer to the bitmap bits.
728 * @param x The upper left corner x coordinate of the destination rectangle.
729 * @param y The upper left corner y coordinate of the destination rectangle.
730 * @param cx The width of the source and destination rectangles.
731 * @param cy The height of the source and destination rectangles.
732 * @thread The emulation thread.
733 * @remark This is just a convenience for using the bitmap conversions of the
734 * graphics device.
735 */
736 DECLR3CALLBACKMEMBER(int, pfnDisplayBlt,(PPDMIDISPLAYPORT pInterface, const void *pvData, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy));
737
738 /**
739 * Render a rectangle from guest VRAM to Framebuffer.
740 *
741 * @param pInterface Pointer to this interface.
742 * @param x The upper left corner x coordinate of the rectangle to be updated.
743 * @param y The upper left corner y coordinate of the rectangle to be updated.
744 * @param cx The width of the rectangle to be updated.
745 * @param cy The height of the rectangle to be updated.
746 * @thread The emulation thread.
747 */
748 DECLR3CALLBACKMEMBER(void, pfnUpdateDisplayRect,(PPDMIDISPLAYPORT pInterface, int32_t x, int32_t y, uint32_t cx, uint32_t cy));
749
750 /**
751 * Setup guest physical VRAM to use the provided page aligned
752 * memory buffer as the guest VRAM, may be equal to current guest VRAM.
753 *
754 * @returns VBox status code.
755 * @param pInterface Pointer to this interface.
756 * @param pvBuffer Page aligned address. NULL for removing previously set buffer.
757 * @param cbBuffer Size of buffer. Must be equal to a whole number of pages.
758 * @thread The emulation thread.
759 */
760 DECLR3CALLBACKMEMBER(int, pfnSetupVRAM,(PPDMIDISPLAYPORT pInterface, void *pvBuffer, uint32_t cbBuffer));
761} PDMIDISPLAYPORT;
762
763
764/** Pointer to a display connector interface. */
765typedef struct PDMIDISPLAYCONNECTOR *PPDMIDISPLAYCONNECTOR;
766/**
767 * Display connector interface.
768 * Pair with PDMIDISPLAYPORT.
769 */
770typedef struct PDMIDISPLAYCONNECTOR
771{
772 /**
773 * Resize the display.
774 * This is called when the resolution changes. This usually happens on
775 * request from the guest os, but may also happen as the result of a reset.
776 *
777 * @param pInterface Pointer to this interface.
778 * @param cBits Color depth (bits per pixel) of the new video mode.
779 * @param pvVRAM Address of guest VRAM.
780 * @param cbLine Size in bytes of a single scan line.
781 * @param cx New display width.
782 * @param cy New display height.
783 * @thread The emulation thread.
784 */
785 DECLR3CALLBACKMEMBER(void, pfnResize,(PPDMIDISPLAYCONNECTOR pInterface, uint32_t cBits, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy));
786
787 /**
788 * Update a rectangle of the display.
789 * PDMIDISPLAYPORT::pfnUpdateDisplay is the caller.
790 *
791 * @param pInterface Pointer to this interface.
792 * @param x The upper left corner x coordinate of the rectangle.
793 * @param y The upper left corner y coordinate of the rectangle.
794 * @param cx The width of the rectangle.
795 * @param cy The height of the rectangle.
796 * @thread The emulation thread.
797 */
798 DECLR3CALLBACKMEMBER(void, pfnUpdateRect,(PPDMIDISPLAYCONNECTOR pInterface, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy));
799
800 /**
801 * Refresh the display.
802 *
803 * The interval between these calls is set by
804 * PDMIDISPLAYPORT::pfnSetRefreshRate(). The driver should call
805 * PDMIDISPLAYPORT::pfnUpdateDisplay() if it wishes to refresh the
806 * display. PDMIDISPLAYPORT::pfnUpdateDisplay calls pfnUpdateRect with
807 * the changed rectangles.
808 *
809 * @param pInterface Pointer to this interface.
810 * @thread The emulation thread.
811 */
812 DECLR3CALLBACKMEMBER(void, pfnRefresh,(PPDMIDISPLAYCONNECTOR pInterface));
813
814 /**
815 * Reset the display.
816 *
817 * Notification message when the graphics card has been reset.
818 *
819 * @param pInterface Pointer to this interface.
820 * @thread The emulation thread.
821 */
822 DECLR3CALLBACKMEMBER(void, pfnReset,(PPDMIDISPLAYCONNECTOR pInterface));
823
824 /**
825 * LFB video mode enter/exit.
826 *
827 * Notification message when LinearFrameBuffer video mode is enabled/disabled.
828 *
829 * @param pInterface Pointer to this interface.
830 * @param fEnabled false - LFB mode was disabled,
831 * true - an LFB mode was disabled
832 * @thread The emulation thread.
833 */
834 DECLCALLBACKMEMBER(void, pfnLFBModeChange)(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
835
836
837 /** Read-only attributes.
838 * For preformance reasons some readonly attributes are kept in the interface.
839 * We trust the interface users to respect the readonlyness of these.
840 * @{
841 */
842 /** Pointer to the display data buffer. */
843 uint8_t *pu8Data;
844 /** Size of a scanline in the data buffer. */
845 uint32_t cbScanline;
846 /** The color depth (in bits) the graphics card is supposed to provide. */
847 uint32_t cBits;
848 /** The display width. */
849 uint32_t cx;
850 /** The display height. */
851 uint32_t cy;
852 /** @} */
853} PDMIDISPLAYCONNECTOR;
854
855
856
857/**
858 * Block drive type.
859 */
860typedef enum PDMBLOCKTYPE
861{
862 /** Error (for the query function). */
863 PDMBLOCKTYPE_ERROR = 1,
864 /** 360KB 5 1/4" floppy drive. */
865 PDMBLOCKTYPE_FLOPPY_360,
866 /** 720KB 3 1/2" floppy drive. */
867 PDMBLOCKTYPE_FLOPPY_720,
868 /** 1.2MB 5 1/4" floppy drive. */
869 PDMBLOCKTYPE_FLOPPY_1_20,
870 /** 1.44MB 3 1/2" floppy drive. */
871 PDMBLOCKTYPE_FLOPPY_1_44,
872 /** 2.88MB 3 1/2" floppy drive. */
873 PDMBLOCKTYPE_FLOPPY_2_88,
874 /** CDROM drive. */
875 PDMBLOCKTYPE_CDROM,
876 /** DVD drive. */
877 PDMBLOCKTYPE_DVD,
878 /** Hard disk drive. */
879 PDMBLOCKTYPE_HARD_DISK
880} PDMBLOCKTYPE;
881
882
883/**
884 * Block raw command data transfer direction.
885 */
886typedef enum PDMBLOCKTXDIR
887{
888 PDMBLOCKTXDIR_NONE = 0,
889 PDMBLOCKTXDIR_FROM_DEVICE,
890 PDMBLOCKTXDIR_TO_DEVICE
891} PDMBLOCKTXDIR;
892
893/**
894 * Block notify interface.
895 * Pair with PDMIBLOCK.
896 */
897typedef PDMIDUMMY PDMIBLOCKPORT;
898/** Pointer to a block notify interface (dummy). */
899typedef PDMIBLOCKPORT *PPDMIBLOCKPORT;
900
901/** Pointer to a block interface. */
902typedef struct PDMIBLOCK *PPDMIBLOCK;
903/**
904 * Block interface.
905 * Pair with PDMIBLOCKPORT.
906 */
907typedef struct PDMIBLOCK
908{
909 /**
910 * Read bits.
911 *
912 * @returns VBox status code.
913 * @param pInterface Pointer to the interface structure containing the called function pointer.
914 * @param off Offset to start reading from.
915 * @param pvBuf Where to store the read bits.
916 * @param cbRead Number of bytes to read.
917 * @thread Any thread.
918 */
919 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIBLOCK pInterface, uint64_t off, void *pvBuf, size_t cbRead));
920
921 /**
922 * Write bits.
923 *
924 * @returns VBox status code.
925 * @param pInterface Pointer to the interface structure containing the called function pointer.
926 * @param off Offset to start writing at.
927 * @param pvBuf Where to store the write bits.
928 * @param cbWrite Number of bytes to write.
929 * @thread Any thread.
930 */
931 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIBLOCK pInterface, uint64_t off, const void *pvBuf, size_t cbWrite));
932
933 /**
934 * Make sure that the bits written are actually on the storage medium.
935 *
936 * @returns VBox status code.
937 * @param pInterface Pointer to the interface structure containing the called function pointer.
938 * @thread Any thread.
939 */
940 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIBLOCK pInterface));
941
942 /**
943 * Send a raw command to the underlying device (CDROM).
944 * This method is optional (i.e. the function pointer may be NULL).
945 *
946 * @returns VBox status code.
947 * @param pInterface Pointer to the interface structure containing the called function pointer.
948 * @param pbCmd Offset to start reading from.
949 * @param enmTxDir Direction of transfer.
950 * @param pvBuf Pointer tp the transfer buffer.
951 * @param cbBuf Size of the transfer buffer.
952 * @param pbSenseKey Status of the command (when return value is VERR_DEV_IO_ERROR).
953 * @param cTimeoutMillies Command timeout in milliseconds.
954 * @thread Any thread.
955 */
956 DECLR3CALLBACKMEMBER(int, pfnSendCmd,(PPDMIBLOCK pInterface, const uint8_t *pbCmd, PDMBLOCKTXDIR enmTxDir, void *pvBuf, size_t *pcbBuf, uint8_t *pbSenseKey, uint32_t cTimeoutMillies));
957
958 /**
959 * Check if the media is readonly or not.
960 *
961 * @returns true if readonly.
962 * @returns false if read/write.
963 * @param pInterface Pointer to the interface structure containing the called function pointer.
964 * @thread Any thread.
965 */
966 DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIBLOCK pInterface));
967
968 /**
969 * Gets the media size in bytes.
970 *
971 * @returns Media size in bytes.
972 * @param pInterface Pointer to the interface structure containing the called function pointer.
973 * @thread Any thread.
974 */
975 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIBLOCK pInterface));
976
977 /**
978 * Gets the block drive type.
979 *
980 * @returns block drive type.
981 * @param pInterface Pointer to the interface structure containing the called function pointer.
982 * @thread Any thread.
983 */
984 DECLR3CALLBACKMEMBER(PDMBLOCKTYPE, pfnGetType,(PPDMIBLOCK pInterface));
985
986 /**
987 * Gets the UUID of the block drive.
988 * Don't return the media UUID if it's removable.
989 *
990 * @returns VBox status code.
991 * @param pInterface Pointer to the interface structure containing the called function pointer.
992 * @param pUuid Where to store the UUID on success.
993 * @thread Any thread.
994 */
995 DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIBLOCK pInterface, PRTUUID pUuid));
996} PDMIBLOCK;
997
998
999/** Pointer to a mount interface. */
1000typedef struct PDMIMOUNTNOTIFY *PPDMIMOUNTNOTIFY;
1001/**
1002 * Block interface.
1003 * Pair with PDMIMOUNT.
1004 */
1005typedef struct PDMIMOUNTNOTIFY
1006{
1007 /**
1008 * Called when a media is mounted.
1009 *
1010 * @param pInterface Pointer to the interface structure containing the called function pointer.
1011 * @thread The emulation thread.
1012 */
1013 DECLR3CALLBACKMEMBER(void, pfnMountNotify,(PPDMIMOUNTNOTIFY pInterface));
1014
1015 /**
1016 * Called when a media is unmounted
1017 * @param pInterface Pointer to the interface structure containing the called function pointer.
1018 * @thread The emulation thread.
1019 */
1020 DECLR3CALLBACKMEMBER(void, pfnUnmountNotify,(PPDMIMOUNTNOTIFY pInterface));
1021} PDMIMOUNTNOTIFY;
1022
1023
1024/* Pointer to mount interface. */
1025typedef struct PDMIMOUNT *PPDMIMOUNT;
1026/**
1027 * Mount interface.
1028 * Pair with PDMIMOUNTNOTIFY.
1029 */
1030typedef struct PDMIMOUNT
1031{
1032 /**
1033 * Mount a media.
1034 *
1035 * This will not unmount any currently mounted media!
1036 *
1037 * @returns VBox status code.
1038 * @param pInterface Pointer to the interface structure containing the called function pointer.
1039 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have
1040 * constructed a configuration which can be attached to the bottom driver.
1041 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL.
1042 * @thread The emulation thread.
1043 */
1044 DECLR3CALLBACKMEMBER(int, pfnMount,(PPDMIMOUNT pInterface, const char *pszFilename, const char *pszCoreDriver));
1045
1046 /**
1047 * Unmount the media.
1048 *
1049 * The driver will validate and pass it on. On the rebounce it will decide whether or not to detach it self.
1050 *
1051 * @returns VBox status code.
1052 * @param pInterface Pointer to the interface structure containing the called function pointer.
1053 * @thread The emulation thread.
1054 */
1055 DECLR3CALLBACKMEMBER(int, pfnUnmount,(PPDMIMOUNT pInterface));
1056
1057 /**
1058 * Checks if a media is mounted.
1059 *
1060 * @returns true if mounted.
1061 * @returns false if not mounted.
1062 * @param pInterface Pointer to the interface structure containing the called function pointer.
1063 * @thread Any thread.
1064 */
1065 DECLR3CALLBACKMEMBER(bool, pfnIsMounted,(PPDMIMOUNT pInterface));
1066
1067 /**
1068 * Locks the media, preventing any unmounting of it.
1069 *
1070 * @returns VBox status code.
1071 * @param pInterface Pointer to the interface structure containing the called function pointer.
1072 * @thread The emulation thread.
1073 */
1074 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMIMOUNT pInterface));
1075
1076 /**
1077 * Unlocks the media, canceling previous calls to pfnLock().
1078 *
1079 * @returns VBox status code.
1080 * @param pInterface Pointer to the interface structure containing the called function pointer.
1081 * @thread The emulation thread.
1082 */
1083 DECLR3CALLBACKMEMBER(int, pfnUnlock,(PPDMIMOUNT pInterface));
1084
1085 /**
1086 * Checks if a media is locked.
1087 *
1088 * @returns true if locked.
1089 * @returns false if not locked.
1090 * @param pInterface Pointer to the interface structure containing the called function pointer.
1091 * @thread Any thread.
1092 */
1093 DECLR3CALLBACKMEMBER(bool, pfnIsLocked,(PPDMIMOUNT pInterface));
1094} PDMIBLOCKMOUNT;
1095
1096/**
1097 * BIOS translation mode.
1098 */
1099typedef enum PDMBIOSTRANSLATION
1100{
1101 /** No translation. */
1102 PDMBIOSTRANSLATION_NONE = 1,
1103 /** LBA translation. */
1104 PDMBIOSTRANSLATION_LBA,
1105 /** Automatic select mode. */
1106 PDMBIOSTRANSLATION_AUTO
1107} PDMBIOSTRANSLATION;
1108
1109/** Pointer to BIOS translation mode. */
1110typedef PDMBIOSTRANSLATION *PPDMBIOSTRANSLATION;
1111
1112/** Pointer to a media interface. */
1113typedef struct PDMIMEDIA *PPDMIMEDIA;
1114/**
1115 * Media interface.
1116 * Makes up the fundation for PDMIBLOCK and PDMIBLOCKBIOS.
1117 */
1118typedef struct PDMIMEDIA
1119{
1120 /**
1121 * Read bits.
1122 *
1123 * @returns VBox status code.
1124 * @param pInterface Pointer to the interface structure containing the called function pointer.
1125 * @param off Offset to start reading from.
1126 * @param pvBuf Where to store the read bits.
1127 * @param cbRead Number of bytes to read.
1128 * @thread Any thread.
1129 */
1130 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead));
1131
1132 /**
1133 * Write bits.
1134 *
1135 * @returns VBox status code.
1136 * @param pInterface Pointer to the interface structure containing the called function pointer.
1137 * @param off Offset to start writing at.
1138 * @param pvBuf Where to store the write bits.
1139 * @param cbWrite Number of bytes to write.
1140 * @thread Any thread.
1141 */
1142 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite));
1143
1144 /**
1145 * Make sure that the bits written are actually on the storage medium.
1146 *
1147 * @returns VBox status code.
1148 * @param pInterface Pointer to the interface structure containing the called function pointer.
1149 * @thread Any thread.
1150 */
1151 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIMEDIA pInterface));
1152
1153 /**
1154 * Get the media size in bytes.
1155 *
1156 * @returns Media size in bytes.
1157 * @param pInterface Pointer to the interface structure containing the called function pointer.
1158 * @thread Any thread.
1159 */
1160 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIMEDIA pInterface));
1161
1162 /**
1163 * Check if the media is readonly or not.
1164 *
1165 * @returns true if readonly.
1166 * @returns false if read/write.
1167 * @param pInterface Pointer to the interface structure containing the called function pointer.
1168 * @thread Any thread.
1169 */
1170 DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIMEDIA pInterface));
1171
1172 /**
1173 * Get stored media geometry - BIOS property.
1174 * This is an optional feature of a media.
1175 *
1176 * @returns VBox status code.
1177 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1178 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnBiosSetGeometry() yet.
1179 * @param pInterface Pointer to the interface structure containing the called function pointer.
1180 * @param pcCylinders Number of cylinders.
1181 * @param pcHeads Number of heads.
1182 * @param pcSectors Number of sectors. This number is 1-based.
1183 * @remark This have no influence on the read/write operations.
1184 * @thread Any thread.
1185 */
1186 DECLR3CALLBACKMEMBER(int, pfnBiosGetGeometry,(PPDMIMEDIA pInterface, uint32_t *pcCylinders, uint32_t *pcHeads, uint32_t *pcSectors));
1187
1188 /**
1189 * Store the media geometry - BIOS property.
1190 * This is an optional feature of a media.
1191 *
1192 * @returns VBox status code.
1193 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1194 * @param pInterface Pointer to the interface structure containing the called function pointer.
1195 * @param cCylinders Number of cylinders.
1196 * @param cHeads Number of heads.
1197 * @param cSectors Number of sectors. This number is 1-based.
1198 * @remark This have no influence on the read/write operations.
1199 * @thread The emulation thread.
1200 */
1201 DECLR3CALLBACKMEMBER(int, pfnBiosSetGeometry,(PPDMIMEDIA pInterface, uint32_t cCylinders, uint32_t cHeads, uint32_t cSectors));
1202
1203 /**
1204 * Get stored geometry translation mode - BIOS property.
1205 * This is an optional feature of a media.
1206 *
1207 * @returns VBox status code.
1208 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry translation mode.
1209 * @returns VERR_PDM_TRANSLATION_NOT_SET if the translation hasn't been set using pfnBiosSetTranslation() yet.
1210 * @param pInterface Pointer to the interface structure containing the called function pointer.
1211 * @param penmTranslation Where to store the translation type.
1212 * @remark This have no influence on the read/write operations.
1213 * @thread Any thread.
1214 */
1215 DECLR3CALLBACKMEMBER(int, pfnBiosGetTranslation,(PPDMIMEDIA pInterface, PPDMBIOSTRANSLATION penmTranslation));
1216
1217 /**
1218 * Store media geometry - BIOS property.
1219 * This is an optional feature of a media.
1220 *
1221 * @returns VBox status code.
1222 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1223 * @param pInterface Pointer to the interface structure containing the called function pointer.
1224 * @param enmTranslation The translation type.
1225 * @remark This have no influence on the read/write operations.
1226 * @thread The emulation thread.
1227 */
1228 DECLR3CALLBACKMEMBER(int, pfnBiosSetTranslation,(PPDMIMEDIA pInterface, PDMBIOSTRANSLATION enmTranslation));
1229
1230 /**
1231 * Gets the UUID of the media drive.
1232 *
1233 * @returns VBox status code.
1234 * @param pInterface Pointer to the interface structure containing the called function pointer.
1235 * @param pUuid Where to store the UUID on success.
1236 * @thread Any thread.
1237 */
1238 DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIMEDIA pInterface, PRTUUID pUuid));
1239
1240} PDMIMEDIA;
1241
1242
1243/** Pointer to a block BIOS interface. */
1244typedef struct PDMIBLOCKBIOS *PPDMIBLOCKBIOS;
1245/**
1246 * Media BIOS interface.
1247 * The interface the getting and setting properties which the BIOS/CMOS care about.
1248 */
1249typedef struct PDMIBLOCKBIOS
1250{
1251 /**
1252 * Get stored media geometry - BIOS property.
1253 * This is an optional feature of a media.
1254 *
1255 * @returns VBox status code.
1256 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1257 * @param pInterface Pointer to the interface structure containing the called function pointer.
1258 * @param pcCylinders Number of cylinders.
1259 * @param pcHeads Number of heads.
1260 * @param pcSectors Number of sectors. This number is 1-based.
1261 * @remark This have no influence on the read/write operations.
1262 * @thread Any thread.
1263 */
1264 DECLR3CALLBACKMEMBER(int, pfnGetGeometry,(PPDMIBLOCKBIOS pInterface, uint32_t *pcCylinders, uint32_t *pcHeads, uint32_t *pcSectors));
1265
1266 /**
1267 * Store the media geometry - BIOS property.
1268 * This is an optional feature of a media.
1269 *
1270 * @returns VBox status code.
1271 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1272 * @param pInterface Pointer to the interface structure containing the called function pointer.
1273 * @param cCylinders Number of cylinders.
1274 * @param cHeads Number of heads.
1275 * @param cSectors Number of sectors. This number is 1-based.
1276 * @remark This have no influence on the read/write operations.
1277 * @thread The emulation thread.
1278 */
1279 DECLR3CALLBACKMEMBER(int, pfnSetGeometry,(PPDMIBLOCKBIOS pInterface, uint32_t cCylinders, uint32_t cHeads, uint32_t cSectors));
1280
1281 /**
1282 * Get stored geometry translation mode - BIOS property.
1283 * This is an optional feature of a media.
1284 *
1285 * @returns VBox status code.
1286 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry translation mode.
1287 * @param pInterface Pointer to the interface structure containing the called function pointer.
1288 * @param penmTranslation Where to store the translation type.
1289 * @remark This have no influence on the read/write operations.
1290 * @thread Any thread.
1291 */
1292 DECLR3CALLBACKMEMBER(int, pfnGetTranslation,(PPDMIBLOCKBIOS pInterface, PPDMBIOSTRANSLATION penmTranslation));
1293
1294 /**
1295 * Store media geometry - BIOS property.
1296 * This is an optional feature of a media.
1297 *
1298 * @returns VBox status code.
1299 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1300 * @param pInterface Pointer to the interface structure containing the called function pointer.
1301 * @param enmTranslation The translation type.
1302 * @remark This have no influence on the read/write operations.
1303 * @thread The emulation thread.
1304 */
1305 DECLR3CALLBACKMEMBER(int, pfnSetTranslation,(PPDMIBLOCKBIOS pInterface, PDMBIOSTRANSLATION enmTranslation));
1306
1307 /**
1308 * Checks if the device should be visible to the BIOS or not.
1309 *
1310 * @returns true if the device is visible to the BIOS.
1311 * @returns false if the device is not visible to the BIOS.
1312 * @param pInterface Pointer to the interface structure containing the called function pointer.
1313 * @thread Any thread.
1314 */
1315 DECLR3CALLBACKMEMBER(bool, pfnIsVisible,(PPDMIBLOCKBIOS pInterface));
1316
1317 /**
1318 * Gets the block drive type.
1319 *
1320 * @returns block drive type.
1321 * @param pInterface Pointer to the interface structure containing the called function pointer.
1322 * @thread Any thread.
1323 */
1324 DECLR3CALLBACKMEMBER(PDMBLOCKTYPE, pfnGetType,(PPDMIBLOCKBIOS pInterface));
1325
1326} PDMIBLOCKBIOS;
1327
1328
1329/** Pointer to a static block core driver interface. */
1330typedef struct PDMIMEDIASTATIC *PPDMIMEDIASTATIC;
1331/**
1332 * Static block core driver interface.
1333 */
1334typedef struct PDMIMEDIASTATIC
1335{
1336 /**
1337 * Check if the specified file is a format which the core driver can handle.
1338 *
1339 * @returns true / false accordingly.
1340 * @param pInterface Pointer to the interface structure containing the called function pointer.
1341 * @param pszFilename Name of the file to probe.
1342 */
1343 DECLR3CALLBACKMEMBER(bool, pfnCanHandle,(PPDMIMEDIASTATIC pInterface, const char *pszFilename));
1344} PDMIMEDIASTATIC;
1345
1346
1347/** Pointer to an iSCSI Request PDU buffer. */
1348typedef struct ISCSIREQ *PISCSIREQ;
1349/**
1350 * iSCSI Request PDU buffer (gather).
1351 */
1352typedef struct ISCSIREQ
1353{
1354 /** Length of PDU segment in bytes. */
1355 size_t cbSeg;
1356 /** Pointer to PDU segment. */
1357 const void *pcvSeg;
1358} ISCSIREQ;
1359
1360/** Pointer to an iSCSI Response PDU buffer. */
1361typedef struct ISCSIRES *PISCSIRES;
1362/**
1363 * iSCSI Response PDU buffer (scatter).
1364 */
1365typedef struct ISCSIRES
1366{
1367 /** Length of PDU segment. */
1368 size_t cbSeg;
1369 /** Pointer to PDU segment. */
1370 void *pvSeg;
1371} ISCSIRES;
1372
1373/** Pointer to an iSCSI transport driver interface. */
1374typedef struct PDMIISCSITRANSPORT *PPDMIISCSITRANSPORT;
1375/**
1376 * iSCSI transport driver interface.
1377 */
1378typedef struct PDMIISCSITRANSPORT
1379{
1380 /**
1381 * Read bytes from an iSCSI transport stream. If the connection fails, it is automatically
1382 * reopened on the next call after the error is signalled. Error recovery in this case is
1383 * the duty of the caller.
1384 *
1385 * @returns VBox status code.
1386 * @param pTransport Pointer to the interface structure containing the called function pointer.
1387 * @param pvBuf Where to store the read bits.
1388 * @param cbBuf Number of bytes to read.
1389 * @param pcbRead Actual number of bytes read.
1390 * @thread Any thread.
1391 * @todo Correct the docs.
1392 */
1393 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIISCSITRANSPORT pTransport, PISCSIRES prgResponse, unsigned int cnResponse));
1394
1395 /**
1396 * Write bytes to an iSCSI transport stream. Padding is performed when necessary. If the connection
1397 * fails, it is automatically reopened on the next call after the error is signalled. Error recovery
1398 * in this case is the duty of the caller.
1399 *
1400 * @returns VBox status code.
1401 * @param pTransport Pointer to the interface structure containing the called function pointer.
1402 * @param pvBuf Where the write bits are stored.
1403 * @param cbWrite Number of bytes to write.
1404 * @thread Any thread.
1405 * @todo Correct the docs.
1406 */
1407 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIISCSITRANSPORT pTransport, PISCSIREQ prgRequest, unsigned int cnRequest));
1408
1409 /**
1410 * Open the iSCSI transport stream.
1411 *
1412 * @returns VBox status code.
1413 * @param pTransport Pointer to the interface structure containing the called function pointer.
1414 * @param pszTargetAddress Pointer to string of the format address:port.
1415 * @thread Any thread.
1416 */
1417 DECLR3CALLBACKMEMBER(int, pfnOpen,(PPDMIISCSITRANSPORT pTransport, const char *pszTargetAddress));
1418
1419 /**
1420 * Close the iSCSI transport stream.
1421 *
1422 * @returns VBox status code.
1423 * @param pTransport Pointer to the interface structure containing the called function pointer.
1424 * @thread Any thread.
1425 */
1426 DECLR3CALLBACKMEMBER(int, pfnClose,(PPDMIISCSITRANSPORT pTransport));
1427} PDMIISCSITRANSPORT;
1428
1429
1430/** Pointer to a char port interface. */
1431typedef struct PDMICHARPORT *PPDMICHARPORT;
1432/**
1433 * Char port interface.
1434 * Pair with PDMICHAR.
1435 */
1436typedef struct PDMICHARPORT
1437{
1438 /**
1439 * Deliver data read to the device/driver.
1440 *
1441 * @returns VBox status code.
1442 * @param pInterface Pointer to the interface structure containing the called function pointer.
1443 * @param pvBuf Where the read bits are stored.
1444 * @param pcbRead Number of bytes available for reading/having been read.
1445 * @thread Any thread.
1446 */
1447 DECLR3CALLBACKMEMBER(int, pfnNotifyRead,(PPDMICHARPORT pInterface, const void *pvBuf, size_t *pcbRead));
1448} PDMICHARPORT;
1449
1450/** Pointer to a char interface. */
1451typedef struct PDMICHAR *PPDMICHAR;
1452/**
1453 * Char interface.
1454 * Pair with PDMICHARPORT.
1455 */
1456typedef struct PDMICHAR
1457{
1458 /**
1459 * Write bits.
1460 *
1461 * @returns VBox status code.
1462 * @param pInterface Pointer to the interface structure containing the called function pointer.
1463 * @param pvBuf Where to store the write bits.
1464 * @param cbWrite Number of bytes to write.
1465 * @thread Any thread.
1466 */
1467 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMICHAR pInterface, const void *pvBuf, size_t cbWrite));
1468} PDMICHAR;
1469
1470
1471/** Pointer to a stream interface. */
1472typedef struct PDMISTREAM *PPDMISTREAM;
1473/**
1474 * Stream interface.
1475 * Makes up the fundation for PDMICHAR.
1476 */
1477typedef struct PDMISTREAM
1478{
1479 /**
1480 * Read bits.
1481 *
1482 * @returns VBox status code.
1483 * @param pInterface Pointer to the interface structure containing the called function pointer.
1484 * @param pvBuf Where to store the read bits.
1485 * @param cbRead Number of bytes to read/bytes actually read.
1486 * @thread Any thread.
1487 */
1488 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMISTREAM pInterface, void *pvBuf, size_t *cbRead));
1489
1490 /**
1491 * Write bits.
1492 *
1493 * @returns VBox status code.
1494 * @param pInterface Pointer to the interface structure containing the called function pointer.
1495 * @param pvBuf Where to store the write bits.
1496 * @param cbWrite Number of bytes to write/bytes actually written.
1497 * @thread Any thread.
1498 */
1499 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMISTREAM pInterface, const void *pvBuf, size_t *cbWrite));
1500} PDMISTREAM;
1501
1502
1503/** ACPI power source identifier */
1504typedef enum PDMACPIPOWERSOURCE
1505{
1506 PDM_ACPI_POWER_SOURCE_UNKNOWN = 0,
1507 PDM_ACPI_POWER_SOURCE_OUTLET,
1508 PDM_ACPI_POWER_SOURCE_BATTERY
1509} PDMACPIPOWERSOURCE;
1510/** Pointer to ACPI battery state. */
1511typedef PDMACPIPOWERSOURCE *PPDMACPIPOWERSOURCE;
1512
1513/** ACPI battey capacity */
1514typedef enum PDMACPIBATCAPACITY
1515{
1516 PDM_ACPI_BAT_CAPACITY_MIN = 0,
1517 PDM_ACPI_BAT_CAPACITY_MAX = 100,
1518 PDM_ACPI_BAT_CAPACITY_UNKNOWN = 255
1519} PDMACPIBATCAPACITY;
1520/** Pointer to ACPI battery capacity. */
1521typedef PDMACPIBATCAPACITY *PPDMACPIBATCAPACITY;
1522
1523/** ACPI battery state. See ACPI 3.0 spec '_BST (Battery Status)' */
1524typedef enum PDMACPIBATSTATE
1525{
1526 PDM_ACPI_BAT_STATE_CHARGED = 0x00,
1527 PDM_ACPI_BAT_STATE_CHARGING = 0x01,
1528 PDM_ACPI_BAT_STATE_DISCHARGING = 0x02,
1529 PDM_ACPI_BAT_STATE_CRITICAL = 0x04
1530} PDMACPIBATSTATE;
1531/** Pointer to ACPI battery state. */
1532typedef PDMACPIBATSTATE *PPDMACPIBATSTATE;
1533
1534/** Pointer to an ACPI port interface. */
1535typedef struct PDMIACPIPORT *PPDMIACPIPORT;
1536/**
1537 * ACPI port interface.
1538 */
1539typedef struct PDMIACPIPORT
1540{
1541 /**
1542 * Send an ACPI power off event.
1543 *
1544 * @returns VBox status code
1545 * @param pInterface Pointer to the interface structure containing the called function pointer.
1546 */
1547 DECLR3CALLBACKMEMBER(int, pfnPowerButtonPress,(PPDMIACPIPORT pInterface));
1548} PDMIACPIPORT;
1549
1550/** Pointer to an ACPI connector interface. */
1551typedef struct PDMIACPICONNECTOR *PPDMIACPICONNECTOR;
1552/**
1553 * ACPI connector interface.
1554 */
1555typedef struct PDMIACPICONNECTOR
1556{
1557 /**
1558 * Get the current power source of the host system.
1559 *
1560 * @returns VBox status code
1561 * @param pInterface Pointer to the interface structure containing the called function pointer.
1562 * @param penmPowerSource Pointer to the power source result variable.
1563 */
1564 DECLR3CALLBACKMEMBER(int, pfnQueryPowerSource,(PPDMIACPICONNECTOR, PPDMACPIPOWERSOURCE penmPowerSource));
1565
1566 /**
1567 * Query the current battery status of the host system.
1568 *
1569 * @returns VBox status code?
1570 * @param pInterface Pointer to the interface structure containing the called function pointer.
1571 * @param pfPresent Is set to true if battery is present, false otherwise.
1572 * @param penmRemainingCapacity Pointer to the battery remaining capacity (0 - 100 or 255 for unknown).
1573 * @param penmBatteryState Pointer to the battery status.
1574 * @param pu32PresentRate Pointer to the present rate (0..1000 of the total capacity).
1575 */
1576 DECLR3CALLBACKMEMBER(int, pfnQueryBatteryStatus,(PPDMIACPICONNECTOR, bool *pfPresent, PPDMACPIBATCAPACITY penmRemainingCapacity,
1577 PPDMACPIBATSTATE penmBatteryState, uint32_t *pu32PresentRate));
1578} PDMIACPICONNECTOR;
1579
1580/** Pointer to a VMMDevice port interface. */
1581typedef struct PDMIVMMDEVPORT *PPDMIVMMDEVPORT;
1582/**
1583 * VMMDevice port interface.
1584 */
1585typedef struct PDMIVMMDEVPORT
1586{
1587 /**
1588 * Return the current absolute mouse position in pixels
1589 *
1590 * @returns VBox status code
1591 * @param pAbsX Pointer of result value, can be NULL
1592 * @param pAbsY Pointer of result value, can be NULL
1593 */
1594 DECLR3CALLBACKMEMBER(int, pfnQueryAbsoluteMouse,(PPDMIVMMDEVPORT pInterface, uint32_t *pAbsX, uint32_t *pAbsY));
1595
1596 /**
1597 * Set the new absolute mouse position in pixels
1598 *
1599 * @returns VBox status code
1600 * @param absX New absolute X position
1601 * @param absY New absolute Y position
1602 */
1603 DECLR3CALLBACKMEMBER(int, pfnSetAbsoluteMouse,(PPDMIVMMDEVPORT pInterface, uint32_t absX, uint32_t absY));
1604
1605 /**
1606 * Return the current mouse capability flags
1607 *
1608 * @returns VBox status code
1609 * @param pCapabilities Pointer of result value
1610 */
1611 DECLR3CALLBACKMEMBER(int, pfnQueryMouseCapabilities,(PPDMIVMMDEVPORT pInterface, uint32_t *pCapabilities));
1612
1613 /**
1614 * Set the current mouse capability flag (host side)
1615 *
1616 * @returns VBox status code
1617 * @param capabilities Capability mask
1618 */
1619 DECLR3CALLBACKMEMBER(int, pfnSetMouseCapabilities,(PPDMIVMMDEVPORT pInterface, uint32_t capabilities));
1620
1621 /**
1622 * Issue a display resolution change request.
1623 *
1624 * Note that there can only one request in the queue and that in case the guest does
1625 * not process it, issuing another request will overwrite the previous.
1626 *
1627 * @returns VBox status code
1628 * @param cx Horizontal pixel resolution (0 = do not change).
1629 * @param cy Vertical pixel resolution (0 = do not change).
1630 * @param cBits Bits per pixel (0 = do not change).
1631 */
1632 DECLR3CALLBACKMEMBER(int, pfnRequestDisplayChange,(PPDMIVMMDEVPORT pInterface, uint32_t cx, uint32_t cy, uint32_t cBits));
1633
1634 /**
1635 * Pass credentials to guest.
1636 *
1637 * Note that there can only be one set of credentials and the guest may or may not
1638 * query them and may do whatever it wants with them.
1639 *
1640 * @returns VBox status code
1641 * @param pszUsername User name, may be empty (UTF-8)
1642 * @param pszPassword Password, may be empty (UTF-8)
1643 * @param pszDomain Domain name, may be empty (UTF-8)
1644 * @param fFlags Bitflags
1645 */
1646 DECLR3CALLBACKMEMBER(int, pfnSetCredentials,(PPDMIVMMDEVPORT pInterface, const char *pszUsername,
1647 const char *pszPassword, const char *pszDomain,
1648 uint32_t fFlags));
1649
1650 /**
1651 * Notify the driver about a VBVA status change.
1652 *
1653 * @returns Nothing. Because it is informational callback.
1654 * @param fEnabled Current VBVA status.
1655 */
1656 DECLCALLBACKMEMBER(void, pfnVBVAChange)(PPDMIVMMDEVPORT pInterface, bool fEnabled);
1657
1658} PDMIVMMDEVPORT;
1659
1660/** Forward declaration of the video accelerator command memory. */
1661struct _VBVAMEMORY;
1662/** Forward declaration of the guest information structure. */
1663struct VBoxGuestInfo;
1664/** Pointer to video accelerator command memory. */
1665typedef struct _VBVAMEMORY *PVBVAMEMORY;
1666
1667/** Pointer to a VMMDev connector interface. */
1668typedef struct PDMIVMMDEVCONNECTOR *PPDMIVMMDEVCONNECTOR;
1669/**
1670 * VMMDev connector interface.
1671 * Pair with PDMIVMMDEVPORT.
1672 */
1673typedef struct PDMIVMMDEVCONNECTOR
1674{
1675 /**
1676 * Report guest OS version.
1677 * Called whenever the Additions issue a guest version report request.
1678 *
1679 * @param pInterface Pointer to this interface.
1680 * @param pGuestInfo Pointer to guest information structure
1681 * @thread The emulation thread.
1682 */
1683 DECLR3CALLBACKMEMBER(void, pfnUpdateGuestVersion,(PPDMIVMMDEVCONNECTOR pInterface, struct VBoxGuestInfo *pGuestInfo));
1684
1685 /**
1686 * Update the mouse capabilities.
1687 * This is called when the mouse capabilities change. The new capabilities
1688 * are given and the connector should update its internal state.
1689 *
1690 * @param pInterface Pointer to this interface.
1691 * @param newCapabilities New capabilities.
1692 * @thread The emulation thread.
1693 */
1694 DECLR3CALLBACKMEMBER(void, pfnUpdateMouseCapabilities,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities));
1695
1696 /**
1697 * Update the pointer shape.
1698 * This is called when the mouse pointer shape changes. The new shape
1699 * is passed as a caller allocated buffer that will be freed after returning
1700 *
1701 * @param pInterface Pointer to this interface.
1702 * @param fVisible Visibility indicator (if false, the other parameters are undefined).
1703 * @param fAlpha Flag whether alpha channel is being passed.
1704 * @param xHot Pointer hot spot x coordinate.
1705 * @param yHot Pointer hot spot y coordinate.
1706 * @param x Pointer new x coordinate on screen.
1707 * @param y Pointer new y coordinate on screen.
1708 * @param cx Pointer width in pixels.
1709 * @param cy Pointer height in pixels.
1710 * @param cbScanline Size of one scanline in bytes.
1711 * @param pvShape New shape buffer.
1712 * @thread The emulation thread.
1713 */
1714 DECLR3CALLBACKMEMBER(void, pfnUpdatePointerShape,(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
1715 uint32_t xHot, uint32_t yHot,
1716 uint32_t cx, uint32_t cy,
1717 void *pvShape));
1718
1719 /**
1720 * Enable or disable video acceleration on behalf of guest.
1721 *
1722 * @param pInterface Pointer to this interface.
1723 * @param fEnable Whether to enable acceleration.
1724 * @param pVbvaMemory Video accelerator memory.
1725
1726 * @return VBox rc. VINF_SUCCESS if VBVA was enabled.
1727 * @thread The emulation thread.
1728 */
1729 DECLR3CALLBACKMEMBER(int, pfnVideoAccelEnable,(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, PVBVAMEMORY pVbvaMemory));
1730
1731 /**
1732 * Force video queue processing.
1733 *
1734 * @param pInterface Pointer to this interface.
1735 * @thread The emulation thread.
1736 */
1737 DECLR3CALLBACKMEMBER(void, pfnVideoAccelFlush,(PPDMIVMMDEVCONNECTOR pInterface));
1738
1739 /**
1740 * Return whether the given video mode is supported/wanted by the host.
1741 *
1742 * @returns VBox status code
1743 * @param pInterface Pointer to this interface.
1744 * @param cy Video mode horizontal resolution in pixels.
1745 * @param cx Video mode vertical resolution in pixels.
1746 * @param cBits Video mode bits per pixel.
1747 * @param pfSupported Where to put the indicator for whether this mode is supported. (output)
1748 * @thread The emulation thread.
1749 */
1750 DECLR3CALLBACKMEMBER(int, pfnVideoModeSupported,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cx, uint32_t cy, uint32_t cBits, bool *pfSupported));
1751
1752 /**
1753 * Queries by how many pixels the height should be reduced when calculating video modes
1754 *
1755 * @returns VBox status code
1756 * @param pInterface Pointer to this interface.
1757 * @param pcyReduction Pointer to the result value.
1758 * @thread The emulation thread.
1759 */
1760 DECLR3CALLBACKMEMBER(int, pfnGetHeightReduction,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcyReduction));
1761
1762 /**
1763 * Informs about a credentials judgement result from the guest.
1764 *
1765 * @returns VBox status code
1766 * @param pInterface Pointer to this interface.
1767 * @param fFlags Judgement result flags.
1768 * @thread The emulation thread.
1769 */
1770 DECLR3CALLBACKMEMBER(int, pfnSetCredentialsJudgementResult,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fFlags));
1771} PDMIVMMDEVCONNECTOR;
1772
1773
1774/**
1775 * MAC address.
1776 * (The first 24 bits are the 'company id', where the first bit seems to have a special meaning if set.)
1777 */
1778typedef union PDMMAC
1779{
1780 /** 8-bit view. */
1781 uint8_t au8[6];
1782 /** 16-bit view. */
1783 uint16_t au16[3];
1784} PDMMAC;
1785/** Pointer to a MAC address. */
1786typedef PDMMAC *PPDMMAC;
1787/** Pointer to a const MAC address. */
1788typedef const PDMMAC *PCPDMMAC;
1789
1790
1791/** Pointer to a network port interface */
1792typedef struct PDMINETWORKPORT *PPDMINETWORKPORT;
1793/**
1794 * Network port interface.
1795 */
1796typedef struct PDMINETWORKPORT
1797{
1798 /**
1799 * Check how much data the device/driver can receive data now.
1800 * This must be called before the pfnRecieve() method is called.
1801 *
1802 * @returns Number of bytes the device can receive now.
1803 * @param pInterface Pointer to the interface structure containing the called function pointer.
1804 * @thread EMT
1805 */
1806 DECLR3CALLBACKMEMBER(size_t, pfnCanReceive,(PPDMINETWORKPORT pInterface));
1807
1808 /**
1809 * Receive data from the network.
1810 *
1811 * @returns VBox status code.
1812 * @param pInterface Pointer to the interface structure containing the called function pointer.
1813 * @param pvBuf The available data.
1814 * @param cb Number of bytes available in the buffer.
1815 * @thread EMT
1816 */
1817 DECLR3CALLBACKMEMBER(int, pfnReceive,(PPDMINETWORKPORT pInterface, const void *pvBuf, size_t cb));
1818
1819} PDMINETWORKPORT;
1820
1821
1822/**
1823 * Network link state.
1824 */
1825typedef enum PDMNETWORKLINKSTATE
1826{
1827 /** Invalid state. */
1828 PDMNETWORKLINKSTATE_INVALID = 0,
1829 /** The link is up. */
1830 PDMNETWORKLINKSTATE_UP,
1831 /** The link is down. */
1832 PDMNETWORKLINKSTATE_DOWN,
1833 /** The link is temporarily down while resuming. */
1834 PDMNETWORKLINKSTATE_DOWN_RESUME
1835} PDMNETWORKLINKSTATE;
1836
1837
1838/** Pointer to a network connector interface */
1839typedef struct PDMINETWORKCONNECTOR *PPDMINETWORKCONNECTOR;
1840/**
1841 * Network connector interface.
1842 */
1843typedef struct PDMINETWORKCONNECTOR
1844{
1845 /**
1846 * Send data to the network.
1847 *
1848 * @returns VBox status code.
1849 * @param pInterface Pointer to the interface structure containing the called function pointer.
1850 * @param pvBuf Data to send.
1851 * @param cb Number of bytes to send.
1852 * @thread EMT
1853 */
1854 DECLR3CALLBACKMEMBER(int, pfnSend,(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb));
1855
1856 /**
1857 * Set promiscuous mode.
1858 *
1859 * This is called when the promiscuous mode is set. This means that there doesn't have
1860 * to be a mode change when it's called.
1861 *
1862 * @param pInterface Pointer to the interface structure containing the called function pointer.
1863 * @param fPromiscuous Set if the adaptor is now in promiscuous mode. Clear if it is not.
1864 * @thread EMT
1865 */
1866 DECLR3CALLBACKMEMBER(void, pfnSetPromiscuousMode,(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous));
1867
1868 /**
1869 * Notification on link status changes.
1870 *
1871 * @param pInterface Pointer to the interface structure containing the called function pointer.
1872 * @param enmLinkState The new link state.
1873 * @thread EMT
1874 */
1875 DECLR3CALLBACKMEMBER(void, pfnNotifyLinkChanged,(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState));
1876
1877 /**
1878 * More receive buffer has become available.
1879 *
1880 * This is called when the NIC frees up receive buffers.
1881 *
1882 * @param pInterface Pointer to the interface structure containing the called function pointer.
1883 * @remark This function isn't called by pcnet nor yet.
1884 * @thread EMT
1885 */
1886 DECLR3CALLBACKMEMBER(void, pfnNotifyCanReceive,(PPDMINETWORKCONNECTOR pInterface));
1887
1888} PDMINETWORKCONNECTOR;
1889
1890
1891/** Pointer to a network config port interface */
1892typedef struct PDMINETWORKCONFIG *PPDMINETWORKCONFIG;
1893/**
1894 * Network config port interface.
1895 */
1896typedef struct PDMINETWORKCONFIG
1897{
1898 /**
1899 * Gets the current Media Access Control (MAC) address.
1900 *
1901 * @returns VBox status code.
1902 * @param pInterface Pointer to the interface structure containing the called function pointer.
1903 * @param pMac Where to store the MAC address.
1904 * @thread EMT
1905 */
1906 DECLR3CALLBACKMEMBER(int, pfnGetMac,(PPDMINETWORKCONFIG pInterface, PPDMMAC *pMac));
1907
1908 /**
1909 * Gets the new link state.
1910 *
1911 * @returns The current link state.
1912 * @param pInterface Pointer to the interface structure containing the called function pointer.
1913 * @thread EMT
1914 */
1915 DECLR3CALLBACKMEMBER(PDMNETWORKLINKSTATE, pfnGetLinkState,(PPDMINETWORKCONFIG pInterface));
1916
1917 /**
1918 * Sets the new link state.
1919 *
1920 * @returns VBox status code.
1921 * @param pInterface Pointer to the interface structure containing the called function pointer.
1922 * @param enmState The new link state
1923 * @thread EMT
1924 */
1925 DECLR3CALLBACKMEMBER(int, pfnSetLinkState,(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState));
1926
1927} PDMINETWORKCONFIG;
1928
1929
1930/** Pointer to a network connector interface */
1931typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
1932/**
1933 * Audio connector interface.
1934 */
1935typedef struct PDMIAUDIOCONNECTOR
1936{
1937 DECLR3CALLBACKMEMBER(void, pfnRun,(PPDMIAUDIOCONNECTOR pInterface));
1938
1939/* DECLR3CALLBACKMEMBER(int, pfnSetRecordSource,(PPDMIAUDIOINCONNECTOR pInterface, AUDIORECSOURCE)); */
1940
1941} PDMIAUDIOCONNECTOR;
1942
1943
1944/** @todo r=bird: the two following interfaces are hacks to work around the missing audio driver
1945 * interface. This should be addressed rather than making more temporary hacks. */
1946
1947/** Pointer to a Audio Sniffer Device port interface. */
1948typedef struct PDMIAUDIOSNIFFERPORT *PPDMIAUDIOSNIFFERPORT;
1949
1950/**
1951 * Audio Sniffer port interface.
1952 */
1953typedef struct PDMIAUDIOSNIFFERPORT
1954{
1955 /**
1956 * Enables or disables sniffing. If sniffing is being enabled also sets a flag
1957 * whether the audio must be also left on the host.
1958 *
1959 * @returns VBox status code
1960 * @param pInterface Pointer to this interface.
1961 * @param fEnable 'true' for enable sniffing, 'false' to disable.
1962 * @param fKeepHostAudio Indicates whether host audio should also present
1963 * 'true' means that sound should not be played
1964 * by the audio device.
1965 */
1966 DECLR3CALLBACKMEMBER(int, pfnSetup,(PPDMIAUDIOSNIFFERPORT pInterface, bool fEnable, bool fKeepHostAudio));
1967
1968} PDMIAUDIOSNIFFERPORT;
1969
1970/** Pointer to a Audio Sniffer connector interface. */
1971typedef struct PDMIAUDIOSNIFFERCONNECTOR *PPDMIAUDIOSNIFFERCONNECTOR;
1972
1973/**
1974 * Audio Sniffer connector interface.
1975 * Pair with PDMIAUDIOSNIFFERPORT.
1976 */
1977typedef struct PDMIAUDIOSNIFFERCONNECTOR
1978{
1979 /**
1980 * AudioSniffer device calls this method when audio samples
1981 * are about to be played and sniffing is enabled.
1982 *
1983 * @param pInterface Pointer to this interface.
1984 * @param pvSamples Audio samples buffer.
1985 * @param cSamples How many complete samples are in the buffer.
1986 * @param iSampleHz The sample frequency in Hz.
1987 * @param cChannels Number of channels. 1 for mono, 2 for stereo.
1988 * @param cBits How many bits a sample for a single channel has. Normally 8 or 16.
1989 * @param fUnsigned Whether samples are unsigned values.
1990 * @thread The emulation thread.
1991 */
1992 DECLR3CALLBACKMEMBER(void, pfnAudioSamplesOut,(PPDMIAUDIOSNIFFERCONNECTOR pInterface, void *pvSamples, uint32_t cSamples,
1993 int iSampleHz, int cChannels, int cBits, bool fUnsigned));
1994
1995 /**
1996 * AudioSniffer device calls this method when output volume is changed.
1997 *
1998 * @param pInterface Pointer to this interface.
1999 * @param u16LeftVolume 0..0xFFFF volume level for left channel.
2000 * @param u16RightVolume 0..0xFFFF volume level for right channel.
2001 * @thread The emulation thread.
2002 */
2003 DECLR3CALLBACKMEMBER(void, pfnAudioVolumeOut,(PPDMIAUDIOSNIFFERCONNECTOR pInterface, uint16_t u16LeftVolume, uint16_t u16RightVolume));
2004
2005} PDMIAUDIOSNIFFERCONNECTOR;
2006
2007
2008/**
2009 * Generic status LED core.
2010 * Note that a unit doesn't have to support all the indicators.
2011 */
2012typedef union PDMLEDCORE
2013{
2014 /** 32-bit view. */
2015 uint32_t volatile u32;
2016 /** Bit view. */
2017 struct
2018 {
2019 /** Reading/Receiving indicator. */
2020 uint32_t fReading : 1;
2021 /** Writing/Sending indicator. */
2022 uint32_t fWriting : 1;
2023 /** Busy indicator. */
2024 uint32_t fBusy : 1;
2025 /** Error indicator. */
2026 uint32_t fError : 1;
2027 } s;
2028} PDMLEDCORE;
2029
2030/** LED bit masks for the u32 view.
2031 * @{ */
2032/** Reading/Receiving indicator. */
2033#define PDMLED_READING BIT(0)
2034/** Writing/Sending indicator. */
2035#define PDMLED_WRITING BIT(1)
2036/** Busy indicator. */
2037#define PDMLED_BUSY BIT(2)
2038/** Error indicator. */
2039#define PDMLED_ERROR BIT(3)
2040/** @} */
2041
2042
2043/**
2044 * Generic status LED.
2045 * Note that a unit doesn't have to support all the indicators.
2046 */
2047typedef struct PDMLED
2048{
2049 /** Just a magic for sanity checking. */
2050 uint32_t u32Magic;
2051 uint32_t u32Alignment; /**< structure size alignment. */
2052 /** The actual LED status.
2053 * Only the device is allowed to change this. */
2054 PDMLEDCORE Actual;
2055 /** The asserted LED status which is cleared by the reader.
2056 * The device will assert the bits but never clear them.
2057 * The driver clears them as it sees fit. */
2058 PDMLEDCORE Asserted;
2059} PDMLED;
2060
2061/** Pointer to an LED. */
2062typedef PDMLED *PPDMLED;
2063/** Pointer to a const LED. */
2064typedef const PDMLED *PCPDMLED;
2065
2066#define PDMLED_MAGIC ( 0x11335577 )
2067
2068/** Pointer to an LED ports interface. */
2069typedef struct PDMILEDPORTS *PPDMILEDPORTS;
2070/**
2071 * Interface for exporting LEDs.
2072 */
2073typedef struct PDMILEDPORTS
2074{
2075 /**
2076 * Gets the pointer to the status LED of a unit.
2077 *
2078 * @returns VBox status code.
2079 * @param pInterface Pointer to the interface structure containing the called function pointer.
2080 * @param iLUN The unit which status LED we desire.
2081 * @param ppLed Where to store the LED pointer.
2082 */
2083 DECLR3CALLBACKMEMBER(int, pfnQueryStatusLed,(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed));
2084
2085} PDMILEDPORTS;
2086
2087
2088/** Pointer to an LED connectors interface. */
2089typedef struct PDMILEDCONNECTORS *PPDMILEDCONNECTORS;
2090/**
2091 * Interface for reading LEDs.
2092 */
2093typedef struct PDMILEDCONNECTORS
2094{
2095 /**
2096 * Notification about a unit which have been changed.
2097 *
2098 * The driver must discard any pointers to data owned by
2099 * the unit and requery it.
2100 *
2101 * @param pInterface Pointer to the interface structure containing the called function pointer.
2102 * @param iLUN The unit number.
2103 */
2104 DECLR3CALLBACKMEMBER(void, pfnUnitChanged,(PPDMILEDCONNECTORS pInterface, unsigned iLUN));
2105} PDMILEDCONNECTORS;
2106
2107
2108/** The special status unit number */
2109#define PDM_STATUS_LUN 999
2110
2111
2112#ifdef VBOX_HGCM
2113
2114/** Abstract HGCM command structure. Used only to define a typed pointer. */
2115struct VBOXHGCMCMD;
2116
2117/** Pointer to HGCM command structure. This pointer is unique and identifies
2118 * the command being processed. The pointer is passed to HGCM connector methods,
2119 * and must be passed back to HGCM port when command is completed.
2120 */
2121typedef struct VBOXHGCMCMD *PVBOXHGCMCMD;
2122
2123/** Pointer to a HGCM port interface. */
2124typedef struct PDMIHGCMPORT *PPDMIHGCMPORT;
2125
2126/**
2127 * HGCM port interface. Normally implemented by VMMDev.
2128 */
2129typedef struct PDMIHGCMPORT
2130{
2131 /**
2132 * Notify the guest on a command completion.
2133 *
2134 * @param pInterface Pointer to this interface.
2135 * @param rc The return code (VBox error code).
2136 * @param pCmd A pointer that identifies the completed command.
2137 *
2138 * @returns VBox status code
2139 */
2140 DECLR3CALLBACKMEMBER(void, pfnCompleted,(PPDMIHGCMPORT pInterface, int32_t rc, PVBOXHGCMCMD pCmd));
2141
2142} PDMIHGCMPORT;
2143
2144
2145/** Pointer to a HGCM connector interface. */
2146typedef struct PDMIHGCMCONNECTOR *PPDMIHGCMCONNECTOR;
2147
2148/** Pointer to a HGCM function parameter. */
2149typedef struct VBOXHGCMSVCPARM *PVBOXHGCMSVCPARM;
2150
2151/** Pointer to a HGCM service location structure. */
2152typedef struct HGCMSERVICELOCATION *PHGCMSERVICELOCATION;
2153
2154/**
2155 * HGCM connector interface.
2156 * Pair with PDMIHGCMPORT.
2157 */
2158typedef struct PDMIHGCMCONNECTOR
2159{
2160 /**
2161 * Locate a service and inform it about a client connection.
2162 *
2163 * @param pInterface Pointer to this interface.
2164 * @param pCmd A pointer that identifies the command.
2165 * @param pServiceLocation Pointer to the service location structure.
2166 * @param pu32ClientID Where to store the client id for the connection.
2167 * @return VBox status code.
2168 * @thread The emulation thread.
2169 */
2170 DECLR3CALLBACKMEMBER(int, pfnConnect,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID));
2171
2172 /**
2173 * Disconnect from service.
2174 *
2175 * @param pInterface Pointer to this interface.
2176 * @param pCmd A pointer that identifies the command.
2177 * @param u32ClientID The client id returned by the pfnConnect call.
2178 * @return VBox status code.
2179 * @thread The emulation thread.
2180 */
2181 DECLR3CALLBACKMEMBER(int, pfnDisconnect,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID));
2182
2183 /**
2184 * Process a guest issued command.
2185 *
2186 * @param pInterface Pointer to this interface.
2187 * @param pCmd A pointer that identifies the command.
2188 * @param u32ClientID The client id returned by the pfnConnect call.
2189 * @param u32Function Function to be performed by the service.
2190 * @param cParms Number of parameters in the array pointed to by paParams.
2191 * @param paParms Pointer to an array of parameters.
2192 * @return VBox status code.
2193 * @thread The emulation thread.
2194 */
2195 DECLR3CALLBACKMEMBER(int, pfnCall,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
2196 uint32_t cParms, PVBOXHGCMSVCPARM paParms));
2197
2198} PDMIHGCMCONNECTOR;
2199
2200#endif
2201
2202/** @} */
2203
2204
2205/** @defgroup grp_pdm_driver Drivers
2206 * @ingroup grp_pdm
2207 * @{
2208 */
2209
2210
2211/**
2212 * Construct a driver instance for a VM.
2213 *
2214 * @returns VBox status.
2215 * @param pDrvIns The driver instance data.
2216 * If the registration structure is needed, pDrvIns->pDrvReg points to it.
2217 * @param pCfgHandle Configuration node handle for the driver. Use this to obtain the configuration
2218 * of the driver instance. It's also found in pDrvIns->pCfgHandle as it's expected
2219 * to be used frequently in this function.
2220 */
2221typedef DECLCALLBACK(int) FNPDMDRVCONSTRUCT(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
2222/** Pointer to a FNPDMDRVCONSTRUCT() function. */
2223typedef FNPDMDRVCONSTRUCT *PFNPDMDRVCONSTRUCT;
2224
2225/**
2226 * Destruct a driver instance.
2227 *
2228 * Most VM resources are freed by the VM. This callback is provided so that
2229 * any non-VM resources can be freed correctly.
2230 *
2231 * @param pDrvIns The driver instance data.
2232 */
2233typedef DECLCALLBACK(void) FNPDMDRVDESTRUCT(PPDMDRVINS pDrvIns);
2234/** Pointer to a FNPDMDRVDESTRUCT() function. */
2235typedef FNPDMDRVDESTRUCT *PFNPDMDRVDESTRUCT;
2236
2237/**
2238 * Driver I/O Control interface.
2239 *
2240 * This is used by external components, such as the COM interface, to
2241 * communicate with a driver using a driver specific interface. Generally,
2242 * the driver interfaces are used for this task.
2243 *
2244 * @returns VBox status code.
2245 * @param pDrvIns Pointer to the driver instance.
2246 * @param uFunction Function to perform.
2247 * @param pvIn Pointer to input data.
2248 * @param cbIn Size of input data.
2249 * @param pvOut Pointer to output data.
2250 * @param cbOut Size of output data.
2251 * @param pcbOut Where to store the actual size of the output data.
2252 */
2253typedef DECLCALLBACK(int) FNPDMDRVIOCTL(PPDMDRVINS pDrvIns, RTUINT uFunction,
2254 void *pvIn, RTUINT cbIn,
2255 void *pvOut, RTUINT cbOut, PRTUINT pcbOut);
2256/** Pointer to a FNPDMDRVIOCTL() function. */
2257typedef FNPDMDRVIOCTL *PFNPDMDRVIOCTL;
2258
2259/**
2260 * Power On notification.
2261 *
2262 * @param pDrvIns The driver instance data.
2263 */
2264typedef DECLCALLBACK(void) FNPDMDRVPOWERON(PPDMDRVINS pDrvIns);
2265/** Pointer to a FNPDMDRVPOWERON() function. */
2266typedef FNPDMDRVPOWERON *PFNPDMDRVPOWERON;
2267
2268/**
2269 * Reset notification.
2270 *
2271 * @returns VBox status.
2272 * @param pDrvIns The driver instance data.
2273 */
2274typedef DECLCALLBACK(void) FNPDMDRVRESET(PPDMDRVINS pDrvIns);
2275/** Pointer to a FNPDMDRVRESET() function. */
2276typedef FNPDMDRVRESET *PFNPDMDRVRESET;
2277
2278/**
2279 * Suspend notification.
2280 *
2281 * @returns VBox status.
2282 * @param pDrvIns The driver instance data.
2283 */
2284typedef DECLCALLBACK(void) FNPDMDRVSUSPEND(PPDMDRVINS pDrvIns);
2285/** Pointer to a FNPDMDRVSUSPEND() function. */
2286typedef FNPDMDRVSUSPEND *PFNPDMDRVSUSPEND;
2287
2288/**
2289 * Resume notification.
2290 *
2291 * @returns VBox status.
2292 * @param pDrvIns The driver instance data.
2293 */
2294typedef DECLCALLBACK(void) FNPDMDRVRESUME(PPDMDRVINS pDrvIns);
2295/** Pointer to a FNPDMDRVRESUME() function. */
2296typedef FNPDMDRVRESUME *PFNPDMDRVRESUME;
2297
2298/**
2299 * Power Off notification.
2300 *
2301 * @param pDrvIns The driver instance data.
2302 */
2303typedef DECLCALLBACK(void) FNPDMDRVPOWEROFF(PPDMDRVINS pDrvIns);
2304/** Pointer to a FNPDMDRVPOWEROFF() function. */
2305typedef FNPDMDRVPOWEROFF *PFNPDMDRVPOWEROFF;
2306
2307/**
2308 * Detach notification.
2309 *
2310 * This is called when a driver below it in the chain is detaching itself
2311 * from it. The driver should adjust it's state to reflect this.
2312 *
2313 * This is like ejecting a cdrom or floppy.
2314 *
2315 * @param pDrvIns The driver instance.
2316 */
2317typedef DECLCALLBACK(void) FNPDMDRVDETACH(PPDMDRVINS pDrvIns);
2318/** Pointer to a FNPDMDRVDETACH() function. */
2319typedef FNPDMDRVDETACH *PFNPDMDRVDETACH;
2320
2321
2322
2323/** PDM Driver Registration Structure,
2324 * This structure is used when registering a driver from
2325 * VBoxInitDrivers() (HC Ring-3). PDM will continue use till
2326 * the VM is terminated.
2327 */
2328typedef struct PDMDRVREG
2329{
2330 /** Structure version. PDM_DRVREG_VERSION defines the current version. */
2331 uint32_t u32Version;
2332 /** Driver name. */
2333 char szDriverName[32];
2334 /** The description of the driver. The UTF-8 string pointed to shall, like this structure,
2335 * remain unchanged from registration till VM destruction. */
2336 const char *pszDescription;
2337
2338 /** Flags, combination of the PDM_DRVREG_FLAGS_* \#defines. */
2339 RTUINT fFlags;
2340 /** Driver class(es), combination of the PDM_DRVREG_CLASS_* \#defines. */
2341 RTUINT fClass;
2342 /** Maximum number of instances (per VM). */
2343 RTUINT cMaxInstances;
2344 /** Size of the instance data. */
2345 RTUINT cbInstance;
2346
2347 /** Construct instance - required. */
2348 PFNPDMDRVCONSTRUCT pfnConstruct;
2349 /** Destruct instance - optional. */
2350 PFNPDMDRVDESTRUCT pfnDestruct;
2351 /** I/O control - optional. */
2352 PFNPDMDRVIOCTL pfnIOCtl;
2353 /** Power on notification - optional. */
2354 PFNPDMDRVPOWERON pfnPowerOn;
2355 /** Reset notification - optional. */
2356 PFNPDMDRVRESET pfnReset;
2357 /** Suspend notification - optional. */
2358 PFNPDMDRVSUSPEND pfnSuspend;
2359 /** Resume notification - optional. */
2360 PFNPDMDRVRESUME pfnResume;
2361 /** Detach notification - optional. */
2362 PFNPDMDRVDETACH pfnDetach;
2363 /** Power off notification - optional. */
2364 PFNPDMDRVPOWEROFF pfnPowerOff;
2365
2366} PDMDRVREG;
2367/** Pointer to a PDM Driver Structure. */
2368typedef PDMDRVREG *PPDMDRVREG;
2369/** Const pointer to a PDM Driver Structure. */
2370typedef PDMDRVREG const *PCPDMDRVREG;
2371
2372/** Current DRVREG version number. */
2373#define PDM_DRVREG_VERSION 0x80010000
2374
2375/** PDM Device Flags.
2376 * @{ */
2377/** @def PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT
2378 * The bit count for the current host. */
2379#if HC_ARCH_BITS == 32
2380# define PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT 0x000000001
2381#elif HC_ARCH_BITS == 64
2382# define PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT 0x000000002
2383#else
2384# error Unsupported HC_ARCH_BITS value.
2385#endif
2386/** The host bit count mask. */
2387#define PDM_DRVREG_FLAGS_HOST_BITS_MASK 0x000000003
2388
2389/** @} */
2390
2391
2392/** PDM Driver Classes.
2393 * @{ */
2394/** Mouse input driver. */
2395#define PDM_DRVREG_CLASS_MOUSE BIT(0)
2396/** Keyboard input driver. */
2397#define PDM_DRVREG_CLASS_KEYBOARD BIT(1)
2398/** Display driver. */
2399#define PDM_DRVREG_CLASS_DISPLAY BIT(2)
2400/** Network transport driver. */
2401#define PDM_DRVREG_CLASS_NETWORK BIT(3)
2402/** Block driver. */
2403#define PDM_DRVREG_CLASS_BLOCK BIT(4)
2404/** Media driver. */
2405#define PDM_DRVREG_CLASS_MEDIA BIT(5)
2406/** Mountable driver. */
2407#define PDM_DRVREG_CLASS_MOUNTABLE BIT(6)
2408/** Audio driver. */
2409#define PDM_DRVREG_CLASS_AUDIO BIT(7)
2410/** VMMDev driver. */
2411#define PDM_DRVREG_CLASS_VMMDEV BIT(8)
2412/** Status driver. */
2413#define PDM_DRVREG_CLASS_STATUS BIT(9)
2414/** ACPI driver. */
2415#define PDM_DRVREG_CLASS_ACPI BIT(10)
2416/** USB related driver. */
2417#define PDM_DRVREG_CLASS_USB BIT(11)
2418/** ISCSI Transport related driver. */
2419#define PDM_DRVREG_CLASS_ISCSITRANSPORT BIT(12)
2420/** Char driver. */
2421#define PDM_DRVREG_CLASS_CHAR BIT(13)
2422/** Stream driver. */
2423#define PDM_DRVREG_CLASS_STREAM BIT(14)
2424/** @} */
2425
2426
2427/**
2428 * Poller callback.
2429 *
2430 * @param pDrvIns The driver instance.
2431 */
2432typedef DECLCALLBACK(void) FNPDMDRVPOLLER(PPDMDRVINS pDrvIns);
2433/** Pointer to a FNPDMDRVPOLLER function. */
2434typedef FNPDMDRVPOLLER *PFNPDMDRVPOLLER;
2435
2436#ifdef IN_RING3
2437/**
2438 * PDM Driver API.
2439 */
2440typedef struct PDMDRVHLP
2441{
2442 /** Structure version. PDM_DRVHLP_VERSION defines the current version. */
2443 uint32_t u32Version;
2444
2445 /**
2446 * Attaches a driver (chain) to the driver.
2447 *
2448 * @returns VBox status code.
2449 * @param pDrvIns Driver instance.
2450 * @param ppBaseInterface Where to store the pointer to the base interface.
2451 */
2452 DECLR3CALLBACKMEMBER(int, pfnAttach,(PPDMDRVINS pDrvIns, PPDMIBASE *ppBaseInterface));
2453
2454 /**
2455 * Detach the driver the drivers below us.
2456 *
2457 * @returns VBox status code.
2458 * @param pDrvIns Driver instance.
2459 */
2460 DECLR3CALLBACKMEMBER(int, pfnDetach,(PPDMDRVINS pDrvIns));
2461
2462 /**
2463 * Detach the driver from the driver above it and destroy this
2464 * driver and all drivers below it.
2465 *
2466 * @returns VBox status code.
2467 * @param pDrvIns Driver instance.
2468 */
2469 DECLR3CALLBACKMEMBER(int, pfnDetachSelf,(PPDMDRVINS pDrvIns));
2470
2471 /**
2472 * Prepare a media mount.
2473 *
2474 * The driver must not have anything attached to itself
2475 * when calling this function as the purpose is to set up the configuration
2476 * of an future attachment.
2477 *
2478 * @returns VBox status code
2479 * @param pDrvIns Driver instance.
2480 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have
2481 * constructed a configuration which can be attached to the bottom driver.
2482 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL.
2483 */
2484 DECLR3CALLBACKMEMBER(int, pfnMountPrepare,(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver));
2485
2486 /**
2487 * Assert that the current thread is the emulation thread.
2488 *
2489 * @returns True if correct.
2490 * @returns False if wrong.
2491 * @param pDrvIns Driver instance.
2492 * @param pszFile Filename of the assertion location.
2493 * @param iLine Linenumber of the assertion location.
2494 * @param pszFunction Function of the assertion location.
2495 */
2496 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2497
2498 /**
2499 * Assert that the current thread is NOT the emulation thread.
2500 *
2501 * @returns True if correct.
2502 * @returns False if wrong.
2503 * @param pDrvIns Driver instance.
2504 * @param pszFile Filename of the assertion location.
2505 * @param iLine Linenumber of the assertion location.
2506 * @param pszFunction Function of the assertion location.
2507 */
2508 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
2509
2510 /**
2511 * Set the VM error message
2512 *
2513 * @returns rc.
2514 * @param pDrvIns Driver instance.
2515 * @param rc VBox status code.
2516 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2517 * @param pszFormat Error message format string.
2518 * @param ... Error message arguments.
2519 */
2520 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
2521
2522 /**
2523 * Set the VM error message
2524 *
2525 * @returns rc.
2526 * @param pDrvIns Driver instance.
2527 * @param rc VBox status code.
2528 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
2529 * @param pszFormat Error message format string.
2530 * @param va Error message arguments.
2531 */
2532 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
2533
2534 /**
2535 * Create a queue.
2536 *
2537 * @returns VBox status code.
2538 * @param pDrvIns Driver instance.
2539 * @param cbItem Size a queue item.
2540 * @param cItems Number of items in the queue.
2541 * @param cMilliesInterval Number of milliseconds between polling the queue.
2542 * If 0 then the emulation thread will be notified whenever an item arrives.
2543 * @param pfnCallback The consumer function.
2544 * @param ppQueue Where to store the queue handle on success.
2545 * @thread The emulation thread.
2546 */
2547 DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue));
2548
2549 /**
2550 * Register a poller function.
2551 * TEMPORARY HACK FOR NETWORKING! DON'T USE!
2552 *
2553 * @returns VBox status code.
2554 * @param pDrvIns Driver instance.
2555 * @param pfnPoller The callback function.
2556 */
2557 DECLR3CALLBACKMEMBER(int, pfnPDMPollerRegister,(PPDMDRVINS pDrvIns, PFNPDMDRVPOLLER pfnPoller));
2558
2559 /**
2560 * Query the virtual timer frequency.
2561 *
2562 * @returns Frequency in Hz.
2563 * @param pDrvIns Driver instance.
2564 * @thread Any thread.
2565 */
2566 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualFreq,(PPDMDRVINS pDrvIns));
2567
2568 /**
2569 * Query the virtual time.
2570 *
2571 * @returns The current virtual time.
2572 * @param pDrvIns Driver instance.
2573 * @thread Any thread.
2574 */
2575 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualTime,(PPDMDRVINS pDrvIns));
2576
2577 /**
2578 * Creates a timer.
2579 *
2580 * @returns VBox status.
2581 * @param pDrvIns Driver instance.
2582 * @param enmClock The clock to use on this timer.
2583 * @param pfnCallback Callback function.
2584 * @param pszDesc Pointer to description string which must stay around
2585 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
2586 * @param ppTimer Where to store the timer on success.
2587 */
2588 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer));
2589
2590 /**
2591 * Register a save state data unit.
2592 *
2593 * @returns VBox status.
2594 * @param pDrvIns Driver instance.
2595 * @param pszName Data unit name.
2596 * @param u32Instance The instance identifier of the data unit.
2597 * This must together with the name be unique.
2598 * @param u32Version Data layout version number.
2599 * @param cbGuess The approximate amount of data in the unit.
2600 * Only for progress indicators.
2601 * @param pfnSavePrep Prepare save callback, optional.
2602 * @param pfnSaveExec Execute save callback, optional.
2603 * @param pfnSaveDone Done save callback, optional.
2604 * @param pfnLoadPrep Prepare load callback, optional.
2605 * @param pfnLoadExec Execute load callback, optional.
2606 * @param pfnLoadDone Done load callback, optional.
2607 */
2608 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
2609 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
2610 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone));
2611
2612 /**
2613 * Deregister a save state data unit.
2614 *
2615 * @returns VBox status.
2616 * @param pDrvIns Driver instance.
2617 * @param pszName Data unit name.
2618 * @param u32Instance The instance identifier of the data unit.
2619 * This must together with the name be unique.
2620 */
2621 DECLR3CALLBACKMEMBER(int, pfnSSMDeregister,(PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance));
2622
2623 /**
2624 * Registers a statistics sample if statistics are enabled.
2625 *
2626 * @param pDrvIns Driver instance.
2627 * @param pvSample Pointer to the sample.
2628 * @param enmType Sample type. This indicates what pvSample is pointing at.
2629 * @param pszName Sample name. The name is on this form "/<component>/<sample>".
2630 * Further nesting is possible.
2631 * @param enmUnit Sample unit.
2632 * @param pszDesc Sample description.
2633 */
2634 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName,
2635 STAMUNIT enmUnit, const char *pszDesc));
2636
2637 /**
2638 * Same as pfnSTAMRegister except that the name is specified in a
2639 * RTStrPrintf like fashion.
2640 *
2641 * @returns VBox status.
2642 * @param pDrvIns Driver instance.
2643 * @param pvSample Pointer to the sample.
2644 * @param enmType Sample type. This indicates what pvSample is pointing at.
2645 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
2646 * @param enmUnit Sample unit.
2647 * @param pszDesc Sample description.
2648 * @param pszName The sample name format string.
2649 * @param ... Arguments to the format string.
2650 */
2651 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2652 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...));
2653
2654 /**
2655 * Same as pfnSTAMRegister except that the name is specified in a
2656 * RTStrPrintfV like fashion.
2657 *
2658 * @returns VBox status.
2659 * @param pDrvIns Driver instance.
2660 * @param pvSample Pointer to the sample.
2661 * @param enmType Sample type. This indicates what pvSample is pointing at.
2662 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
2663 * @param enmUnit Sample unit.
2664 * @param pszDesc Sample description.
2665 * @param pszName The sample name format string.
2666 * @param args Arguments to the format string.
2667 */
2668 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
2669 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args));
2670
2671 /**
2672 * Calls the HC R0 VMM entry point, in a safer but slower manner than SUPCallVMMR0.
2673 * When entering using this call the R0 components can call into the host kernel
2674 * (i.e. use the SUPR0 and RT APIs).
2675 *
2676 * See VMMR0Entry() for more details.
2677 *
2678 * @returns error code specific to uFunction.
2679 * @param pDrvIns The driver instance.
2680 * @param uOperation Operation to execute.
2681 * This is limited to services.
2682 * @param pvArg Pointer to argument structure or if cbArg is 0 just an value.
2683 * @param cbArg The size of the argument. This is used to copy whatever the argument
2684 * points at into a kernel buffer to avoid problems like the user page
2685 * being invalidated while we're executing the call.
2686 */
2687 DECLR3CALLBACKMEMBER(int, pfnSUPCallVMMR0Ex,(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg));
2688
2689 /** Just a safety precaution. */
2690 uint32_t u32TheEnd;
2691} PDMDRVHLP;
2692/** Pointer PDM Driver API. */
2693typedef PDMDRVHLP *PPDMDRVHLP;
2694/** Pointer const PDM Driver API. */
2695typedef const PDMDRVHLP *PCPDMDRVHLP;
2696
2697/** Current DRVHLP version number. */
2698#define PDM_DRVHLP_VERSION 0x90010000
2699
2700
2701
2702/**
2703 * PDM Driver Instance.
2704 */
2705typedef struct PDMDRVINS
2706{
2707 /** Structure version. PDM_DRVINS_VERSION defines the current version. */
2708 uint32_t u32Version;
2709
2710 /** Internal data. */
2711 union
2712 {
2713#ifdef PDMDRVINSINT_DECLARED
2714 PDMDRVINSINT s;
2715#endif
2716 uint8_t padding[HC_ARCH_BITS == 32 ? 32 : 64];
2717 } Internal;
2718
2719 /** Pointer the PDM Driver API. */
2720 HCPTRTYPE(PCPDMDRVHLP) pDrvHlp;
2721 /** Pointer to driver registration structure. */
2722 HCPTRTYPE(PCPDMDRVREG) pDrvReg;
2723 /** Configuration handle. */
2724 HCPTRTYPE(PCFGMNODE) pCfgHandle;
2725 /** Driver instance number. */
2726 RTUINT iInstance;
2727 /** Pointer to the base interface of the device/driver instance above. */
2728 HCPTRTYPE(PPDMIBASE) pUpBase;
2729 /** Pointer to the base interface of the driver instance below. */
2730 HCPTRTYPE(PPDMIBASE) pDownBase;
2731 /** The base interface of the driver.
2732 * The driver constructor initializes this. */
2733 PDMIBASE IBase;
2734 /* padding to make achInstanceData aligned at 16 byte boundrary. */
2735 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 3 : 1];
2736 /** Pointer to driver instance data. */
2737 HCPTRTYPE(void *) pvInstanceData;
2738 /** Driver instance data. The size of this area is defined
2739 * in the PDMDRVREG::cbInstanceData field. */
2740 char achInstanceData[4];
2741} PDMDRVINS;
2742
2743/** Current DRVREG version number. */
2744#define PDM_DRVINS_VERSION 0xa0010000
2745
2746/** Converts a pointer to the PDMDRVINS::IBase to a pointer to PDMDRVINS. */
2747#define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDRVINS, IBase)) )
2748
2749/**
2750 * @copydoc PDMDRVHLP::pfnVMSetError
2751 */
2752DECLINLINE(int) PDMDrvHlpVMSetError(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
2753{
2754 va_list va;
2755 va_start(va, pszFormat);
2756 pDrvIns->pDrvHlp->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
2757 va_end(va);
2758 return rc;
2759}
2760
2761/** @def PDMDRV_SET_ERROR
2762 * Set the VM error. See PDMDrvHlpVMSetError() for printf like message formatting.
2763 * Don't use any '%' in the error string!
2764 */
2765#define PDMDRV_SET_ERROR(pDrvIns, rc, pszError) \
2766 PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, pszError)
2767
2768#endif /* IN_RING3 */
2769
2770
2771/** @def PDMDRV_ASSERT_EMT
2772 * Assert that the current thread is the emulation thread.
2773 */
2774#ifdef VBOX_STRICT
2775# define PDMDRV_ASSERT_EMT(pDrvIns) pDrvIns->pDrvHlp->pfnAssertEMT(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
2776#else
2777# define PDMDRV_ASSERT_EMT(pDrvIns) do { } while (0)
2778#endif
2779
2780/** @def PDMDRV_ASSERT_OTHER
2781 * Assert that the current thread is NOT the emulation thread.
2782 */
2783#ifdef VBOX_STRICT
2784# define PDMDRV_ASSERT_OTHER(pDrvIns) pDrvIns->pDrvHlp->pfnAssertOther(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
2785#else
2786# define PDMDRV_ASSERT_OTHER(pDrvIns) do { } while (0)
2787#endif
2788
2789
2790#ifdef IN_RING3
2791/**
2792 * @copydoc PDMDRVHLP::pfnSTAMRegister
2793 */
2794DECLINLINE(void) PDMDrvHlpSTAMRegister(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
2795{
2796 pDrvIns->pDrvHlp->pfnSTAMRegister(pDrvIns, pvSample, enmType, pszName, enmUnit, pszDesc);
2797}
2798
2799/**
2800 * @copydoc PDMDRVHLP::pfnSTAMRegisterF
2801 */
2802DECLINLINE(void) PDMDrvHlpSTAMRegisterF(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
2803 const char *pszDesc, const char *pszName, ...)
2804{
2805 va_list va;
2806 va_start(va, pszName);
2807 pDrvIns->pDrvHlp->pfnSTAMRegisterV(pDrvIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
2808 va_end(va);
2809}
2810#endif /* IN_RING3 */
2811
2812
2813
2814/** Pointer to callbacks provided to the VBoxDriverRegister() call. */
2815typedef struct PDMDRVREGCB *PPDMDRVREGCB;
2816/** Pointer to const callbacks provided to the VBoxDriverRegister() call. */
2817typedef const struct PDMDRVREGCB *PCPDMDRVREGCB;
2818
2819/**
2820 * Callbacks for VBoxDriverRegister().
2821 */
2822typedef struct PDMDRVREGCB
2823{
2824 /** Interface version.
2825 * This is set to PDM_DRVREG_CB_VERSION. */
2826 uint32_t u32Version;
2827
2828 /**
2829 * Registers a driver with the current VM instance.
2830 *
2831 * @returns VBox status code.
2832 * @param pCallbacks Pointer to the callback table.
2833 * @param pDrvReg Pointer to the driver registration record.
2834 * This data must be permanent and readonly.
2835 */
2836 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pDrvReg));
2837} PDMDRVREGCB;
2838
2839/** Current version of the PDMDRVREGCB structure. */
2840#define PDM_DRVREG_CB_VERSION 0xb0010000
2841
2842
2843/**
2844 * The VBoxDriverRegister callback function.
2845 *
2846 * PDM will invoke this function after loading a driver module and letting
2847 * the module decide which drivers to register and how to handle conflicts.
2848 *
2849 * @returns VBox status code.
2850 * @param pCallbacks Pointer to the callback table.
2851 * @param u32Version VBox version number.
2852 */
2853typedef DECLCALLBACK(int) FNPDMVBOXDRIVERSREGISTER(PCPDMDRVREGCB pCallbacks, uint32_t u32Version);
2854
2855/**
2856 * Register external drivers
2857 *
2858 * @returns VBox status code.
2859 * @param pVM The VM to operate on.
2860 * @param pfnCallback Driver registration callback
2861 */
2862PDMR3DECL(int) PDMR3RegisterDrivers(PVM pVM, FNPDMVBOXDRIVERSREGISTER pfnCallback);
2863
2864/** @} */
2865
2866
2867
2868
2869/** @defgroup grp_pdm_device Devices
2870 * @ingroup grp_pdm
2871 * @{
2872 */
2873
2874
2875/** @def PDMBOTHCBDECL
2876 * Macro for declaring a callback which is static in HC and exported in GC.
2877 */
2878#if defined(IN_GC) || defined(IN_RING0)
2879# define PDMBOTHCBDECL(type) DECLEXPORT(type)
2880#else
2881# define PDMBOTHCBDECL(type) static type
2882#endif
2883
2884
2885/**
2886 * Construct a device instance for a VM.
2887 *
2888 * @returns VBox status.
2889 * @param pDevIns The device instance data.
2890 * If the registration structure is needed, pDevIns->pDevReg points to it.
2891 * @param iInstance Instance number. Use this to figure out which registers and such to use.
2892 * The instance number is also found in pDevIns->iInstance, but since it's
2893 * likely to be freqently used PDM passes it as parameter.
2894 * @param pCfgHandle Configuration node handle for the device. Use this to obtain the configuration
2895 * of the device instance. It's also found in pDevIns->pCfgHandle, but since it's
2896 * primary usage will in this function it's passed as a parameter.
2897 */
2898typedef DECLCALLBACK(int) FNPDMDEVCONSTRUCT(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfgHandle);
2899/** Pointer to a FNPDMDEVCONSTRUCT() function. */
2900typedef FNPDMDEVCONSTRUCT *PFNPDMDEVCONSTRUCT;
2901
2902/**
2903 * Destruct a device instance.
2904 *
2905 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
2906 * resources can be freed correctly.
2907 *
2908 * @returns VBox status.
2909 * @param pDevIns The device instance data.
2910 */
2911typedef DECLCALLBACK(int) FNPDMDEVDESTRUCT(PPDMDEVINS pDevIns);
2912/** Pointer to a FNPDMDEVDESTRUCT() function. */
2913typedef FNPDMDEVDESTRUCT *PFNPDMDEVDESTRUCT;
2914
2915/**
2916 * Device relocation callback.
2917 *
2918 * When this callback is called the device instance data, and if the
2919 * device have a GC component, is being relocated, or/and the selectors
2920 * have been changed. The device must use the chance to perform the
2921 * necessary pointer relocations and data updates.
2922 *
2923 * Before the GC code is executed the first time, this function will be
2924 * called with a 0 delta so GC pointer calculations can be one in one place.
2925 *
2926 * @param pDevIns Pointer to the device instance.
2927 * @param offDelta The relocation delta relative to the old location.
2928 *
2929 * @remark A relocation CANNOT fail.
2930 */
2931typedef DECLCALLBACK(void) FNPDMDEVRELOCATE(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
2932/** Pointer to a FNPDMDEVRELOCATE() function. */
2933typedef FNPDMDEVRELOCATE *PFNPDMDEVRELOCATE;
2934
2935
2936/**
2937 * Device I/O Control interface.
2938 *
2939 * This is used by external components, such as the COM interface, to
2940 * communicate with devices using a class wide interface or a device
2941 * specific interface.
2942 *
2943 * @returns VBox status code.
2944 * @param pDevIns Pointer to the device instance.
2945 * @param uFunction Function to perform.
2946 * @param pvIn Pointer to input data.
2947 * @param cbIn Size of input data.
2948 * @param pvOut Pointer to output data.
2949 * @param cbOut Size of output data.
2950 * @param pcbOut Where to store the actual size of the output data.
2951 */
2952typedef DECLCALLBACK(int) FNPDMDEVIOCTL(PPDMDEVINS pDevIns, RTUINT uFunction,
2953 void *pvIn, RTUINT cbIn,
2954 void *pvOut, RTUINT cbOut, PRTUINT pcbOut);
2955/** Pointer to a FNPDMDEVIOCTL() function. */
2956typedef FNPDMDEVIOCTL *PFNPDMDEVIOCTL;
2957
2958/**
2959 * Power On notification.
2960 *
2961 * @returns VBox status.
2962 * @param pDevIns The device instance data.
2963 */
2964typedef DECLCALLBACK(void) FNPDMDEVPOWERON(PPDMDEVINS pDevIns);
2965/** Pointer to a FNPDMDEVPOWERON() function. */
2966typedef FNPDMDEVPOWERON *PFNPDMDEVPOWERON;
2967
2968/**
2969 * Reset notification.
2970 *
2971 * @returns VBox status.
2972 * @param pDevIns The device instance data.
2973 */
2974typedef DECLCALLBACK(void) FNPDMDEVRESET(PPDMDEVINS pDevIns);
2975/** Pointer to a FNPDMDEVRESET() function. */
2976typedef FNPDMDEVRESET *PFNPDMDEVRESET;
2977
2978/**
2979 * Suspend notification.
2980 *
2981 * @returns VBox status.
2982 * @param pDevIns The device instance data.
2983 */
2984typedef DECLCALLBACK(void) FNPDMDEVSUSPEND(PPDMDEVINS pDevIns);
2985/** Pointer to a FNPDMDEVSUSPEND() function. */
2986typedef FNPDMDEVSUSPEND *PFNPDMDEVSUSPEND;
2987
2988/**
2989 * Resume notification.
2990 *
2991 * @returns VBox status.
2992 * @param pDevIns The device instance data.
2993 */
2994typedef DECLCALLBACK(void) FNPDMDEVRESUME(PPDMDEVINS pDevIns);
2995/** Pointer to a FNPDMDEVRESUME() function. */
2996typedef FNPDMDEVRESUME *PFNPDMDEVRESUME;
2997
2998/**
2999 * Power Off notification.
3000 *
3001 * @param pDevIns The device instance data.
3002 */
3003typedef DECLCALLBACK(void) FNPDMDEVPOWEROFF(PPDMDEVINS pDevIns);
3004/** Pointer to a FNPDMDEVPOWEROFF() function. */
3005typedef FNPDMDEVPOWEROFF *PFNPDMDEVPOWEROFF;
3006
3007/**
3008 * Attach command.
3009 *
3010 * This is called to let the device attach to a driver for a specified LUN
3011 * during runtime. This is not called during VM construction, the device
3012 * constructor have to attach to all the available drivers.
3013 *
3014 * This is like plugging in the keyboard or mouse after turning on the PC.
3015 *
3016 * @returns VBox status code.
3017 * @param pDevIns The device instance.
3018 * @param iLUN The logical unit which is being detached.
3019 */
3020typedef DECLCALLBACK(int) FNPDMDEVATTACH(PPDMDEVINS pDevIns, unsigned iLUN);
3021/** Pointer to a FNPDMDEVATTACH() function. */
3022typedef FNPDMDEVATTACH *PFNPDMDEVATTACH;
3023
3024/**
3025 * Detach notification.
3026 *
3027 * This is called when a driver is detaching itself from a LUN of the device.
3028 * The device should adjust it's state to reflect this.
3029 *
3030 * This is like unplugging the network cable to use it for the laptop or
3031 * something while the PC is still running.
3032 *
3033 * @param pDevIns The device instance.
3034 * @param iLUN The logical unit which is being detached.
3035 */
3036typedef DECLCALLBACK(void) FNPDMDEVDETACH(PPDMDEVINS pDevIns, unsigned iLUN);
3037/** Pointer to a FNPDMDEVDETACH() function. */
3038typedef FNPDMDEVDETACH *PFNPDMDEVDETACH;
3039
3040/**
3041 * Query the base interface of a logical unit.
3042 *
3043 * @returns VBOX status code.
3044 * @param pDevIns The device instance.
3045 * @param iLUN The logicial unit to query.
3046 * @param ppBase Where to store the pointer to the base interface of the LUN.
3047 */
3048typedef DECLCALLBACK(int) FNPDMDEVQUERYINTERFACE(PPDMDEVINS pDevIns, unsigned iLUN, PPDMIBASE *ppBase);
3049/** Pointer to a FNPDMDEVQUERYINTERFACE() function. */
3050typedef FNPDMDEVQUERYINTERFACE *PFNPDMDEVQUERYINTERFACE;
3051
3052/**
3053 * Init complete notification.
3054 * This can be done to do communication with other devices and other
3055 * initialization which requires everything to be in place.
3056 *
3057 * @returns VBOX status code.
3058 * @param pDevIns The device instance.
3059 */
3060typedef DECLCALLBACK(int) FNPDMDEVINITCOMPLETE(PPDMDEVINS pDevIns);
3061/** Pointer to a FNPDMDEVINITCOMPLETE() function. */
3062typedef FNPDMDEVINITCOMPLETE *PFNPDMDEVINITCOMPLETE;
3063
3064
3065
3066/** PDM Device Registration Structure,
3067 * This structure is used when registering a device from
3068 * VBoxInitDevices() in HC Ring-3. PDM will continue use till
3069 * the VM is terminated.
3070 */
3071typedef struct PDMDEVREG
3072{
3073 /** Structure version. PDM_DEVREG_VERSION defines the current version. */
3074 uint32_t u32Version;
3075 /** Device name. */
3076 char szDeviceName[32];
3077 /** Name of guest context module (no path).
3078 * Only evalutated if PDM_DEVREG_FLAGS_GC is set. */
3079 char szGCMod[32];
3080 /** Name of guest context module (no path).
3081 * Only evalutated if PDM_DEVREG_FLAGS_GC is set. */
3082 char szR0Mod[32];
3083 /** The description of the device. The UTF-8 string pointed to shall, like this structure,
3084 * remain unchanged from registration till VM destruction. */
3085 const char *pszDescription;
3086
3087 /** Flags, combination of the PDM_DEVREG_FLAGS_* \#defines. */
3088 RTUINT fFlags;
3089 /** Device class(es), combination of the PDM_DEVREG_CLASS_* \#defines. */
3090 RTUINT fClass;
3091 /** Maximum number of instances (per VM). */
3092 RTUINT cMaxInstances;
3093 /** Size of the instance data. */
3094 RTUINT cbInstance;
3095
3096 /** Construct instance - required. */
3097 PFNPDMDEVCONSTRUCT pfnConstruct;
3098 /** Destruct instance - optional. */
3099 PFNPDMDEVDESTRUCT pfnDestruct;
3100 /** Relocation command - optional. */
3101 PFNPDMDEVRELOCATE pfnRelocate;
3102 /** I/O Control interface - optional. */
3103 PFNPDMDEVIOCTL pfnIOCtl;
3104 /** Power on notification - optional. */
3105 PFNPDMDEVPOWERON pfnPowerOn;
3106 /** Reset notification - optional. */
3107 PFNPDMDEVRESET pfnReset;
3108 /** Suspend notification - optional. */
3109 PFNPDMDEVSUSPEND pfnSuspend;
3110 /** Resume notification - optional. */
3111 PFNPDMDEVRESUME pfnResume;
3112 /** Attach command - optional. */
3113 PFNPDMDEVATTACH pfnAttach;
3114 /** Detach notification - optional. */
3115 PFNPDMDEVDETACH pfnDetach;
3116 /** Query a LUN base interface - optional. */
3117 PFNPDMDEVQUERYINTERFACE pfnQueryInterface;
3118 /** Init complete notification - optional. */
3119 PFNPDMDEVINITCOMPLETE pfnInitComplete;
3120 /** Power off notification - optional. */
3121 PFNPDMDEVPOWEROFF pfnPowerOff;
3122} PDMDEVREG;
3123/** Pointer to a PDM Device Structure. */
3124typedef PDMDEVREG *PPDMDEVREG;
3125/** Const pointer to a PDM Device Structure. */
3126typedef PDMDEVREG const *PCPDMDEVREG;
3127
3128/** Current DEVREG version number. */
3129#define PDM_DEVREG_VERSION 0xc0010000
3130
3131/** PDM Device Flags.
3132 * @{ */
3133/** This flag is used to indicate that the device has a GC component. */
3134#define PDM_DEVREG_FLAGS_GC 0x00000001
3135/** This flag is used to indicate that the device has a R0 component. */
3136#define PDM_DEVREG_FLAGS_R0 0x00010000
3137
3138/** @def PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT
3139 * The bit count for the current host. */
3140#if HC_ARCH_BITS == 32
3141# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000002
3142#elif HC_ARCH_BITS == 64
3143# define PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT 0x00000004
3144#else
3145# error Unsupported HC_ARCH_BITS value.
3146#endif
3147/** The host bit count mask. */
3148#define PDM_DEVREG_FLAGS_HOST_BITS_MASK 0x00000006
3149
3150/** The device support only 32-bit guests. */
3151#define PDM_DEVREG_FLAGS_GUEST_BITS_32 0x00000008
3152/** The device support only 64-bit guests. */
3153#define PDM_DEVREG_FLAGS_GUEST_BITS_64 0x00000010
3154/** The device support both 32-bit & 64-bit guests. */
3155#define PDM_DEVREG_FLAGS_GUEST_BITS_32_64 0x00000018
3156/** @def PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT
3157 * The guest bit count for the current compilation. */
3158#if GC_ARCH_BITS == 32
3159# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_32
3160#elif GC_ARCH_BITS == 64
3161# define PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT PDM_DEVREG_FLAGS_GUEST_BITS_64
3162#else
3163# error Unsupported GC_ARCH_BITS value.
3164#endif
3165/** The guest bit count mask. */
3166#define PDM_DEVREG_FLAGS_GUEST_BITS_MASK 0x00000018
3167
3168/** Indicates that the devices support PAE36 on a 32-bit guest. */
3169#define PDM_DEVREG_FLAGS_PAE36 0x00000020
3170/** @} */
3171
3172
3173/** PDM Device Classes.
3174 * The order is important, lower bit earlier instantiation.
3175 * @{ */
3176/** Architecture device. */
3177#define PDM_DEVREG_CLASS_ARCH BIT(0)
3178/** Architecture BIOS device. */
3179#define PDM_DEVREG_CLASS_ARCH_BIOS BIT(1)
3180/** PCI bus brigde. */
3181#define PDM_DEVREG_CLASS_BUS_PCI BIT(2)
3182/** ISA bus brigde. */
3183#define PDM_DEVREG_CLASS_BUS_ISA BIT(3)
3184/** Input device (mouse, keyboard, joystick,..). */
3185#define PDM_DEVREG_CLASS_INPUT BIT(4)
3186/** Interrupt controller (PIC). */
3187#define PDM_DEVREG_CLASS_PIC BIT(5)
3188/** Interval controoler (PIT). */
3189#define PDM_DEVREG_CLASS_PIT BIT(6)
3190/** RTC/CMOS. */
3191#define PDM_DEVREG_CLASS_RTC BIT(7)
3192/** DMA controller. */
3193#define PDM_DEVREG_CLASS_DMA BIT(8)
3194/** VMM Device. */
3195#define PDM_DEVREG_CLASS_VMM_DEV BIT(9)
3196/** Graphics device, like VGA. */
3197#define PDM_DEVREG_CLASS_GRAPHICS BIT(10)
3198/** Storage controller device. */
3199#define PDM_DEVREG_CLASS_STORAGE BIT(11)
3200/** Network interface controller. */
3201#define PDM_DEVREG_CLASS_NETWORK BIT(12)
3202/** Audio. */
3203#define PDM_DEVREG_CLASS_AUDIO BIT(13)
3204/** USB bus? */
3205#define PDM_DEVREG_CLASS_BUS_USB BIT(14) /* ??? */
3206/** ACPI. */
3207#define PDM_DEVREG_CLASS_ACPI BIT(15)
3208/** Serial controller device. */
3209#define PDM_DEVREG_CLASS_SERIAL BIT(16)
3210/** @} */
3211
3212
3213/**
3214 * PCI Bus registaration structure.
3215 * All the callbacks, except the PCIBIOS hack, are working on PCI devices.
3216 */
3217typedef struct PDMPCIBUSREG
3218{
3219 /** Structure version number. PDM_PCIBUSREG_VERSION defines the current version. */
3220 uint32_t u32Version;
3221
3222 /**
3223 * Registers the device with the default PCI bus.
3224 *
3225 * @returns VBox status code.
3226 * @param pDevIns Device instance of the PCI Bus.
3227 * @param pPciDev The PCI device structure.
3228 * Any PCI enabled device must keep this in it's instance data!
3229 * Fill in the PCI data config before registration, please.
3230 * @param pszName Pointer to device name (permanent, readonly). For debugging, not unique.
3231 * @param iDev The device number ((dev << 3) | function) the device should have on the bus.
3232 * If negative, the pci bus device will assign one.
3233 */
3234 DECLR3CALLBACKMEMBER(int, pfnRegisterHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
3235
3236 /**
3237 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
3238 *
3239 * @returns VBox status code.
3240 * @param pDevIns Device instance of the PCI Bus.
3241 * @param pPciDev The PCI device structure.
3242 * @param iRegion The region number.
3243 * @param cbRegion Size of the region.
3244 * @param iType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
3245 * @param pfnCallback Callback for doing the mapping.
3246 */
3247 DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
3248
3249 /**
3250 * Set the IRQ for a PCI device.
3251 *
3252 * @param pDevIns Device instance of the PCI Bus.
3253 * @param pPciDev The PCI device structure.
3254 * @param iIrq IRQ number to set.
3255 * @param iLevel IRQ level.
3256 */
3257 DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
3258
3259 /**
3260 * Saves a state of the PCI device.
3261 *
3262 * @returns VBox status code.
3263 * @param pDevIns Device instance of the PCI Bus.
3264 * @param pPciDev Pointer to PCI device.
3265 * @param pSSMHandle The handle to save the state to.
3266 */
3267 DECLR3CALLBACKMEMBER(int, pfnSaveExecHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
3268
3269 /**
3270 * Loads a saved PCI device state.
3271 *
3272 * @returns VBox status code.
3273 * @param pDevIns Device instance of the PCI Bus.
3274 * @param pPciDev Pointer to PCI device.
3275 * @param pSSMHandle The handle to the saved state.
3276 */
3277 DECLR3CALLBACKMEMBER(int, pfnLoadExecHC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
3278
3279 /**
3280 * Called to perform the job of the bios.
3281 * This is only called for the first PCI Bus - it is expected to
3282 * service all the PCI buses.
3283 *
3284 * @returns VBox status.
3285 * @param pDevIns Device instance of the first bus.
3286 */
3287 DECLR3CALLBACKMEMBER(int, pfnFakePCIBIOSHC,(PPDMDEVINS pDevIns));
3288
3289 /** The name of the SetIrq GC entry point. */
3290 const char *pszSetIrqGC;
3291
3292 /** The name of the SetIrq R0 entry point. */
3293 const char *pszSetIrqR0;
3294
3295} PDMPCIBUSREG;
3296/** Pointer to a PCI bus registration structure. */
3297typedef PDMPCIBUSREG *PPDMPCIBUSREG;
3298
3299/** Current PDMPCIBUSREG version number. */
3300#define PDM_PCIBUSREG_VERSION 0xd0010000
3301
3302/**
3303 * PCI Bus GC helpers.
3304 */
3305typedef struct PDMPCIHLPGC
3306{
3307 /** Structure version. PDM_PCIHLPGC_VERSION defines the current version. */
3308 uint32_t u32Version;
3309
3310 /**
3311 * Set an ISA IRQ.
3312 *
3313 * @param pDevIns PCI device instance.
3314 * @param iIrq IRQ number to set.
3315 * @param iLevel IRQ level.
3316 * @thread EMT only.
3317 */
3318 DECLGCCALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3319
3320 /**
3321 * Set an I/O-APIC IRQ.
3322 *
3323 * @param pDevIns PCI device instance.
3324 * @param iIrq IRQ number to set.
3325 * @param iLevel IRQ level.
3326 * @thread EMT only.
3327 */
3328 DECLGCCALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3329
3330#ifdef VBOX_WITH_PDM_LOCK
3331 /**
3332 * Acquires the PDM lock.
3333 *
3334 * @returns VINF_SUCCESS on success.
3335 * @returns rc if we failed to acquire the lock.
3336 * @param pDevIns The PCI device instance.
3337 * @param rc What to return if we fail to acquire the lock.
3338 */
3339 DECLGCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3340
3341 /**
3342 * Releases the PDM lock.
3343 *
3344 * @param pDevIns The PCI device instance.
3345 */
3346 DECLGCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3347#endif
3348 /** Just a safety precaution. */
3349 uint32_t u32TheEnd;
3350} PDMPCIHLPGC;
3351/** Pointer to PCI helpers. */
3352typedef GCPTRTYPE(PDMPCIHLPGC *) PPDMPCIHLPGC;
3353/** Pointer to const PCI helpers. */
3354typedef GCPTRTYPE(const PDMPCIHLPGC *) PCPDMPCIHLPGC;
3355
3356/** Current PDMPCIHLPR3 version number. */
3357#define PDM_PCIHLPGC_VERSION 0xe1010000
3358
3359
3360/**
3361 * PCI Bus R0 helpers.
3362 */
3363typedef struct PDMPCIHLPR0
3364{
3365 /** Structure version. PDM_PCIHLPR0_VERSION defines the current version. */
3366 uint32_t u32Version;
3367
3368 /**
3369 * Set an ISA IRQ.
3370 *
3371 * @param pDevIns PCI device instance.
3372 * @param iIrq IRQ number to set.
3373 * @param iLevel IRQ level.
3374 * @thread EMT only.
3375 */
3376 DECLR0CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3377
3378 /**
3379 * Set an I/O-APIC IRQ.
3380 *
3381 * @param pDevIns PCI device instance.
3382 * @param iIrq IRQ number to set.
3383 * @param iLevel IRQ level.
3384 * @thread EMT only.
3385 */
3386 DECLR0CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3387
3388#ifdef VBOX_WITH_PDM_LOCK
3389 /**
3390 * Acquires the PDM lock.
3391 *
3392 * @returns VINF_SUCCESS on success.
3393 * @returns rc if we failed to acquire the lock.
3394 * @param pDevIns The PCI device instance.
3395 * @param rc What to return if we fail to acquire the lock.
3396 */
3397 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3398
3399 /**
3400 * Releases the PDM lock.
3401 *
3402 * @param pDevIns The PCI device instance.
3403 */
3404 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3405#endif
3406
3407 /** Just a safety precaution. */
3408 uint32_t u32TheEnd;
3409} PDMPCIHLPR0;
3410/** Pointer to PCI helpers. */
3411typedef HCPTRTYPE(PDMPCIHLPR0 *) PPDMPCIHLPR0;
3412/** Pointer to const PCI helpers. */
3413typedef HCPTRTYPE(const PDMPCIHLPR0 *) PCPDMPCIHLPR0;
3414
3415/** Current PDMPCIHLPR0 version number. */
3416#define PDM_PCIHLPR0_VERSION 0xe1010000
3417
3418/**
3419 * PCI device helpers.
3420 */
3421typedef struct PDMPCIHLPR3
3422{
3423 /** Structure version. PDM_PCIHLPR3_VERSION defines the current version. */
3424 uint32_t u32Version;
3425
3426 /**
3427 * Set an ISA IRQ.
3428 *
3429 * @param pDevIns The PCI device instance.
3430 * @param iIrq IRQ number to set.
3431 * @param iLevel IRQ level.
3432 * @thread EMT only.
3433 */
3434 DECLR3CALLBACKMEMBER(void, pfnIsaSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3435
3436 /**
3437 * Set an I/O-APIC IRQ.
3438 *
3439 * @param pDevIns The PCI device instance.
3440 * @param iIrq IRQ number to set.
3441 * @param iLevel IRQ level.
3442 * @thread EMT only.
3443 */
3444 DECLR3CALLBACKMEMBER(void, pfnIoApicSetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3445
3446#ifdef VBOX_WITH_PDM_LOCK
3447 /**
3448 * Acquires the PDM lock.
3449 *
3450 * @returns VINF_SUCCESS on success.
3451 * @returns Fatal error on failure.
3452 * @param pDevIns The PCI device instance.
3453 * @param rc Dummy for making the interface identical to the GC and R0 versions.
3454 */
3455 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3456
3457 /**
3458 * Releases the PDM lock.
3459 *
3460 * @param pDevIns The PCI device instance.
3461 */
3462 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3463#endif
3464
3465 /**
3466 * Gets the address of the GC PCI Bus helpers.
3467 *
3468 * This should be called at both construction and relocation time
3469 * to obtain the correct address of the GC helpers.
3470 *
3471 * @returns GC pointer to the PCI Bus helpers.
3472 * @param pDevIns Device instance of the PCI Bus.
3473 * @thread EMT only.
3474 */
3475 DECLR3CALLBACKMEMBER(PCPDMPCIHLPGC, pfnGetGCHelpers,(PPDMDEVINS pDevIns));
3476
3477 /**
3478 * Gets the address of the R0 PCI Bus helpers.
3479 *
3480 * This should be called at both construction and relocation time
3481 * to obtain the correct address of the GC helpers.
3482 *
3483 * @returns R0 pointer to the PCI Bus helpers.
3484 * @param pDevIns Device instance of the PCI Bus.
3485 * @thread EMT only.
3486 */
3487 DECLR3CALLBACKMEMBER(PCPDMPCIHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
3488
3489 /** Just a safety precaution. */
3490 uint32_t u32TheEnd;
3491} PDMPCIHLPR3;
3492/** Pointer to PCI helpers. */
3493typedef HCPTRTYPE(PDMPCIHLPR3 *) PPDMPCIHLPR3;
3494/** Pointer to const PCI helpers. */
3495typedef HCPTRTYPE(const PDMPCIHLPR3 *) PCPDMPCIHLPR3;
3496
3497/** Current PDMPCIHLPR3 version number. */
3498#define PDM_PCIHLPR3_VERSION 0xf1010000
3499
3500
3501/**
3502 * Programmable Interrupt Controller registration structure.
3503 */
3504typedef struct PDMPICREG
3505{
3506 /** Structure version number. PDM_PICREG_VERSION defines the current version. */
3507 uint32_t u32Version;
3508
3509 /**
3510 * Set the an IRQ.
3511 *
3512 * @param pDevIns Device instance of the PIC.
3513 * @param iIrq IRQ number to set.
3514 * @param iLevel IRQ level.
3515 */
3516 DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
3517
3518 /**
3519 * Get a pending interrupt.
3520 *
3521 * @returns Pending interrupt number.
3522 * @param pDevIns Device instance of the PIC.
3523 */
3524 DECLR3CALLBACKMEMBER(int, pfnGetInterruptHC,(PPDMDEVINS pDevIns));
3525
3526 /** The name of the GC SetIrq entry point. */
3527 const char *pszSetIrqGC;
3528 /** The name of the GC GetInterrupt entry point. */
3529 const char *pszGetInterruptGC;
3530
3531 /** The name of the R0 SetIrq entry point. */
3532 const char *pszSetIrqR0;
3533 /** The name of the R0 GetInterrupt entry point. */
3534 const char *pszGetInterruptR0;
3535} PDMPICREG;
3536/** Pointer to a PIC registration structure. */
3537typedef PDMPICREG *PPDMPICREG;
3538
3539/** Current PDMPICREG version number. */
3540#define PDM_PICREG_VERSION 0xe0020000
3541
3542/**
3543 * PIC GC helpers.
3544 */
3545typedef struct PDMPICHLPGC
3546{
3547 /** Structure version. PDM_PICHLPGC_VERSION defines the current version. */
3548 uint32_t u32Version;
3549
3550 /**
3551 * Set the interrupt force action flag.
3552 *
3553 * @param pDevIns Device instance of the PIC.
3554 */
3555 DECLGCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
3556
3557 /**
3558 * Clear the interrupt force action flag.
3559 *
3560 * @param pDevIns Device instance of the PIC.
3561 */
3562 DECLGCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
3563
3564#ifdef VBOX_WITH_PDM_LOCK
3565 /**
3566 * Acquires the PDM lock.
3567 *
3568 * @returns VINF_SUCCESS on success.
3569 * @returns rc if we failed to acquire the lock.
3570 * @param pDevIns The PIC device instance.
3571 * @param rc What to return if we fail to acquire the lock.
3572 */
3573 DECLGCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3574
3575 /**
3576 * Releases the PDM lock.
3577 *
3578 * @param pDevIns The PIC device instance.
3579 */
3580 DECLGCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3581#endif
3582 /** Just a safety precaution. */
3583 uint32_t u32TheEnd;
3584} PDMPICHLPGC;
3585
3586/** Pointer to PIC GC helpers. */
3587typedef GCPTRTYPE(PDMPICHLPGC *) PPDMPICHLPGC;
3588/** Pointer to const PIC GC helpers. */
3589typedef GCPTRTYPE(const PDMPICHLPGC *) PCPDMPICHLPGC;
3590
3591/** Current PDMPICHLPGC version number. */
3592#define PDM_PICHLPGC_VERSION 0xfc010000
3593
3594
3595/**
3596 * PIC R0 helpers.
3597 */
3598typedef struct PDMPICHLPR0
3599{
3600 /** Structure version. PDM_PICHLPR0_VERSION defines the current version. */
3601 uint32_t u32Version;
3602
3603 /**
3604 * Set the interrupt force action flag.
3605 *
3606 * @param pDevIns Device instance of the PIC.
3607 */
3608 DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
3609
3610 /**
3611 * Clear the interrupt force action flag.
3612 *
3613 * @param pDevIns Device instance of the PIC.
3614 */
3615 DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
3616
3617#ifdef VBOX_WITH_PDM_LOCK
3618 /**
3619 * Acquires the PDM lock.
3620 *
3621 * @returns VINF_SUCCESS on success.
3622 * @returns rc if we failed to acquire the lock.
3623 * @param pDevIns The PIC device instance.
3624 * @param rc What to return if we fail to acquire the lock.
3625 */
3626 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3627
3628 /**
3629 * Releases the PDM lock.
3630 *
3631 * @param pDevIns The PCI device instance.
3632 */
3633 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3634#endif
3635
3636 /** Just a safety precaution. */
3637 uint32_t u32TheEnd;
3638} PDMPICHLPR0;
3639
3640/** Pointer to PIC R0 helpers. */
3641typedef HCPTRTYPE(PDMPICHLPR0 *) PPDMPICHLPR0;
3642/** Pointer to const PIC R0 helpers. */
3643typedef HCPTRTYPE(const PDMPICHLPR0 *) PCPDMPICHLPR0;
3644
3645/** Current PDMPICHLPR0 version number. */
3646#define PDM_PICHLPR0_VERSION 0xfc010000
3647
3648/**
3649 * PIC HC helpers.
3650 */
3651typedef struct PDMPICHLPR3
3652{
3653 /** Structure version. PDM_PICHLP_VERSION defines the current version. */
3654 uint32_t u32Version;
3655
3656 /**
3657 * Set the interrupt force action flag.
3658 *
3659 * @param pDevIns Device instance of the PIC.
3660 */
3661 DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
3662
3663 /**
3664 * Clear the interrupt force action flag.
3665 *
3666 * @param pDevIns Device instance of the PIC.
3667 */
3668 DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
3669
3670#ifdef VBOX_WITH_PDM_LOCK
3671 /**
3672 * Acquires the PDM lock.
3673 *
3674 * @returns VINF_SUCCESS on success.
3675 * @returns Fatal error on failure.
3676 * @param pDevIns The PIC device instance.
3677 * @param rc Dummy for making the interface identical to the GC and R0 versions.
3678 */
3679 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3680
3681 /**
3682 * Releases the PDM lock.
3683 *
3684 * @param pDevIns The PIC device instance.
3685 */
3686 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3687#endif
3688
3689 /**
3690 * Gets the address of the GC PIC helpers.
3691 *
3692 * This should be called at both construction and relocation time
3693 * to obtain the correct address of the GC helpers.
3694 *
3695 * @returns GC pointer to the PIC helpers.
3696 * @param pDevIns Device instance of the PIC.
3697 */
3698 DECLR3CALLBACKMEMBER(PCPDMPICHLPGC, pfnGetGCHelpers,(PPDMDEVINS pDevIns));
3699
3700 /**
3701 * Gets the address of the R0 PIC helpers.
3702 *
3703 * This should be called at both construction and relocation time
3704 * to obtain the correct address of the GC helpers.
3705 *
3706 * @returns R0 pointer to the PIC helpers.
3707 * @param pDevIns Device instance of the PIC.
3708 */
3709 DECLR3CALLBACKMEMBER(PCPDMPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
3710
3711 /** Just a safety precaution. */
3712 uint32_t u32TheEnd;
3713} PDMPICHLPR3;
3714
3715/** Pointer to PIC HC helpers. */
3716typedef HCPTRTYPE(PDMPICHLPR3 *) PPDMPICHLPR3;
3717/** Pointer to const PIC HC helpers. */
3718typedef HCPTRTYPE(const PDMPICHLPR3 *) PCPDMPICHLPR3;
3719
3720/** Current PDMPICHLPR3 version number. */
3721#define PDM_PICHLPR3_VERSION 0xf0010000
3722
3723
3724
3725/**
3726 * Advanced Programmable Interrupt Controller registration structure.
3727 */
3728typedef struct PDMAPICREG
3729{
3730 /** Structure version number. PDM_APICREG_VERSION defines the current version. */
3731 uint32_t u32Version;
3732
3733 /**
3734 * Get a pending interrupt.
3735 *
3736 * @returns Pending interrupt number.
3737 * @param pDevIns Device instance of the APIC.
3738 */
3739 DECLR3CALLBACKMEMBER(int, pfnGetInterruptHC,(PPDMDEVINS pDevIns));
3740
3741 /**
3742 * Set the APIC base.
3743 *
3744 * @param pDevIns Device instance of the APIC.
3745 * @param u64Base The new base.
3746 */
3747 DECLR3CALLBACKMEMBER(void, pfnSetBaseHC,(PPDMDEVINS pDevIns, uint64_t u64Base));
3748
3749 /**
3750 * Get the APIC base.
3751 *
3752 * @returns Current base.
3753 * @param pDevIns Device instance of the APIC.
3754 */
3755 DECLR3CALLBACKMEMBER(uint64_t, pfnGetBaseHC,(PPDMDEVINS pDevIns));
3756
3757 /**
3758 * Set the TPR (task priority register?).
3759 *
3760 * @param pDevIns Device instance of the APIC.
3761 * @param u8TPR The new TPR.
3762 */
3763 DECLR3CALLBACKMEMBER(void, pfnSetTPRHC,(PPDMDEVINS pDevIns, uint8_t u8TPR));
3764
3765 /**
3766 * Get the TPR (task priority register?).
3767 *
3768 * @returns The current TPR.
3769 * @param pDevIns Device instance of the APIC.
3770 */
3771 DECLR3CALLBACKMEMBER(uint8_t, pfnGetTPRHC,(PPDMDEVINS pDevIns));
3772
3773 /**
3774 * Private interface between the IOAPIC and APIC.
3775 *
3776 * This is a low-level, APIC/IOAPIC implementation specific interface
3777 * which is registered with PDM only because it makes life so much
3778 * simpler right now (GC bits). This is a bad bad hack! The correct
3779 * way of doing this would involve some way of querying GC interfaces
3780 * and relocating them. Perhaps doing some kind of device init in GC...
3781 *
3782 * @returns The current TPR.
3783 * @param pDevIns Device instance of the APIC.
3784 * @param u8Dest See APIC implementation.
3785 * @param u8DestMode See APIC implementation.
3786 * @param u8DeliveryMode See APIC implementation.
3787 * @param iVector See APIC implementation.
3788 * @param u8Polarity See APIC implementation.
3789 * @param u8TriggerMode See APIC implementation.
3790 */
3791 DECLR3CALLBACKMEMBER(void, pfnBusDeliverHC,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
3792 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
3793
3794 /** The name of the GC GetInterrupt entry point. */
3795 const char *pszGetInterruptGC;
3796 /** The name of the GC SetBase entry point. */
3797 const char *pszSetBaseGC;
3798 /** The name of the GC GetBase entry point. */
3799 const char *pszGetBaseGC;
3800 /** The name of the GC SetTPR entry point. */
3801 const char *pszSetTPRGC;
3802 /** The name of the GC GetTPR entry point. */
3803 const char *pszGetTPRGC;
3804 /** The name of the GC BusDeliver entry point. */
3805 const char *pszBusDeliverGC;
3806
3807 /** The name of the R0 GetInterrupt entry point. */
3808 const char *pszGetInterruptR0;
3809 /** The name of the R0 SetBase entry point. */
3810 const char *pszSetBaseR0;
3811 /** The name of the R0 GetBase entry point. */
3812 const char *pszGetBaseR0;
3813 /** The name of the R0 SetTPR entry point. */
3814 const char *pszSetTPRR0;
3815 /** The name of the R0 GetTPR entry point. */
3816 const char *pszGetTPRR0;
3817 /** The name of the R0 BusDeliver entry point. */
3818 const char *pszBusDeliverR0;
3819
3820} PDMAPICREG;
3821/** Pointer to an APIC registration structure. */
3822typedef PDMAPICREG *PPDMAPICREG;
3823
3824/** Current PDMAPICREG version number. */
3825#define PDM_APICREG_VERSION 0x70010000
3826
3827
3828/**
3829 * APIC GC helpers.
3830 */
3831typedef struct PDMAPICHLPGC
3832{
3833 /** Structure version. PDM_APICHLPGC_VERSION defines the current version. */
3834 uint32_t u32Version;
3835
3836 /**
3837 * Set the interrupt force action flag.
3838 *
3839 * @param pDevIns Device instance of the APIC.
3840 */
3841 DECLGCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
3842
3843 /**
3844 * Clear the interrupt force action flag.
3845 *
3846 * @param pDevIns Device instance of the APIC.
3847 */
3848 DECLGCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
3849
3850 /**
3851 * Sets or clears the APIC bit in the CPUID feature masks.
3852 *
3853 * @param pDevIns Device instance of the APIC.
3854 * @param fEnabled If true the bit is set, else cleared.
3855 */
3856 DECLGCCALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
3857
3858#ifdef VBOX_WITH_PDM_LOCK
3859 /**
3860 * Acquires the PDM lock.
3861 *
3862 * @returns VINF_SUCCESS on success.
3863 * @returns rc if we failed to acquire the lock.
3864 * @param pDevIns The APIC device instance.
3865 * @param rc What to return if we fail to acquire the lock.
3866 */
3867 DECLGCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3868
3869 /**
3870 * Releases the PDM lock.
3871 *
3872 * @param pDevIns The APIC device instance.
3873 */
3874 DECLGCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3875#endif
3876 /** Just a safety precaution. */
3877 uint32_t u32TheEnd;
3878} PDMAPICHLPGC;
3879/** Pointer to APIC GC helpers. */
3880typedef GCPTRTYPE(PDMAPICHLPGC *) PPDMAPICHLPGC;
3881/** Pointer to const APIC helpers. */
3882typedef GCPTRTYPE(const PDMAPICHLPGC *) PCPDMAPICHLPGC;
3883
3884/** Current PDMAPICHLPGC version number. */
3885#define PDM_APICHLPGC_VERSION 0x60010000
3886
3887
3888/**
3889 * APIC R0 helpers.
3890 */
3891typedef struct PDMAPICHLPR0
3892{
3893 /** Structure version. PDM_APICHLPR0_VERSION defines the current version. */
3894 uint32_t u32Version;
3895
3896 /**
3897 * Set the interrupt force action flag.
3898 *
3899 * @param pDevIns Device instance of the APIC.
3900 */
3901 DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
3902
3903 /**
3904 * Clear the interrupt force action flag.
3905 *
3906 * @param pDevIns Device instance of the APIC.
3907 */
3908 DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
3909
3910 /**
3911 * Sets or clears the APIC bit in the CPUID feature masks.
3912 *
3913 * @param pDevIns Device instance of the APIC.
3914 * @param fEnabled If true the bit is set, else cleared.
3915 */
3916 DECLR0CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
3917
3918#ifdef VBOX_WITH_PDM_LOCK
3919 /**
3920 * Acquires the PDM lock.
3921 *
3922 * @returns VINF_SUCCESS on success.
3923 * @returns rc if we failed to acquire the lock.
3924 * @param pDevIns The APIC device instance.
3925 * @param rc What to return if we fail to acquire the lock.
3926 */
3927 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3928
3929 /**
3930 * Releases the PDM lock.
3931 *
3932 * @param pDevIns The APIC device instance.
3933 */
3934 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3935#endif
3936
3937 /** Just a safety precaution. */
3938 uint32_t u32TheEnd;
3939} PDMAPICHLPR0;
3940/** Pointer to APIC GC helpers. */
3941typedef GCPTRTYPE(PDMAPICHLPR0 *) PPDMAPICHLPR0;
3942/** Pointer to const APIC helpers. */
3943typedef HCPTRTYPE(const PDMAPICHLPR0 *) PCPDMAPICHLPR0;
3944
3945/** Current PDMAPICHLPR0 version number. */
3946#define PDM_APICHLPR0_VERSION 0x60010000
3947
3948/**
3949 * APIC HC helpers.
3950 */
3951typedef struct PDMAPICHLPR3
3952{
3953 /** Structure version. PDM_APICHLPR3_VERSION defines the current version. */
3954 uint32_t u32Version;
3955
3956 /**
3957 * Set the interrupt force action flag.
3958 *
3959 * @param pDevIns Device instance of the APIC.
3960 */
3961 DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
3962
3963 /**
3964 * Clear the interrupt force action flag.
3965 *
3966 * @param pDevIns Device instance of the APIC.
3967 */
3968 DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
3969
3970 /**
3971 * Sets or clears the APIC bit in the CPUID feature masks.
3972 *
3973 * @param pDevIns Device instance of the APIC.
3974 * @param fEnabled If true the bit is set, else cleared.
3975 */
3976 DECLR3CALLBACKMEMBER(void, pfnChangeFeature,(PPDMDEVINS pDevIns, bool fEnabled));
3977
3978#ifdef VBOX_WITH_PDM_LOCK
3979 /**
3980 * Acquires the PDM lock.
3981 *
3982 * @returns VINF_SUCCESS on success.
3983 * @returns Fatal error on failure.
3984 * @param pDevIns The APIC device instance.
3985 * @param rc Dummy for making the interface identical to the GC and R0 versions.
3986 */
3987 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
3988
3989 /**
3990 * Releases the PDM lock.
3991 *
3992 * @param pDevIns The APIC device instance.
3993 */
3994 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
3995#endif
3996
3997 /**
3998 * Gets the address of the GC APIC helpers.
3999 *
4000 * This should be called at both construction and relocation time
4001 * to obtain the correct address of the GC helpers.
4002 *
4003 * @returns GC pointer to the APIC helpers.
4004 * @param pDevIns Device instance of the APIC.
4005 */
4006 DECLR3CALLBACKMEMBER(PCPDMAPICHLPGC, pfnGetGCHelpers,(PPDMDEVINS pDevIns));
4007
4008 /**
4009 * Gets the address of the R0 APIC helpers.
4010 *
4011 * This should be called at both construction and relocation time
4012 * to obtain the correct address of the R0 helpers.
4013 *
4014 * @returns R0 pointer to the APIC helpers.
4015 * @param pDevIns Device instance of the APIC.
4016 */
4017 DECLR3CALLBACKMEMBER(PCPDMAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
4018
4019 /** Just a safety precaution. */
4020 uint32_t u32TheEnd;
4021} PDMAPICHLPR3;
4022/** Pointer to APIC helpers. */
4023typedef HCPTRTYPE(PDMAPICHLPR3 *) PPDMAPICHLPR3;
4024/** Pointer to const APIC helpers. */
4025typedef HCPTRTYPE(const PDMAPICHLPR3 *) PCPDMAPICHLPR3;
4026
4027/** Current PDMAPICHLP version number. */
4028#define PDM_APICHLPR3_VERSION 0xfd010000
4029
4030
4031/**
4032 * I/O APIC registration structure.
4033 */
4034typedef struct PDMIOAPICREG
4035{
4036 /** Struct version+magic number (PDM_IOAPICREG_VERSION). */
4037 uint32_t u32Version;
4038
4039 /**
4040 * Set the an IRQ.
4041 *
4042 * @param pDevIns Device instance of the I/O APIC.
4043 * @param iIrq IRQ number to set.
4044 * @param iLevel IRQ level.
4045 */
4046 DECLR3CALLBACKMEMBER(void, pfnSetIrqHC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4047
4048 /** The name of the GC SetIrq entry point. */
4049 const char *pszSetIrqGC;
4050
4051 /** The name of the R0 SetIrq entry point. */
4052 const char *pszSetIrqR0;
4053} PDMIOAPICREG;
4054/** Pointer to an APIC registration structure. */
4055typedef PDMIOAPICREG *PPDMIOAPICREG;
4056
4057/** Current PDMAPICREG version number. */
4058#define PDM_IOAPICREG_VERSION 0x50010000
4059
4060
4061/**
4062 * IOAPIC GC helpers.
4063 */
4064typedef struct PDMIOAPICHLPGC
4065{
4066 /** Structure version. PDM_IOAPICHLPGC_VERSION defines the current version. */
4067 uint32_t u32Version;
4068
4069 /**
4070 * Private interface between the IOAPIC and APIC.
4071 *
4072 * See comments about this hack on PDMAPICREG::pfnBusDeliverHC.
4073 *
4074 * @returns The current TPR.
4075 * @param pDevIns Device instance of the IOAPIC.
4076 * @param u8Dest See APIC implementation.
4077 * @param u8DestMode See APIC implementation.
4078 * @param u8DeliveryMode See APIC implementation.
4079 * @param iVector See APIC implementation.
4080 * @param u8Polarity See APIC implementation.
4081 * @param u8TriggerMode See APIC implementation.
4082 */
4083 DECLGCCALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
4084 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
4085
4086#ifdef VBOX_WITH_PDM_LOCK
4087 /**
4088 * Acquires the PDM lock.
4089 *
4090 * @returns VINF_SUCCESS on success.
4091 * @returns rc if we failed to acquire the lock.
4092 * @param pDevIns The IOAPIC device instance.
4093 * @param rc What to return if we fail to acquire the lock.
4094 */
4095 DECLGCCALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
4096
4097 /**
4098 * Releases the PDM lock.
4099 *
4100 * @param pDevIns The IOAPIC device instance.
4101 */
4102 DECLGCCALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
4103#endif
4104
4105 /** Just a safety precaution. */
4106 uint32_t u32TheEnd;
4107} PDMIOAPICHLPGC;
4108/** Pointer to IOAPIC GC helpers. */
4109typedef GCPTRTYPE(PDMAPICHLPGC *)PPDMIOAPICHLPGC;
4110/** Pointer to const IOAPIC helpers. */
4111typedef GCPTRTYPE(const PDMIOAPICHLPGC *) PCPDMIOAPICHLPGC;
4112
4113/** Current PDMIOAPICHLPGC version number. */
4114#define PDM_IOAPICHLPGC_VERSION 0xfe010000
4115
4116
4117/**
4118 * IOAPIC R0 helpers.
4119 */
4120typedef struct PDMIOAPICHLPR0
4121{
4122 /** Structure version. PDM_IOAPICHLPR0_VERSION defines the current version. */
4123 uint32_t u32Version;
4124
4125 /**
4126 * Private interface between the IOAPIC and APIC.
4127 *
4128 * See comments about this hack on PDMAPICREG::pfnBusDeliverHC.
4129 *
4130 * @returns The current TPR.
4131 * @param pDevIns Device instance of the IOAPIC.
4132 * @param u8Dest See APIC implementation.
4133 * @param u8DestMode See APIC implementation.
4134 * @param u8DeliveryMode See APIC implementation.
4135 * @param iVector See APIC implementation.
4136 * @param u8Polarity See APIC implementation.
4137 * @param u8TriggerMode See APIC implementation.
4138 */
4139 DECLR0CALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
4140 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
4141
4142#ifdef VBOX_WITH_PDM_LOCK
4143 /**
4144 * Acquires the PDM lock.
4145 *
4146 * @returns VINF_SUCCESS on success.
4147 * @returns rc if we failed to acquire the lock.
4148 * @param pDevIns The IOAPIC device instance.
4149 * @param rc What to return if we fail to acquire the lock.
4150 */
4151 DECLR0CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
4152
4153 /**
4154 * Releases the PDM lock.
4155 *
4156 * @param pDevIns The IOAPIC device instance.
4157 */
4158 DECLR0CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
4159#endif
4160
4161 /** Just a safety precaution. */
4162 uint32_t u32TheEnd;
4163} PDMIOAPICHLPR0;
4164/** Pointer to IOAPIC R0 helpers. */
4165typedef HCPTRTYPE(PDMAPICHLPGC *)PPDMIOAPICHLPR0;
4166/** Pointer to const IOAPIC helpers. */
4167typedef HCPTRTYPE(const PDMIOAPICHLPR0 *) PCPDMIOAPICHLPR0;
4168
4169/** Current PDMIOAPICHLPR0 version number. */
4170#define PDM_IOAPICHLPR0_VERSION 0xfe010000
4171
4172/**
4173 * IOAPIC HC helpers.
4174 */
4175typedef struct PDMIOAPICHLPR3
4176{
4177 /** Structure version. PDM_IOAPICHLPR3_VERSION defines the current version. */
4178 uint32_t u32Version;
4179
4180 /**
4181 * Private interface between the IOAPIC and APIC.
4182 *
4183 * See comments about this hack on PDMAPICREG::pfnBusDeliverHC.
4184 *
4185 * @returns The current TPR.
4186 * @param pDevIns Device instance of the IOAPIC.
4187 * @param u8Dest See APIC implementation.
4188 * @param u8DestMode See APIC implementation.
4189 * @param u8DeliveryMode See APIC implementation.
4190 * @param iVector See APIC implementation.
4191 * @param u8Polarity See APIC implementation.
4192 * @param u8TriggerMode See APIC implementation.
4193 */
4194 DECLR3CALLBACKMEMBER(void, pfnApicBusDeliver,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
4195 uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
4196
4197#ifdef VBOX_WITH_PDM_LOCK
4198 /**
4199 * Acquires the PDM lock.
4200 *
4201 * @returns VINF_SUCCESS on success.
4202 * @returns Fatal error on failure.
4203 * @param pDevIns The IOAPIC device instance.
4204 * @param rc Dummy for making the interface identical to the GC and R0 versions.
4205 */
4206 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMDEVINS pDevIns, int rc));
4207
4208 /**
4209 * Releases the PDM lock.
4210 *
4211 * @param pDevIns The IOAPIC device instance.
4212 */
4213 DECLR3CALLBACKMEMBER(void, pfnUnlock,(PPDMDEVINS pDevIns));
4214#endif
4215
4216 /**
4217 * Gets the address of the GC IOAPIC helpers.
4218 *
4219 * This should be called at both construction and relocation time
4220 * to obtain the correct address of the GC helpers.
4221 *
4222 * @returns GC pointer to the IOAPIC helpers.
4223 * @param pDevIns Device instance of the IOAPIC.
4224 */
4225 DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPGC, pfnGetGCHelpers,(PPDMDEVINS pDevIns));
4226
4227 /**
4228 * Gets the address of the R0 IOAPIC helpers.
4229 *
4230 * This should be called at both construction and relocation time
4231 * to obtain the correct address of the R0 helpers.
4232 *
4233 * @returns R0 pointer to the IOAPIC helpers.
4234 * @param pDevIns Device instance of the IOAPIC.
4235 */
4236 DECLR3CALLBACKMEMBER(PCPDMIOAPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
4237
4238 /** Just a safety precaution. */
4239 uint32_t u32TheEnd;
4240} PDMIOAPICHLPR3;
4241/** Pointer to IOAPIC HC helpers. */
4242typedef HCPTRTYPE(PDMIOAPICHLPR3 *) PPDMIOAPICHLPR3;
4243/** Pointer to const IOAPIC helpers. */
4244typedef HCPTRTYPE(const PDMIOAPICHLPR3 *) PCPDMIOAPICHLPR3;
4245
4246/** Current PDMIOAPICHLPR3 version number. */
4247#define PDM_IOAPICHLPR3_VERSION 0xff010000
4248
4249
4250
4251#ifdef IN_RING3
4252
4253/**
4254 * DMA Transfer Handler.
4255 *
4256 * @returns Number of bytes transferred.
4257 * @param pDevIns Device instance of the DMA.
4258 * @param pvUser User pointer.
4259 * @param uChannel Channel number.
4260 * @param off DMA position.
4261 * @param cb Block size.
4262 */
4263typedef DECLCALLBACK(uint32_t) FNDMATRANSFERHANDLER(PPDMDEVINS pDevIns, void *pvUser, unsigned uChannel, uint32_t off, uint32_t cb);
4264/** Pointer to a FNDMATRANSFERHANDLER(). */
4265typedef FNDMATRANSFERHANDLER *PFNDMATRANSFERHANDLER;
4266
4267/**
4268 * DMA Controller registration structure.
4269 */
4270typedef struct PDMDMAREG
4271{
4272 /** Structure version number. PDM_DMACREG_VERSION defines the current version. */
4273 uint32_t u32Version;
4274
4275 /**
4276 * Execute pending transfers.
4277 *
4278 * @returns A more work indiciator. I.e. 'true' if there is more to be done, and 'false' if all is done.
4279 * @param pDevIns Device instance of the DMAC.
4280 */
4281 DECLR3CALLBACKMEMBER(bool, pfnRun,(PPDMDEVINS pDevIns));
4282
4283 /**
4284 * Register transfer function for DMA channel.
4285 *
4286 * @param pDevIns Device instance of the DMAC.
4287 * @param uChannel Channel number.
4288 * @param pfnTransferHandler Device specific transfer function.
4289 * @param pvUSer User pointer to be passed to the callback.
4290 */
4291 DECLR3CALLBACKMEMBER(void, pfnRegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
4292
4293 /**
4294 * Read memory
4295 *
4296 * @returns Number of bytes read.
4297 * @param pDevIns Device instance of the DMAC.
4298 * @param pvBuffer Pointer to target buffer.
4299 * @param off DMA position.
4300 * @param cbBlock Block size.
4301 */
4302 DECLR3CALLBACKMEMBER(uint32_t, pfnReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock));
4303
4304 /**
4305 * Write memory
4306 *
4307 * @returns Number of bytes written.
4308 * @param pDevIns Device instance of the DMAC.
4309 * @param pvBuffer Memory to write.
4310 * @param off DMA position.
4311 * @param cbBlock Block size.
4312 */
4313 DECLR3CALLBACKMEMBER(uint32_t, pfnWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock));
4314
4315 /**
4316 * Set the DREQ line.
4317 *
4318 * @param pDevIns Device instance of the DMAC.
4319 * @param uChannel Channel number.
4320 * @param uLevel Level of the line.
4321 */
4322 DECLR3CALLBACKMEMBER(void, pfnSetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
4323
4324 /**
4325 * Get channel mode
4326 *
4327 * @returns Channel mode.
4328 * @param pDevIns Device instance of the DMAC.
4329 * @param uChannel Channel number.
4330 */
4331 DECLR3CALLBACKMEMBER(uint8_t, pfnGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
4332
4333} PDMDMACREG;
4334/** Pointer to a DMAC registration structure. */
4335typedef PDMDMACREG *PPDMDMACREG;
4336
4337/** Current PDMDMACREG version number. */
4338#define PDM_DMACREG_VERSION 0xf5010000
4339
4340
4341/**
4342 * DMA Controller device helpers.
4343 */
4344typedef struct PDMDMACHLP
4345{
4346 /** Structure version. PDM_DMACHLP_VERSION defines the current version. */
4347 uint32_t u32Version;
4348
4349 /* to-be-defined */
4350
4351} PDMDMACHLP;
4352/** Pointer to DMAC helpers. */
4353typedef PDMDMACHLP *PPDMDMACHLP;
4354/** Pointer to const DMAC helpers. */
4355typedef const PDMDMACHLP *PCPDMDMACHLP;
4356
4357/** Current PDMDMACHLP version number. */
4358#define PDM_DMACHLP_VERSION 0xf6010000
4359
4360#endif /* IN_RING3 */
4361
4362
4363
4364/**
4365 * RTC registration structure.
4366 */
4367typedef struct PDMRTCREG
4368{
4369 /** Structure version number. PDM_RTCREG_VERSION defines the current version. */
4370 uint32_t u32Version;
4371 uint32_t u32Alignment; /**< structure size alignment. */
4372
4373 /**
4374 * Write to a CMOS register and update the checksum if necessary.
4375 *
4376 * @returns VBox status code.
4377 * @param pDevIns Device instance of the RTC.
4378 * @param iReg The CMOS register index.
4379 * @param u8Value The CMOS register value.
4380 */
4381 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
4382
4383 /**
4384 * Read a CMOS register.
4385 *
4386 * @returns VBox status code.
4387 * @param pDevIns Device instance of the RTC.
4388 * @param iReg The CMOS register index.
4389 * @param pu8Value Where to store the CMOS register value.
4390 */
4391 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
4392
4393} PDMRTCREG;
4394/** Pointer to a RTC registration structure. */
4395typedef PDMRTCREG *PPDMRTCREG;
4396/** Pointer to a const RTC registration structure. */
4397typedef const PDMRTCREG *PCPDMRTCREG;
4398
4399/** Current PDMRTCREG version number. */
4400#define PDM_RTCREG_VERSION 0xfa010000
4401
4402
4403/**
4404 * RTC device helpers.
4405 */
4406typedef struct PDMRTCHLP
4407{
4408 /** Structure version. PDM_RTCHLP_VERSION defines the current version. */
4409 uint32_t u32Version;
4410
4411 /* to-be-defined */
4412
4413} PDMRTCHLP;
4414/** Pointer to RTC helpers. */
4415typedef PDMRTCHLP *PPDMRTCHLP;
4416/** Pointer to const RTC helpers. */
4417typedef const PDMRTCHLP *PCPDMRTCHLP;
4418
4419/** Current PDMRTCHLP version number. */
4420#define PDM_RTCHLP_VERSION 0xf6010000
4421
4422
4423
4424#ifdef IN_RING3
4425
4426/**
4427 * PDM Device API.
4428 */
4429typedef struct PDMDEVHLP
4430{
4431 /** Structure version. PDM_DEVHLP_VERSION defines the current version. */
4432 uint32_t u32Version;
4433
4434 /**
4435 * Register a number of I/O ports with a device.
4436 *
4437 * These callbacks are of course for the host context (HC).
4438 * Register HC handlers before guest context (GC) handlers! There must be a
4439 * HC handler for every GC handler!
4440 *
4441 * @returns VBox status.
4442 * @param pDevIns The device instance to register the ports with.
4443 * @param Port First port number in the range.
4444 * @param cPorts Number of ports to register.
4445 * @param pvUser User argument.
4446 * @param pfnOut Pointer to function which is gonna handle OUT operations.
4447 * @param pfnIn Pointer to function which is gonna handle IN operations.
4448 * @param pfnOutStr Pointer to function which is gonna handle string OUT operations.
4449 * @param pfnInStr Pointer to function which is gonna handle string IN operations.
4450 * @param pszDesc Pointer to description string. This must not be freed.
4451 */
4452 DECLR3CALLBACKMEMBER(int, pfnIOPortRegister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
4453 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
4454 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc));
4455
4456 /**
4457 * Register a number of I/O ports with a device for GC.
4458 *
4459 * These callbacks are for the host context (GC).
4460 * Register host context (HC) handlers before guest context handlers! There must be a
4461 * HC handler for every GC handler!
4462 *
4463 * @returns VBox status.
4464 * @param pDevIns The device instance to register the ports with and which GC module
4465 * to resolve the names against.
4466 * @param Port First port number in the range.
4467 * @param cPorts Number of ports to register.
4468 * @param pvUser User argument.
4469 * @param pszOut Name of the GC function which is gonna handle OUT operations.
4470 * @param pszIn Name of the GC function which is gonna handle IN operations.
4471 * @param pszOutStr Name of the GC function which is gonna handle string OUT operations.
4472 * @param pszInStr Name of the GC function which is gonna handle string IN operations.
4473 * @param pszDesc Pointer to description string. This must not be freed.
4474 */
4475 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterGC,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTGCPTR pvUser,
4476 const char *pszOut, const char *pszIn,
4477 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
4478
4479 /**
4480 * Register a number of I/O ports with a device.
4481 *
4482 * These callbacks are of course for the ring-0 host context (R0).
4483 * Register R3 (HC) handlers before R0 (R0) handlers! There must be a R3 (HC) handler for every R0 handler!
4484 *
4485 * @returns VBox status.
4486 * @param pDevIns The device instance to register the ports with.
4487 * @param Port First port number in the range.
4488 * @param cPorts Number of ports to register.
4489 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
4490 * @param pszOut Name of the R0 function which is gonna handle OUT operations.
4491 * @param pszIn Name of the R0 function which is gonna handle IN operations.
4492 * @param pszOutStr Name of the R0 function which is gonna handle string OUT operations.
4493 * @param pszInStr Name of the R0 function which is gonna handle string IN operations.
4494 * @param pszDesc Pointer to description string. This must not be freed.
4495 */
4496 DECLR3CALLBACKMEMBER(int, pfnIOPortRegisterR0,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
4497 const char *pszOut, const char *pszIn,
4498 const char *pszOutStr, const char *pszInStr, const char *pszDesc));
4499
4500 /**
4501 * Deregister I/O ports.
4502 *
4503 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
4504 *
4505 * @returns VBox status.
4506 * @param pDevIns The device instance owning the ports.
4507 * @param Port First port number in the range.
4508 * @param cPorts Number of ports to deregister.
4509 */
4510 DECLR3CALLBACKMEMBER(int, pfnIOPortDeregister,(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts));
4511
4512
4513 /**
4514 * Register a Memory Mapped I/O (MMIO) region.
4515 *
4516 * These callbacks are of course for the host context (HC).
4517 * Register HC handlers before guest context (GC) handlers! There must be a
4518 * HC handler for every GC handler!
4519 *
4520 * @returns VBox status.
4521 * @param pDevIns The device instance to register the MMIO with.
4522 * @param GCPhysStart First physical address in the range.
4523 * @param cbRange The size of the range (in bytes).
4524 * @param pvUser User argument.
4525 * @param pfnWrite Pointer to function which is gonna handle Write operations.
4526 * @param pfnRead Pointer to function which is gonna handle Read operations.
4527 * @param pfnFill Pointer to function which is gonna handle Fill/memset operations. (optional)
4528 * @param pszDesc Pointer to description string. This must not be freed.
4529 */
4530 DECLR3CALLBACKMEMBER(int, pfnMMIORegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
4531 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
4532 const char *pszDesc));
4533
4534 /**
4535 * Register a Memory Mapped I/O (MMIO) region for GC.
4536 *
4537 * These callbacks are for the guest context (GC).
4538 * Register host context (HC) handlers before guest context handlers! There must be a
4539 * HC handler for every GC handler!
4540 *
4541 * @returns VBox status.
4542 * @param pDevIns The device instance to register the MMIO with.
4543 * @param GCPhysStart First physical address in the range.
4544 * @param cbRange The size of the range (in bytes).
4545 * @param pvUser User argument.
4546 * @param pszWrite Name of the GC function which is gonna handle Write operations.
4547 * @param pszRead Name of the GC function which is gonna handle Read operations.
4548 * @param pszFill Name of the GC function which is gonna handle Fill/memset operations. (optional)
4549 * @param pszDesc Pointer to description string. This must not be freed.
4550 */
4551 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterGC,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
4552 const char *pszWrite, const char *pszRead, const char *pszFill,
4553 const char *pszDesc));
4554
4555 /**
4556 * Register a Memory Mapped I/O (MMIO) region for R0.
4557 *
4558 * These callbacks are for the ring-0 host context (R0).
4559 * Register R3 (HC) handlers before R0 handlers! There must be a R3 handler for every R0 handler!
4560 *
4561 * @returns VBox status.
4562 * @param pDevIns The device instance to register the MMIO with.
4563 * @param GCPhysStart First physical address in the range.
4564 * @param cbRange The size of the range (in bytes).
4565 * @param pvUser User argument. (if pointer, then it must be in locked memory!)
4566 * @param pszWrite Name of the GC function which is gonna handle Write operations.
4567 * @param pszRead Name of the GC function which is gonna handle Read operations.
4568 * @param pszFill Name of the GC function which is gonna handle Fill/memset operations. (optional)
4569 * @param pszDesc Pointer to description string. This must not be freed.
4570 */
4571 DECLR3CALLBACKMEMBER(int, pfnMMIORegisterR0,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
4572 const char *pszWrite, const char *pszRead, const char *pszFill,
4573 const char *pszDesc));
4574
4575 /**
4576 * Deregister a Memory Mapped I/O (MMIO) region.
4577 *
4578 * This naturally affects both guest context (GC), ring-0 (R0) and ring-3 (R3/HC) handlers.
4579 *
4580 * @returns VBox status.
4581 * @param pDevIns The device instance owning the MMIO region(s).
4582 * @param GCPhysStart First physical address in the range.
4583 * @param cbRange The size of the range (in bytes).
4584 */
4585 DECLR3CALLBACKMEMBER(int, pfnMMIODeregister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange));
4586
4587 /**
4588 * Register a ROM (BIOS) region.
4589 *
4590 * It goes without saying that this is read-only memory. The memory region must be
4591 * in unassigned memory. I.e. from the top of the address space or on the PC in
4592 * the 0xa0000-0xfffff range.
4593 *
4594 * @returns VBox status.
4595 * @param pDevIns The device instance owning the ROM region.
4596 * @param GCPhysStart First physical address in the range.
4597 * Must be page aligned!
4598 * @param cbRange The size of the range (in bytes).
4599 * Must be page aligned!
4600 * @param pvBinary Pointer to the binary data backing the ROM image.
4601 * This must be cbRange bytes big.
4602 * It will be copied and doesn't have to stick around.
4603 * @param pszDesc Pointer to description string. This must not be freed.
4604 * @remark There is no way to remove the rom, automatically on device cleanup or
4605 * manually from the device yet. At present I doubt we need such features...
4606 */
4607 DECLR3CALLBACKMEMBER(int, pfnROMRegister,(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, const char *pszDesc));
4608
4609 /**
4610 * Register a save state data unit.
4611 *
4612 * @returns VBox status.
4613 * @param pDevIns Device instance.
4614 * @param pszName Data unit name.
4615 * @param u32Instance The instance identifier of the data unit.
4616 * This must together with the name be unique.
4617 * @param u32Version Data layout version number.
4618 * @param cbGuess The approximate amount of data in the unit.
4619 * Only for progress indicators.
4620 * @param pfnSavePrep Prepare save callback, optional.
4621 * @param pfnSaveExec Execute save callback, optional.
4622 * @param pfnSaveDone Done save callback, optional.
4623 * @param pfnLoadPrep Prepare load callback, optional.
4624 * @param pfnLoadExec Execute load callback, optional.
4625 * @param pfnLoadDone Done load callback, optional.
4626 */
4627 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
4628 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
4629 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone));
4630
4631 /**
4632 * Creates a timer.
4633 *
4634 * @returns VBox status.
4635 * @param pDevIns Device instance.
4636 * @param enmClock The clock to use on this timer.
4637 * @param pfnCallback Callback function.
4638 * @param pszDesc Pointer to description string which must stay around
4639 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
4640 * @param ppTimer Where to store the timer on success.
4641 */
4642 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer));
4643
4644 /**
4645 * Creates an external timer.
4646 *
4647 * @returns timer pointer
4648 * @param pDevIns Device instance.
4649 * @param enmClock The clock to use on this timer.
4650 * @param pfnCallback Callback function.
4651 * @param pvUser User pointer
4652 * @param pszDesc Pointer to description string which must stay around
4653 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
4654 */
4655 DECLR3CALLBACKMEMBER(PTMTIMERHC, pfnTMTimerCreateExternal,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc));
4656
4657 /**
4658 * Registers the device with the default PCI bus.
4659 *
4660 * @returns VBox status code.
4661 * @param pDevIns Device instance.
4662 * @param pPciDev The PCI device structure.
4663 * Any PCI enabled device must keep this in it's instance data!
4664 * Fill in the PCI data config before registration, please.
4665 * @remark This is the simple interface, a Ex interface will be created if
4666 * more features are needed later.
4667 */
4668 DECLR3CALLBACKMEMBER(int, pfnPCIRegister,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev));
4669
4670 /**
4671 * Registers a I/O region (memory mapped or I/O ports) for a PCI device.
4672 *
4673 * @returns VBox status code.
4674 * @param pDevIns Device instance.
4675 * @param iRegion The region number.
4676 * @param cbRegion Size of the region.
4677 * @param enmType PCI_ADDRESS_SPACE_MEM, PCI_ADDRESS_SPACE_IO or PCI_ADDRESS_SPACE_MEM_PREFETCH.
4678 * @param pfnCallback Callback for doing the mapping.
4679 */
4680 DECLR3CALLBACKMEMBER(int, pfnPCIIORegionRegister,(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
4681
4682 /**
4683 * Set the IRQ for a PCI device.
4684 *
4685 * @param pDevIns Device instance.
4686 * @param iIrq IRQ number to set.
4687 * @param iLevel IRQ level.
4688 * @thread Any thread, but will involve the emulation thread.
4689 */
4690 DECLR3CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4691
4692 /**
4693 * Set the IRQ for a PCI device, but don't wait for EMT to process
4694 * the request when not called from EMT.
4695 *
4696 * @param pDevIns Device instance.
4697 * @param iIrq IRQ number to set.
4698 * @param iLevel IRQ level.
4699 * @thread Any thread, but will involve the emulation thread.
4700 */
4701 DECLR3CALLBACKMEMBER(void, pfnPCISetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4702
4703 /**
4704 * Set ISA IRQ for a device.
4705 *
4706 * @param pDevIns Device instance.
4707 * @param iIrq IRQ number to set.
4708 * @param iLevel IRQ level.
4709 * @thread Any thread, but will involve the emulation thread.
4710 */
4711 DECLR3CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4712
4713 /**
4714 * Set the ISA IRQ for a device, but don't wait for EMT to process
4715 * the request when not called from EMT.
4716 *
4717 * @param pDevIns Device instance.
4718 * @param iIrq IRQ number to set.
4719 * @param iLevel IRQ level.
4720 * @thread Any thread, but will involve the emulation thread.
4721 */
4722 DECLR3CALLBACKMEMBER(void, pfnISASetIrqNoWait,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
4723
4724 /**
4725 * Attaches a driver (chain) to the device.
4726 *
4727 * The first call for a LUN this will serve as a registartion of the LUN. The pBaseInterface and
4728 * the pszDesc string will be registered with that LUN and kept around for PDMR3QueryDeviceLun().
4729 *
4730 * @returns VBox status code.
4731 * @param pDevIns Device instance.
4732 * @param iLun The logical unit to attach.
4733 * @param pBaseInterface Pointer to the base interface for that LUN. (device side / down)
4734 * @param ppBaseInterface Where to store the pointer to the base interface. (driver side / up)
4735 * @param pszDesc Pointer to a string describing the LUN. This string must remain valid
4736 * for the live of the device instance.
4737 */
4738 DECLR3CALLBACKMEMBER(int, pfnDriverAttach,(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc));
4739
4740#if 0
4741 /* USB... */
4742
4743#endif
4744
4745 /**
4746 * Allocate memory which is associated with current VM instance
4747 * and automatically freed on it's destruction.
4748 *
4749 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
4750 * @param pDevIns Device instance.
4751 * @param cb Number of bytes to allocate.
4752 */
4753 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVINS pDevIns, size_t cb));
4754
4755 /**
4756 * Allocate memory which is associated with current VM instance
4757 * and automatically freed on it's destruction. The memory is ZEROed.
4758 *
4759 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
4760 * @param pDevIns Device instance.
4761 * @param cb Number of bytes to allocate.
4762 */
4763 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAllocZ,(PPDMDEVINS pDevIns, size_t cb));
4764
4765 /**
4766 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
4767 *
4768 * @param pDevIns Device instance.
4769 * @param pv Pointer to the memory to free.
4770 */
4771 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDEVINS pDevIns, void *pv));
4772
4773 /**
4774 * Set the VM error message
4775 *
4776 * @returns rc.
4777 * @param pDevIns Device instance.
4778 * @param rc VBox status code.
4779 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
4780 * @param pszFormat Error message format string.
4781 * @param ... Error message arguments.
4782 */
4783 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
4784
4785 /**
4786 * Set the VM error message
4787 *
4788 * @returns rc.
4789 * @param pDevIns Device instance.
4790 * @param rc VBox status code.
4791 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
4792 * @param pszFormat Error message format string.
4793 * @param va Error message arguments.
4794 */
4795 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
4796
4797 /**
4798 * Assert that the current thread is the emulation thread.
4799 *
4800 * @returns True if correct.
4801 * @returns False if wrong.
4802 * @param pDevIns Device instance.
4803 * @param pszFile Filename of the assertion location.
4804 * @param iLine The linenumber of the assertion location.
4805 * @param pszFunction Function of the assertion location.
4806 */
4807 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
4808
4809 /**
4810 * Assert that the current thread is NOT the emulation thread.
4811 *
4812 * @returns True if correct.
4813 * @returns False if wrong.
4814 * @param pDevIns Device instance.
4815 * @param pszFile Filename of the assertion location.
4816 * @param iLine The linenumber of the assertion location.
4817 * @param pszFunction Function of the assertion location.
4818 */
4819 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
4820
4821 /**
4822 * Stops the VM and enters the debugger to look at the guest state.
4823 *
4824 * Use the PDMDeviceDBGFStop() inline function with the RT_SRC_POS macro instead of
4825 * invoking this function directly.
4826 *
4827 * @returns VBox status code which must be passed up to the VMM.
4828 * @param pDevIns Device instance.
4829 * @param pszFile Filename of the assertion location.
4830 * @param iLine The linenumber of the assertion location.
4831 * @param pszFunction Function of the assertion location.
4832 * @param pszFormat Message. (optional)
4833 * @param args Message parameters.
4834 */
4835 DECLR3CALLBACKMEMBER(int, pfnDBGFStopV,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args));
4836
4837 /**
4838 * Register a info handler with DBGF,
4839 *
4840 * @returns VBox status code.
4841 * @param pDevIns Device instance.
4842 * @param pszName The identifier of the info.
4843 * @param pszDesc The description of the info and any arguments the handler may take.
4844 * @param pfnHandler The handler function to be called to display the info.
4845 */
4846 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler));
4847
4848 /**
4849 * Registers a statistics sample if statistics are enabled.
4850 *
4851 * @param pDevIns Device instance of the DMA.
4852 * @param pvSample Pointer to the sample.
4853 * @param enmType Sample type. This indicates what pvSample is pointing at.
4854 * @param pszName Sample name. The name is on this form "/<component>/<sample>".
4855 * Further nesting is possible.
4856 * @param enmUnit Sample unit.
4857 * @param pszDesc Sample description.
4858 */
4859 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc));
4860
4861 /**
4862 * Same as pfnSTAMRegister except that the name is specified in a
4863 * RTStrPrintf like fashion.
4864 *
4865 * @returns VBox status.
4866 * @param pDevIns Device instance of the DMA.
4867 * @param pvSample Pointer to the sample.
4868 * @param enmType Sample type. This indicates what pvSample is pointing at.
4869 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
4870 * @param enmUnit Sample unit.
4871 * @param pszDesc Sample description.
4872 * @param pszName The sample name format string.
4873 * @param ... Arguments to the format string.
4874 */
4875 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
4876 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...));
4877
4878 /**
4879 * Same as pfnSTAMRegister except that the name is specified in a
4880 * RTStrPrintfV like fashion.
4881 *
4882 * @returns VBox status.
4883 * @param pDevIns Device instance of the DMA.
4884 * @param pvSample Pointer to the sample.
4885 * @param enmType Sample type. This indicates what pvSample is pointing at.
4886 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
4887 * @param enmUnit Sample unit.
4888 * @param pszDesc Sample description.
4889 * @param pszName The sample name format string.
4890 * @param args Arguments to the format string.
4891 */
4892 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
4893 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args));
4894
4895 /**
4896 * Register the RTC device.
4897 *
4898 * @returns VBox status code.
4899 * @param pDevIns Device instance.
4900 * @param pRtcReg Pointer to a RTC registration structure.
4901 * @param ppRtcHlp Where to store the pointer to the helper functions.
4902 */
4903 DECLR3CALLBACKMEMBER(int, pfnRTCRegister,(PPDMDEVINS pDevIns, PCPDMRTCREG pRtcReg, PCPDMRTCHLP *ppRtcHlp));
4904
4905 /**
4906 * Create a queue.
4907 *
4908 * @returns VBox status code.
4909 * @param pDevIns The device instance.
4910 * @param cbItem The size of a queue item.
4911 * @param cItems The number of items in the queue.
4912 * @param cMilliesInterval The number of milliseconds between polling the queue.
4913 * If 0 then the emulation thread will be notified whenever an item arrives.
4914 * @param pfnCallback The consumer function.
4915 * @param fGCEnabled Set if the queue should work in GC too.
4916 * @param ppQueue Where to store the queue handle on success.
4917 * @thread The emulation thread.
4918 */
4919 DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
4920 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue));
4921
4922 /**
4923 * Initializes a PDM critical section.
4924 *
4925 * The PDM critical sections are derived from the IPRT critical sections, but
4926 * works in GC as well.
4927 *
4928 * @returns VBox status code.
4929 * @param pDevIns Device instance.
4930 * @param pCritSect Pointer to the critical section.
4931 * @param pszName The name of the critical section (for statistics).
4932 */
4933 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName));
4934
4935
4936 /** API available to trusted devices only.
4937 *
4938 * These APIs are providing unrestricted access to the guest and the VM,
4939 * or they are interacting intimately with PDM.
4940 *
4941 * @{
4942 */
4943 /**
4944 * Gets the VM handle. Restricted API.
4945 *
4946 * @returns VM Handle.
4947 * @param pDevIns Device instance.
4948 */
4949 DECLR3CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
4950
4951 /**
4952 * Register the PCI Bus.
4953 *
4954 * @returns VBox status code.
4955 * @param pDevIns Device instance.
4956 * @param pPciBusReg Pointer to PCI bus registration structure.
4957 * @param ppPciHlpR3 Where to store the pointer to the PCI Bus helpers.
4958 */
4959 DECLR3CALLBACKMEMBER(int, pfnPCIBusRegister,(PPDMDEVINS pDevIns, PPDMPCIBUSREG pPciBusReg, PCPDMPCIHLPR3 *ppPciHlpR3));
4960
4961 /**
4962 * Register the PIC device.
4963 *
4964 * @returns VBox status code.
4965 * @param pDevIns Device instance.
4966 * @param pPicReg Pointer to a PIC registration structure.
4967 * @param ppPicHlpR3 Where to store the pointer to the PIC HC helpers.
4968 */
4969 DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3));
4970
4971 /**
4972 * Register the APIC device.
4973 *
4974 * @returns VBox status code.
4975 * @param pDevIns Device instance.
4976 * @param pApicReg Pointer to a APIC registration structure.
4977 * @param ppApicHlpR3 Where to store the pointer to the APIC helpers.
4978 */
4979 DECLR3CALLBACKMEMBER(int, pfnAPICRegister,(PPDMDEVINS pDevIns, PPDMAPICREG pApicReg, PCPDMAPICHLPR3 *ppApicHlpR3));
4980
4981 /**
4982 * Register the I/O APIC device.
4983 *
4984 * @returns VBox status code.
4985 * @param pDevIns Device instance.
4986 * @param pIoApicReg Pointer to a I/O APIC registration structure.
4987 * @param ppIoApicHlpR3 Where to store the pointer to the IOAPIC helpers.
4988 */
4989 DECLR3CALLBACKMEMBER(int, pfnIOAPICRegister,(PPDMDEVINS pDevIns, PPDMIOAPICREG pIoApicReg, PCPDMIOAPICHLPR3 *ppIoApicHlpR3));
4990
4991 /**
4992 * Register the DMA device.
4993 *
4994 * @returns VBox status code.
4995 * @param pDevIns Device instance.
4996 * @param pDmacReg Pointer to a DMAC registration structure.
4997 * @param ppDmacHlp Where to store the pointer to the DMA helpers.
4998 */
4999 DECLR3CALLBACKMEMBER(int, pfnDMACRegister,(PPDMDEVINS pDevIns, PPDMDMACREG pDmacReg, PCPDMDMACHLP *ppDmacHlp));
5000
5001 /**
5002 * Read physical memory.
5003 *
5004 * @param pDevIns Device instance.
5005 * @param GCPhys Physical address start reading from.
5006 * @param pvBuf Where to put the read bits.
5007 * @param cbRead How many bytes to read.
5008 * @thread Any thread, but the call may involve the emulation thread.
5009 */
5010 DECLR3CALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
5011
5012 /**
5013 * Write to physical memory.
5014 *
5015 * @param pDevIns Device instance.
5016 * @param GCPhys Physical address to write to.
5017 * @param pvBuf What to write.
5018 * @param cbWrite How many bytes to write.
5019 * @thread Any thread, but the call may involve the emulation thread.
5020 */
5021 DECLR3CALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
5022
5023 /**
5024 * Read guest physical memory by virtual address.
5025 *
5026 * @param pDevIns Device instance.
5027 * @param pvDst Where to put the read bits.
5028 * @param GCVirtSrc Guest virtual address to start reading from.
5029 * @param cb How many bytes to read.
5030 * @thread The emulation thread.
5031 */
5032 DECLR3CALLBACKMEMBER(int, pfnPhysReadGCVirt,(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb));
5033
5034 /**
5035 * Write to guest physical memory by virtual address.
5036 *
5037 * @param pDevIns Device instance.
5038 * @param GCVirtDst Guest virtual address to write to.
5039 * @param pvSrc What to write.
5040 * @param cb How many bytes to write.
5041 * @thread The emulation thread.
5042 */
5043 DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb));
5044
5045 /**
5046 * Reserve physical address space for ROM and MMIO ranges.
5047 *
5048 * @returns VBox status code.
5049 * @param pDevIns Device instance.
5050 * @param GCPhys Start physical address.
5051 * @param cbRange The size of the range.
5052 * @param pszDesc Description string.
5053 * @thread The emulation thread.
5054 */
5055 DECLR3CALLBACKMEMBER(int, pfnPhysReserve,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc));
5056
5057 /**
5058 * Convert a guest physical address to a host virtual address.
5059 *
5060 * @returns VBox status code.
5061 * @param pDevIns Device instance.
5062 * @param GCPhys Start physical address.
5063 * @param cbRange The size of the range. Use 0 if you don't care about the range.
5064 * @param ppvHC Where to store the HC pointer corresponding to GCPhys.
5065 * @thread Any thread.
5066 */
5067 DECLR3CALLBACKMEMBER(int, pfnPhys2HCVirt,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC));
5068
5069 /**
5070 * Convert a guest virtual address to a host virtual address.
5071 *
5072 * @returns VBox status code.
5073 * @param pDevIns Device instance.
5074 * @param GCPtr Guest virtual address.
5075 * @param pHCPtr Where to store the HC pointer corresponding to GCPtr.
5076 * @thread The emulation thread.
5077 * @remark Careful with page boundraries.
5078 */
5079 DECLR3CALLBACKMEMBER(int, pfnPhysGCPtr2HCPtr,(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr));
5080
5081 /**
5082 * Checks if the Gate A20 is enabled or not.
5083 *
5084 * @returns true if A20 is enabled.
5085 * @returns false if A20 is disabled.
5086 * @param pDevIns Device instance.
5087 * @thread The emulation thread.
5088 */
5089 DECLR3CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
5090
5091 /**
5092 * Enables or disables the Gate A20.
5093 *
5094 * @param pDevIns Device instance.
5095 * @param fEnable Set this flag to enable the Gate A20; clear it to disable.
5096 * @thread The emulation thread.
5097 */
5098 DECLR3CALLBACKMEMBER(void, pfnA20Set,(PPDMDEVINS pDevIns, bool fEnable));
5099
5100 /**
5101 * Resets the VM.
5102 *
5103 * @returns The appropriate VBox status code to pass around on reset.
5104 * @param pDevIns Device instance.
5105 * @thread The emulation thread.
5106 */
5107 DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns));
5108
5109 /**
5110 * Suspends the VM.
5111 *
5112 * @returns The appropriate VBox status code to pass around on suspend.
5113 * @param pDevIns Device instance.
5114 * @thread The emulation thread.
5115 */
5116 DECLR3CALLBACKMEMBER(int, pfnVMSuspend,(PPDMDEVINS pDevIns));
5117
5118 /**
5119 * Power off the VM.
5120 *
5121 * @returns The appropriate VBox status code to pass around on power off.
5122 * @param pDevIns Device instance.
5123 * @thread The emulation thread.
5124 */
5125 DECLR3CALLBACKMEMBER(int, pfnVMPowerOff,(PPDMDEVINS pDevIns));
5126
5127 /**
5128 * Acquire global VM lock
5129 *
5130 * @returns VBox status code
5131 * @param pDevIns Device instance.
5132 */
5133 DECLR3CALLBACKMEMBER(int , pfnLockVM,(PPDMDEVINS pDevIns));
5134
5135 /**
5136 * Release global VM lock
5137 *
5138 * @returns VBox status code
5139 * @param pDevIns Device instance.
5140 */
5141 DECLR3CALLBACKMEMBER(int, pfnUnlockVM,(PPDMDEVINS pDevIns));
5142
5143 /**
5144 * Check that the current thread owns the global VM lock.
5145 *
5146 * @returns boolean
5147 * @param pDevIns Device instance.
5148 * @param pszFile Filename of the assertion location.
5149 * @param iLine Linenumber of the assertion location.
5150 * @param pszFunction Function of the assertion location.
5151 */
5152 DECLR3CALLBACKMEMBER(bool, pfnAssertVMLock,(PPDMDEVINS pDevIns, const char *pszFile, unsigned iLine, const char *pszFunction));
5153
5154 /**
5155 * Register transfer function for DMA channel.
5156 *
5157 * @returns VBox status code.
5158 * @param pDevIns Device instance.
5159 * @param uChannel Channel number.
5160 * @param pfnTransferHandler Device specific transfer callback function.
5161 * @param pvUser User pointer to pass to the callback.
5162 * @thread EMT
5163 */
5164 DECLR3CALLBACKMEMBER(int, pfnDMARegister,(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser));
5165
5166 /**
5167 * Read memory.
5168 *
5169 * @returns VBox status code.
5170 * @param pDevIns Device instance.
5171 * @param uChannel Channel number.
5172 * @param pvBuffer Pointer to target buffer.
5173 * @param off DMA position.
5174 * @param cbBlock Block size.
5175 * @param pcbRead Where to store the number of bytes which was read. optional.
5176 * @thread EMT
5177 */
5178 DECLR3CALLBACKMEMBER(int, pfnDMAReadMemory,(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead));
5179
5180 /**
5181 * Write memory.
5182 *
5183 * @returns VBox status code.
5184 * @param pDevIns Device instance.
5185 * @param uChannel Channel number.
5186 * @param pvBuffer Memory to write.
5187 * @param off DMA position.
5188 * @param cbBlock Block size.
5189 * @param pcbWritten Where to store the number of bytes which was written. optional.
5190 * @thread EMT
5191 */
5192 DECLR3CALLBACKMEMBER(int, pfnDMAWriteMemory,(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten));
5193
5194 /**
5195 * Set the DREQ line.
5196 *
5197 * @returns VBox status code.
5198 * @param pDevIns Device instance.
5199 * @param uChannel Channel number.
5200 * @param uLevel Level of the line.
5201 * @thread EMT
5202 */
5203 DECLR3CALLBACKMEMBER(int, pfnDMASetDREQ,(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel));
5204
5205 /**
5206 * Get channel mode.
5207 *
5208 * @returns Channel mode. See specs.
5209 * @param pDevIns Device instance.
5210 * @param uChannel Channel number.
5211 * @thread EMT
5212 */
5213 DECLR3CALLBACKMEMBER(uint8_t, pfnDMAGetChannelMode,(PPDMDEVINS pDevIns, unsigned uChannel));
5214
5215 /**
5216 * Schedule DMA execution.
5217 *
5218 * @param pDevIns Device instance.
5219 * @thread Any thread.
5220 */
5221 DECLR3CALLBACKMEMBER(void, pfnDMASchedule,(PPDMDEVINS pDevIns));
5222
5223 /**
5224 * Write CMOS value and update the checksum(s).
5225 *
5226 * @returns VBox status code.
5227 * @param pDevIns Device instance.
5228 * @param iReg The CMOS register index.
5229 * @param u8Value The CMOS register value.
5230 * @thread EMT
5231 */
5232 DECLR3CALLBACKMEMBER(int, pfnCMOSWrite,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value));
5233
5234 /**
5235 * Read CMOS value.
5236 *
5237 * @returns VBox status code.
5238 * @param pDevIns Device instance.
5239 * @param iReg The CMOS register index.
5240 * @param pu8Value Where to store the CMOS register value.
5241 * @thread EMT
5242 */
5243 DECLR3CALLBACKMEMBER(int, pfnCMOSRead,(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value));
5244
5245 /** @} */
5246
5247 /** Just a safety precaution. (The value is 0.) */
5248 uint32_t u32TheEnd;
5249} PDMDEVHLP;
5250#endif /* !IN_RING3 */
5251/** Pointer PDM Device API. */
5252typedef HCPTRTYPE(struct PDMDEVHLP *) PPDMDEVHLP;
5253/** Pointer PDM Device API. */
5254typedef HCPTRTYPE(const struct PDMDEVHLP *) PCPDMDEVHLP;
5255
5256/** Current PDMDEVHLP version number. */
5257#define PDM_DEVHLP_VERSION 0xf2010000
5258
5259
5260/**
5261 * PDM Device API - GC Variant.
5262 */
5263typedef struct PDMDEVHLPGC
5264{
5265 /** Structure version. PDM_DEVHLPGC_VERSION defines the current version. */
5266 uint32_t u32Version;
5267
5268 /**
5269 * Set the IRQ for a PCI device.
5270 *
5271 * @param pDevIns Device instance.
5272 * @param iIrq IRQ number to set.
5273 * @param iLevel IRQ level.
5274 * @thread Any thread, but will involve the emulation thread.
5275 */
5276 DECLGCCALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
5277
5278 /**
5279 * Set ISA IRQ for a device.
5280 *
5281 * @param pDevIns Device instance.
5282 * @param iIrq IRQ number to set.
5283 * @param iLevel IRQ level.
5284 * @thread Any thread, but will involve the emulation thread.
5285 */
5286 DECLGCCALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
5287
5288 /**
5289 * Read physical memory.
5290 *
5291 * @param pDevIns Device instance.
5292 * @param GCPhys Physical address start reading from.
5293 * @param pvBuf Where to put the read bits.
5294 * @param cbRead How many bytes to read.
5295 */
5296 DECLGCCALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
5297
5298 /**
5299 * Write to physical memory.
5300 *
5301 * @param pDevIns Device instance.
5302 * @param GCPhys Physical address to write to.
5303 * @param pvBuf What to write.
5304 * @param cbWrite How many bytes to write.
5305 */
5306 DECLGCCALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
5307
5308 /**
5309 * Checks if the Gate A20 is enabled or not.
5310 *
5311 * @returns true if A20 is enabled.
5312 * @returns false if A20 is disabled.
5313 * @param pDevIns Device instance.
5314 * @thread The emulation thread.
5315 */
5316 DECLGCCALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
5317
5318 /**
5319 * Set the VM error message
5320 *
5321 * @returns rc.
5322 * @param pDrvIns Driver instance.
5323 * @param rc VBox status code.
5324 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
5325 * @param pszFormat Error message format string.
5326 * @param ... Error message arguments.
5327 */
5328 DECLGCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
5329
5330 /**
5331 * Set the VM error message
5332 *
5333 * @returns rc.
5334 * @param pDrvIns Driver instance.
5335 * @param rc VBox status code.
5336 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
5337 * @param pszFormat Error message format string.
5338 * @param va Error message arguments.
5339 */
5340 DECLGCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
5341
5342 /**
5343 * Set parameters for pending MMIO patch operation
5344 *
5345 * @returns VBox status code.
5346 * @param pDevIns Device instance.
5347 * @param GCPhys MMIO physical address
5348 * @param pCachedData GC pointer to cached data
5349 */
5350 DECLGCCALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
5351
5352 /** Just a safety precaution. */
5353 uint32_t u32TheEnd;
5354} PDMDEVHLPGC;
5355/** Pointer PDM Device GC API. */
5356typedef GCPTRTYPE(struct PDMDEVHLPGC *) PPDMDEVHLPGC;
5357/** Pointer PDM Device GC API. */
5358typedef GCPTRTYPE(const struct PDMDEVHLPGC *) PCPDMDEVHLPGC;
5359
5360/** Current PDMDEVHLP version number. */
5361#define PDM_DEVHLPGC_VERSION 0xfb010000
5362
5363
5364/**
5365 * PDM Device API - R0 Variant.
5366 */
5367typedef struct PDMDEVHLPR0
5368{
5369 /** Structure version. PDM_DEVHLPR0_VERSION defines the current version. */
5370 uint32_t u32Version;
5371
5372 /**
5373 * Set the IRQ for a PCI device.
5374 *
5375 * @param pDevIns Device instance.
5376 * @param iIrq IRQ number to set.
5377 * @param iLevel IRQ level.
5378 * @thread Any thread, but will involve the emulation thread.
5379 */
5380 DECLR0CALLBACKMEMBER(void, pfnPCISetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
5381
5382 /**
5383 * Set ISA IRQ for a device.
5384 *
5385 * @param pDevIns Device instance.
5386 * @param iIrq IRQ number to set.
5387 * @param iLevel IRQ level.
5388 * @thread Any thread, but will involve the emulation thread.
5389 */
5390 DECLR0CALLBACKMEMBER(void, pfnISASetIrq,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
5391
5392 /**
5393 * Read physical memory.
5394 *
5395 * @param pDevIns Device instance.
5396 * @param GCPhys Physical address start reading from.
5397 * @param pvBuf Where to put the read bits.
5398 * @param cbRead How many bytes to read.
5399 */
5400 DECLR0CALLBACKMEMBER(void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));
5401
5402 /**
5403 * Write to physical memory.
5404 *
5405 * @param pDevIns Device instance.
5406 * @param GCPhys Physical address to write to.
5407 * @param pvBuf What to write.
5408 * @param cbWrite How many bytes to write.
5409 */
5410 DECLR0CALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));
5411
5412 /**
5413 * Checks if the Gate A20 is enabled or not.
5414 *
5415 * @returns true if A20 is enabled.
5416 * @returns false if A20 is disabled.
5417 * @param pDevIns Device instance.
5418 * @thread The emulation thread.
5419 */
5420 DECLR0CALLBACKMEMBER(bool, pfnA20IsEnabled,(PPDMDEVINS pDevIns));
5421
5422 /**
5423 * Set the VM error message
5424 *
5425 * @returns rc.
5426 * @param pDrvIns Driver instance.
5427 * @param rc VBox status code.
5428 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
5429 * @param pszFormat Error message format string.
5430 * @param ... Error message arguments.
5431 */
5432 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
5433
5434 /**
5435 * Set the VM error message
5436 *
5437 * @returns rc.
5438 * @param pDrvIns Driver instance.
5439 * @param rc VBox status code.
5440 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
5441 * @param pszFormat Error message format string.
5442 * @param va Error message arguments.
5443 */
5444 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
5445
5446 /**
5447 * Set parameters for pending MMIO patch operation
5448 *
5449 * @returns rc.
5450 * @param pDevIns Device instance.
5451 * @param GCPhys MMIO physical address
5452 * @param pCachedData GC pointer to cached data
5453 */
5454 DECLR0CALLBACKMEMBER(int, pfnPATMSetMMIOPatchInfo,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPTR pCachedData));
5455
5456 /** Just a safety precaution. */
5457 uint32_t u32TheEnd;
5458} PDMDEVHLPR0;
5459/** Pointer PDM Device R0 API. */
5460typedef HCPTRTYPE(struct PDMDEVHLPR0 *) PPDMDEVHLPR0;
5461/** Pointer PDM Device GC API. */
5462typedef HCPTRTYPE(const struct PDMDEVHLPR0 *) PCPDMDEVHLPR0;
5463
5464/** Current PDMDEVHLP version number. */
5465#define PDM_DEVHLPR0_VERSION 0xfb010000
5466
5467
5468
5469/**
5470 * PDM Device Instance.
5471 */
5472typedef struct PDMDEVINS
5473{
5474 /** Structure version. PDM_DEVINS_VERSION defines the current version. */
5475 uint32_t u32Version;
5476 /** Device instance number. */
5477 RTUINT iInstance;
5478 /** The base interface of the device.
5479 * The device constructor initializes this if it has any
5480 * device level interfaces to export. To obtain this interface
5481 * call PDMR3QueryDevice(). */
5482 PDMIBASE IBase;
5483
5484 /** Internal data. */
5485 union
5486 {
5487#ifdef PDMDEVINSINT_DECLARED
5488 PDMDEVINSINT s;
5489#endif
5490 uint8_t padding[HC_ARCH_BITS == 32 ? 48 : 96];
5491 } Internal;
5492
5493 /** Pointer the HC PDM Device API. */
5494 HCPTRTYPE(PCPDMDEVHLP) pDevHlp;
5495 /** Pointer the R0 PDM Device API. */
5496 R0PTRTYPE(PCPDMDEVHLPR0) pDevHlpR0;
5497 /** Pointer to device registration structure. */
5498 HCPTRTYPE(PCPDMDEVREG) pDevReg;
5499 /** Configuration handle. */
5500 HCPTRTYPE(PCFGMNODE) pCfgHandle;
5501 /** Pointer to device instance data. */
5502 HCPTRTYPE(void *) pvInstanceDataHC;
5503 /** Pointer the GC PDM Device API. */
5504 GCPTRTYPE(PCPDMDEVHLPGC) pDevHlpGC;
5505 /** Pointer to device instance data. */
5506 GCPTRTYPE(void *) pvInstanceDataGC;
5507#if HC_ARCH_BITS == 32
5508 /* padding to make achInstanceData aligned at 16 byte boundrary. */
5509 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 2 : 0];
5510#endif
5511 /** Device instance data. The size of this area is defined
5512 * in the PDMDEVREG::cbInstanceData field. */
5513 char achInstanceData[8];
5514} PDMDEVINS;
5515
5516/** Current DEVREG version number. */
5517#define PDM_DEVINS_VERSION 0xf3010000
5518
5519/** Converts a pointer to the PDMDEVINS::IBase to a pointer to PDMDEVINS. */
5520#define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDEVINS, IBase)) )
5521
5522
5523/** @def PDMDEV_ASSERT_EMT
5524 * Assert that the current thread is the emulation thread.
5525 */
5526#ifdef VBOX_STRICT
5527# define PDMDEV_ASSERT_EMT(pDevIns) pDevIns->pDevHlp->pfnAssertEMT(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5528#else
5529# define PDMDEV_ASSERT_EMT(pDevIns) do { } while (0)
5530#endif
5531
5532/** @def PDMDEV_ASSERT_OTHER
5533 * Assert that the current thread is NOT the emulation thread.
5534 */
5535#ifdef VBOX_STRICT
5536# define PDMDEV_ASSERT_OTHER(pDevIns) pDevIns->pDevHlp->pfnAssertOther(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5537#else
5538# define PDMDEV_ASSERT_OTHER(pDevIns) do { } while (0)
5539#endif
5540
5541/** @def PDMDEV_ASSERT_VMLOCK_OWNER
5542 * Assert that the current thread is owner of the VM lock.
5543 */
5544#ifdef VBOX_STRICT
5545# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) pDevIns->pDevHlp->pfnAssertVMLock(pDevIns, __FILE__, __LINE__, __FUNCTION__)
5546#else
5547# define PDMDEV_ASSERT_VMLOCK_OWNER(pDevIns) do { } while (0)
5548#endif
5549
5550/** @def PDMDEV_SET_ERROR
5551 * Set the VM error. See PDMDevHlpVMSetError() for printf like message formatting.
5552 * Don't use any '%' in the error string!
5553 */
5554#define PDMDEV_SET_ERROR(pDevIns, rc, pszError) \
5555 PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, pszError)
5556
5557/** @def PDMINS2DATA
5558 * Converts a PDM Device or Driver instance pointer to a pointer to the instance data.
5559 */
5560#define PDMINS2DATA(pIns, type) ( (type)(void *)&(pIns)->achInstanceData[0] )
5561
5562/** @def PDMINS2DATA_GCPTR
5563 * Converts a PDM Device or Driver instance pointer to a GC pointer to the instance data.
5564 */
5565#define PDMINS2DATA_GCPTR(pIns) ( (pIns)->pvInstanceDataGC )
5566
5567/** @def PDMINS2DATA_HCPTR
5568 * Converts a PDM Device or Driver instance pointer to a HC pointer to the instance data.
5569 */
5570#define PDMINS2DATA_HCPTR(pIns) ( (pIns)->pvInstanceDataHC )
5571
5572/** @def PDMDEVINS_2_GCPTR
5573 * Converts a PDM Device instance pointer a GC PDM Device instance pointer.
5574 */
5575#define PDMDEVINS_2_GCPTR(pDevIns) ( (GCPTRTYPE(PPDMDEVINS))((RTGCUINTPTR)(pDevIns)->pvInstanceDataGC - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
5576
5577/** @def PDMDEVINS_2_HCPTR
5578 * Converts a PDM Device instance pointer a HC PDM Device instance pointer.
5579 */
5580#define PDMDEVINS_2_HCPTR(pDevIns) ( (HCPTRTYPE(PPDMDEVINS))((RTHCUINTPTR)(pDevIns)->pvInstanceDataHC - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )
5581
5582
5583/**
5584 * VBOX_STRICT wrapper for pDevHlp->pfnDBGFStopV.
5585 *
5586 * @returns VBox status code which must be passed up to the VMM.
5587 * @param pDevIns Device instance.
5588 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
5589 * @param pszFormat Message. (optional)
5590 * @param ... Message parameters.
5591 */
5592DECLINLINE(int) PDMDeviceDBGFStop(PPDMDEVINS pDevIns, RT_SRC_POS_DECL, const char *pszFormat, ...)
5593{
5594#ifdef VBOX_STRICT
5595# ifdef IN_RING3
5596 int rc;
5597 va_list args;
5598 va_start(args, pszFormat);
5599 rc = pDevIns->pDevHlp->pfnDBGFStopV(pDevIns, RT_SRC_POS_ARGS, pszFormat, args);
5600 va_end(args);
5601 return rc;
5602# else
5603 return VINF_EM_DBG_STOP;
5604# endif
5605#else
5606 return VINF_SUCCESS;
5607#endif
5608}
5609
5610
5611#ifdef IN_RING3
5612/**
5613 * @copydoc PDMDEVHLP::pfnIOPortRegister
5614 */
5615DECLINLINE(int) PDMDevHlpIOPortRegister(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
5616 PFNIOMIOPORTOUT pfnOut, PFNIOMIOPORTIN pfnIn,
5617 PFNIOMIOPORTOUTSTRING pfnOutStr, PFNIOMIOPORTINSTRING pfnInStr, const char *pszDesc)
5618{
5619 return pDevIns->pDevHlp->pfnIOPortRegister(pDevIns, Port, cPorts, pvUser, pfnOut, pfnIn, pfnOutStr, pfnInStr, pszDesc);
5620}
5621
5622/**
5623 * @copydoc PDMDEVHLP::pfnIOPortRegisterGC
5624 */
5625DECLINLINE(int) PDMDevHlpIOPortRegisterGC(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTGCPTR pvUser,
5626 const char *pszOut, const char *pszIn, const char *pszOutStr,
5627 const char *pszInStr, const char *pszDesc)
5628{
5629 return pDevIns->pDevHlp->pfnIOPortRegisterGC(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
5630}
5631
5632/**
5633 * @copydoc PDMDEVHLP::pfnIOPortRegisterR0
5634 */
5635DECLINLINE(int) PDMDevHlpIOPortRegisterR0(PPDMDEVINS pDevIns, RTIOPORT Port, RTUINT cPorts, RTHCPTR pvUser,
5636 const char *pszOut, const char *pszIn, const char *pszOutStr,
5637 const char *pszInStr, const char *pszDesc)
5638{
5639 return pDevIns->pDevHlp->pfnIOPortRegisterR0(pDevIns, Port, cPorts, pvUser, pszOut, pszIn, pszOutStr, pszInStr, pszDesc);
5640}
5641
5642/**
5643 * @copydoc PDMDEVHLP::pfnMMIORegister
5644 */
5645DECLINLINE(int) PDMDevHlpMMIORegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
5646 PFNIOMMMIOWRITE pfnWrite, PFNIOMMMIOREAD pfnRead, PFNIOMMMIOFILL pfnFill,
5647 const char *pszDesc)
5648{
5649 return pDevIns->pDevHlp->pfnMMIORegister(pDevIns, GCPhysStart, cbRange, pvUser, pfnWrite, pfnRead, pfnFill, pszDesc);
5650}
5651
5652/**
5653 * @copydoc PDMDEVHLP::pfnMMIORegisterGC
5654 */
5655DECLINLINE(int) PDMDevHlpMMIORegisterGC(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
5656 const char *pszWrite, const char *pszRead, const char *pszFill, const char *pszDesc)
5657{
5658 return pDevIns->pDevHlp->pfnMMIORegisterGC(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, pszDesc);
5659}
5660
5661/**
5662 * @copydoc PDMDEVHLP::pfnMMIORegisterR0
5663 */
5664DECLINLINE(int) PDMDevHlpMMIORegisterR0(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
5665 const char *pszWrite, const char *pszRead, const char *pszFill, const char *pszDesc)
5666{
5667 return pDevIns->pDevHlp->pfnMMIORegisterR0(pDevIns, GCPhysStart, cbRange, pvUser, pszWrite, pszRead, pszFill, pszDesc);
5668}
5669
5670/**
5671 * @copydoc PDMDEVHLP::pfnROMRegister
5672 */
5673DECLINLINE(int) PDMDevHlpROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, const char *pszDesc)
5674{
5675 return pDevIns->pDevHlp->pfnROMRegister(pDevIns, GCPhysStart, cbRange, pvBinary, pszDesc);
5676}
5677
5678/**
5679 * @copydoc PDMDEVHLP::pfnSSMRegister
5680 */
5681DECLINLINE(int) PDMDevHlpSSMRegister(PPDMDEVINS pDevIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
5682 PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
5683 PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone)
5684{
5685 return pDevIns->pDevHlp->pfnSSMRegister(pDevIns, pszName, u32Instance, u32Version, cbGuess,
5686 pfnSavePrep, pfnSaveExec, pfnSaveDone,
5687 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
5688}
5689
5690/**
5691 * @copydoc PDMDEVHLP::pfnTMTimerCreate
5692 */
5693DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer)
5694{
5695 return pDevIns->pDevHlp->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pszDesc, ppTimer);
5696}
5697
5698/**
5699 * @copydoc PDMDEVHLP::pfnPCIRegister
5700 */
5701DECLINLINE(int) PDMDevHlpPCIRegister(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev)
5702{
5703 return pDevIns->pDevHlp->pfnPCIRegister(pDevIns, pPciDev);
5704}
5705
5706/**
5707 * @copydoc PDMDEVHLP::pfnPCIIORegionRegister
5708 */
5709DECLINLINE(int) PDMDevHlpPCIIORegionRegister(PPDMDEVINS pDevIns, int iRegion, uint32_t cbRegion, PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback)
5710{
5711 return pDevIns->pDevHlp->pfnPCIIORegionRegister(pDevIns, iRegion, cbRegion, enmType, pfnCallback);
5712}
5713
5714/**
5715 * @copydoc PDMDEVHLP::pfnDriverAttach
5716 */
5717DECLINLINE(int) PDMDevHlpDriverAttach(PPDMDEVINS pDevIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
5718{
5719 return pDevIns->pDevHlp->pfnDriverAttach(pDevIns, iLun, pBaseInterface, ppBaseInterface, pszDesc);
5720}
5721
5722/**
5723 * @copydoc PDMDEVHLP::pfnMMHeapAlloc
5724 */
5725DECLINLINE(void *) PDMDevHlpMMHeapAlloc(PPDMDEVINS pDevIns, size_t cb)
5726{
5727 return pDevIns->pDevHlp->pfnMMHeapAlloc(pDevIns, cb);
5728}
5729
5730/**
5731 * @copydoc PDMDEVHLP::pfnMMHeapAllocZ
5732 */
5733DECLINLINE(void *) PDMDevHlpMMHeapAllocZ(PPDMDEVINS pDevIns, size_t cb)
5734{
5735 return pDevIns->pDevHlp->pfnMMHeapAllocZ(pDevIns, cb);
5736}
5737
5738/**
5739 * @copydoc PDMDEVHLP::pfnMMHeapFree
5740 */
5741DECLINLINE(void) PDMDevHlpMMHeapFree(PPDMDEVINS pDevIns, void *pv)
5742{
5743 pDevIns->pDevHlp->pfnMMHeapFree(pDevIns, pv);
5744}
5745
5746/**
5747 * @copydoc PDMDEVHLP::pfnDBGFInfoRegister
5748 */
5749DECLINLINE(int) PDMDevHlpDBGFInfoRegister(PPDMDEVINS pDevIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler)
5750{
5751 return pDevIns->pDevHlp->pfnDBGFInfoRegister(pDevIns, pszName, pszDesc, pfnHandler);
5752}
5753
5754/**
5755 * @copydoc PDMDEVHLP::pfnSTAMRegister
5756 */
5757DECLINLINE(void) PDMDevHlpSTAMRegister(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
5758{
5759 pDevIns->pDevHlp->pfnSTAMRegister(pDevIns, pvSample, enmType, pszName, enmUnit, pszDesc);
5760}
5761
5762/**
5763 * @copydoc PDMDEVHLP::pfnSTAMRegisterF
5764 */
5765DECLINLINE(void) PDMDevHlpSTAMRegisterF(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
5766 const char *pszDesc, const char *pszName, ...)
5767{
5768 va_list va;
5769 va_start(va, pszName);
5770 pDevIns->pDevHlp->pfnSTAMRegisterV(pDevIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
5771 va_end(va);
5772}
5773
5774/**
5775 * @copydoc PDMDEVHLP::pfnPDMQueueCreate
5776 */
5777DECLINLINE(int) PDMDevHlpPDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
5778 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue)
5779{
5780 return pDevIns->pDevHlp->pfnPDMQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue);
5781}
5782
5783/**
5784 * @copydoc PDMDEVHLP::pfnCritSectInit
5785 */
5786DECLINLINE(int) PDMDevHlpCritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName)
5787{
5788 return pDevIns->pDevHlp->pfnCritSectInit(pDevIns, pCritSect, pszName);
5789}
5790
5791/**
5792 * @copydoc PDMDEVHLP::pfnGetVM
5793 */
5794DECLINLINE(PVM) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
5795{
5796 return pDevIns->pDevHlp->pfnGetVM(pDevIns);
5797}
5798
5799/**
5800 * @copydoc PDMDEVHLP::pfnPhysReadGCVirt
5801 */
5802DECLINLINE(int) PDMDevHlpPhysReadGCVirt(PPDMDEVINS pDevIns, void *pvDst, RTGCPTR GCVirtSrc, size_t cb)
5803{
5804 return pDevIns->pDevHlp->pfnPhysReadGCVirt(pDevIns, pvDst, GCVirtSrc, cb);
5805}
5806
5807/**
5808 * @copydoc PDMDEVHLP::pfnPhysWriteGCVirt
5809 */
5810DECLINLINE(int) PDMDevHlpPhysWriteGCVirt(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)
5811{
5812 return pDevIns->pDevHlp->pfnPhysWriteGCVirt(pDevIns, GCVirtDst, pvSrc, cb);
5813}
5814
5815/**
5816 * @copydoc PDMDEVHLP::pfnPhysReserve
5817 */
5818DECLINLINE(int) PDMDevHlpPhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc)
5819{
5820 return pDevIns->pDevHlp->pfnPhysReserve(pDevIns, GCPhys, cbRange, pszDesc);
5821}
5822
5823/**
5824 * @copydoc PDMDEVHLP::pfnPhys2HCVirt
5825 */
5826DECLINLINE(int) PDMDevHlpPhys2HCVirt(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC)
5827{
5828 return pDevIns->pDevHlp->pfnPhys2HCVirt(pDevIns, GCPhys, cbRange, ppvHC);
5829}
5830
5831/**
5832 * @copydoc PDMDEVHLP::pfnPhysGCPtr2HCPtr
5833 */
5834DECLINLINE(int) PDMDevHlpPhysGCPtr2HCPtr(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr)
5835{
5836 return pDevIns->pDevHlp->pfnPhysGCPtr2HCPtr(pDevIns, GCPtr, pHCPtr);
5837}
5838
5839/**
5840 * @copydoc PDMDEVHLP::pfnA20Set
5841 */
5842DECLINLINE(void) PDMDevHlpA20Set(PPDMDEVINS pDevIns, bool fEnable)
5843{
5844 pDevIns->pDevHlp->pfnA20Set(pDevIns, fEnable);
5845}
5846
5847/**
5848 * @copydoc PDMDEVHLP::pfnVMReset
5849 */
5850DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns)
5851{
5852 return pDevIns->pDevHlp->pfnVMReset(pDevIns);
5853}
5854
5855/**
5856 * @copydoc PDMDEVHLP::pfnVMSuspend
5857 */
5858DECLINLINE(int) PDMDevHlpVMSuspend(PPDMDEVINS pDevIns)
5859{
5860 return pDevIns->pDevHlp->pfnVMSuspend(pDevIns);
5861}
5862
5863/**
5864 * @copydoc PDMDEVHLP::pfnVMPowerOff
5865 */
5866DECLINLINE(int) PDMDevHlpVMPowerOff(PPDMDEVINS pDevIns)
5867{
5868 return pDevIns->pDevHlp->pfnVMPowerOff(pDevIns);
5869}
5870
5871/**
5872 * @copydoc PDMDEVHLP::pfnDMARegister
5873 */
5874DECLINLINE(int) PDMDevHlpDMARegister(PPDMDEVINS pDevIns, unsigned uChannel, PFNDMATRANSFERHANDLER pfnTransferHandler, void *pvUser)
5875{
5876 return pDevIns->pDevHlp->pfnDMARegister(pDevIns, uChannel, pfnTransferHandler, pvUser);
5877}
5878
5879/**
5880 * @copydoc PDMDEVHLP::pfnDMAReadMemory
5881 */
5882DECLINLINE(int) PDMDevHlpDMAReadMemory(PPDMDEVINS pDevIns, unsigned uChannel, void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbRead)
5883{
5884 return pDevIns->pDevHlp->pfnDMAReadMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbRead);
5885}
5886
5887/**
5888 * @copydoc PDMDEVHLP::pfnDMAWriteMemory
5889 */
5890DECLINLINE(int) PDMDevHlpDMAWriteMemory(PPDMDEVINS pDevIns, unsigned uChannel, const void *pvBuffer, uint32_t off, uint32_t cbBlock, uint32_t *pcbWritten)
5891{
5892 return pDevIns->pDevHlp->pfnDMAWriteMemory(pDevIns, uChannel, pvBuffer, off, cbBlock, pcbWritten);
5893}
5894
5895/**
5896 * @copydoc PDMDEVHLP::pfnDMASetDREQ
5897 */
5898DECLINLINE(int) PDMDevHlpDMASetDREQ(PPDMDEVINS pDevIns, unsigned uChannel, unsigned uLevel)
5899{
5900 return pDevIns->pDevHlp->pfnDMASetDREQ(pDevIns, uChannel, uLevel);
5901}
5902
5903/**
5904 * @copydoc PDMDEVHLP::pfnDMAGetChannelMode
5905 */
5906DECLINLINE(uint8_t) PDMDevHlpDMAGetChannelMode(PPDMDEVINS pDevIns, unsigned uChannel)
5907{
5908 return pDevIns->pDevHlp->pfnDMAGetChannelMode(pDevIns, uChannel);
5909}
5910
5911/**
5912 * @copydoc PDMDEVHLP::pfnDMASchedule
5913 */
5914DECLINLINE(void) PDMDevHlpDMASchedule(PPDMDEVINS pDevIns)
5915{
5916 pDevIns->pDevHlp->pfnDMASchedule(pDevIns);
5917}
5918
5919/**
5920 * @copydoc PDMDEVHLP::pfnCMOSWrite
5921 */
5922DECLINLINE(int) PDMDevHlpCMOSWrite(PPDMDEVINS pDevIns, unsigned iReg, uint8_t u8Value)
5923{
5924 return pDevIns->pDevHlp->pfnCMOSWrite(pDevIns, iReg, u8Value);
5925}
5926
5927/**
5928 * @copydoc PDMDEVHLP::pfnCMOSRead
5929 */
5930DECLINLINE(int) PDMDevHlpCMOSRead(PPDMDEVINS pDevIns, unsigned iReg, uint8_t *pu8Value)
5931{
5932 return pDevIns->pDevHlp->pfnCMOSRead(pDevIns, iReg, pu8Value);
5933}
5934#endif /* IN_RING3 */
5935
5936
5937/**
5938 * @copydoc PDMDEVHLP::pfnPCISetIrq
5939 */
5940DECLINLINE(void) PDMDevHlpPCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
5941{
5942#ifdef IN_GC
5943 pDevIns->pDevHlpGC->pfnPCISetIrq(pDevIns, iIrq, iLevel);
5944#elif defined(IN_RING0)
5945 pDevIns->pDevHlpR0->pfnPCISetIrq(pDevIns, iIrq, iLevel);
5946#else
5947 pDevIns->pDevHlp->pfnPCISetIrq(pDevIns, iIrq, iLevel);
5948#endif
5949}
5950
5951/**
5952 * @copydoc PDMDEVHLP::pfnPCISetIrqNoWait
5953 */
5954DECLINLINE(void) PDMDevHlpPCISetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
5955{
5956#ifdef IN_GC
5957 pDevIns->pDevHlpGC->pfnPCISetIrq(pDevIns, iIrq, iLevel);
5958#elif defined(IN_RING0)
5959 pDevIns->pDevHlpR0->pfnPCISetIrq(pDevIns, iIrq, iLevel);
5960#else
5961 pDevIns->pDevHlp->pfnPCISetIrqNoWait(pDevIns, iIrq, iLevel);
5962#endif
5963}
5964
5965/**
5966 * @copydoc PDMDEVHLP::pfnISASetIrq
5967 */
5968DECLINLINE(void) PDMDevHlpISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel)
5969{
5970#ifdef IN_GC
5971 pDevIns->pDevHlpGC->pfnISASetIrq(pDevIns, iIrq, iLevel);
5972#elif defined(IN_RING0)
5973 pDevIns->pDevHlpR0->pfnISASetIrq(pDevIns, iIrq, iLevel);
5974#else
5975 pDevIns->pDevHlp->pfnISASetIrq(pDevIns, iIrq, iLevel);
5976#endif
5977}
5978
5979/**
5980 * @copydoc PDMDEVHLP::pfnISASetIrqNoWait
5981 */
5982DECLINLINE(void) PDMDevHlpISASetIrqNoWait(PPDMDEVINS pDevIns, int iIrq, int iLevel)
5983{
5984#ifdef IN_GC
5985 pDevIns->pDevHlpGC->pfnISASetIrq(pDevIns, iIrq, iLevel);
5986#elif defined(IN_RING0)
5987 pDevIns->pDevHlpR0->pfnISASetIrq(pDevIns, iIrq, iLevel);
5988#else
5989 pDevIns->pDevHlp->pfnISASetIrqNoWait(pDevIns, iIrq, iLevel);
5990#endif
5991}
5992
5993/**
5994 * @copydoc PDMDEVHLP::pfnPhysRead
5995 */
5996DECLINLINE(void) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
5997{
5998#ifdef IN_GC
5999 pDevIns->pDevHlpGC->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
6000#elif defined(IN_RING0)
6001 pDevIns->pDevHlpR0->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
6002#else
6003 pDevIns->pDevHlp->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);
6004#endif
6005}
6006
6007/**
6008 * @copydoc PDMDEVHLP::pfnPhysWrite
6009 */
6010DECLINLINE(void) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
6011{
6012#ifdef IN_GC
6013 pDevIns->pDevHlpGC->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
6014#elif defined(IN_RING0)
6015 pDevIns->pDevHlpR0->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
6016#else
6017 pDevIns->pDevHlp->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite);
6018#endif
6019}
6020
6021/**
6022 * @copydoc PDMDEVHLP::pfnA20IsEnabled
6023 */
6024DECLINLINE(bool) PDMDevHlpA20IsEnabled(PPDMDEVINS pDevIns)
6025{
6026#ifdef IN_GC
6027 return pDevIns->pDevHlpGC->pfnA20IsEnabled(pDevIns);
6028#elif defined(IN_RING0)
6029 return pDevIns->pDevHlpR0->pfnA20IsEnabled(pDevIns);
6030#else
6031 return pDevIns->pDevHlp->pfnA20IsEnabled(pDevIns);
6032#endif
6033}
6034
6035/**
6036 * @copydoc PDMDEVHLP::pfnVMSetError
6037 */
6038DECLINLINE(int) PDMDevHlpVMSetError(PPDMDEVINS pDevIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
6039{
6040 va_list va;
6041 va_start(va, pszFormat);
6042#ifdef IN_GC
6043 pDevIns->pDevHlpGC->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
6044#elif defined(IN_RING0)
6045 pDevIns->pDevHlpR0->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
6046#else
6047 pDevIns->pDevHlp->pfnVMSetErrorV(pDevIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
6048#endif
6049 va_end(va);
6050 return rc;
6051}
6052
6053
6054
6055/** Pointer to callbacks provided to the VBoxDeviceRegister() call. */
6056typedef struct PDMDEVREGCB *PPDMDEVREGCB;
6057
6058/**
6059 * Callbacks for VBoxDeviceRegister().
6060 */
6061typedef struct PDMDEVREGCB
6062{
6063 /** Interface version.
6064 * This is set to PDM_DEVREG_CB_VERSION. */
6065 uint32_t u32Version;
6066
6067 /**
6068 * Registers a device with the current VM instance.
6069 *
6070 * @returns VBox status code.
6071 * @param pCallbacks Pointer to the callback table.
6072 * @param pDevReg Pointer to the device registration record.
6073 * This data must be permanent and readonly.
6074 */
6075 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pDevReg));
6076
6077 /**
6078 * Allocate memory which is associated with current VM instance
6079 * and automatically freed on it's destruction.
6080 *
6081 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.
6082 * @param pCallbacks Pointer to the callback table.
6083 * @param cb Number of bytes to allocate.
6084 */
6085 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVREGCB pCallbacks, size_t cb));
6086} PDMDEVREGCB;
6087
6088/** Current version of the PDMDEVREGCB structure. */
6089#define PDM_DEVREG_CB_VERSION 0xf4010000
6090
6091
6092/**
6093 * The VBoxDevicesRegister callback function.
6094 *
6095 * PDM will invoke this function after loading a device module and letting
6096 * the module decide which devices to register and how to handle conflicts.
6097 *
6098 * @returns VBox status code.
6099 * @param pCallbacks Pointer to the callback table.
6100 * @param u32Version VBox version number.
6101 */
6102typedef DECLCALLBACK(int) FNPDMVBOXDEVICESREGISTER(PPDMDEVREGCB pCallbacks, uint32_t u32Version);
6103
6104/** @} */
6105
6106
6107
6108
6109/** @defgroup grp_pdm_services Services
6110 * @ingroup grp_pdm
6111 * @{ */
6112
6113
6114/**
6115 * Construct a service instance for a VM.
6116 *
6117 * @returns VBox status.
6118 * @param pSrvIns The service instance data.
6119 * If the registration structure is needed, pSrvIns->pReg points to it.
6120 * @param pCfg Configuration node handle for the service. Use this to obtain the configuration
6121 * of the driver instance. It's also found in pSrvIns->pCfg, but since it's primary
6122 * usage is expected in this function it is passed as a parameter.
6123 */
6124typedef DECLCALLBACK(int) FNPDMSRVCONSTRUCT(PPDMSRVINS pSrvIns, PCFGMNODE pCfg);
6125/** Pointer to a FNPDMSRVCONSTRUCT() function. */
6126typedef FNPDMSRVCONSTRUCT *PFNPDMSRVCONSTRUCT;
6127
6128/**
6129 * Destruct a driver instance.
6130 *
6131 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
6132 * resources can be freed correctly.
6133 *
6134 * @param pSrvIns The service instance data.
6135 */
6136typedef DECLCALLBACK(void) FNPDMSRVDESTRUCT(PPDMSRVINS pSrvIns);
6137/** Pointer to a FNPDMSRVDESTRUCT() function. */
6138typedef FNPDMSRVDESTRUCT *PFNPDMSRVDESTRUCT;
6139
6140/**
6141 * Power On notification.
6142 *
6143 * @param pSrvIns The service instance data.
6144 */
6145typedef DECLCALLBACK(void) FNPDMSRVPOWERON(PPDMSRVINS pSrvIns);
6146/** Pointer to a FNPDMSRVPOWERON() function. */
6147typedef FNPDMSRVPOWERON *PFNPDMSRVPOWERON;
6148
6149/**
6150 * Reset notification.
6151 *
6152 * @returns VBox status.
6153 * @param pSrvIns The service instance data.
6154 */
6155typedef DECLCALLBACK(void) FNPDMSRVRESET(PPDMSRVINS pSrvIns);
6156/** Pointer to a FNPDMSRVRESET() function. */
6157typedef FNPDMSRVRESET *PFNPDMSRVRESET;
6158
6159/**
6160 * Suspend notification.
6161 *
6162 * @returns VBox status.
6163 * @param pSrvIns The service instance data.
6164 */
6165typedef DECLCALLBACK(void) FNPDMSRVSUSPEND(PPDMSRVINS pSrvIns);
6166/** Pointer to a FNPDMSRVSUSPEND() function. */
6167typedef FNPDMSRVSUSPEND *PFNPDMSRVSUSPEND;
6168
6169/**
6170 * Resume notification.
6171 *
6172 * @returns VBox status.
6173 * @param pSrvIns The service instance data.
6174 */
6175typedef DECLCALLBACK(void) FNPDMSRVRESUME(PPDMSRVINS pSrvIns);
6176/** Pointer to a FNPDMSRVRESUME() function. */
6177typedef FNPDMSRVRESUME *PFNPDMSRVRESUME;
6178
6179/**
6180 * Power Off notification.
6181 *
6182 * @param pSrvIns The service instance data.
6183 */
6184typedef DECLCALLBACK(void) FNPDMSRVPOWEROFF(PPDMSRVINS pSrvIns);
6185/** Pointer to a FNPDMSRVPOWEROFF() function. */
6186typedef FNPDMSRVPOWEROFF *PFNPDMSRVPOWEROFF;
6187
6188/**
6189 * Detach notification.
6190 *
6191 * This is called when a driver or device is detached from the service
6192 *
6193 * @param pSrvIns The service instance data.
6194 */
6195typedef DECLCALLBACK(void) FNPDMSRVDETACH(PPDMSRVINS pSrvIns, PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns);
6196/** Pointer to a FNPDMSRVDETACH() function. */
6197typedef FNPDMSRVDETACH *PFNPDMSRVDETACH;
6198
6199
6200
6201/** PDM Service Registration Structure,
6202 * This structure is used when registering a driver from
6203 * VBoxServicesRegister() (HC Ring-3). PDM will continue use till
6204 * the VM is terminated.
6205 */
6206typedef struct PDMSRVREG
6207{
6208 /** Structure version. PDM_SRVREG_VERSION defines the current version. */
6209 uint32_t u32Version;
6210 /** Driver name. */
6211 char szServiceName[32];
6212 /** The description of the driver. The UTF-8 string pointed to shall, like this structure,
6213 * remain unchanged from registration till VM destruction. */
6214 const char *pszDescription;
6215
6216 /** Flags, combination of the PDM_SRVREG_FLAGS_* \#defines. */
6217 RTUINT fFlags;
6218 /** Size of the instance data. */
6219 RTUINT cbInstance;
6220
6221 /** Construct instance - required. */
6222 PFNPDMSRVCONSTRUCT pfnConstruct;
6223 /** Destruct instance - optional. */
6224 PFNPDMSRVDESTRUCT pfnDestruct;
6225 /** Power on notification - optional. */
6226 PFNPDMSRVPOWERON pfnPowerOn;
6227 /** Reset notification - optional. */
6228 PFNPDMSRVRESET pfnReset;
6229 /** Suspend notification - optional. */
6230 PFNPDMSRVSUSPEND pfnSuspend;
6231 /** Resume notification - optional. */
6232 PFNPDMSRVRESUME pfnResume;
6233 /** Detach notification - optional. */
6234 PFNPDMSRVDETACH pfnDetach;
6235 /** Power off notification - optional. */
6236 PFNPDMSRVPOWEROFF pfnPowerOff;
6237
6238} PDMSRVREG;
6239/** Pointer to a PDM Driver Structure. */
6240typedef PDMSRVREG *PPDMSRVREG;
6241/** Const pointer to a PDM Driver Structure. */
6242typedef PDMSRVREG const *PCPDMSRVREG;
6243
6244
6245
6246/**
6247 * PDM Service API.
6248 */
6249typedef struct PDMSRVHLP
6250{
6251 /** Structure version. PDM_SRVHLP_VERSION defines the current version. */
6252 uint32_t u32Version;
6253
6254 /**
6255 * Assert that the current thread is the emulation thread.
6256 *
6257 * @returns True if correct.
6258 * @returns False if wrong.
6259 * @param pSrvIns Service instance.
6260 * @param pszFile Filename of the assertion location.
6261 * @param iLine Linenumber of the assertion location.
6262 * @param pszFunction Function of the assertion location.
6263 */
6264 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMSRVINS pSrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
6265
6266 /**
6267 * Assert that the current thread is NOT the emulation thread.
6268 *
6269 * @returns True if correct.
6270 * @returns False if wrong.
6271 * @param pSrvIns Service instance.
6272 * @param pszFile Filename of the assertion location.
6273 * @param iLine Linenumber of the assertion location.
6274 * @param pszFunction Function of the assertion location.
6275 */
6276 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMSRVINS pSrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
6277
6278 /**
6279 * Creates a timer.
6280 *
6281 * @returns VBox status.
6282 * @param pVM The VM to create the timer in.
6283 * @param pSrvIns Service instance.
6284 * @param enmClock The clock to use on this timer.
6285 * @param pfnCallback Callback function.
6286 * @param pszDesc Pointer to description string which must stay around
6287 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
6288 * @param ppTimer Where to store the timer on success.
6289 */
6290 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMSRVINS pSrvIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer));
6291
6292 /**
6293 * Query the virtual timer frequency.
6294 *
6295 * @returns Frequency in Hz.
6296 * @param pSrvIns Service instance.
6297 * @thread Any thread.
6298 */
6299 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualFreq,(PPDMSRVINS pSrvIns));
6300
6301 /**
6302 * Query the virtual time.
6303 *
6304 * @returns The current virtual time.
6305 * @param pSrvIns Service instance.
6306 * @thread Any thread.
6307 */
6308 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualTime,(PPDMSRVINS pSrvIns));
6309
6310} PDMSRVHLP;
6311/** Pointer PDM Service API. */
6312typedef PDMSRVHLP *PPDMSRVHLP;
6313/** Pointer const PDM Service API. */
6314typedef const PDMSRVHLP *PCPDMSRVHLP;
6315
6316/** Current SRVHLP version number. */
6317#define PDM_SRVHLP_VERSION 0xf9010000
6318
6319
6320/**
6321 * PDM Service Instance.
6322 */
6323typedef struct PDMSRVINS
6324{
6325 /** Structure version. PDM_SRVINS_VERSION defines the current version. */
6326 uint32_t u32Version;
6327
6328 /** Internal data. */
6329 union
6330 {
6331#ifdef PDMSRVINSINT_DECLARED
6332 PDMSRVINSINT s;
6333#endif
6334 uint8_t padding[HC_ARCH_BITS == 32 ? 32 : 32];
6335 } Internal;
6336
6337 /** Pointer the PDM Service API. */
6338 HCPTRTYPE(PCPDMSRVHLP) pHlp;
6339 /** Pointer to driver registration structure. */
6340 HCPTRTYPE(PCPDMSRVREG) pReg;
6341 /** Configuration handle. */
6342 HCPTRTYPE(PCFGMNODE) pCfg;
6343 /** The base interface of the service.
6344 * The service constructor initializes this. */
6345 PDMIBASE IBase;
6346 /* padding to make achInstanceData aligned at 16 byte boundrary. */
6347 uint32_t au32Padding[2];
6348 /** Pointer to driver instance data. */
6349 HCPTRTYPE(void *) pvInstanceData;
6350 /** Driver instance data. The size of this area is defined
6351 * in the PDMSRVREG::cbInstanceData field. */
6352 char achInstanceData[4];
6353} PDMSRVINS;
6354
6355/** Current PDMSRVREG version number. */
6356#define PDM_SRVINS_VERSION 0xf7010000
6357
6358/** Converts a pointer to the PDMSRVINS::IBase to a pointer to PDMSRVINS. */
6359#define PDMIBASE_2_PDMSRV(pInterface) ( (PPDMSRVINS)((char *)(pInterface) - RT_OFFSETOF(PDMSRVINS, IBase)) )
6360
6361
6362
6363/** Pointer to callbacks provided to the VBoxServiceRegister() call. */
6364typedef struct PDMSRVREGCB *PPDMSRVREGCB;
6365
6366/**
6367 * Callbacks for VBoxServiceRegister().
6368 */
6369typedef struct PDMSRVREGCB
6370{
6371 /** Interface version.
6372 * This is set to PDM_SRVREG_CB_VERSION. */
6373 uint32_t u32Version;
6374
6375 /**
6376 * Registers a service with the current VM instance.
6377 *
6378 * @returns VBox status code.
6379 * @param pCallbacks Pointer to the callback table.
6380 * @param pSrvReg Pointer to the device registration record.
6381 * This data must be permanent and readonly.
6382 */
6383 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMSRVREGCB pCallbacks, PCPDMSRVREG pSrvReg));
6384} PDMSRVREGCB;
6385
6386/** Current version of the PDMSRVREGCB structure. */
6387#define PDM_SRVREG_CB_VERSION 0xf8010000
6388
6389
6390/**
6391 * The VBoxServicesRegister callback function.
6392 *
6393 * PDM will invoke this function after loading a device module and letting
6394 * the module decide which devices to register and how to handle conflicts.
6395 *
6396 * @returns VBox status code.
6397 * @param pCallbacks Pointer to the callback table.
6398 * @param u32Version VBox version number.
6399 */
6400typedef DECLCALLBACK(int) FNPDMVBOXSERVICESREGISTER(PPDMSRVREGCB pCallbacks, uint32_t u32Version);
6401
6402
6403/** @} */
6404
6405/**
6406 * Gets the pending interrupt.
6407 *
6408 * @returns VBox status code.
6409 * @param pVM VM handle.
6410 * @param pu8Interrupt Where to store the interrupt on success.
6411 */
6412PDMDECL(int) PDMGetInterrupt(PVM pVM, uint8_t *pu8Interrupt);
6413
6414/**
6415 * Sets the pending ISA interrupt.
6416 *
6417 * @returns VBox status code.
6418 * @param pVM VM handle.
6419 * @param u8Irq The IRQ line.
6420 * @param u8Level The new level.
6421 */
6422PDMDECL(int) PDMIsaSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level);
6423
6424/**
6425 * Sets the pending I/O APIC interrupt.
6426 *
6427 * @returns VBox status code.
6428 * @param pVM VM handle.
6429 * @param u8Irq The IRQ line.
6430 * @param u8Level The new level.
6431 */
6432PDMDECL(int) PDMIoApicSetIrq(PVM pVM, uint8_t u8Irq, uint8_t u8Level);
6433
6434/**
6435 * Set the APIC base.
6436 *
6437 * @returns VBox status code.
6438 * @param pVM VM handle.
6439 * @param u64Base The new base.
6440 */
6441PDMDECL(int) PDMApicSetBase(PVM pVM, uint64_t u64Base);
6442
6443/**
6444 * Get the APIC base.
6445 *
6446 * @returns VBox status code.
6447 * @param pVM VM handle.
6448 * @param pu64Base Where to store the APIC base.
6449 */
6450PDMDECL(int) PDMApicGetBase(PVM pVM, uint64_t *pu64Base);
6451
6452/**
6453 * Set the TPR (task priority register?).
6454 *
6455 * @returns VBox status code.
6456 * @param pVM VM handle.
6457 * @param u8TPR The new TPR.
6458 */
6459PDMDECL(int) PDMApicSetTPR(PVM pVM, uint8_t u8TPR);
6460
6461/**
6462 * Get the TPR (task priority register?).
6463 *
6464 * @returns The current TPR.
6465 * @param pVM VM handle.
6466 * @param pu8TPR Where to store the TRP.
6467 */
6468PDMDECL(int) PDMApicGetTPR(PVM pVM, uint8_t *pu8TPR);
6469
6470
6471#ifdef IN_RING3
6472/** @defgroup grp_pdm_r3 The PDM Host Context Ring-3 API
6473 * @ingroup grp_pdm
6474 * @{
6475 */
6476
6477/**
6478 * Initializes the PDM.
6479 *
6480 * @returns VBox status code.
6481 * @param pVM The VM to operate on.
6482 */
6483PDMR3DECL(int) PDMR3Init(PVM pVM);
6484
6485/**
6486 * This function will notify all the devices and their
6487 * attached drivers about the VM now being powered on.
6488 *
6489 * @param pVM VM Handle.
6490 */
6491PDMR3DECL(void) PDMR3PowerOn(PVM pVM);
6492
6493/**
6494 * This function will notify all the devices and their
6495 * attached drivers about the VM now being reset.
6496 *
6497 * @param pVM VM Handle.
6498 */
6499PDMR3DECL(void) PDMR3Reset(PVM pVM);
6500
6501/**
6502 * This function will notify all the devices and their
6503 * attached drivers about the VM now being suspended.
6504 *
6505 * @param pVM VM Handle.
6506 */
6507PDMR3DECL(void) PDMR3Suspend(PVM pVM);
6508
6509/**
6510 * This function will notify all the devices and their
6511 * attached drivers about the VM now being resumed.
6512 *
6513 * @param pVM VM Handle.
6514 */
6515PDMR3DECL(void) PDMR3Resume(PVM pVM);
6516
6517/**
6518 * This function will notify all the devices and their
6519 * attached drivers about the VM being powered off.
6520 *
6521 * @param pVM VM Handle.
6522 */
6523PDMR3DECL(void) PDMR3PowerOff(PVM pVM);
6524
6525
6526/**
6527 * Applies relocations to GC modules.
6528 *
6529 * This must be done very early in the relocation
6530 * process so that components can resolve GC symbols during relocation.
6531 *
6532 * @param pVM VM handle.
6533 * @param offDelta Relocation delta relative to old location.
6534 */
6535PDMR3DECL(void) PDMR3LdrRelocate(PVM pVM, RTGCINTPTR offDelta);
6536
6537/**
6538 * Applies relocations to data and code managed by this
6539 * component. This function will be called at init and
6540 * whenever the VMM need to relocate it self inside the GC.
6541 *
6542 * @param pVM VM handle.
6543 * @param offDelta Relocation delta relative to old location.
6544 */
6545PDMR3DECL(void) PDMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
6546
6547/**
6548 * Terminates the PDM.
6549 *
6550 * Termination means cleaning up and freeing all resources,
6551 * the VM it self is at this point powered off or suspended.
6552 *
6553 * @returns VBox status code.
6554 * @param pVM The VM to operate on.
6555 */
6556PDMR3DECL(int) PDMR3Term(PVM pVM);
6557
6558
6559/**
6560 * Get the address of a symbol in a given HC ring-3 module.
6561 *
6562 * @returns VBox status code.
6563 * @param pVM VM handle.
6564 * @param pszModule Module name.
6565 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
6566 * ordinal value rather than a string pointer.
6567 * @param ppvValue Where to store the symbol value.
6568 */
6569PDMR3DECL(int) PDMR3GetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
6570
6571/**
6572 * Get the address of a symbol in a given HC ring-0 module.
6573 *
6574 * @returns VBox status code.
6575 * @param pVM VM handle.
6576 * @param pszModule Module name. If NULL the main R0 module (VMMR0.r0) is assumed.
6577 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
6578 * ordinal value rather than a string pointer.
6579 * @param ppvValue Where to store the symbol value.
6580 */
6581PDMR3DECL(int) PDMR3GetSymbolR0(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
6582
6583/**
6584 * Same as PDMR3GetSymbolR0 except that the module will be attempted loaded if not found.
6585 *
6586 * @returns VBox status code.
6587 * @param pVM VM handle.
6588 * @param pszModule Module name. If NULL the main R0 module (VMMR0.r0) is assumed.
6589 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
6590 * ordinal value rather than a string pointer.
6591 * @param ppvValue Where to store the symbol value.
6592 */
6593PDMR3DECL(int) PDMR3GetSymbolR0Lazy(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
6594
6595/**
6596 * Loads a module into the guest context (i.e. into the Hypervisor memory region).
6597 *
6598 * The external (to PDM) use of this interface is to load VMMGC.gc.
6599 *
6600 * @returns VBox status code.
6601 * @param pVM The VM to load it into.
6602 * @param pszFilename Filename of the module binary.
6603 * @param pszName Module name. Case sensitive and the length is limited!
6604 */
6605PDMR3DECL(int) PDMR3LoadGC(PVM pVM, const char *pszFilename, const char *pszName);
6606
6607/**
6608 * Get the address of a symbol in a given GC module.
6609 *
6610 * @returns VBox status code.
6611 * @param pVM VM handle.
6612 * @param pszModule Module name. If NULL the main GC module (VMMGC.gc) is assumed.
6613 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
6614 * ordinal value rather than a string pointer.
6615 * @param pGCPtrValue Where to store the symbol value.
6616 */
6617PDMR3DECL(int) PDMR3GetSymbolGC(PVM pVM, const char *pszModule, const char *pszSymbol, PRTGCPTR pGCPtrValue);
6618
6619/**
6620 * Same as PDMR3GetSymbolGC except that the module will be attempted loaded if not found.
6621 *
6622 * @returns VBox status code.
6623 * @param pVM VM handle.
6624 * @param pszModule Module name. If NULL the main GC module (VMMGC.gc) is assumed.
6625 * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
6626 * ordinal value rather than a string pointer.
6627 * @param pGCPtrValue Where to store the symbol value.
6628 */
6629PDMR3DECL(int) PDMR3GetSymbolGCLazy(PVM pVM, const char *pszModule, const char *pszSymbol, PRTGCPTR pGCPtrValue);
6630
6631/**
6632 * Queries module information from an EIP.
6633 *
6634 * This is typically used to locate a crash address.
6635 *
6636 * @returns VBox status code.
6637 * @param pVM VM handle
6638 * @param uEIP EIP to locate.
6639 * @param pszModName Where to store the module name.
6640 * @param cchModName Size of the module name buffer.
6641 * @param pMod Base address of the module.
6642 * @param pszNearSym1 Name of the closes symbol from below.
6643 * @param cchNearSym1 Size of the buffer pointed to by pszNearSym1.
6644 * @param pNearSym1 The address of pszNearSym1.
6645 * @param pszNearSym2 Name of the closes symbol from below.
6646 * @param cchNearSym2 Size of the buffer pointed to by pszNearSym2.
6647 * @param pNearSym2 The address of pszNearSym2.
6648 */
6649PDMR3DECL(int) PDMR3QueryModFromEIP(PVM pVM, uint32_t uEIP,
6650 char *pszModName, unsigned cchModName, RTGCPTR *pMod,
6651 char *pszNearSym1, unsigned cchNearSym1, RTGCPTR *pNearSym1,
6652 char *pszNearSym2, unsigned cchNearSym2, RTGCPTR *pNearSym2);
6653
6654
6655/**
6656 * Module enumeration callback function.
6657 *
6658 * @returns VBox status.
6659 * Failure will stop the search and return the return code.
6660 * Warnings will be ignored and not returned.
6661 * @param pVM VM Handle.
6662 * @param pszFilename Module filename.
6663 * @param pszName Module name. (short and unique)
6664 * @param ImageBase Address where to executable image is loaded.
6665 * @param cbImage Size of the executable image.
6666 * @param fGC Set if guest context, clear if host context.
6667 * @param pvArg User argument.
6668 */
6669typedef DECLCALLBACK(int) FNPDMR3ENUM(PVM pVM, const char *pszFilename, const char *pszName, RTUINTPTR ImageBase, size_t cbImage, bool fGC);
6670/** Pointer to a FNPDMR3ENUM() function. */
6671typedef FNPDMR3ENUM *PFNPDMR3ENUM;
6672
6673
6674/**
6675 * Enumerate all PDM modules.
6676 *
6677 * @returns VBox status.
6678 * @param pVM VM Handle.
6679 * @param pfnCallback Function to call back for each of the modules.
6680 * @param pvArg User argument.
6681 */
6682PDMR3DECL(int) PDMR3EnumModules(PVM pVM, PFNPDMR3ENUM pfnCallback, void *pvArg);
6683
6684
6685/**
6686 * Queries the base interace of a device instance.
6687 *
6688 * The caller can use this to query other interfaces the device implements
6689 * and use them to talk to the device.
6690 *
6691 * @returns VBox status code.
6692 * @param pVM VM handle.
6693 * @param pszDevice Device name.
6694 * @param iInstance Device instance.
6695 * @param ppBase Where to store the pointer to the base device interface on success.
6696 * @remark We're doing any locking ATM, so don't try call this at times when the
6697 * device chain is known to be updated.
6698 */
6699PDMR3DECL(int) PDMR3QueryDevice(PVM pVM, const char *pszDevice, unsigned iInstance, PPDMIBASE *ppBase);
6700
6701/**
6702 * Queries the base interface of a device LUN.
6703 *
6704 * This differs from PDMR3QueryLun by that it returns the interface on the
6705 * device and not the top level driver.
6706 *
6707 * @returns VBox status code.
6708 * @param pVM VM Handle.
6709 * @param pszDevice Device name.
6710 * @param iInstance Device instance.
6711 * @param iLun The Logical Unit to obtain the interface of.
6712 * @param ppBase Where to store the base interface pointer.
6713 * @remark We're doing any locking ATM, so don't try call this at times when the
6714 * device chain is known to be updated.
6715 */
6716PDMR3DECL(int) PDMR3QueryDeviceLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMIBASE *ppBase);
6717
6718/**
6719 * Query the interface of the top level driver on a LUN.
6720 *
6721 * @returns VBox status code.
6722 * @param pVM VM Handle.
6723 * @param pszDevice Device name.
6724 * @param iInstance Device instance.
6725 * @param iLun The Logical Unit to obtain the interface of.
6726 * @param ppBase Where to store the base interface pointer.
6727 * @remark We're doing any locking ATM, so don't try call this at times when the
6728 * device chain is known to be updated.
6729 */
6730PDMR3DECL(int) PDMR3QueryLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMIBASE *ppBase);
6731
6732/**
6733 * Attaches a preconfigured driver to an existing device instance.
6734 *
6735 * This is used to change drivers and suchlike at runtime.
6736 *
6737 * @returns VBox status code.
6738 * @param pVM VM Handle.
6739 * @param pszDevice Device name.
6740 * @param iInstance Device instance.
6741 * @param iLun The Logical Unit to obtain the interface of.
6742 * @param ppBase Where to store the base interface pointer. Optional.
6743 * @thread EMT
6744 */
6745PDMR3DECL(int) PDMR3DeviceAttach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMIBASE *ppBase);
6746
6747/**
6748 * Detaches a driver from an existing device instance.
6749 *
6750 * This is used to change drivers and suchlike at runtime.
6751 *
6752 * @returns VBox status code.
6753 * @param pVM VM Handle.
6754 * @param pszDevice Device name.
6755 * @param iInstance Device instance.
6756 * @param iLun The Logical Unit to obtain the interface of.
6757 * @thread EMT
6758 */
6759PDMR3DECL(int) PDMR3DeviceDetach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun);
6760
6761/**
6762 * Executes pending DMA transfers.
6763 * Forced Action handler.
6764 *
6765 * @param pVM VM handle.
6766 */
6767PDMR3DECL(void) PDMR3DmaRun(PVM pVM);
6768
6769/**
6770 * Call polling function.
6771 *
6772 * @param pVM VM handle.
6773 */
6774PDMR3DECL(void) PDMR3Poll(PVM pVM);
6775
6776/**
6777 * Service a VMMCALLHOST_PDM_LOCK call.
6778 *
6779 * @returns VBox status code.
6780 * @param pVM The VM handle.
6781 */
6782PDMR3DECL(int) PDMR3LockCall(PVM pVM);
6783
6784/** @} */
6785#endif
6786
6787
6788#ifdef IN_GC
6789/** @defgroup grp_pdm_gc The PDM Guest Context API
6790 * @ingroup grp_pdm
6791 * @{
6792 */
6793/** @} */
6794#endif
6795
6796__END_DECLS
6797
6798/** @} */
6799
6800#endif
6801
Note: See TracBrowser for help on using the repository browser.

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