VirtualBox

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

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

Update for setting the visible region from within the guest

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

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