VirtualBox

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

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

Removed obsolete visible region methods.

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