VirtualBox

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

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

PDM_DEVREG_CLASS_MISC

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

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