VirtualBox

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

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

Added TMR3UCTNow, exported it as a DevHlp and made VMMDev use it as time source. TMR3UCTNow adjust for lag we intend to catchup so the guest time wont run ahead of real-world time.

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

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