VirtualBox

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

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

Do not block EMT while resizing the framebuffer.

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