VirtualBox

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

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

Implement log flag usecrlf, which translates LF line ending to CR/LF.
Activate it by default for Windows builds, only for release log so far.
Also fixed a couple of typos in comments.

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