VirtualBox

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

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

Stricter pointer typechecking. (R0 vs R3)

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

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