VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmifs.h@ 51504

Last change on this file since 51504 was 51342, checked in by vboxsync, 11 years ago

Main,DrvVD: Interface to pass the keys to the disk encryption module from Main

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 129.8 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Interfaces.
3 */
4
5/*
6 * Copyright (C) 2006-2012 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.215389.xyz. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_vmm_pdmifs_h
27#define ___VBox_vmm_pdmifs_h
28
29#include <iprt/sg.h>
30#include <VBox/types.h>
31#include <VBox/hgcmsvc.h>
32
33
34RT_C_DECLS_BEGIN
35
36/** @defgroup grp_pdm_interfaces The PDM Interface Definitions
37 * @ingroup grp_pdm
38 *
39 * For historical reasons (the PDMINTERFACE enum) a lot of interface was stuffed
40 * together in this group instead, dragging stuff into global space that didn't
41 * need to be there and making this file huge (>2500 lines). Since we're using
42 * UUIDs as interface identifiers (IIDs) now, no only generic PDM interface will
43 * be added to this file. Component specific interface should be defined in the
44 * header file of that component.
45 *
46 * Interfaces consists of a method table (typedef'ed struct) and an interface
47 * ID. The typename of the method table should have an 'I' in it, be all
48 * capitals and according to the rules, no underscores. The interface ID is a
49 * \#define constructed by appending '_IID' to the typename. The IID value is a
50 * UUID string on the form "a2299c0d-b709-4551-aa5a-73f59ffbed74". If you stick
51 * to these rules, you can make use of the PDMIBASE_QUERY_INTERFACE and
52 * PDMIBASE_RETURN_INTERFACE when querying interface and implementing
53 * PDMIBASE::pfnQueryInterface respectively.
54 *
55 * In most interface descriptions the orientation of the interface is given as
56 * 'down' or 'up'. This refers to a model with the device on the top and the
57 * drivers stacked below it. Sometimes there is mention of 'main' or 'external'
58 * which normally means the same, i.e. the Main or VBoxBFE API. Picture the
59 * orientation of 'main' as horizontal.
60 *
61 * @{
62 */
63
64
65/** @name PDMIBASE
66 * @{
67 */
68
69/**
70 * PDM Base Interface.
71 *
72 * Everyone implements this.
73 */
74typedef struct PDMIBASE
75{
76 /**
77 * Queries an interface to the driver.
78 *
79 * @returns Pointer to interface.
80 * @returns NULL if the interface was not supported by the driver.
81 * @param pInterface Pointer to this interface structure.
82 * @param pszIID The interface ID, a UUID string.
83 * @thread Any thread.
84 */
85 DECLR3CALLBACKMEMBER(void *, pfnQueryInterface,(struct PDMIBASE *pInterface, const char *pszIID));
86} PDMIBASE;
87/** PDMIBASE interface ID. */
88#define PDMIBASE_IID "a2299c0d-b709-4551-aa5a-73f59ffbed74"
89
90/**
91 * Helper macro for querying an interface from PDMIBASE.
92 *
93 * @returns Correctly typed PDMIBASE::pfnQueryInterface return value.
94 *
95 * @param pIBase Pointer to the base interface.
96 * @param InterfaceType The interface type name. The interface ID is
97 * derived from this by appending _IID.
98 */
99#define PDMIBASE_QUERY_INTERFACE(pIBase, InterfaceType) \
100 ( (InterfaceType *)(pIBase)->pfnQueryInterface(pIBase, InterfaceType##_IID ) )
101
102/**
103 * Helper macro for implementing PDMIBASE::pfnQueryInterface.
104 *
105 * Return @a pInterface if @a pszIID matches the @a InterfaceType. This will
106 * perform basic type checking.
107 *
108 * @param pszIID The ID of the interface that is being queried.
109 * @param InterfaceType The interface type name. The interface ID is
110 * derived from this by appending _IID.
111 * @param pInterface The interface address expression.
112 */
113#define PDMIBASE_RETURN_INTERFACE(pszIID, InterfaceType, pInterface) \
114 do { \
115 if (RTUuidCompare2Strs((pszIID), InterfaceType##_IID) == 0) \
116 { \
117 P##InterfaceType pReturnInterfaceTypeCheck = (pInterface); \
118 return pReturnInterfaceTypeCheck; \
119 } \
120 } while (0)
121
122/** @} */
123
124
125/** @name PDMIBASERC
126 * @{
127 */
128
129/**
130 * PDM Base Interface for querying ring-mode context interfaces in
131 * ring-3.
132 *
133 * This is mandatory for drivers present in raw-mode context.
134 */
135typedef struct PDMIBASERC
136{
137 /**
138 * Queries an ring-mode context interface to the driver.
139 *
140 * @returns Pointer to interface.
141 * @returns NULL if the interface was not supported by the driver.
142 * @param pInterface Pointer to this interface structure.
143 * @param pszIID The interface ID, a UUID string.
144 * @thread Any thread.
145 */
146 DECLR3CALLBACKMEMBER(RTRCPTR, pfnQueryInterface,(struct PDMIBASERC *pInterface, const char *pszIID));
147} PDMIBASERC;
148/** Pointer to a PDM Base Interface for query ring-mode context interfaces. */
149typedef PDMIBASERC *PPDMIBASERC;
150/** PDMIBASERC interface ID. */
151#define PDMIBASERC_IID "f6a6c649-6cb3-493f-9737-4653f221aeca"
152
153/**
154 * Helper macro for querying an interface from PDMIBASERC.
155 *
156 * @returns PDMIBASERC::pfnQueryInterface return value.
157 *
158 * @param pIBaseRC Pointer to the base raw-mode context interface. Can
159 * be NULL.
160 * @param InterfaceType The interface type base name, no trailing RC. The
161 * interface ID is derived from this by appending _IID.
162 *
163 * @remarks Unlike PDMIBASE_QUERY_INTERFACE, this macro is not able to do any
164 * implicit type checking for you.
165 */
166#define PDMIBASERC_QUERY_INTERFACE(pIBaseRC, InterfaceType) \
167 ( (P##InterfaceType##RC)((pIBaseRC) ? (pIBaseRC)->pfnQueryInterface(pIBaseRC, InterfaceType##_IID) : NIL_RTRCPTR) )
168
169/**
170 * Helper macro for implementing PDMIBASERC::pfnQueryInterface.
171 *
172 * Return @a pInterface if @a pszIID matches the @a InterfaceType. This will
173 * perform basic type checking.
174 *
175 * @param pIns Pointer to the instance data.
176 * @param pszIID The ID of the interface that is being queried.
177 * @param InterfaceType The interface type base name, no trailing RC. The
178 * interface ID is derived from this by appending _IID.
179 * @param pInterface The interface address expression. This must resolve
180 * to some address within the instance data.
181 * @remarks Don't use with PDMIBASE.
182 */
183#define PDMIBASERC_RETURN_INTERFACE(pIns, pszIID, InterfaceType, pInterface) \
184 do { \
185 Assert((uintptr_t)pInterface - PDMINS_2_DATA(pIns, uintptr_t) < _4M); \
186 if (RTUuidCompare2Strs((pszIID), InterfaceType##_IID) == 0) \
187 { \
188 InterfaceType##RC *pReturnInterfaceTypeCheck = (pInterface); \
189 return (uintptr_t)pReturnInterfaceTypeCheck \
190 - PDMINS_2_DATA(pIns, uintptr_t) \
191 + PDMINS_2_DATA_RCPTR(pIns); \
192 } \
193 } while (0)
194
195/** @} */
196
197
198/** @name PDMIBASER0
199 * @{
200 */
201
202/**
203 * PDM Base Interface for querying ring-0 interfaces in ring-3.
204 *
205 * This is mandatory for drivers present in ring-0 context.
206 */
207typedef struct PDMIBASER0
208{
209 /**
210 * Queries an ring-0 interface to the driver.
211 *
212 * @returns Pointer to interface.
213 * @returns NULL if the interface was not supported by the driver.
214 * @param pInterface Pointer to this interface structure.
215 * @param pszIID The interface ID, a UUID string.
216 * @thread Any thread.
217 */
218 DECLR3CALLBACKMEMBER(RTR0PTR, pfnQueryInterface,(struct PDMIBASER0 *pInterface, const char *pszIID));
219} PDMIBASER0;
220/** Pointer to a PDM Base Interface for query ring-0 context interfaces. */
221typedef PDMIBASER0 *PPDMIBASER0;
222/** PDMIBASER0 interface ID. */
223#define PDMIBASER0_IID "9c9b99b8-7f53-4f59-a3c2-5bc9659c7944"
224
225/**
226 * Helper macro for querying an interface from PDMIBASER0.
227 *
228 * @returns PDMIBASER0::pfnQueryInterface return value.
229 *
230 * @param pIBaseR0 Pointer to the base ring-0 interface. Can be NULL.
231 * @param InterfaceType The interface type base name, no trailing R0. The
232 * interface ID is derived from this by appending _IID.
233 *
234 * @remarks Unlike PDMIBASE_QUERY_INTERFACE, this macro is not able to do any
235 * implicit type checking for you.
236 */
237#define PDMIBASER0_QUERY_INTERFACE(pIBaseR0, InterfaceType) \
238 ( (P##InterfaceType##R0)((pIBaseR0) ? (pIBaseR0)->pfnQueryInterface(pIBaseR0, InterfaceType##_IID) : NIL_RTR0PTR) )
239
240/**
241 * Helper macro for implementing PDMIBASER0::pfnQueryInterface.
242 *
243 * Return @a pInterface if @a pszIID matches the @a InterfaceType. This will
244 * perform basic type checking.
245 *
246 * @param pIns Pointer to the instance data.
247 * @param pszIID The ID of the interface that is being queried.
248 * @param InterfaceType The interface type base name, no trailing R0. The
249 * interface ID is derived from this by appending _IID.
250 * @param pInterface The interface address expression. This must resolve
251 * to some address within the instance data.
252 * @remarks Don't use with PDMIBASE.
253 */
254#define PDMIBASER0_RETURN_INTERFACE(pIns, pszIID, InterfaceType, pInterface) \
255 do { \
256 Assert((uintptr_t)pInterface - PDMINS_2_DATA(pIns, uintptr_t) < _4M); \
257 if (RTUuidCompare2Strs((pszIID), InterfaceType##_IID) == 0) \
258 { \
259 InterfaceType##R0 *pReturnInterfaceTypeCheck = (pInterface); \
260 return (uintptr_t)pReturnInterfaceTypeCheck \
261 - PDMINS_2_DATA(pIns, uintptr_t) \
262 + PDMINS_2_DATA_R0PTR(pIns); \
263 } \
264 } while (0)
265
266/** @} */
267
268
269/**
270 * Dummy interface.
271 *
272 * This is used to typedef other dummy interfaces. The purpose of a dummy
273 * interface is to validate the logical function of a driver/device and
274 * full a natural interface pair.
275 */
276typedef struct PDMIDUMMY
277{
278 RTHCPTR pvDummy;
279} PDMIDUMMY;
280
281
282/** Pointer to a mouse port interface. */
283typedef struct PDMIMOUSEPORT *PPDMIMOUSEPORT;
284/**
285 * Mouse port interface (down).
286 * Pair with PDMIMOUSECONNECTOR.
287 */
288typedef struct PDMIMOUSEPORT
289{
290 /**
291 * Puts a mouse event.
292 *
293 * This is called by the source of mouse events. The event will be passed up
294 * until the topmost driver, which then calls the registered event handler.
295 *
296 * @returns VBox status code. Return VERR_TRY_AGAIN if you cannot process the
297 * event now and want it to be repeated at a later point.
298 *
299 * @param pInterface Pointer to this interface structure.
300 * @param dx The X delta.
301 * @param dy The Y delta.
302 * @param dz The Z delta.
303 * @param dw The W (horizontal scroll button) delta.
304 * @param fButtons The button states, see the PDMIMOUSEPORT_BUTTON_* \#defines.
305 */
306 DECLR3CALLBACKMEMBER(int, pfnPutEvent,(PPDMIMOUSEPORT pInterface,
307 int32_t dx, int32_t dy, int32_t dz,
308 int32_t dw, uint32_t fButtons));
309 /**
310 * Puts an absolute mouse event.
311 *
312 * This is called by the source of mouse events. The event will be passed up
313 * until the topmost driver, which then calls the registered event handler.
314 *
315 * @returns VBox status code. Return VERR_TRY_AGAIN if you cannot process the
316 * event now and want it to be repeated at a later point.
317 *
318 * @param pInterface Pointer to this interface structure.
319 * @param x The X value, in the range 0 to 0xffff.
320 * @param z The Y value, in the range 0 to 0xffff.
321 * @param dz The Z delta.
322 * @param dw The W (horizontal scroll button) delta.
323 * @param fButtons The button states, see the PDMIMOUSEPORT_BUTTON_* \#defines.
324 */
325 DECLR3CALLBACKMEMBER(int, pfnPutEventAbs,(PPDMIMOUSEPORT pInterface,
326 uint32_t x, uint32_t z,
327 int32_t dz, int32_t dw,
328 uint32_t fButtons));
329 /**
330 * Puts a multi-touch event.
331 *
332 * @returns VBox status code. Return VERR_TRY_AGAIN if you cannot process the
333 * event now and want it to be repeated at a later point.
334 *
335 * @param pInterface Pointer to this interface structure.
336 * @param cContacts How many touch contacts in this event.
337 * @param pau64Contacts Pointer to array of packed contact information.
338 * Each 64bit element contains:
339 * Bits 0..15: X coordinate in pixels (signed).
340 * Bits 16..31: Y coordinate in pixels (signed).
341 * Bits 32..39: contact identifier.
342 * Bit 40: "in contact" flag, which indicates that
343 * there is a contact with the touch surface.
344 * Bit 41: "in range" flag, the contact is close enough
345 * to the touch surface.
346 * All other bits are reserved for future use and must be set to 0.
347 * @param u32ScanTime Timestamp of this event in milliseconds. Only relative
348 * time between event is important.
349 */
350 DECLR3CALLBACKMEMBER(int, pfnPutEventMultiTouch,(PPDMIMOUSEPORT pInterface,
351 uint8_t cContacts,
352 const uint64_t *pau64Contacts,
353 uint32_t u32ScanTime));
354} PDMIMOUSEPORT;
355/** PDMIMOUSEPORT interface ID. */
356#define PDMIMOUSEPORT_IID "359364f0-9fa3-4490-a6b4-7ed771901c93"
357
358/** Mouse button defines for PDMIMOUSEPORT::pfnPutEvent.
359 * @{ */
360#define PDMIMOUSEPORT_BUTTON_LEFT RT_BIT(0)
361#define PDMIMOUSEPORT_BUTTON_RIGHT RT_BIT(1)
362#define PDMIMOUSEPORT_BUTTON_MIDDLE RT_BIT(2)
363#define PDMIMOUSEPORT_BUTTON_X1 RT_BIT(3)
364#define PDMIMOUSEPORT_BUTTON_X2 RT_BIT(4)
365/** @} */
366
367
368/** Pointer to a mouse connector interface. */
369typedef struct PDMIMOUSECONNECTOR *PPDMIMOUSECONNECTOR;
370/**
371 * Mouse connector interface (up).
372 * Pair with PDMIMOUSEPORT.
373 */
374typedef struct PDMIMOUSECONNECTOR
375{
376 /**
377 * Notifies the the downstream driver of changes to the reporting modes
378 * supported by the driver
379 *
380 * @param pInterface Pointer to the this interface.
381 * @param fRelative Whether relative mode is currently supported.
382 * @param fAbsolute Whether absolute mode is currently supported.
383 * @param fAbsolute Whether multi-touch mode is currently supported.
384 */
385 DECLR3CALLBACKMEMBER(void, pfnReportModes,(PPDMIMOUSECONNECTOR pInterface, bool fRelative, bool fAbsolute, bool fMultiTouch));
386
387} PDMIMOUSECONNECTOR;
388/** PDMIMOUSECONNECTOR interface ID. */
389#define PDMIMOUSECONNECTOR_IID "ce64d7bd-fa8f-41d1-a6fb-d102a2d6bffe"
390
391
392/** Pointer to a keyboard port interface. */
393typedef struct PDMIKEYBOARDPORT *PPDMIKEYBOARDPORT;
394/**
395 * Keyboard port interface (down).
396 * Pair with PDMIKEYBOARDCONNECTOR.
397 */
398typedef struct PDMIKEYBOARDPORT
399{
400 /**
401 * Puts a scan code based keyboard event.
402 *
403 * This is called by the source of keyboard events. The event will be passed up
404 * until the topmost driver, which then calls the registered event handler.
405 *
406 * @returns VBox status code. Return VERR_TRY_AGAIN if you cannot process the
407 * event now and want it to be repeated at a later point.
408 *
409 * @param pInterface Pointer to this interface structure.
410 * @param u8ScanCode The scan code to queue.
411 */
412 DECLR3CALLBACKMEMBER(int, pfnPutEventScan,(PPDMIKEYBOARDPORT pInterface, uint8_t u8KeyCode));
413
414 /**
415 * Puts a USB HID usage ID based keyboard event.
416 *
417 * This is called by the source of keyboard events. The event will be passed up
418 * until the topmost driver, which then calls the registered event handler.
419 *
420 * @returns VBox status code. Return VERR_TRY_AGAIN if you cannot process the
421 * event now and want it to be repeated at a later point.
422 *
423 * @param pInterface Pointer to this interface structure.
424 * @param u32UsageID The HID usage code event to queue.
425 */
426 DECLR3CALLBACKMEMBER(int, pfnPutEventHid,(PPDMIKEYBOARDPORT pInterface, uint32_t u32UsageID));
427} PDMIKEYBOARDPORT;
428/** PDMIKEYBOARDPORT interface ID. */
429#define PDMIKEYBOARDPORT_IID "2a0844f0-410b-40ab-a6ed-6575f3aa3e29"
430
431
432/**
433 * Keyboard LEDs.
434 */
435typedef enum PDMKEYBLEDS
436{
437 /** No leds. */
438 PDMKEYBLEDS_NONE = 0x0000,
439 /** Num Lock */
440 PDMKEYBLEDS_NUMLOCK = 0x0001,
441 /** Caps Lock */
442 PDMKEYBLEDS_CAPSLOCK = 0x0002,
443 /** Scroll Lock */
444 PDMKEYBLEDS_SCROLLLOCK = 0x0004
445} PDMKEYBLEDS;
446
447/** Pointer to keyboard connector interface. */
448typedef struct PDMIKEYBOARDCONNECTOR *PPDMIKEYBOARDCONNECTOR;
449/**
450 * Keyboard connector interface (up).
451 * Pair with PDMIKEYBOARDPORT
452 */
453typedef struct PDMIKEYBOARDCONNECTOR
454{
455 /**
456 * Notifies the the downstream driver about an LED change initiated by the guest.
457 *
458 * @param pInterface Pointer to the this interface.
459 * @param enmLeds The new led mask.
460 */
461 DECLR3CALLBACKMEMBER(void, pfnLedStatusChange,(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds));
462
463 /**
464 * Notifies the the downstream driver of changes in driver state.
465 *
466 * @param pInterface Pointer to the this interface.
467 * @param fActive Whether interface wishes to get "focus".
468 */
469 DECLR3CALLBACKMEMBER(void, pfnSetActive,(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive));
470
471} PDMIKEYBOARDCONNECTOR;
472/** PDMIKEYBOARDCONNECTOR interface ID. */
473#define PDMIKEYBOARDCONNECTOR_IID "db3f7bd5-953e-436f-9f8e-077905a92d82"
474
475
476
477/** Pointer to a display port interface. */
478typedef struct PDMIDISPLAYPORT *PPDMIDISPLAYPORT;
479/**
480 * Display port interface (down).
481 * Pair with PDMIDISPLAYCONNECTOR.
482 */
483typedef struct PDMIDISPLAYPORT
484{
485 /**
486 * Update the display with any changed regions.
487 *
488 * Flushes any display changes to the memory pointed to by the
489 * PDMIDISPLAYCONNECTOR interface and calles PDMIDISPLAYCONNECTOR::pfnUpdateRect()
490 * while doing so.
491 *
492 * @returns VBox status code.
493 * @param pInterface Pointer to this interface.
494 * @thread The emulation thread.
495 */
496 DECLR3CALLBACKMEMBER(int, pfnUpdateDisplay,(PPDMIDISPLAYPORT pInterface));
497
498 /**
499 * Update the entire display.
500 *
501 * Flushes the entire display content to the memory pointed to by the
502 * PDMIDISPLAYCONNECTOR interface and calles PDMIDISPLAYCONNECTOR::pfnUpdateRect().
503 *
504 * @returns VBox status code.
505 * @param pInterface Pointer to this interface.
506 * @thread The emulation thread.
507 */
508 DECLR3CALLBACKMEMBER(int, pfnUpdateDisplayAll,(PPDMIDISPLAYPORT pInterface));
509
510 /**
511 * Return the current guest color depth in bits per pixel (bpp).
512 *
513 * As the graphics card is able to provide display updates with the bpp
514 * requested by the host, this method can be used to query the actual
515 * guest color depth.
516 *
517 * @returns VBox status code.
518 * @param pInterface Pointer to this interface.
519 * @param pcBits Where to store the current guest color depth.
520 * @thread Any thread.
521 */
522 DECLR3CALLBACKMEMBER(int, pfnQueryColorDepth,(PPDMIDISPLAYPORT pInterface, uint32_t *pcBits));
523
524 /**
525 * Sets the refresh rate and restart the timer.
526 * The rate is defined as the minimum interval between the return of
527 * one PDMIDISPLAYPORT::pfnRefresh() call to the next one.
528 *
529 * The interval timer will be restarted by this call. So at VM startup
530 * this function must be called to start the refresh cycle. The refresh
531 * rate is not saved, but have to be when resuming a loaded VM state.
532 *
533 * @returns VBox status code.
534 * @param pInterface Pointer to this interface.
535 * @param cMilliesInterval Number of millis between two refreshes.
536 * @thread Any thread.
537 */
538 DECLR3CALLBACKMEMBER(int, pfnSetRefreshRate,(PPDMIDISPLAYPORT pInterface, uint32_t cMilliesInterval));
539
540 /**
541 * Create a 32-bbp screenshot of the display.
542 *
543 * This will allocate and return a 32-bbp bitmap. Size of the bitmap scanline in bytes is 4*width.
544 *
545 * The allocated bitmap buffer must be freed with pfnFreeScreenshot.
546 *
547 * @param pInterface Pointer to this interface.
548 * @param ppu8Data Where to store the pointer to the allocated buffer.
549 * @param pcbData Where to store the actual size of the bitmap.
550 * @param pcx Where to store the width of the bitmap.
551 * @param pcy Where to store the height of the bitmap.
552 * @thread The emulation thread.
553 */
554 DECLR3CALLBACKMEMBER(int, pfnTakeScreenshot,(PPDMIDISPLAYPORT pInterface, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pcx, uint32_t *pcy));
555
556 /**
557 * Free screenshot buffer.
558 *
559 * This will free the memory buffer allocated by pfnTakeScreenshot.
560 *
561 * @param pInterface Pointer to this interface.
562 * @param ppu8Data Pointer to the buffer returned by pfnTakeScreenshot.
563 * @thread Any.
564 */
565 DECLR3CALLBACKMEMBER(void, pfnFreeScreenshot,(PPDMIDISPLAYPORT pInterface, uint8_t *pu8Data));
566
567 /**
568 * Copy bitmap to the display.
569 *
570 * This will convert and copy a 32-bbp bitmap (with dword aligned scanline length) to
571 * the memory pointed to by the PDMIDISPLAYCONNECTOR interface.
572 *
573 * @param pInterface Pointer to this interface.
574 * @param pvData Pointer to the bitmap bits.
575 * @param x The upper left corner x coordinate of the destination rectangle.
576 * @param y The upper left corner y coordinate of the destination rectangle.
577 * @param cx The width of the source and destination rectangles.
578 * @param cy The height of the source and destination rectangles.
579 * @thread The emulation thread.
580 * @remark This is just a convenience for using the bitmap conversions of the
581 * graphics device.
582 */
583 DECLR3CALLBACKMEMBER(int, pfnDisplayBlt,(PPDMIDISPLAYPORT pInterface, const void *pvData, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy));
584
585 /**
586 * Render a rectangle from guest VRAM to Framebuffer.
587 *
588 * @param pInterface Pointer to this interface.
589 * @param x The upper left corner x coordinate of the rectangle to be updated.
590 * @param y The upper left corner y coordinate of the rectangle to be updated.
591 * @param cx The width of the rectangle to be updated.
592 * @param cy The height of the rectangle to be updated.
593 * @thread The emulation thread.
594 */
595 DECLR3CALLBACKMEMBER(void, pfnUpdateDisplayRect,(PPDMIDISPLAYPORT pInterface, int32_t x, int32_t y, uint32_t cx, uint32_t cy));
596
597 /**
598 * Inform the VGA device whether the Display is directly using the guest VRAM and there is no need
599 * to render the VRAM to the framebuffer memory.
600 *
601 * @param pInterface Pointer to this interface.
602 * @param fRender Whether the VRAM content must be rendered to the framebuffer.
603 * @thread The emulation thread.
604 */
605 DECLR3CALLBACKMEMBER(void, pfnSetRenderVRAM,(PPDMIDISPLAYPORT pInterface, bool fRender));
606
607 /**
608 * Render a bitmap rectangle from source to target buffer.
609 *
610 * @param pInterface Pointer to this interface.
611 * @param cx The width of the rectangle to be copied.
612 * @param cy The height of the rectangle to be copied.
613 * @param pbSrc Source frame buffer 0,0.
614 * @param xSrc The upper left corner x coordinate of the source rectangle.
615 * @param ySrc The upper left corner y coordinate of the source rectangle.
616 * @param cxSrc The width of the source frame buffer.
617 * @param cySrc The height of the source frame buffer.
618 * @param cbSrcLine The line length of the source frame buffer.
619 * @param cSrcBitsPerPixel The pixel depth of the source.
620 * @param pbDst Destination frame buffer 0,0.
621 * @param xDst The upper left corner x coordinate of the destination rectangle.
622 * @param yDst The upper left corner y coordinate of the destination rectangle.
623 * @param cxDst The width of the destination frame buffer.
624 * @param cyDst The height of the destination frame buffer.
625 * @param cbDstLine The line length of the destination frame buffer.
626 * @param cDstBitsPerPixel The pixel depth of the destination.
627 * @thread The emulation thread.
628 */
629 DECLR3CALLBACKMEMBER(int, pfnCopyRect,(PPDMIDISPLAYPORT pInterface, uint32_t cx, uint32_t cy,
630 const uint8_t *pbSrc, int32_t xSrc, int32_t ySrc, uint32_t cxSrc, uint32_t cySrc, uint32_t cbSrcLine, uint32_t cSrcBitsPerPixel,
631 uint8_t *pbDst, int32_t xDst, int32_t yDst, uint32_t cxDst, uint32_t cyDst, uint32_t cbDstLine, uint32_t cDstBitsPerPixel));
632
633} PDMIDISPLAYPORT;
634/** PDMIDISPLAYPORT interface ID. */
635#define PDMIDISPLAYPORT_IID "22d3d93d-3407-487a-8308-85367eae00bb"
636
637
638typedef struct VBOXVHWACMD *PVBOXVHWACMD; /**< @todo r=bird: A line what it is to make doxygen happy. */
639typedef struct VBVACMDHDR *PVBVACMDHDR;
640typedef struct VBVAINFOSCREEN *PVBVAINFOSCREEN;
641typedef struct VBVAINFOVIEW *PVBVAINFOVIEW;
642typedef struct VBVAHOSTFLAGS *PVBVAHOSTFLAGS;
643struct VBOXVDMACMD_CHROMIUM_CMD; /* <- chromium [hgsmi] command */
644struct VBOXVDMACMD_CHROMIUM_CTL; /* <- chromium [hgsmi] command */
645
646
647/** Pointer to a display connector interface. */
648typedef struct PDMIDISPLAYCONNECTOR *PPDMIDISPLAYCONNECTOR;
649struct VBOXCRCMDCTL;
650typedef DECLCALLBACKPTR(void, PFNCRCTLCOMPLETION)(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
651/**
652 * Display connector interface (up).
653 * Pair with PDMIDISPLAYPORT.
654 */
655typedef struct PDMIDISPLAYCONNECTOR
656{
657 /**
658 * Resize the display.
659 * This is called when the resolution changes. This usually happens on
660 * request from the guest os, but may also happen as the result of a reset.
661 * If the callback returns VINF_VGA_RESIZE_IN_PROGRESS, the caller (VGA device)
662 * must not access the connector and return.
663 *
664 * @returns VINF_SUCCESS if the framebuffer resize was completed,
665 * VINF_VGA_RESIZE_IN_PROGRESS if resize takes time and not yet finished.
666 * @param pInterface Pointer to this interface.
667 * @param cBits Color depth (bits per pixel) of the new video mode.
668 * @param pvVRAM Address of the guest VRAM.
669 * @param cbLine Size in bytes of a single scan line.
670 * @param cx New display width.
671 * @param cy New display height.
672 * @thread The emulation thread.
673 */
674 DECLR3CALLBACKMEMBER(int, pfnResize,(PPDMIDISPLAYCONNECTOR pInterface, uint32_t cBits, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy));
675
676 /**
677 * Update a rectangle of the display.
678 * PDMIDISPLAYPORT::pfnUpdateDisplay is the caller.
679 *
680 * @param pInterface Pointer to this interface.
681 * @param x The upper left corner x coordinate of the rectangle.
682 * @param y The upper left corner y coordinate of the rectangle.
683 * @param cx The width of the rectangle.
684 * @param cy The height of the rectangle.
685 * @thread The emulation thread.
686 */
687 DECLR3CALLBACKMEMBER(void, pfnUpdateRect,(PPDMIDISPLAYCONNECTOR pInterface, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy));
688
689 /**
690 * Refresh the display.
691 *
692 * The interval between these calls is set by
693 * PDMIDISPLAYPORT::pfnSetRefreshRate(). The driver should call
694 * PDMIDISPLAYPORT::pfnUpdateDisplay() if it wishes to refresh the
695 * display. PDMIDISPLAYPORT::pfnUpdateDisplay calls pfnUpdateRect with
696 * the changed rectangles.
697 *
698 * @param pInterface Pointer to this interface.
699 * @thread The emulation thread.
700 */
701 DECLR3CALLBACKMEMBER(void, pfnRefresh,(PPDMIDISPLAYCONNECTOR pInterface));
702
703 /**
704 * Reset the display.
705 *
706 * Notification message when the graphics card has been reset.
707 *
708 * @param pInterface Pointer to this interface.
709 * @thread The emulation thread.
710 */
711 DECLR3CALLBACKMEMBER(void, pfnReset,(PPDMIDISPLAYCONNECTOR pInterface));
712
713 /**
714 * LFB video mode enter/exit.
715 *
716 * Notification message when LinearFrameBuffer video mode is enabled/disabled.
717 *
718 * @param pInterface Pointer to this interface.
719 * @param fEnabled false - LFB mode was disabled,
720 * true - an LFB mode was disabled
721 * @thread The emulation thread.
722 */
723 DECLR3CALLBACKMEMBER(void, pfnLFBModeChange, (PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled));
724
725 /**
726 * Process the guest graphics adapter information.
727 *
728 * Direct notification from guest to the display connector.
729 *
730 * @param pInterface Pointer to this interface.
731 * @param pvVRAM Address of the guest VRAM.
732 * @param u32VRAMSize Size of the guest VRAM.
733 * @thread The emulation thread.
734 */
735 DECLR3CALLBACKMEMBER(void, pfnProcessAdapterData, (PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize));
736
737 /**
738 * Process the guest display information.
739 *
740 * Direct notification from guest to the display connector.
741 *
742 * @param pInterface Pointer to this interface.
743 * @param pvVRAM Address of the guest VRAM.
744 * @param uScreenId The index of the guest display to be processed.
745 * @thread The emulation thread.
746 */
747 DECLR3CALLBACKMEMBER(void, pfnProcessDisplayData, (PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId));
748
749 /**
750 * Process the guest Video HW Acceleration command.
751 *
752 * @param pInterface Pointer to this interface.
753 * @param pCmd Video HW Acceleration Command to be processed.
754 * @returns VINF_SUCCESS - command is completed,
755 * VINF_CALLBACK_RETURN - command will by asynchronously completed via complete callback
756 * VERR_INVALID_STATE - the command could not be processed (most likely because the framebuffer was disconnected) - the post should be retried later
757 * @thread The emulation thread.
758 */
759 DECLR3CALLBACKMEMBER(int, pfnVHWACommandProcess, (PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCmd));
760
761 /**
762 * Process the guest chromium command.
763 *
764 * @param pInterface Pointer to this interface.
765 * @param pCmd Video HW Acceleration Command to be processed.
766 * @thread The emulation thread.
767 */
768 DECLR3CALLBACKMEMBER(void, pfnCrHgsmiCommandProcess, (PPDMIDISPLAYCONNECTOR pInterface, struct VBOXVDMACMD_CHROMIUM_CMD* pCmd, uint32_t cbCmd));
769
770 /**
771 * Process the guest chromium control command.
772 *
773 * @param pInterface Pointer to this interface.
774 * @param pCmd Video HW Acceleration Command to be processed.
775 * @thread The emulation thread.
776 */
777 DECLR3CALLBACKMEMBER(void, pfnCrHgsmiControlProcess, (PPDMIDISPLAYCONNECTOR pInterface, struct VBOXVDMACMD_CHROMIUM_CTL* pCtl, uint32_t cbCtl));
778
779 /**
780 * Process the guest chromium control command.
781 *
782 * @param pInterface Pointer to this interface.
783 * @param pCmd Video HW Acceleration Command to be processed.
784 * @thread The emulation thread.
785 */
786 DECLR3CALLBACKMEMBER(int, pfnCrHgcmCtlSubmit, (PPDMIDISPLAYCONNECTOR pInterface,
787 struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
788 PFNCRCTLCOMPLETION pfnCompletion,
789 void *pvCompletion));
790
791 /**
792 * The specified screen enters VBVA mode.
793 *
794 * @param pInterface Pointer to this interface.
795 * @param uScreenId The screen updates are for.
796 * @param fRenderThreadMode if true - the graphics device has a separate thread that does all rendering.
797 * This means that:
798 * 1. all pfnVBVAXxx callbacks (including the current pfnVBVAEnable call), except displayVBVAMousePointerShape
799 * will be called in the context of the render thread rather than the emulation thread
800 * 2. PDMIDISPLAYCONNECTOR implementor (i.e. DisplayImpl) must NOT notify crogl backend
801 * about vbva-originated events (e.g. resize), because crogl is working in CrCmd mode,
802 * in the context of the render thread as part of the Graphics device, and gets notified about those events directly
803 * @thread if fRenderThreadMode is TRUE - the render thread, otherwise - the emulation thread.
804 */
805 DECLR3CALLBACKMEMBER(int, pfnVBVAEnable,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags, bool fRenderThreadMode));
806
807 /**
808 * The specified screen leaves VBVA mode.
809 *
810 * @param pInterface Pointer to this interface.
811 * @param uScreenId The screen updates are for.
812 * @thread if render thread mode is on (fRenderThreadMode that was passed to pfnVBVAEnable is TRUE) - the render thread pfnVBVAEnable was called in,
813 * otherwise - the emulation thread.
814 */
815 DECLR3CALLBACKMEMBER(void, pfnVBVADisable,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId));
816
817 /**
818 * A sequence of pfnVBVAUpdateProcess calls begins.
819 *
820 * @param pInterface Pointer to this interface.
821 * @param uScreenId The screen updates are for.
822 * @thread if render thread mode is on (fRenderThreadMode that was passed to pfnVBVAEnable is TRUE) - the render thread pfnVBVAEnable was called in,
823 * otherwise - the emulation thread.
824 */
825 DECLR3CALLBACKMEMBER(void, pfnVBVAUpdateBegin,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId));
826
827 /**
828 * Process the guest VBVA command.
829 *
830 * @param pInterface Pointer to this interface.
831 * @param pCmd Video HW Acceleration Command to be processed.
832 * @thread if render thread mode is on (fRenderThreadMode that was passed to pfnVBVAEnable is TRUE) - the render thread pfnVBVAEnable was called in,
833 * otherwise - the emulation thread.
834 */
835 DECLR3CALLBACKMEMBER(void, pfnVBVAUpdateProcess,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, const PVBVACMDHDR pCmd, size_t cbCmd));
836
837 /**
838 * A sequence of pfnVBVAUpdateProcess calls ends.
839 *
840 * @param pInterface Pointer to this interface.
841 * @param uScreenId The screen updates are for.
842 * @param x The upper left corner x coordinate of the combined rectangle of all VBVA updates.
843 * @param y The upper left corner y coordinate of the rectangle.
844 * @param cx The width of the rectangle.
845 * @param cy The height of the rectangle.
846 * @thread if render thread mode is on (fRenderThreadMode that was passed to pfnVBVAEnable is TRUE) - the render thread pfnVBVAEnable was called in,
847 * otherwise - the emulation thread.
848 */
849 DECLR3CALLBACKMEMBER(void, pfnVBVAUpdateEnd,(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y, uint32_t cx, uint32_t cy));
850
851 /**
852 * Resize the display.
853 * This is called when the resolution changes. This usually happens on
854 * request from the guest os, but may also happen as the result of a reset.
855 * If the callback returns VINF_VGA_RESIZE_IN_PROGRESS, the caller (VGA device)
856 * must not access the connector and return.
857 *
858 * @todo Merge with pfnResize.
859 *
860 * @returns VINF_SUCCESS if the framebuffer resize was completed,
861 * VINF_VGA_RESIZE_IN_PROGRESS if resize takes time and not yet finished.
862 * @param pInterface Pointer to this interface.
863 * @param pView The description of VRAM block for this screen.
864 * @param pScreen The data of screen being resized.
865 * @param pvVRAM Address of the guest VRAM.
866 * @thread if render thread mode is on (fRenderThreadMode that was passed to pfnVBVAEnable is TRUE) - the render thread pfnVBVAEnable was called in,
867 * otherwise - the emulation thread.
868 */
869 DECLR3CALLBACKMEMBER(int, pfnVBVAResize,(PPDMIDISPLAYCONNECTOR pInterface, const PVBVAINFOVIEW pView, const PVBVAINFOSCREEN pScreen, void *pvVRAM));
870
871 /**
872 * Update the pointer shape.
873 * This is called when the mouse pointer shape changes. The new shape
874 * is passed as a caller allocated buffer that will be freed after returning
875 *
876 * @param pInterface Pointer to this interface.
877 * @param fVisible Visibility indicator (if false, the other parameters are undefined).
878 * @param fAlpha Flag whether alpha channel is being passed.
879 * @param xHot Pointer hot spot x coordinate.
880 * @param yHot Pointer hot spot y coordinate.
881 * @param x Pointer new x coordinate on screen.
882 * @param y Pointer new y coordinate on screen.
883 * @param cx Pointer width in pixels.
884 * @param cy Pointer height in pixels.
885 * @param cbScanline Size of one scanline in bytes.
886 * @param pvShape New shape buffer.
887 * @thread The emulation thread.
888 */
889 DECLR3CALLBACKMEMBER(int, pfnVBVAMousePointerShape,(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
890 uint32_t xHot, uint32_t yHot,
891 uint32_t cx, uint32_t cy,
892 const void *pvShape));
893
894 /** Read-only attributes.
895 * For preformance reasons some readonly attributes are kept in the interface.
896 * We trust the interface users to respect the readonlyness of these.
897 * @{
898 */
899 /** Pointer to the display data buffer. */
900 uint8_t *pu8Data;
901 /** Size of a scanline in the data buffer. */
902 uint32_t cbScanline;
903 /** The color depth (in bits) the graphics card is supposed to provide. */
904 uint32_t cBits;
905 /** The display width. */
906 uint32_t cx;
907 /** The display height. */
908 uint32_t cy;
909 /** @} */
910} PDMIDISPLAYCONNECTOR;
911/** PDMIDISPLAYCONNECTOR interface ID. */
912#define PDMIDISPLAYCONNECTOR_IID "906d0c25-091f-497e-908c-1d70cb7e6114"
913
914
915/** Pointer to a block port interface. */
916typedef struct PDMIBLOCKPORT *PPDMIBLOCKPORT;
917/**
918 * Block notify interface (down).
919 * Pair with PDMIBLOCK.
920 */
921typedef struct PDMIBLOCKPORT
922{
923 /**
924 * Returns the storage controller name, instance and LUN of the attached medium.
925 *
926 * @returns VBox status.
927 * @param pInterface Pointer to this interface.
928 * @param ppcszController Where to store the name of the storage controller.
929 * @param piInstance Where to store the instance number of the controller.
930 * @param piLUN Where to store the LUN of the attached device.
931 */
932 DECLR3CALLBACKMEMBER(int, pfnQueryDeviceLocation, (PPDMIBLOCKPORT pInterface, const char **ppcszController,
933 uint32_t *piInstance, uint32_t *piLUN));
934
935} PDMIBLOCKPORT;
936/** PDMIBLOCKPORT interface ID. */
937#define PDMIBLOCKPORT_IID "bbbed4cf-0862-4ffd-b60c-f7a65ef8e8ff"
938
939
940/**
941 * Callback which provides progress information.
942 *
943 * @return VBox status code.
944 * @param pvUser Opaque user data.
945 * @param uPercent Completion percentage.
946 */
947typedef DECLCALLBACK(int) FNSIMPLEPROGRESS(void *pvUser, unsigned uPercentage);
948/** Pointer to FNSIMPLEPROGRESS() */
949typedef FNSIMPLEPROGRESS *PFNSIMPLEPROGRESS;
950
951
952/**
953 * Block drive type.
954 */
955typedef enum PDMBLOCKTYPE
956{
957 /** Error (for the query function). */
958 PDMBLOCKTYPE_ERROR = 1,
959 /** 360KB 5 1/4" floppy drive. */
960 PDMBLOCKTYPE_FLOPPY_360,
961 /** 720KB 3 1/2" floppy drive. */
962 PDMBLOCKTYPE_FLOPPY_720,
963 /** 1.2MB 5 1/4" floppy drive. */
964 PDMBLOCKTYPE_FLOPPY_1_20,
965 /** 1.44MB 3 1/2" floppy drive. */
966 PDMBLOCKTYPE_FLOPPY_1_44,
967 /** 2.88MB 3 1/2" floppy drive. */
968 PDMBLOCKTYPE_FLOPPY_2_88,
969 /** Fake drive that can take up to 15.6 MB images.
970 * C=255, H=2, S=63. */
971 PDMBLOCKTYPE_FLOPPY_FAKE_15_6,
972 /** Fake drive that can take up to 63.5 MB images.
973 * C=255, H=2, S=255. */
974 PDMBLOCKTYPE_FLOPPY_FAKE_63_5,
975 /** CDROM drive. */
976 PDMBLOCKTYPE_CDROM,
977 /** DVD drive. */
978 PDMBLOCKTYPE_DVD,
979 /** Hard disk drive. */
980 PDMBLOCKTYPE_HARD_DISK
981} PDMBLOCKTYPE;
982
983/** Check if the given block type is a floppy. */
984#define PDMBLOCKTYPE_IS_FLOPPY(a_enmType) ( (a_enmType) >= PDMBLOCKTYPE_FLOPPY_360 && (a_enmType) <= PDMBLOCKTYPE_FLOPPY_2_88 )
985
986/**
987 * Block raw command data transfer direction.
988 */
989typedef enum PDMBLOCKTXDIR
990{
991 PDMBLOCKTXDIR_NONE = 0,
992 PDMBLOCKTXDIR_FROM_DEVICE,
993 PDMBLOCKTXDIR_TO_DEVICE
994} PDMBLOCKTXDIR;
995
996
997/** Pointer to a block interface. */
998typedef struct PDMIBLOCK *PPDMIBLOCK;
999/**
1000 * Block interface (up).
1001 * Pair with PDMIBLOCKPORT.
1002 */
1003typedef struct PDMIBLOCK
1004{
1005 /**
1006 * Read bits.
1007 *
1008 * @returns VBox status code.
1009 * @param pInterface Pointer to the interface structure containing the called function pointer.
1010 * @param off Offset to start reading from. The offset must be aligned to a sector boundary.
1011 * @param pvBuf Where to store the read bits.
1012 * @param cbRead Number of bytes to read. Must be aligned to a sector boundary.
1013 * @thread Any thread.
1014 */
1015 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIBLOCK pInterface, uint64_t off, void *pvBuf, size_t cbRead));
1016
1017 /**
1018 * Write bits.
1019 *
1020 * @returns VBox status code.
1021 * @param pInterface Pointer to the interface structure containing the called function pointer.
1022 * @param off Offset to start writing at. The offset must be aligned to a sector boundary.
1023 * @param pvBuf Where to store the write bits.
1024 * @param cbWrite Number of bytes to write. Must be aligned to a sector boundary.
1025 * @thread Any thread.
1026 */
1027 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIBLOCK pInterface, uint64_t off, const void *pvBuf, size_t cbWrite));
1028
1029 /**
1030 * Make sure that the bits written are actually on the storage medium.
1031 *
1032 * @returns VBox status code.
1033 * @param pInterface Pointer to the interface structure containing the called function pointer.
1034 * @thread Any thread.
1035 */
1036 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIBLOCK pInterface));
1037
1038 /**
1039 * Send a raw command to the underlying device (CDROM).
1040 * This method is optional (i.e. the function pointer may be NULL).
1041 *
1042 * @returns VBox status code.
1043 * @param pInterface Pointer to the interface structure containing the called function pointer.
1044 * @param pbCmd Offset to start reading from.
1045 * @param enmTxDir Direction of transfer.
1046 * @param pvBuf Pointer tp the transfer buffer.
1047 * @param cbBuf Size of the transfer buffer.
1048 * @param pbSenseKey Status of the command (when return value is VERR_DEV_IO_ERROR).
1049 * @param cTimeoutMillies Command timeout in milliseconds.
1050 * @thread Any thread.
1051 */
1052 DECLR3CALLBACKMEMBER(int, pfnSendCmd,(PPDMIBLOCK pInterface, const uint8_t *pbCmd, PDMBLOCKTXDIR enmTxDir, void *pvBuf, uint32_t *pcbBuf, uint8_t *pabSense, size_t cbSense, uint32_t cTimeoutMillies));
1053
1054 /**
1055 * Merge medium contents during a live snapshot deletion.
1056 *
1057 * @returns VBox status code.
1058 * @param pInterface Pointer to the interface structure containing the called function pointer.
1059 * @param pfnProgress Function pointer for progress notification.
1060 * @param pvUser Opaque user data for progress notification.
1061 * @thread Any thread.
1062 */
1063 DECLR3CALLBACKMEMBER(int, pfnMerge,(PPDMIBLOCK pInterface, PFNSIMPLEPROGRESS pfnProgress, void *pvUser));
1064
1065 /**
1066 * Check if the media is readonly or not.
1067 *
1068 * @returns true if readonly.
1069 * @returns false if read/write.
1070 * @param pInterface Pointer to the interface structure containing the called function pointer.
1071 * @thread Any thread.
1072 */
1073 DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIBLOCK pInterface));
1074
1075 /**
1076 * Gets the media size in bytes.
1077 *
1078 * @returns Media size in bytes.
1079 * @param pInterface Pointer to the interface structure containing the called function pointer.
1080 * @thread Any thread.
1081 */
1082 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIBLOCK pInterface));
1083
1084 /**
1085 * Gets the media sector size in bytes.
1086 *
1087 * @returns Media sector size in bytes.
1088 * @param pInterface Pointer to the interface structure containing the called function pointer.
1089 * @thread Any thread.
1090 */
1091 DECLR3CALLBACKMEMBER(uint32_t, pfnGetSectorSize,(PPDMIBLOCK pInterface));
1092
1093 /**
1094 * Gets the block drive type.
1095 *
1096 * @returns block drive type.
1097 * @param pInterface Pointer to the interface structure containing the called function pointer.
1098 * @thread Any thread.
1099 */
1100 DECLR3CALLBACKMEMBER(PDMBLOCKTYPE, pfnGetType,(PPDMIBLOCK pInterface));
1101
1102 /**
1103 * Gets the UUID of the block drive.
1104 * Don't return the media UUID if it's removable.
1105 *
1106 * @returns VBox status code.
1107 * @param pInterface Pointer to the interface structure containing the called function pointer.
1108 * @param pUuid Where to store the UUID on success.
1109 * @thread Any thread.
1110 */
1111 DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIBLOCK pInterface, PRTUUID pUuid));
1112
1113 /**
1114 * Discards the given range.
1115 *
1116 * @returns VBox status code.
1117 * @param pInterface Pointer to the interface structure containing the called function pointer.
1118 * @param paRanges Array of ranges to discard.
1119 * @param cRanges Number of entries in the array.
1120 * @thread Any thread.
1121 */
1122 DECLR3CALLBACKMEMBER(int, pfnDiscard,(PPDMIBLOCK pInterface, PCRTRANGE paRanges, unsigned cRanges));
1123} PDMIBLOCK;
1124/** PDMIBLOCK interface ID. */
1125#define PDMIBLOCK_IID "5e7123dd-8cdf-4a6e-97a5-ab0c68d7e850"
1126
1127
1128/** Pointer to a mount interface. */
1129typedef struct PDMIMOUNTNOTIFY *PPDMIMOUNTNOTIFY;
1130/**
1131 * Block interface (up).
1132 * Pair with PDMIMOUNT.
1133 */
1134typedef struct PDMIMOUNTNOTIFY
1135{
1136 /**
1137 * Called when a media is mounted.
1138 *
1139 * @param pInterface Pointer to the interface structure containing the called function pointer.
1140 * @thread The emulation thread.
1141 */
1142 DECLR3CALLBACKMEMBER(void, pfnMountNotify,(PPDMIMOUNTNOTIFY pInterface));
1143
1144 /**
1145 * Called when a media is unmounted
1146 * @param pInterface Pointer to the interface structure containing the called function pointer.
1147 * @thread The emulation thread.
1148 */
1149 DECLR3CALLBACKMEMBER(void, pfnUnmountNotify,(PPDMIMOUNTNOTIFY pInterface));
1150} PDMIMOUNTNOTIFY;
1151/** PDMIMOUNTNOTIFY interface ID. */
1152#define PDMIMOUNTNOTIFY_IID "fa143ac9-9fc6-498e-997f-945380a558f9"
1153
1154
1155/** Pointer to mount interface. */
1156typedef struct PDMIMOUNT *PPDMIMOUNT;
1157/**
1158 * Mount interface (down).
1159 * Pair with PDMIMOUNTNOTIFY.
1160 */
1161typedef struct PDMIMOUNT
1162{
1163 /**
1164 * Mount a media.
1165 *
1166 * This will not unmount any currently mounted media!
1167 *
1168 * @returns VBox status code.
1169 * @param pInterface Pointer to the interface structure containing the called function pointer.
1170 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have
1171 * constructed a configuration which can be attached to the bottom driver.
1172 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL.
1173 * @thread The emulation thread.
1174 */
1175 DECLR3CALLBACKMEMBER(int, pfnMount,(PPDMIMOUNT pInterface, const char *pszFilename, const char *pszCoreDriver));
1176
1177 /**
1178 * Unmount the media.
1179 *
1180 * The driver will validate and pass it on. On the rebounce it will decide whether or not to detach it self.
1181 *
1182 * @returns VBox status code.
1183 * @param pInterface Pointer to the interface structure containing the called function pointer.
1184 * @thread The emulation thread.
1185 * @param fForce Force the unmount, even for locked media.
1186 * @param fEject Eject the medium. Only relevant for host drives.
1187 * @thread The emulation thread.
1188 */
1189 DECLR3CALLBACKMEMBER(int, pfnUnmount,(PPDMIMOUNT pInterface, bool fForce, bool fEject));
1190
1191 /**
1192 * Checks if a media is mounted.
1193 *
1194 * @returns true if mounted.
1195 * @returns false if not mounted.
1196 * @param pInterface Pointer to the interface structure containing the called function pointer.
1197 * @thread Any thread.
1198 */
1199 DECLR3CALLBACKMEMBER(bool, pfnIsMounted,(PPDMIMOUNT pInterface));
1200
1201 /**
1202 * Locks the media, preventing any unmounting of it.
1203 *
1204 * @returns VBox status code.
1205 * @param pInterface Pointer to the interface structure containing the called function pointer.
1206 * @thread The emulation thread.
1207 */
1208 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMIMOUNT pInterface));
1209
1210 /**
1211 * Unlocks the media, canceling previous calls to pfnLock().
1212 *
1213 * @returns VBox status code.
1214 * @param pInterface Pointer to the interface structure containing the called function pointer.
1215 * @thread The emulation thread.
1216 */
1217 DECLR3CALLBACKMEMBER(int, pfnUnlock,(PPDMIMOUNT pInterface));
1218
1219 /**
1220 * Checks if a media is locked.
1221 *
1222 * @returns true if locked.
1223 * @returns false if not locked.
1224 * @param pInterface Pointer to the interface structure containing the called function pointer.
1225 * @thread Any thread.
1226 */
1227 DECLR3CALLBACKMEMBER(bool, pfnIsLocked,(PPDMIMOUNT pInterface));
1228} PDMIMOUNT;
1229/** PDMIMOUNT interface ID. */
1230#define PDMIMOUNT_IID "34fc7a4c-623a-4806-a6bf-5be1be33c99f"
1231
1232
1233/**
1234 * Media geometry structure.
1235 */
1236typedef struct PDMMEDIAGEOMETRY
1237{
1238 /** Number of cylinders. */
1239 uint32_t cCylinders;
1240 /** Number of heads. */
1241 uint32_t cHeads;
1242 /** Number of sectors. */
1243 uint32_t cSectors;
1244} PDMMEDIAGEOMETRY;
1245
1246/** Pointer to media geometry structure. */
1247typedef PDMMEDIAGEOMETRY *PPDMMEDIAGEOMETRY;
1248/** Pointer to constant media geometry structure. */
1249typedef const PDMMEDIAGEOMETRY *PCPDMMEDIAGEOMETRY;
1250
1251/** Pointer to a media port interface. */
1252typedef struct PDMIMEDIAPORT *PPDMIMEDIAPORT;
1253/**
1254 * Media port interface (down).
1255 */
1256typedef struct PDMIMEDIAPORT
1257{
1258 /**
1259 * Returns the storage controller name, instance and LUN of the attached medium.
1260 *
1261 * @returns VBox status.
1262 * @param pInterface Pointer to this interface.
1263 * @param ppcszController Where to store the name of the storage controller.
1264 * @param piInstance Where to store the instance number of the controller.
1265 * @param piLUN Where to store the LUN of the attached device.
1266 */
1267 DECLR3CALLBACKMEMBER(int, pfnQueryDeviceLocation, (PPDMIMEDIAPORT pInterface, const char **ppcszController,
1268 uint32_t *piInstance, uint32_t *piLUN));
1269
1270} PDMIMEDIAPORT;
1271/** PDMIMEDIAPORT interface ID. */
1272#define PDMIMEDIAPORT_IID "9f7e8c9e-6d35-4453-bbef-1f78033174d6"
1273
1274/** Pointer to a media interface. */
1275typedef struct PDMIMEDIA *PPDMIMEDIA;
1276/**
1277 * Media interface (up).
1278 * Makes up the foundation for PDMIBLOCK and PDMIBLOCKBIOS.
1279 * Pairs with PDMIMEDIAPORT.
1280 */
1281typedef struct PDMIMEDIA
1282{
1283 /**
1284 * Read bits.
1285 *
1286 * @returns VBox status code.
1287 * @param pInterface Pointer to the interface structure containing the called function pointer.
1288 * @param off Offset to start reading from. The offset must be aligned to a sector boundary.
1289 * @param pvBuf Where to store the read bits.
1290 * @param cbRead Number of bytes to read. Must be aligned to a sector boundary.
1291 * @thread Any thread.
1292 */
1293 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead));
1294
1295 /**
1296 * Write bits.
1297 *
1298 * @returns VBox status code.
1299 * @param pInterface Pointer to the interface structure containing the called function pointer.
1300 * @param off Offset to start writing at. The offset must be aligned to a sector boundary.
1301 * @param pvBuf Where to store the write bits.
1302 * @param cbWrite Number of bytes to write. Must be aligned to a sector boundary.
1303 * @thread Any thread.
1304 */
1305 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite));
1306
1307 /**
1308 * Make sure that the bits written are actually on the storage medium.
1309 *
1310 * @returns VBox status code.
1311 * @param pInterface Pointer to the interface structure containing the called function pointer.
1312 * @thread Any thread.
1313 */
1314 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIMEDIA pInterface));
1315
1316 /**
1317 * Merge medium contents during a live snapshot deletion. All details
1318 * must have been configured through CFGM or this will fail.
1319 * This method is optional (i.e. the function pointer may be NULL).
1320 *
1321 * @returns VBox status code.
1322 * @param pInterface Pointer to the interface structure containing the called function pointer.
1323 * @param pfnProgress Function pointer for progress notification.
1324 * @param pvUser Opaque user data for progress notification.
1325 * @thread Any thread.
1326 */
1327 DECLR3CALLBACKMEMBER(int, pfnMerge,(PPDMIMEDIA pInterface, PFNSIMPLEPROGRESS pfnProgress, void *pvUser));
1328
1329 /**
1330 * Merge medium contents during a live snapshot deletion. All details
1331 * must have been configured through CFGM or this will fail.
1332 * This method is optional (i.e. the function pointer may be NULL).
1333 *
1334 * @returns VBox status code.
1335 * @param pInterface Pointer to the interface structure containing the called function pointer.
1336 * @param pbKey Pointer to the key.
1337 * @param cbKey Size of the key in bytes.
1338 * @thread Any thread.
1339 */
1340 DECLR3CALLBACKMEMBER(int, pfnSetKey,(PPDMIMEDIA pInterface, const uint8_t *pbKey, size_t cbKey));
1341
1342 /**
1343 * Get the media size in bytes.
1344 *
1345 * @returns Media size in bytes.
1346 * @param pInterface Pointer to the interface structure containing the called function pointer.
1347 * @thread Any thread.
1348 */
1349 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIMEDIA pInterface));
1350
1351 /**
1352 * Gets the media sector size in bytes.
1353 *
1354 * @returns Media sector size in bytes.
1355 * @param pInterface Pointer to the interface structure containing the called function pointer.
1356 * @thread Any thread.
1357 */
1358 DECLR3CALLBACKMEMBER(uint32_t, pfnGetSectorSize,(PPDMIMEDIA pInterface));
1359
1360 /**
1361 * Check if the media is readonly or not.
1362 *
1363 * @returns true if readonly.
1364 * @returns false if read/write.
1365 * @param pInterface Pointer to the interface structure containing the called function pointer.
1366 * @thread Any thread.
1367 */
1368 DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIMEDIA pInterface));
1369
1370 /**
1371 * Get stored media geometry (physical CHS, PCHS) - BIOS property.
1372 * This is an optional feature of a media.
1373 *
1374 * @returns VBox status code.
1375 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1376 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnBiosSetPCHSGeometry() yet.
1377 * @param pInterface Pointer to the interface structure containing the called function pointer.
1378 * @param pPCHSGeometry Pointer to PCHS geometry (cylinders/heads/sectors).
1379 * @remark This has no influence on the read/write operations.
1380 * @thread Any thread.
1381 */
1382 DECLR3CALLBACKMEMBER(int, pfnBiosGetPCHSGeometry,(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry));
1383
1384 /**
1385 * Store the media geometry (physical CHS, PCHS) - BIOS property.
1386 * This is an optional feature of a media.
1387 *
1388 * @returns VBox status code.
1389 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1390 * @param pInterface Pointer to the interface structure containing the called function pointer.
1391 * @param pPCHSGeometry Pointer to PCHS geometry (cylinders/heads/sectors).
1392 * @remark This has no influence on the read/write operations.
1393 * @thread The emulation thread.
1394 */
1395 DECLR3CALLBACKMEMBER(int, pfnBiosSetPCHSGeometry,(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry));
1396
1397 /**
1398 * Get stored media geometry (logical CHS, LCHS) - BIOS property.
1399 * This is an optional feature of a media.
1400 *
1401 * @returns VBox status code.
1402 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1403 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnBiosSetLCHSGeometry() yet.
1404 * @param pInterface Pointer to the interface structure containing the called function pointer.
1405 * @param pLCHSGeometry Pointer to LCHS geometry (cylinders/heads/sectors).
1406 * @remark This has no influence on the read/write operations.
1407 * @thread Any thread.
1408 */
1409 DECLR3CALLBACKMEMBER(int, pfnBiosGetLCHSGeometry,(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry));
1410
1411 /**
1412 * Store the media geometry (logical CHS, LCHS) - BIOS property.
1413 * This is an optional feature of a media.
1414 *
1415 * @returns VBox status code.
1416 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1417 * @param pInterface Pointer to the interface structure containing the called function pointer.
1418 * @param pLCHSGeometry Pointer to LCHS geometry (cylinders/heads/sectors).
1419 * @remark This has no influence on the read/write operations.
1420 * @thread The emulation thread.
1421 */
1422 DECLR3CALLBACKMEMBER(int, pfnBiosSetLCHSGeometry,(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry));
1423
1424 /**
1425 * Gets the UUID of the media drive.
1426 *
1427 * @returns VBox status code.
1428 * @param pInterface Pointer to the interface structure containing the called function pointer.
1429 * @param pUuid Where to store the UUID on success.
1430 * @thread Any thread.
1431 */
1432 DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIMEDIA pInterface, PRTUUID pUuid));
1433
1434 /**
1435 * Discards the given range.
1436 *
1437 * @returns VBox status code.
1438 * @param pInterface Pointer to the interface structure containing the called function pointer.
1439 * @param paRanges Array of ranges to discard.
1440 * @param cRanges Number of entries in the array.
1441 * @thread Any thread.
1442 */
1443 DECLR3CALLBACKMEMBER(int, pfnDiscard,(PPDMIMEDIA pInterface, PCRTRANGE paRanges, unsigned cRanges));
1444
1445} PDMIMEDIA;
1446/** PDMIMEDIA interface ID. */
1447#define PDMIMEDIA_IID "ec385d21-7aa9-42ca-8cfb-e1388297fa52"
1448
1449
1450/** Pointer to a block BIOS interface. */
1451typedef struct PDMIBLOCKBIOS *PPDMIBLOCKBIOS;
1452/**
1453 * Media BIOS interface (Up / External).
1454 * The interface the getting and setting properties which the BIOS/CMOS care about.
1455 */
1456typedef struct PDMIBLOCKBIOS
1457{
1458 /**
1459 * Get stored media geometry (physical CHS, PCHS) - BIOS property.
1460 * This is an optional feature of a media.
1461 *
1462 * @returns VBox status code.
1463 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1464 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnSetPCHSGeometry() yet.
1465 * @param pInterface Pointer to the interface structure containing the called function pointer.
1466 * @param pPCHSGeometry Pointer to PCHS geometry (cylinders/heads/sectors).
1467 * @remark This has no influence on the read/write operations.
1468 * @thread Any thread.
1469 */
1470 DECLR3CALLBACKMEMBER(int, pfnGetPCHSGeometry,(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry));
1471
1472 /**
1473 * Store the media geometry (physical CHS, PCHS) - BIOS property.
1474 * This is an optional feature of a media.
1475 *
1476 * @returns VBox status code.
1477 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1478 * @param pInterface Pointer to the interface structure containing the called function pointer.
1479 * @param pPCHSGeometry Pointer to PCHS geometry (cylinders/heads/sectors).
1480 * @remark This has no influence on the read/write operations.
1481 * @thread The emulation thread.
1482 */
1483 DECLR3CALLBACKMEMBER(int, pfnSetPCHSGeometry,(PPDMIBLOCKBIOS pInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry));
1484
1485 /**
1486 * Get stored media geometry (logical CHS, LCHS) - BIOS property.
1487 * This is an optional feature of a media.
1488 *
1489 * @returns VBox status code.
1490 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1491 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnSetLCHSGeometry() yet.
1492 * @param pInterface Pointer to the interface structure containing the called function pointer.
1493 * @param pLCHSGeometry Pointer to LCHS geometry (cylinders/heads/sectors).
1494 * @remark This has no influence on the read/write operations.
1495 * @thread Any thread.
1496 */
1497 DECLR3CALLBACKMEMBER(int, pfnGetLCHSGeometry,(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry));
1498
1499 /**
1500 * Store the media geometry (logical CHS, LCHS) - BIOS property.
1501 * This is an optional feature of a media.
1502 *
1503 * @returns VBox status code.
1504 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
1505 * @param pInterface Pointer to the interface structure containing the called function pointer.
1506 * @param pLCHSGeometry Pointer to LCHS geometry (cylinders/heads/sectors).
1507 * @remark This has no influence on the read/write operations.
1508 * @thread The emulation thread.
1509 */
1510 DECLR3CALLBACKMEMBER(int, pfnSetLCHSGeometry,(PPDMIBLOCKBIOS pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry));
1511
1512 /**
1513 * Checks if the device should be visible to the BIOS or not.
1514 *
1515 * @returns true if the device is visible to the BIOS.
1516 * @returns false if the device is not visible to the BIOS.
1517 * @param pInterface Pointer to the interface structure containing the called function pointer.
1518 * @thread Any thread.
1519 */
1520 DECLR3CALLBACKMEMBER(bool, pfnIsVisible,(PPDMIBLOCKBIOS pInterface));
1521
1522 /**
1523 * Gets the block drive type.
1524 *
1525 * @returns block drive type.
1526 * @param pInterface Pointer to the interface structure containing the called function pointer.
1527 * @thread Any thread.
1528 */
1529 DECLR3CALLBACKMEMBER(PDMBLOCKTYPE, pfnGetType,(PPDMIBLOCKBIOS pInterface));
1530
1531} PDMIBLOCKBIOS;
1532/** PDMIBLOCKBIOS interface ID. */
1533#define PDMIBLOCKBIOS_IID "477c3eee-a48d-48a9-82fd-2a54de16b2e9"
1534
1535
1536/** Pointer to a static block core driver interface. */
1537typedef struct PDMIMEDIASTATIC *PPDMIMEDIASTATIC;
1538/**
1539 * Static block core driver interface.
1540 */
1541typedef struct PDMIMEDIASTATIC
1542{
1543 /**
1544 * Check if the specified file is a format which the core driver can handle.
1545 *
1546 * @returns true / false accordingly.
1547 * @param pInterface Pointer to the interface structure containing the called function pointer.
1548 * @param pszFilename Name of the file to probe.
1549 */
1550 DECLR3CALLBACKMEMBER(bool, pfnCanHandle,(PPDMIMEDIASTATIC pInterface, const char *pszFilename));
1551} PDMIMEDIASTATIC;
1552
1553
1554
1555
1556
1557/** Pointer to an asynchronous block notify interface. */
1558typedef struct PDMIBLOCKASYNCPORT *PPDMIBLOCKASYNCPORT;
1559/**
1560 * Asynchronous block notify interface (up).
1561 * Pair with PDMIBLOCKASYNC.
1562 */
1563typedef struct PDMIBLOCKASYNCPORT
1564{
1565 /**
1566 * Notify completion of an asynchronous transfer.
1567 *
1568 * @returns VBox status code.
1569 * @param pInterface Pointer to the interface structure containing the called function pointer.
1570 * @param pvUser The user argument given in pfnStartWrite/Read.
1571 * @param rcReq IPRT Status code of the completed request.
1572 * @thread Any thread.
1573 */
1574 DECLR3CALLBACKMEMBER(int, pfnTransferCompleteNotify, (PPDMIBLOCKASYNCPORT pInterface, void *pvUser, int rcReq));
1575} PDMIBLOCKASYNCPORT;
1576/** PDMIBLOCKASYNCPORT interface ID. */
1577#define PDMIBLOCKASYNCPORT_IID "e3bdc0cb-9d99-41dd-8eec-0dc8cf5b2a92"
1578
1579
1580
1581/** Pointer to an asynchronous block interface. */
1582typedef struct PDMIBLOCKASYNC *PPDMIBLOCKASYNC;
1583/**
1584 * Asynchronous block interface (down).
1585 * Pair with PDMIBLOCKASYNCPORT.
1586 */
1587typedef struct PDMIBLOCKASYNC
1588{
1589 /**
1590 * Start reading task.
1591 *
1592 * @returns VBox status code.
1593 * @param pInterface Pointer to the interface structure containing the called function pointer.
1594 * @param off Offset to start reading from.c
1595 * @param paSegs Pointer to the S/G segment array.
1596 * @param cSegs Number of entries in the array.
1597 * @param cbRead Number of bytes to read. Must be aligned to a sector boundary.
1598 * @param pvUser User argument which is returned in completion callback.
1599 * @thread Any thread.
1600 */
1601 DECLR3CALLBACKMEMBER(int, pfnStartRead,(PPDMIBLOCKASYNC pInterface, uint64_t off, PCRTSGSEG paSegs, unsigned cSegs, size_t cbRead, void *pvUser));
1602
1603 /**
1604 * Write bits.
1605 *
1606 * @returns VBox status code.
1607 * @param pInterface Pointer to the interface structure containing the called function pointer.
1608 * @param off Offset to start writing at. The offset must be aligned to a sector boundary.
1609 * @param paSegs Pointer to the S/G segment array.
1610 * @param cSegs Number of entries in the array.
1611 * @param cbWrite Number of bytes to write. Must be aligned to a sector boundary.
1612 * @param pvUser User argument which is returned in completion callback.
1613 * @thread Any thread.
1614 */
1615 DECLR3CALLBACKMEMBER(int, pfnStartWrite,(PPDMIBLOCKASYNC pInterface, uint64_t off, PCRTSGSEG paSegs, unsigned cSegs, size_t cbWrite, void *pvUser));
1616
1617 /**
1618 * Flush everything to disk.
1619 *
1620 * @returns VBox status code.
1621 * @param pInterface Pointer to the interface structure containing the called function pointer.
1622 * @param pvUser User argument which is returned in completion callback.
1623 * @thread Any thread.
1624 */
1625 DECLR3CALLBACKMEMBER(int, pfnStartFlush,(PPDMIBLOCKASYNC pInterface, void *pvUser));
1626
1627 /**
1628 * Discards the given range.
1629 *
1630 * @returns VBox status code.
1631 * @param pInterface Pointer to the interface structure containing the called function pointer.
1632 * @param paRanges Array of ranges to discard.
1633 * @param cRanges Number of entries in the array.
1634 * @param pvUser User argument which is returned in completion callback.
1635 * @thread Any thread.
1636 */
1637 DECLR3CALLBACKMEMBER(int, pfnStartDiscard,(PPDMIBLOCKASYNC pInterface, PCRTRANGE paRanges, unsigned cRanges, void *pvUser));
1638
1639} PDMIBLOCKASYNC;
1640/** PDMIBLOCKASYNC interface ID. */
1641#define PDMIBLOCKASYNC_IID "a921dd96-1748-4ecd-941e-d5f3cd4c8fe4"
1642
1643
1644/** Pointer to an asynchronous notification interface. */
1645typedef struct PDMIMEDIAASYNCPORT *PPDMIMEDIAASYNCPORT;
1646/**
1647 * Asynchronous version of the media interface (up).
1648 * Pair with PDMIMEDIAASYNC.
1649 */
1650typedef struct PDMIMEDIAASYNCPORT
1651{
1652 /**
1653 * Notify completion of a task.
1654 *
1655 * @returns VBox status code.
1656 * @param pInterface Pointer to the interface structure containing the called function pointer.
1657 * @param pvUser The user argument given in pfnStartWrite.
1658 * @param rcReq IPRT Status code of the completed request.
1659 * @thread Any thread.
1660 */
1661 DECLR3CALLBACKMEMBER(int, pfnTransferCompleteNotify, (PPDMIMEDIAASYNCPORT pInterface, void *pvUser, int rcReq));
1662} PDMIMEDIAASYNCPORT;
1663/** PDMIMEDIAASYNCPORT interface ID. */
1664#define PDMIMEDIAASYNCPORT_IID "22d38853-901f-4a71-9670-4d9da6e82317"
1665
1666
1667/** Pointer to an asynchronous media interface. */
1668typedef struct PDMIMEDIAASYNC *PPDMIMEDIAASYNC;
1669/**
1670 * Asynchronous version of PDMIMEDIA (down).
1671 * Pair with PDMIMEDIAASYNCPORT.
1672 */
1673typedef struct PDMIMEDIAASYNC
1674{
1675 /**
1676 * Start reading task.
1677 *
1678 * @returns VBox status code.
1679 * @param pInterface Pointer to the interface structure containing the called function pointer.
1680 * @param off Offset to start reading from. Must be aligned to a sector boundary.
1681 * @param paSegs Pointer to the S/G segment array.
1682 * @param cSegs Number of entries in the array.
1683 * @param cbRead Number of bytes to read. Must be aligned to a sector boundary.
1684 * @param pvUser User data.
1685 * @thread Any thread.
1686 */
1687 DECLR3CALLBACKMEMBER(int, pfnStartRead,(PPDMIMEDIAASYNC pInterface, uint64_t off, PCRTSGSEG paSegs, unsigned cSegs, size_t cbRead, void *pvUser));
1688
1689 /**
1690 * Start writing task.
1691 *
1692 * @returns VBox status code.
1693 * @param pInterface Pointer to the interface structure containing the called function pointer.
1694 * @param off Offset to start writing at. Must be aligned to a sector boundary.
1695 * @param paSegs Pointer to the S/G segment array.
1696 * @param cSegs Number of entries in the array.
1697 * @param cbWrite Number of bytes to write. Must be aligned to a sector boundary.
1698 * @param pvUser User data.
1699 * @thread Any thread.
1700 */
1701 DECLR3CALLBACKMEMBER(int, pfnStartWrite,(PPDMIMEDIAASYNC pInterface, uint64_t off, PCRTSGSEG paSegs, unsigned cSegs, size_t cbWrite, void *pvUser));
1702
1703 /**
1704 * Flush everything to disk.
1705 *
1706 * @returns VBox status code.
1707 * @param pInterface Pointer to the interface structure containing the called function pointer.
1708 * @param pvUser User argument which is returned in completion callback.
1709 * @thread Any thread.
1710 */
1711 DECLR3CALLBACKMEMBER(int, pfnStartFlush,(PPDMIMEDIAASYNC pInterface, void *pvUser));
1712
1713 /**
1714 * Discards the given range.
1715 *
1716 * @returns VBox status code.
1717 * @param pInterface Pointer to the interface structure containing the called function pointer.
1718 * @param paRanges Array of ranges to discard.
1719 * @param cRanges Number of entries in the array.
1720 * @param pvUser User argument which is returned in completion callback.
1721 * @thread Any thread.
1722 */
1723 DECLR3CALLBACKMEMBER(int, pfnStartDiscard,(PPDMIMEDIAASYNC pInterface, PCRTRANGE paRanges, unsigned cRanges, void *pvUser));
1724
1725} PDMIMEDIAASYNC;
1726/** PDMIMEDIAASYNC interface ID. */
1727#define PDMIMEDIAASYNC_IID "4be209d3-ccb5-4297-82fe-7d8018bc6ab4"
1728
1729
1730/** Pointer to a char port interface. */
1731typedef struct PDMICHARPORT *PPDMICHARPORT;
1732/**
1733 * Char port interface (down).
1734 * Pair with PDMICHARCONNECTOR.
1735 */
1736typedef struct PDMICHARPORT
1737{
1738 /**
1739 * Deliver data read to the device/driver.
1740 *
1741 * @returns VBox status code.
1742 * @param pInterface Pointer to the interface structure containing the called function pointer.
1743 * @param pvBuf Where the read bits are stored.
1744 * @param pcbRead Number of bytes available for reading/having been read.
1745 * @thread Any thread.
1746 */
1747 DECLR3CALLBACKMEMBER(int, pfnNotifyRead,(PPDMICHARPORT pInterface, const void *pvBuf, size_t *pcbRead));
1748
1749 /**
1750 * Notify the device/driver when the status lines changed.
1751 *
1752 * @returns VBox status code.
1753 * @param pInterface Pointer to the interface structure containing the called function pointer.
1754 * @param fNewStatusLine New state of the status line pins.
1755 * @thread Any thread.
1756 */
1757 DECLR3CALLBACKMEMBER(int, pfnNotifyStatusLinesChanged,(PPDMICHARPORT pInterface, uint32_t fNewStatusLines));
1758
1759 /**
1760 * Notify the device when the driver buffer is full.
1761 *
1762 * @returns VBox status code.
1763 * @param pInterface Pointer to the interface structure containing the called function pointer.
1764 * @param fFull Buffer full.
1765 * @thread Any thread.
1766 */
1767 DECLR3CALLBACKMEMBER(int, pfnNotifyBufferFull,(PPDMICHARPORT pInterface, bool fFull));
1768
1769 /**
1770 * Notify the device/driver that a break occurred.
1771 *
1772 * @returns VBox statsus code.
1773 * @param pInterface Pointer to the interface structure containing the called function pointer.
1774 * @thread Any thread.
1775 */
1776 DECLR3CALLBACKMEMBER(int, pfnNotifyBreak,(PPDMICHARPORT pInterface));
1777} PDMICHARPORT;
1778/** PDMICHARPORT interface ID. */
1779#define PDMICHARPORT_IID "22769834-ea8b-4a6d-ade1-213dcdbd1228"
1780
1781/** @name Bit mask definitions for status line type.
1782 * @{ */
1783#define PDMICHARPORT_STATUS_LINES_DCD RT_BIT(0)
1784#define PDMICHARPORT_STATUS_LINES_RI RT_BIT(1)
1785#define PDMICHARPORT_STATUS_LINES_DSR RT_BIT(2)
1786#define PDMICHARPORT_STATUS_LINES_CTS RT_BIT(3)
1787/** @} */
1788
1789
1790/** Pointer to a char interface. */
1791typedef struct PDMICHARCONNECTOR *PPDMICHARCONNECTOR;
1792/**
1793 * Char connector interface (up).
1794 * Pair with PDMICHARPORT.
1795 */
1796typedef struct PDMICHARCONNECTOR
1797{
1798 /**
1799 * Write bits.
1800 *
1801 * @returns VBox status code.
1802 * @param pInterface Pointer to the interface structure containing the called function pointer.
1803 * @param pvBuf Where to store the write bits.
1804 * @param cbWrite Number of bytes to write.
1805 * @thread Any thread.
1806 */
1807 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMICHARCONNECTOR pInterface, const void *pvBuf, size_t cbWrite));
1808
1809 /**
1810 * Set device parameters.
1811 *
1812 * @returns VBox status code.
1813 * @param pInterface Pointer to the interface structure containing the called function pointer.
1814 * @param Bps Speed of the serial connection. (bits per second)
1815 * @param chParity Parity method: 'E' - even, 'O' - odd, 'N' - none.
1816 * @param cDataBits Number of data bits.
1817 * @param cStopBits Number of stop bits.
1818 * @thread Any thread.
1819 */
1820 DECLR3CALLBACKMEMBER(int, pfnSetParameters,(PPDMICHARCONNECTOR pInterface, unsigned Bps, char chParity, unsigned cDataBits, unsigned cStopBits));
1821
1822 /**
1823 * Set the state of the modem lines.
1824 *
1825 * @returns VBox status code.
1826 * @param pInterface Pointer to the interface structure containing the called function pointer.
1827 * @param fRequestToSend Set to true to make the Request to Send line active otherwise to 0.
1828 * @param fDataTerminalReady Set to true to make the Data Terminal Ready line active otherwise 0.
1829 * @thread Any thread.
1830 */
1831 DECLR3CALLBACKMEMBER(int, pfnSetModemLines,(PPDMICHARCONNECTOR pInterface, bool fRequestToSend, bool fDataTerminalReady));
1832
1833 /**
1834 * Sets the TD line into break condition.
1835 *
1836 * @returns VBox status code.
1837 * @param pInterface Pointer to the interface structure containing the called function pointer.
1838 * @param fBreak Set to true to let the device send a break false to put into normal operation.
1839 * @thread Any thread.
1840 */
1841 DECLR3CALLBACKMEMBER(int, pfnSetBreak,(PPDMICHARCONNECTOR pInterface, bool fBreak));
1842} PDMICHARCONNECTOR;
1843/** PDMICHARCONNECTOR interface ID. */
1844#define PDMICHARCONNECTOR_IID "4ad5c190-b408-4cef-926f-fbffce0dc5cc"
1845
1846
1847/** Pointer to a stream interface. */
1848typedef struct PDMISTREAM *PPDMISTREAM;
1849/**
1850 * Stream interface (up).
1851 * Makes up the foundation for PDMICHARCONNECTOR. No pair interface.
1852 */
1853typedef struct PDMISTREAM
1854{
1855 /**
1856 * Read bits.
1857 *
1858 * @returns VBox status code.
1859 * @param pInterface Pointer to the interface structure containing the called function pointer.
1860 * @param pvBuf Where to store the read bits.
1861 * @param cbRead Number of bytes to read/bytes actually read.
1862 * @thread Any thread.
1863 */
1864 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMISTREAM pInterface, void *pvBuf, size_t *cbRead));
1865
1866 /**
1867 * Write bits.
1868 *
1869 * @returns VBox status code.
1870 * @param pInterface Pointer to the interface structure containing the called function pointer.
1871 * @param pvBuf Where to store the write bits.
1872 * @param cbWrite Number of bytes to write/bytes actually written.
1873 * @thread Any thread.
1874 */
1875 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMISTREAM pInterface, const void *pvBuf, size_t *cbWrite));
1876} PDMISTREAM;
1877/** PDMISTREAM interface ID. */
1878#define PDMISTREAM_IID "d1a5bf5e-3d2c-449a-bde9-addd7920b71f"
1879
1880
1881/** Mode of the parallel port */
1882typedef enum PDMPARALLELPORTMODE
1883{
1884 /** First invalid mode. */
1885 PDM_PARALLEL_PORT_MODE_INVALID = 0,
1886 /** SPP (Compatibility mode). */
1887 PDM_PARALLEL_PORT_MODE_SPP,
1888 /** EPP Data mode. */
1889 PDM_PARALLEL_PORT_MODE_EPP_DATA,
1890 /** EPP Address mode. */
1891 PDM_PARALLEL_PORT_MODE_EPP_ADDR,
1892 /** ECP mode (not implemented yet). */
1893 PDM_PARALLEL_PORT_MODE_ECP,
1894 /** 32bit hack. */
1895 PDM_PARALLEL_PORT_MODE_32BIT_HACK = 0x7fffffff
1896} PDMPARALLELPORTMODE;
1897
1898/** Pointer to a host parallel port interface. */
1899typedef struct PDMIHOSTPARALLELPORT *PPDMIHOSTPARALLELPORT;
1900/**
1901 * Host parallel port interface (down).
1902 * Pair with PDMIHOSTPARALLELCONNECTOR.
1903 */
1904typedef struct PDMIHOSTPARALLELPORT
1905{
1906 /**
1907 * Notify device/driver that an interrupt has occurred.
1908 *
1909 * @returns VBox status code.
1910 * @param pInterface Pointer to the interface structure containing the called function pointer.
1911 * @thread Any thread.
1912 */
1913 DECLR3CALLBACKMEMBER(int, pfnNotifyInterrupt,(PPDMIHOSTPARALLELPORT pInterface));
1914} PDMIHOSTPARALLELPORT;
1915/** PDMIHOSTPARALLELPORT interface ID. */
1916#define PDMIHOSTPARALLELPORT_IID "f24b8668-e7f6-4eaa-a14c-4aa2a5f7048e"
1917
1918
1919
1920/** Pointer to a Host Parallel connector interface. */
1921typedef struct PDMIHOSTPARALLELCONNECTOR *PPDMIHOSTPARALLELCONNECTOR;
1922/**
1923 * Host parallel connector interface (up).
1924 * Pair with PDMIHOSTPARALLELPORT.
1925 */
1926typedef struct PDMIHOSTPARALLELCONNECTOR
1927{
1928 /**
1929 * Write bits.
1930 *
1931 * @returns VBox status code.
1932 * @param pInterface Pointer to the interface structure containing the called function pointer.
1933 * @param pvBuf Where to store the write bits.
1934 * @param cbWrite Number of bytes to write.
1935 * @param enmMode Mode to write the data.
1936 * @thread Any thread.
1937 * @todo r=klaus cbWrite only defines buffer length, method needs a way top return actually written amount of data.
1938 */
1939 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIHOSTPARALLELCONNECTOR pInterface, const void *pvBuf,
1940 size_t cbWrite, PDMPARALLELPORTMODE enmMode));
1941
1942 /**
1943 * Read bits.
1944 *
1945 * @returns VBox status code.
1946 * @param pInterface Pointer to the interface structure containing the called function pointer.
1947 * @param pvBuf Where to store the read bits.
1948 * @param cbRead Number of bytes to read.
1949 * @param enmMode Mode to read the data.
1950 * @thread Any thread.
1951 * @todo r=klaus cbRead only defines buffer length, method needs a way top return actually read amount of data.
1952 */
1953 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIHOSTPARALLELCONNECTOR pInterface, void *pvBuf,
1954 size_t cbRead, PDMPARALLELPORTMODE enmMode));
1955
1956 /**
1957 * Set data direction of the port (forward/reverse).
1958 *
1959 * @returns VBox status code.
1960 * @param pInterface Pointer to the interface structure containing the called function pointer.
1961 * @param fForward Flag whether to indicate whether the port is operated in forward or reverse mode.
1962 * @thread Any thread.
1963 */
1964 DECLR3CALLBACKMEMBER(int, pfnSetPortDirection,(PPDMIHOSTPARALLELCONNECTOR pInterface, bool fForward));
1965
1966 /**
1967 * Write control register bits.
1968 *
1969 * @returns VBox status code.
1970 * @param pInterface Pointer to the interface structure containing the called function pointer.
1971 * @param fReg The new control register value.
1972 * @thread Any thread.
1973 */
1974 DECLR3CALLBACKMEMBER(int, pfnWriteControl,(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t fReg));
1975
1976 /**
1977 * Read control register bits.
1978 *
1979 * @returns VBox status code.
1980 * @param pInterface Pointer to the interface structure containing the called function pointer.
1981 * @param pfReg Where to store the control register bits.
1982 * @thread Any thread.
1983 */
1984 DECLR3CALLBACKMEMBER(int, pfnReadControl,(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg));
1985
1986 /**
1987 * Read status register bits.
1988 *
1989 * @returns VBox status code.
1990 * @param pInterface Pointer to the interface structure containing the called function pointer.
1991 * @param pfReg Where to store the status register bits.
1992 * @thread Any thread.
1993 */
1994 DECLR3CALLBACKMEMBER(int, pfnReadStatus,(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg));
1995
1996} PDMIHOSTPARALLELCONNECTOR;
1997/** PDMIHOSTPARALLELCONNECTOR interface ID. */
1998#define PDMIHOSTPARALLELCONNECTOR_IID "7c532602-7438-4fbc-9265-349d9f0415f9"
1999
2000
2001/** ACPI power source identifier */
2002typedef enum PDMACPIPOWERSOURCE
2003{
2004 PDM_ACPI_POWER_SOURCE_UNKNOWN = 0,
2005 PDM_ACPI_POWER_SOURCE_OUTLET,
2006 PDM_ACPI_POWER_SOURCE_BATTERY
2007} PDMACPIPOWERSOURCE;
2008/** Pointer to ACPI battery state. */
2009typedef PDMACPIPOWERSOURCE *PPDMACPIPOWERSOURCE;
2010
2011/** ACPI battey capacity */
2012typedef enum PDMACPIBATCAPACITY
2013{
2014 PDM_ACPI_BAT_CAPACITY_MIN = 0,
2015 PDM_ACPI_BAT_CAPACITY_MAX = 100,
2016 PDM_ACPI_BAT_CAPACITY_UNKNOWN = 255
2017} PDMACPIBATCAPACITY;
2018/** Pointer to ACPI battery capacity. */
2019typedef PDMACPIBATCAPACITY *PPDMACPIBATCAPACITY;
2020
2021/** ACPI battery state. See ACPI 3.0 spec '_BST (Battery Status)' */
2022typedef enum PDMACPIBATSTATE
2023{
2024 PDM_ACPI_BAT_STATE_CHARGED = 0x00,
2025 PDM_ACPI_BAT_STATE_DISCHARGING = 0x01,
2026 PDM_ACPI_BAT_STATE_CHARGING = 0x02,
2027 PDM_ACPI_BAT_STATE_CRITICAL = 0x04
2028} PDMACPIBATSTATE;
2029/** Pointer to ACPI battery state. */
2030typedef PDMACPIBATSTATE *PPDMACPIBATSTATE;
2031
2032/** Pointer to an ACPI port interface. */
2033typedef struct PDMIACPIPORT *PPDMIACPIPORT;
2034/**
2035 * ACPI port interface (down). Used by both the ACPI driver and (grumble) main.
2036 * Pair with PDMIACPICONNECTOR.
2037 */
2038typedef struct PDMIACPIPORT
2039{
2040 /**
2041 * Send an ACPI power off event.
2042 *
2043 * @returns VBox status code
2044 * @param pInterface Pointer to the interface structure containing the called function pointer.
2045 */
2046 DECLR3CALLBACKMEMBER(int, pfnPowerButtonPress,(PPDMIACPIPORT pInterface));
2047
2048 /**
2049 * Send an ACPI sleep button event.
2050 *
2051 * @returns VBox status code
2052 * @param pInterface Pointer to the interface structure containing the called function pointer.
2053 */
2054 DECLR3CALLBACKMEMBER(int, pfnSleepButtonPress,(PPDMIACPIPORT pInterface));
2055
2056 /**
2057 * Check if the last power button event was handled by the guest.
2058 *
2059 * @returns VBox status code
2060 * @param pInterface Pointer to the interface structure containing the called function pointer.
2061 * @param pfHandled Is set to true if the last power button event was handled, false otherwise.
2062 */
2063 DECLR3CALLBACKMEMBER(int, pfnGetPowerButtonHandled,(PPDMIACPIPORT pInterface, bool *pfHandled));
2064
2065 /**
2066 * Check if the guest entered the ACPI mode.
2067 *
2068 * @returns VBox status code
2069 * @param pInterface Pointer to the interface structure containing the called function pointer.
2070 * @param pfEnabled Is set to true if the guest entered the ACPI mode, false otherwise.
2071 */
2072 DECLR3CALLBACKMEMBER(int, pfnGetGuestEnteredACPIMode,(PPDMIACPIPORT pInterface, bool *pfEntered));
2073
2074 /**
2075 * Check if the given CPU is still locked by the guest.
2076 *
2077 * @returns VBox status code
2078 * @param pInterface Pointer to the interface structure containing the called function pointer.
2079 * @param uCpu The CPU to check for.
2080 * @param pfLocked Is set to true if the CPU is still locked by the guest, false otherwise.
2081 */
2082 DECLR3CALLBACKMEMBER(int, pfnGetCpuStatus,(PPDMIACPIPORT pInterface, unsigned uCpu, bool *pfLocked));
2083} PDMIACPIPORT;
2084/** PDMIACPIPORT interface ID. */
2085#define PDMIACPIPORT_IID "30d3dc4c-6a73-40c8-80e9-34309deacbb3"
2086
2087
2088/** Pointer to an ACPI connector interface. */
2089typedef struct PDMIACPICONNECTOR *PPDMIACPICONNECTOR;
2090/**
2091 * ACPI connector interface (up).
2092 * Pair with PDMIACPIPORT.
2093 */
2094typedef struct PDMIACPICONNECTOR
2095{
2096 /**
2097 * Get the current power source of the host system.
2098 *
2099 * @returns VBox status code
2100 * @param pInterface Pointer to the interface structure containing the called function pointer.
2101 * @param penmPowerSource Pointer to the power source result variable.
2102 */
2103 DECLR3CALLBACKMEMBER(int, pfnQueryPowerSource,(PPDMIACPICONNECTOR, PPDMACPIPOWERSOURCE penmPowerSource));
2104
2105 /**
2106 * Query the current battery status of the host system.
2107 *
2108 * @returns VBox status code?
2109 * @param pInterface Pointer to the interface structure containing the called function pointer.
2110 * @param pfPresent Is set to true if battery is present, false otherwise.
2111 * @param penmRemainingCapacity Pointer to the battery remaining capacity (0 - 100 or 255 for unknown).
2112 * @param penmBatteryState Pointer to the battery status.
2113 * @param pu32PresentRate Pointer to the present rate (0..1000 of the total capacity).
2114 */
2115 DECLR3CALLBACKMEMBER(int, pfnQueryBatteryStatus,(PPDMIACPICONNECTOR, bool *pfPresent, PPDMACPIBATCAPACITY penmRemainingCapacity,
2116 PPDMACPIBATSTATE penmBatteryState, uint32_t *pu32PresentRate));
2117} PDMIACPICONNECTOR;
2118/** PDMIACPICONNECTOR interface ID. */
2119#define PDMIACPICONNECTOR_IID "5f14bf8d-1edf-4e3a-a1e1-cca9fd08e359"
2120
2121
2122/** Pointer to a VMMDevice port interface. */
2123typedef struct PDMIVMMDEVPORT *PPDMIVMMDEVPORT;
2124/**
2125 * VMMDevice port interface (down).
2126 * Pair with PDMIVMMDEVCONNECTOR.
2127 */
2128typedef struct PDMIVMMDEVPORT
2129{
2130 /**
2131 * Return the current absolute mouse position in pixels
2132 *
2133 * @returns VBox status code
2134 * @param pInterface Pointer to the interface structure containing the called function pointer.
2135 * @param pxAbs Pointer of result value, can be NULL
2136 * @param pyAbs Pointer of result value, can be NULL
2137 */
2138 DECLR3CALLBACKMEMBER(int, pfnQueryAbsoluteMouse,(PPDMIVMMDEVPORT pInterface, int32_t *pxAbs, int32_t *pyAbs));
2139
2140 /**
2141 * Set the new absolute mouse position in pixels
2142 *
2143 * @returns VBox status code
2144 * @param pInterface Pointer to the interface structure containing the called function pointer.
2145 * @param xabs New absolute X position
2146 * @param yAbs New absolute Y position
2147 */
2148 DECLR3CALLBACKMEMBER(int, pfnSetAbsoluteMouse,(PPDMIVMMDEVPORT pInterface, int32_t xAbs, int32_t yAbs));
2149
2150 /**
2151 * Return the current mouse capability flags
2152 *
2153 * @returns VBox status code
2154 * @param pInterface Pointer to the interface structure containing the called function pointer.
2155 * @param pfCapabilities Pointer of result value
2156 */
2157 DECLR3CALLBACKMEMBER(int, pfnQueryMouseCapabilities,(PPDMIVMMDEVPORT pInterface, uint32_t *pfCapabilities));
2158
2159 /**
2160 * Set the current mouse capability flag (host side)
2161 *
2162 * @returns VBox status code
2163 * @param pInterface Pointer to the interface structure containing the called function pointer.
2164 * @param fCapsAdded Mask of capabilities to add to the flag
2165 * @param fCapsRemoved Mask of capabilities to remove from the flag
2166 */
2167 DECLR3CALLBACKMEMBER(int, pfnUpdateMouseCapabilities,(PPDMIVMMDEVPORT pInterface, uint32_t fCapsAdded, uint32_t fCapsRemoved));
2168
2169 /**
2170 * Issue a display resolution change request.
2171 *
2172 * Note that there can only one request in the queue and that in case the guest does
2173 * not process it, issuing another request will overwrite the previous.
2174 *
2175 * @returns VBox status code
2176 * @param pInterface Pointer to the interface structure containing the called function pointer.
2177 * @param cx Horizontal pixel resolution (0 = do not change).
2178 * @param cy Vertical pixel resolution (0 = do not change).
2179 * @param cBits Bits per pixel (0 = do not change).
2180 * @param idxDisplay The display index.
2181 * @param xOrigin The X coordinate of the lower left
2182 * corner of the secondary display with
2183 * ID = idxDisplay
2184 * @param yOrigin The Y coordinate of the lower left
2185 * corner of the secondary display with
2186 * ID = idxDisplay
2187 * @param fEnabled Whether the display is enabled or not. (Guessing
2188 * again.)
2189 * @param fChangeOrigin Whether the display origin point changed. (Guess)
2190 */
2191 DECLR3CALLBACKMEMBER(int, pfnRequestDisplayChange,(PPDMIVMMDEVPORT pInterface, uint32_t cx,
2192 uint32_t cy, uint32_t cBits, uint32_t idxDisplay,
2193 int32_t xOrigin, int32_t yOrigin, bool fEnabled, bool fChangeOrigin));
2194
2195 /**
2196 * Pass credentials to guest.
2197 *
2198 * Note that there can only be one set of credentials and the guest may or may not
2199 * query them and may do whatever it wants with them.
2200 *
2201 * @returns VBox status code.
2202 * @param pInterface Pointer to the interface structure containing the called function pointer.
2203 * @param pszUsername User name, may be empty (UTF-8).
2204 * @param pszPassword Password, may be empty (UTF-8).
2205 * @param pszDomain Domain name, may be empty (UTF-8).
2206 * @param fFlags VMMDEV_SETCREDENTIALS_*.
2207 */
2208 DECLR3CALLBACKMEMBER(int, pfnSetCredentials,(PPDMIVMMDEVPORT pInterface, const char *pszUsername,
2209 const char *pszPassword, const char *pszDomain,
2210 uint32_t fFlags));
2211
2212 /**
2213 * Notify the driver about a VBVA status change.
2214 *
2215 * @returns Nothing. Because it is informational callback.
2216 * @param pInterface Pointer to the interface structure containing the called function pointer.
2217 * @param fEnabled Current VBVA status.
2218 */
2219 DECLR3CALLBACKMEMBER(void, pfnVBVAChange, (PPDMIVMMDEVPORT pInterface, bool fEnabled));
2220
2221 /**
2222 * Issue a seamless mode change request.
2223 *
2224 * Note that there can only one request in the queue and that in case the guest does
2225 * not process it, issuing another request will overwrite the previous.
2226 *
2227 * @returns VBox status code
2228 * @param pInterface Pointer to the interface structure containing the called function pointer.
2229 * @param fEnabled Seamless mode enabled or not
2230 */
2231 DECLR3CALLBACKMEMBER(int, pfnRequestSeamlessChange,(PPDMIVMMDEVPORT pInterface, bool fEnabled));
2232
2233 /**
2234 * Issue a memory balloon change request.
2235 *
2236 * Note that there can only one request in the queue and that in case the guest does
2237 * not process it, issuing another request will overwrite the previous.
2238 *
2239 * @returns VBox status code
2240 * @param pInterface Pointer to the interface structure containing the called function pointer.
2241 * @param cMbBalloon Balloon size in megabytes
2242 */
2243 DECLR3CALLBACKMEMBER(int, pfnSetMemoryBalloon,(PPDMIVMMDEVPORT pInterface, uint32_t cMbBalloon));
2244
2245 /**
2246 * Issue a statistcs interval change request.
2247 *
2248 * Note that there can only one request in the queue and that in case the guest does
2249 * not process it, issuing another request will overwrite the previous.
2250 *
2251 * @returns VBox status code
2252 * @param pInterface Pointer to the interface structure containing the called function pointer.
2253 * @param cSecsStatInterval Statistics query interval in seconds
2254 * (0=disable).
2255 */
2256 DECLR3CALLBACKMEMBER(int, pfnSetStatisticsInterval,(PPDMIVMMDEVPORT pInterface, uint32_t cSecsStatInterval));
2257
2258 /**
2259 * Notify the guest about a VRDP status change.
2260 *
2261 * @returns VBox status code
2262 * @param pInterface Pointer to the interface structure containing the called function pointer.
2263 * @param fVRDPEnabled Current VRDP status.
2264 * @param uVRDPExperienceLevel Which visual effects to be disabled in
2265 * the guest.
2266 */
2267 DECLR3CALLBACKMEMBER(int, pfnVRDPChange, (PPDMIVMMDEVPORT pInterface, bool fVRDPEnabled, uint32_t uVRDPExperienceLevel));
2268
2269 /**
2270 * Notify the guest of CPU hot-unplug event.
2271 *
2272 * @returns VBox status code
2273 * @param pInterface Pointer to the interface structure containing the called function pointer.
2274 * @param idCpuCore The core id of the CPU to remove.
2275 * @param idCpuPackage The package id of the CPU to remove.
2276 */
2277 DECLR3CALLBACKMEMBER(int, pfnCpuHotUnplug, (PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage));
2278
2279 /**
2280 * Notify the guest of CPU hot-plug event.
2281 *
2282 * @returns VBox status code
2283 * @param pInterface Pointer to the interface structure containing the called function pointer.
2284 * @param idCpuCore The core id of the CPU to add.
2285 * @param idCpuPackage The package id of the CPU to add.
2286 */
2287 DECLR3CALLBACKMEMBER(int, pfnCpuHotPlug, (PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage));
2288
2289} PDMIVMMDEVPORT;
2290/** PDMIVMMDEVPORT interface ID. */
2291#define PDMIVMMDEVPORT_IID "d7e52035-3b6c-422e-9215-2a75646a945d"
2292
2293
2294/** Pointer to a HPET legacy notification interface. */
2295typedef struct PDMIHPETLEGACYNOTIFY *PPDMIHPETLEGACYNOTIFY;
2296/**
2297 * HPET legacy notification interface.
2298 */
2299typedef struct PDMIHPETLEGACYNOTIFY
2300{
2301 /**
2302 * Notify about change of HPET legacy mode.
2303 *
2304 * @param pInterface Pointer to the interface structure containing the
2305 * called function pointer.
2306 * @param fActivated If HPET legacy mode is activated (@c true) or
2307 * deactivated (@c false).
2308 */
2309 DECLR3CALLBACKMEMBER(void, pfnModeChanged,(PPDMIHPETLEGACYNOTIFY pInterface, bool fActivated));
2310} PDMIHPETLEGACYNOTIFY;
2311/** PDMIHPETLEGACYNOTIFY interface ID. */
2312#define PDMIHPETLEGACYNOTIFY_IID "c9ada595-4b65-4311-8b21-b10498997774"
2313
2314
2315/** @name Flags for PDMIVMMDEVPORT::pfnSetCredentials.
2316 * @{ */
2317/** The guest should perform a logon with the credentials. */
2318#define VMMDEV_SETCREDENTIALS_GUESTLOGON RT_BIT(0)
2319/** The guest should prevent local logons. */
2320#define VMMDEV_SETCREDENTIALS_NOLOCALLOGON RT_BIT(1)
2321/** The guest should verify the credentials. */
2322#define VMMDEV_SETCREDENTIALS_JUDGE RT_BIT(15)
2323/** @} */
2324
2325/** Forward declaration of the guest information structure. */
2326struct VBoxGuestInfo;
2327/** Forward declaration of the guest information-2 structure. */
2328struct VBoxGuestInfo2;
2329/** Forward declaration of the guest statistics structure */
2330struct VBoxGuestStatistics;
2331/** Forward declaration of the guest status structure */
2332struct VBoxGuestStatus;
2333
2334/** Forward declaration of the video accelerator command memory. */
2335struct VBVAMEMORY;
2336/** Pointer to video accelerator command memory. */
2337typedef struct VBVAMEMORY *PVBVAMEMORY;
2338
2339/** Pointer to a VMMDev connector interface. */
2340typedef struct PDMIVMMDEVCONNECTOR *PPDMIVMMDEVCONNECTOR;
2341/**
2342 * VMMDev connector interface (up).
2343 * Pair with PDMIVMMDEVPORT.
2344 */
2345typedef struct PDMIVMMDEVCONNECTOR
2346{
2347 /**
2348 * Update guest facility status.
2349 *
2350 * Called in response to VMMDevReq_ReportGuestStatus, reset or state restore.
2351 *
2352 * @param pInterface Pointer to this interface.
2353 * @param uFacility The facility.
2354 * @param uStatus The status.
2355 * @param fFlags Flags assoicated with the update. Currently
2356 * reserved and should be ignored.
2357 * @param pTimeSpecTS Pointer to the timestamp of this report.
2358 * @thread The emulation thread.
2359 */
2360 DECLR3CALLBACKMEMBER(void, pfnUpdateGuestStatus,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFacility, uint16_t uStatus,
2361 uint32_t fFlags, PCRTTIMESPEC pTimeSpecTS));
2362
2363 /**
2364 * Updates a guest user state.
2365 *
2366 * Called in response to VMMDevReq_ReportGuestUserState.
2367 *
2368 * @param pInterface Pointer to this interface.
2369 * @param pszUser Guest user name to update status for.
2370 * @param pszDomain Domain the guest user is bound to. Optional.
2371 * @param uState New guest user state to notify host about.
2372 * @param puDetails Pointer to optional state data.
2373 * @param cbDetails Size (in bytes) of optional state data.
2374 * @thread The emulation thread.
2375 */
2376 DECLR3CALLBACKMEMBER(void, pfnUpdateGuestUserState,(PPDMIVMMDEVCONNECTOR pInterface, const char *pszUser, const char *pszDomain,
2377 uint32_t uState,
2378 const uint8_t *puDetails, uint32_t cbDetails));
2379
2380 /**
2381 * Reports the guest API and OS version.
2382 * Called whenever the Additions issue a guest info report request.
2383 *
2384 * @param pInterface Pointer to this interface.
2385 * @param pGuestInfo Pointer to guest information structure
2386 * @thread The emulation thread.
2387 */
2388 DECLR3CALLBACKMEMBER(void, pfnUpdateGuestInfo,(PPDMIVMMDEVCONNECTOR pInterface, const struct VBoxGuestInfo *pGuestInfo));
2389
2390 /**
2391 * Reports the detailed Guest Additions version.
2392 *
2393 * @param pInterface Pointer to this interface.
2394 * @param uFullVersion The guest additions version as a full version.
2395 * Use VBOX_FULL_VERSION_GET_MAJOR,
2396 * VBOX_FULL_VERSION_GET_MINOR and
2397 * VBOX_FULL_VERSION_GET_BUILD to access it.
2398 * (This will not be zero, so turn down the
2399 * paranoia level a notch.)
2400 * @param pszName Pointer to the sanitized version name. This can
2401 * be empty, but will not be NULL. If not empty,
2402 * it will contain a build type tag and/or a
2403 * publisher tag. If both, then they are separated
2404 * by an underscore (VBOX_VERSION_STRING fashion).
2405 * @param uRevision The SVN revision. Can be 0.
2406 * @param fFeatures Feature mask, currently none are defined.
2407 *
2408 * @thread The emulation thread.
2409 */
2410 DECLR3CALLBACKMEMBER(void, pfnUpdateGuestInfo2,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFullVersion,
2411 const char *pszName, uint32_t uRevision, uint32_t fFeatures));
2412
2413 /**
2414 * Update the guest additions capabilities.
2415 * This is called when the guest additions capabilities change. The new capabilities
2416 * are given and the connector should update its internal state.
2417 *
2418 * @param pInterface Pointer to this interface.
2419 * @param newCapabilities New capabilities.
2420 * @thread The emulation thread.
2421 */
2422 DECLR3CALLBACKMEMBER(void, pfnUpdateGuestCapabilities,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities));
2423
2424 /**
2425 * Update the mouse capabilities.
2426 * This is called when the mouse capabilities change. The new capabilities
2427 * are given and the connector should update its internal state.
2428 *
2429 * @param pInterface Pointer to this interface.
2430 * @param newCapabilities New capabilities.
2431 * @thread The emulation thread.
2432 */
2433 DECLR3CALLBACKMEMBER(void, pfnUpdateMouseCapabilities,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities));
2434
2435 /**
2436 * Update the pointer shape.
2437 * This is called when the mouse pointer shape changes. The new shape
2438 * is passed as a caller allocated buffer that will be freed after returning
2439 *
2440 * @param pInterface Pointer to this interface.
2441 * @param fVisible Visibility indicator (if false, the other parameters are undefined).
2442 * @param fAlpha Flag whether alpha channel is being passed.
2443 * @param xHot Pointer hot spot x coordinate.
2444 * @param yHot Pointer hot spot y coordinate.
2445 * @param x Pointer new x coordinate on screen.
2446 * @param y Pointer new y coordinate on screen.
2447 * @param cx Pointer width in pixels.
2448 * @param cy Pointer height in pixels.
2449 * @param cbScanline Size of one scanline in bytes.
2450 * @param pvShape New shape buffer.
2451 * @thread The emulation thread.
2452 */
2453 DECLR3CALLBACKMEMBER(void, pfnUpdatePointerShape,(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
2454 uint32_t xHot, uint32_t yHot,
2455 uint32_t cx, uint32_t cy,
2456 void *pvShape));
2457
2458 /**
2459 * Enable or disable video acceleration on behalf of guest.
2460 *
2461 * @param pInterface Pointer to this interface.
2462 * @param fEnable Whether to enable acceleration.
2463 * @param pVbvaMemory Video accelerator memory.
2464
2465 * @return VBox rc. VINF_SUCCESS if VBVA was enabled.
2466 * @thread The emulation thread.
2467 */
2468 DECLR3CALLBACKMEMBER(int, pfnVideoAccelEnable,(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, PVBVAMEMORY pVbvaMemory));
2469
2470 /**
2471 * Force video queue processing.
2472 *
2473 * @param pInterface Pointer to this interface.
2474 * @thread The emulation thread.
2475 */
2476 DECLR3CALLBACKMEMBER(void, pfnVideoAccelFlush,(PPDMIVMMDEVCONNECTOR pInterface));
2477
2478 /**
2479 * Return whether the given video mode is supported/wanted by the host.
2480 *
2481 * @returns VBox status code
2482 * @param pInterface Pointer to this interface.
2483 * @param display The guest monitor, 0 for primary.
2484 * @param cy Video mode horizontal resolution in pixels.
2485 * @param cx Video mode vertical resolution in pixels.
2486 * @param cBits Video mode bits per pixel.
2487 * @param pfSupported Where to put the indicator for whether this mode is supported. (output)
2488 * @thread The emulation thread.
2489 */
2490 DECLR3CALLBACKMEMBER(int, pfnVideoModeSupported,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t cx, uint32_t cy, uint32_t cBits, bool *pfSupported));
2491
2492 /**
2493 * Queries by how many pixels the height should be reduced when calculating video modes
2494 *
2495 * @returns VBox status code
2496 * @param pInterface Pointer to this interface.
2497 * @param pcyReduction Pointer to the result value.
2498 * @thread The emulation thread.
2499 */
2500 DECLR3CALLBACKMEMBER(int, pfnGetHeightReduction,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcyReduction));
2501
2502 /**
2503 * Informs about a credentials judgement result from the guest.
2504 *
2505 * @returns VBox status code
2506 * @param pInterface Pointer to this interface.
2507 * @param fFlags Judgement result flags.
2508 * @thread The emulation thread.
2509 */
2510 DECLR3CALLBACKMEMBER(int, pfnSetCredentialsJudgementResult,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fFlags));
2511
2512 /**
2513 * Set the visible region of the display
2514 *
2515 * @returns VBox status code.
2516 * @param pInterface Pointer to this interface.
2517 * @param cRect Number of rectangles in pRect
2518 * @param pRect Rectangle array
2519 * @thread The emulation thread.
2520 */
2521 DECLR3CALLBACKMEMBER(int, pfnSetVisibleRegion,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect));
2522
2523 /**
2524 * Query the visible region of the display
2525 *
2526 * @returns VBox status code.
2527 * @param pInterface Pointer to this interface.
2528 * @param pcRect Number of rectangles in pRect
2529 * @param pRect Rectangle array (set to NULL to query the number of rectangles)
2530 * @thread The emulation thread.
2531 */
2532 DECLR3CALLBACKMEMBER(int, pfnQueryVisibleRegion,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect));
2533
2534 /**
2535 * Request the statistics interval
2536 *
2537 * @returns VBox status code.
2538 * @param pInterface Pointer to this interface.
2539 * @param pulInterval Pointer to interval in seconds
2540 * @thread The emulation thread.
2541 */
2542 DECLR3CALLBACKMEMBER(int, pfnQueryStatisticsInterval,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval));
2543
2544 /**
2545 * Report new guest statistics
2546 *
2547 * @returns VBox status code.
2548 * @param pInterface Pointer to this interface.
2549 * @param pGuestStats Guest statistics
2550 * @thread The emulation thread.
2551 */
2552 DECLR3CALLBACKMEMBER(int, pfnReportStatistics,(PPDMIVMMDEVCONNECTOR pInterface, struct VBoxGuestStatistics *pGuestStats));
2553
2554 /**
2555 * Query the current balloon size
2556 *
2557 * @returns VBox status code.
2558 * @param pInterface Pointer to this interface.
2559 * @param pcbBalloon Balloon size
2560 * @thread The emulation thread.
2561 */
2562 DECLR3CALLBACKMEMBER(int, pfnQueryBalloonSize,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcbBalloon));
2563
2564 /**
2565 * Query the current page fusion setting
2566 *
2567 * @returns VBox status code.
2568 * @param pInterface Pointer to this interface.
2569 * @param pfPageFusionEnabled Pointer to boolean
2570 * @thread The emulation thread.
2571 */
2572 DECLR3CALLBACKMEMBER(int, pfnIsPageFusionEnabled,(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled));
2573
2574} PDMIVMMDEVCONNECTOR;
2575/** PDMIVMMDEVCONNECTOR interface ID. */
2576#define PDMIVMMDEVCONNECTOR_IID "aff90240-a443-434e-9132-80c186ab97d4"
2577
2578
2579#ifndef VBOX_WITH_PDM_AUDIO_DRIVER
2580/** Pointer to a network connector interface */
2581typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
2582/**
2583 * Audio connector interface (up).
2584 * No interface pair yet.
2585 */
2586typedef struct PDMIAUDIOCONNECTOR
2587{
2588 DECLR3CALLBACKMEMBER(void, pfnRun,(PPDMIAUDIOCONNECTOR pInterface));
2589
2590/* DECLR3CALLBACKMEMBER(int, pfnSetRecordSource,(PPDMIAUDIOINCONNECTOR pInterface, AUDIORECSOURCE)); */
2591
2592} PDMIAUDIOCONNECTOR;
2593/** PDMIAUDIOCONNECTOR interface ID. */
2594#define PDMIAUDIOCONNECTOR_IID "85d52af5-b3aa-4b3e-b176-4b5ebfc52f47"
2595
2596
2597#endif
2598/** @todo r=bird: the two following interfaces are hacks to work around the missing audio driver
2599 * interface. This should be addressed rather than making more temporary hacks. */
2600
2601/** Pointer to a Audio Sniffer Device port interface. */
2602typedef struct PDMIAUDIOSNIFFERPORT *PPDMIAUDIOSNIFFERPORT;
2603/**
2604 * Audio Sniffer port interface (down).
2605 * Pair with PDMIAUDIOSNIFFERCONNECTOR.
2606 */
2607typedef struct PDMIAUDIOSNIFFERPORT
2608{
2609 /**
2610 * Enables or disables sniffing.
2611 *
2612 * If sniffing is being enabled also sets a flag whether the audio must be also
2613 * left on the host.
2614 *
2615 * @returns VBox status code
2616 * @param pInterface Pointer to this interface.
2617 * @param fEnable 'true' for enable sniffing, 'false' to disable.
2618 * @param fKeepHostAudio Indicates whether host audio should also present
2619 * 'true' means that sound should not be played
2620 * by the audio device.
2621 */
2622 DECLR3CALLBACKMEMBER(int, pfnSetup,(PPDMIAUDIOSNIFFERPORT pInterface, bool fEnable, bool fKeepHostAudio));
2623
2624 /**
2625 * Enables or disables audio input.
2626 *
2627 * @returns VBox status code
2628 * @param pInterface Pointer to this interface.
2629 * @param fIntercept 'true' for interception of audio input,
2630 * 'false' to let the host audio backend do audio input.
2631 */
2632 DECLR3CALLBACKMEMBER(int, pfnAudioInputIntercept,(PPDMIAUDIOSNIFFERPORT pInterface, bool fIntercept));
2633
2634 /**
2635 * Audio input is about to start.
2636 *
2637 * @returns VBox status code.
2638 * @param pvContext The callback context, supplied in the
2639 * PDMIAUDIOSNIFFERCONNECTOR::pfnAudioInputBegin as pvContext.
2640 * @param iSampleHz The sample frequency in Hz.
2641 * @param cChannels Number of channels. 1 for mono, 2 for stereo.
2642 * @param cBits How many bits a sample for a single channel has. Normally 8 or 16.
2643 * @param fUnsigned Whether samples are unsigned values.
2644 */
2645 DECLR3CALLBACKMEMBER(int, pfnAudioInputEventBegin,(PPDMIAUDIOSNIFFERPORT pInterface,
2646 void *pvContext,
2647 int iSampleHz,
2648 int cChannels,
2649 int cBits,
2650 bool fUnsigned));
2651
2652 /**
2653 * Callback which delivers audio data to the audio device.
2654 *
2655 * @returns VBox status code.
2656 * @param pvContext The callback context, supplied in the
2657 * PDMIAUDIOSNIFFERCONNECTOR::pfnAudioInputBegin as pvContext.
2658 * @param pvData Event specific data.
2659 * @param cbData Size of the buffer pointed by pvData.
2660 */
2661 DECLR3CALLBACKMEMBER(int, pfnAudioInputEventData,(PPDMIAUDIOSNIFFERPORT pInterface,
2662 void *pvContext,
2663 const void *pvData,
2664 uint32_t cbData));
2665
2666 /**
2667 * Audio input ends.
2668 *
2669 * @param pvContext The callback context, supplied in the
2670 * PDMIAUDIOSNIFFERCONNECTOR::pfnAudioInputBegin as pvContext.
2671 */
2672 DECLR3CALLBACKMEMBER(void, pfnAudioInputEventEnd,(PPDMIAUDIOSNIFFERPORT pInterface,
2673 void *pvContext));
2674} PDMIAUDIOSNIFFERPORT;
2675/** PDMIAUDIOSNIFFERPORT interface ID. */
2676#define PDMIAUDIOSNIFFERPORT_IID "8ad25d78-46e9-479b-a363-bb0bc0fe022f"
2677
2678
2679/** Pointer to a Audio Sniffer connector interface. */
2680typedef struct PDMIAUDIOSNIFFERCONNECTOR *PPDMIAUDIOSNIFFERCONNECTOR;
2681
2682/**
2683 * Audio Sniffer connector interface (up).
2684 * Pair with PDMIAUDIOSNIFFERPORT.
2685 */
2686typedef struct PDMIAUDIOSNIFFERCONNECTOR
2687{
2688 /**
2689 * AudioSniffer device calls this method when audio samples
2690 * are about to be played and sniffing is enabled.
2691 *
2692 * @param pInterface Pointer to this interface.
2693 * @param pvSamples Audio samples buffer.
2694 * @param cSamples How many complete samples are in the buffer.
2695 * @param iSampleHz The sample frequency in Hz.
2696 * @param cChannels Number of channels. 1 for mono, 2 for stereo.
2697 * @param cBits How many bits a sample for a single channel has. Normally 8 or 16.
2698 * @param fUnsigned Whether samples are unsigned values.
2699 * @thread The emulation thread.
2700 */
2701 DECLR3CALLBACKMEMBER(void, pfnAudioSamplesOut,(PPDMIAUDIOSNIFFERCONNECTOR pInterface, void *pvSamples, uint32_t cSamples,
2702 int iSampleHz, int cChannels, int cBits, bool fUnsigned));
2703
2704 /**
2705 * AudioSniffer device calls this method when output volume is changed.
2706 *
2707 * @param pInterface Pointer to this interface.
2708 * @param u16LeftVolume 0..0xFFFF volume level for left channel.
2709 * @param u16RightVolume 0..0xFFFF volume level for right channel.
2710 * @thread The emulation thread.
2711 */
2712 DECLR3CALLBACKMEMBER(void, pfnAudioVolumeOut,(PPDMIAUDIOSNIFFERCONNECTOR pInterface, uint16_t u16LeftVolume, uint16_t u16RightVolume));
2713
2714 /**
2715 * Audio input has been requested by the virtual audio device.
2716 *
2717 * @param pInterface Pointer to this interface.
2718 * @param ppvUserCtx The interface context for this audio input stream,
2719 * it will be used in the pfnAudioInputEnd call.
2720 * @param pvContext The context pointer to be used in PDMIAUDIOSNIFFERPORT::pfnAudioInputEvent.
2721 * @param cSamples How many samples in a block is preferred in
2722 * PDMIAUDIOSNIFFERPORT::pfnAudioInputEvent.
2723 * @param iSampleHz The sample frequency in Hz.
2724 * @param cChannels Number of channels. 1 for mono, 2 for stereo.
2725 * @param cBits How many bits a sample for a single channel has. Normally 8 or 16.
2726 * @thread The emulation thread.
2727 */
2728 DECLR3CALLBACKMEMBER(int, pfnAudioInputBegin,(PPDMIAUDIOSNIFFERCONNECTOR pInterface,
2729 void **ppvUserCtx,
2730 void *pvContext,
2731 uint32_t cSamples,
2732 uint32_t iSampleHz,
2733 uint32_t cChannels,
2734 uint32_t cBits));
2735
2736 /**
2737 * Audio input has been requested by the virtual audio device.
2738 *
2739 * @param pInterface Pointer to this interface.
2740 * @param pvUserCtx The interface context for this audio input stream,
2741 * which was returned by pfnAudioInputBegin call.
2742 * @thread The emulation thread.
2743 */
2744 DECLR3CALLBACKMEMBER(void, pfnAudioInputEnd,(PPDMIAUDIOSNIFFERCONNECTOR pInterface,
2745 void *pvUserCtx));
2746} PDMIAUDIOSNIFFERCONNECTOR;
2747/** PDMIAUDIOSNIFFERCONNECTOR - The Audio Sniffer Driver connector interface. */
2748#define PDMIAUDIOSNIFFERCONNECTOR_IID "9d37f543-27af-45f8-8002-8ef7abac71e4"
2749
2750
2751/**
2752 * Generic status LED core.
2753 * Note that a unit doesn't have to support all the indicators.
2754 */
2755typedef union PDMLEDCORE
2756{
2757 /** 32-bit view. */
2758 uint32_t volatile u32;
2759 /** Bit view. */
2760 struct
2761 {
2762 /** Reading/Receiving indicator. */
2763 uint32_t fReading : 1;
2764 /** Writing/Sending indicator. */
2765 uint32_t fWriting : 1;
2766 /** Busy indicator. */
2767 uint32_t fBusy : 1;
2768 /** Error indicator. */
2769 uint32_t fError : 1;
2770 } s;
2771} PDMLEDCORE;
2772
2773/** LED bit masks for the u32 view.
2774 * @{ */
2775/** Reading/Receiving indicator. */
2776#define PDMLED_READING RT_BIT(0)
2777/** Writing/Sending indicator. */
2778#define PDMLED_WRITING RT_BIT(1)
2779/** Busy indicator. */
2780#define PDMLED_BUSY RT_BIT(2)
2781/** Error indicator. */
2782#define PDMLED_ERROR RT_BIT(3)
2783/** @} */
2784
2785
2786/**
2787 * Generic status LED.
2788 * Note that a unit doesn't have to support all the indicators.
2789 */
2790typedef struct PDMLED
2791{
2792 /** Just a magic for sanity checking. */
2793 uint32_t u32Magic;
2794 uint32_t u32Alignment; /**< structure size alignment. */
2795 /** The actual LED status.
2796 * Only the device is allowed to change this. */
2797 PDMLEDCORE Actual;
2798 /** The asserted LED status which is cleared by the reader.
2799 * The device will assert the bits but never clear them.
2800 * The driver clears them as it sees fit. */
2801 PDMLEDCORE Asserted;
2802} PDMLED;
2803
2804/** Pointer to an LED. */
2805typedef PDMLED *PPDMLED;
2806/** Pointer to a const LED. */
2807typedef const PDMLED *PCPDMLED;
2808
2809/** Magic value for PDMLED::u32Magic. */
2810#define PDMLED_MAGIC UINT32_C(0x11335577)
2811
2812/** Pointer to an LED ports interface. */
2813typedef struct PDMILEDPORTS *PPDMILEDPORTS;
2814/**
2815 * Interface for exporting LEDs (down).
2816 * Pair with PDMILEDCONNECTORS.
2817 */
2818typedef struct PDMILEDPORTS
2819{
2820 /**
2821 * Gets the pointer to the status LED of a unit.
2822 *
2823 * @returns VBox status code.
2824 * @param pInterface Pointer to the interface structure containing the called function pointer.
2825 * @param iLUN The unit which status LED we desire.
2826 * @param ppLed Where to store the LED pointer.
2827 */
2828 DECLR3CALLBACKMEMBER(int, pfnQueryStatusLed,(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed));
2829
2830} PDMILEDPORTS;
2831/** PDMILEDPORTS interface ID. */
2832#define PDMILEDPORTS_IID "435e0cec-8549-4ca0-8c0d-98e52f1dc038"
2833
2834
2835/** Pointer to an LED connectors interface. */
2836typedef struct PDMILEDCONNECTORS *PPDMILEDCONNECTORS;
2837/**
2838 * Interface for reading LEDs (up).
2839 * Pair with PDMILEDPORTS.
2840 */
2841typedef struct PDMILEDCONNECTORS
2842{
2843 /**
2844 * Notification about a unit which have been changed.
2845 *
2846 * The driver must discard any pointers to data owned by
2847 * the unit and requery it.
2848 *
2849 * @param pInterface Pointer to the interface structure containing the called function pointer.
2850 * @param iLUN The unit number.
2851 */
2852 DECLR3CALLBACKMEMBER(void, pfnUnitChanged,(PPDMILEDCONNECTORS pInterface, unsigned iLUN));
2853} PDMILEDCONNECTORS;
2854/** PDMILEDCONNECTORS interface ID. */
2855#define PDMILEDCONNECTORS_IID "8ed63568-82a7-4193-b57b-db8085ac4495"
2856
2857
2858/** Pointer to a Media Notification interface. */
2859typedef struct PDMIMEDIANOTIFY *PPDMIMEDIANOTIFY;
2860/**
2861 * Interface for exporting Medium eject information (up). No interface pair.
2862 */
2863typedef struct PDMIMEDIANOTIFY
2864{
2865 /**
2866 * Signals that the medium was ejected.
2867 *
2868 * @returns VBox status code.
2869 * @param pInterface Pointer to the interface structure containing the called function pointer.
2870 * @param iLUN The unit which had the medium ejected.
2871 */
2872 DECLR3CALLBACKMEMBER(int, pfnEjected,(PPDMIMEDIANOTIFY pInterface, unsigned iLUN));
2873
2874} PDMIMEDIANOTIFY;
2875/** PDMIMEDIANOTIFY interface ID. */
2876#define PDMIMEDIANOTIFY_IID "fc22d53e-feb1-4a9c-b9fb-0a990a6ab288"
2877
2878
2879/** The special status unit number */
2880#define PDM_STATUS_LUN 999
2881
2882
2883#ifdef VBOX_WITH_HGCM
2884
2885/** Abstract HGCM command structure. Used only to define a typed pointer. */
2886struct VBOXHGCMCMD;
2887
2888/** Pointer to HGCM command structure. This pointer is unique and identifies
2889 * the command being processed. The pointer is passed to HGCM connector methods,
2890 * and must be passed back to HGCM port when command is completed.
2891 */
2892typedef struct VBOXHGCMCMD *PVBOXHGCMCMD;
2893
2894/** Pointer to a HGCM port interface. */
2895typedef struct PDMIHGCMPORT *PPDMIHGCMPORT;
2896/**
2897 * Host-Guest communication manager port interface (down). Normally implemented
2898 * by VMMDev.
2899 * Pair with PDMIHGCMCONNECTOR.
2900 */
2901typedef struct PDMIHGCMPORT
2902{
2903 /**
2904 * Notify the guest on a command completion.
2905 *
2906 * @param pInterface Pointer to this interface.
2907 * @param rc The return code (VBox error code).
2908 * @param pCmd A pointer that identifies the completed command.
2909 *
2910 * @returns VBox status code
2911 */
2912 DECLR3CALLBACKMEMBER(void, pfnCompleted,(PPDMIHGCMPORT pInterface, int32_t rc, PVBOXHGCMCMD pCmd));
2913
2914} PDMIHGCMPORT;
2915/** PDMIHGCMPORT interface ID. */
2916# define PDMIHGCMPORT_IID "e00a0cbf-b75a-45c3-87f4-41cddbc5ae0b"
2917
2918
2919/** Pointer to a HGCM service location structure. */
2920typedef struct HGCMSERVICELOCATION *PHGCMSERVICELOCATION;
2921
2922/** Pointer to a HGCM connector interface. */
2923typedef struct PDMIHGCMCONNECTOR *PPDMIHGCMCONNECTOR;
2924/**
2925 * The Host-Guest communication manager connector interface (up). Normally
2926 * implemented by Main::VMMDevInterface.
2927 * Pair with PDMIHGCMPORT.
2928 */
2929typedef struct PDMIHGCMCONNECTOR
2930{
2931 /**
2932 * Locate a service and inform it about a client connection.
2933 *
2934 * @param pInterface Pointer to this interface.
2935 * @param pCmd A pointer that identifies the command.
2936 * @param pServiceLocation Pointer to the service location structure.
2937 * @param pu32ClientID Where to store the client id for the connection.
2938 * @return VBox status code.
2939 * @thread The emulation thread.
2940 */
2941 DECLR3CALLBACKMEMBER(int, pfnConnect,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID));
2942
2943 /**
2944 * Disconnect from service.
2945 *
2946 * @param pInterface Pointer to this interface.
2947 * @param pCmd A pointer that identifies the command.
2948 * @param u32ClientID The client id returned by the pfnConnect call.
2949 * @return VBox status code.
2950 * @thread The emulation thread.
2951 */
2952 DECLR3CALLBACKMEMBER(int, pfnDisconnect,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID));
2953
2954 /**
2955 * Process a guest issued command.
2956 *
2957 * @param pInterface Pointer to this interface.
2958 * @param pCmd A pointer that identifies the command.
2959 * @param u32ClientID The client id returned by the pfnConnect call.
2960 * @param u32Function Function to be performed by the service.
2961 * @param cParms Number of parameters in the array pointed to by paParams.
2962 * @param paParms Pointer to an array of parameters.
2963 * @return VBox status code.
2964 * @thread The emulation thread.
2965 */
2966 DECLR3CALLBACKMEMBER(int, pfnCall,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
2967 uint32_t cParms, PVBOXHGCMSVCPARM paParms));
2968
2969} PDMIHGCMCONNECTOR;
2970/** PDMIHGCMCONNECTOR interface ID. */
2971# define PDMIHGCMCONNECTOR_IID "a1104758-c888-4437-8f2a-7bac17865b5c"
2972
2973#endif /* VBOX_WITH_HGCM */
2974
2975/**
2976 * Data direction.
2977 */
2978typedef enum PDMSCSIREQUESTTXDIR
2979{
2980 PDMSCSIREQUESTTXDIR_UNKNOWN = 0x00,
2981 PDMSCSIREQUESTTXDIR_FROM_DEVICE = 0x01,
2982 PDMSCSIREQUESTTXDIR_TO_DEVICE = 0x02,
2983 PDMSCSIREQUESTTXDIR_NONE = 0x03,
2984 PDMSCSIREQUESTTXDIR_32BIT_HACK = 0x7fffffff
2985} PDMSCSIREQUESTTXDIR;
2986
2987/**
2988 * SCSI request structure.
2989 */
2990typedef struct PDMSCSIREQUEST
2991{
2992 /** The logical unit. */
2993 uint32_t uLogicalUnit;
2994 /** Direction of the data flow. */
2995 PDMSCSIREQUESTTXDIR uDataDirection;
2996 /** Size of the SCSI CDB. */
2997 uint32_t cbCDB;
2998 /** Pointer to the SCSI CDB. */
2999 uint8_t *pbCDB;
3000 /** Overall size of all scatter gather list elements
3001 * for data transfer if any. */
3002 uint32_t cbScatterGather;
3003 /** Number of elements in the scatter gather list. */
3004 uint32_t cScatterGatherEntries;
3005 /** Pointer to the head of the scatter gather list. */
3006 PRTSGSEG paScatterGatherHead;
3007 /** Size of the sense buffer. */
3008 uint32_t cbSenseBuffer;
3009 /** Pointer to the sense buffer. *
3010 * Current assumption that the sense buffer is not scattered. */
3011 uint8_t *pbSenseBuffer;
3012 /** Opaque user data for use by the device. Left untouched by everything else! */
3013 void *pvUser;
3014} PDMSCSIREQUEST, *PPDMSCSIREQUEST;
3015/** Pointer to a const SCSI request structure. */
3016typedef const PDMSCSIREQUEST *PCSCSIREQUEST;
3017
3018/** Pointer to a SCSI port interface. */
3019typedef struct PDMISCSIPORT *PPDMISCSIPORT;
3020/**
3021 * SCSI command execution port interface (down).
3022 * Pair with PDMISCSICONNECTOR.
3023 */
3024typedef struct PDMISCSIPORT
3025{
3026
3027 /**
3028 * Notify the device on request completion.
3029 *
3030 * @returns VBox status code.
3031 * @param pInterface Pointer to this interface.
3032 * @param pSCSIRequest Pointer to the finished SCSI request.
3033 * @param rcCompletion SCSI_STATUS_* code for the completed request.
3034 * @param fRedo Flag whether the request can to be redone
3035 * when it failed.
3036 * @param rcReq The status code the request completed with (VERR_*)
3037 * Should be only used to choose the correct error message
3038 * displayed to the user if the error can be fixed by him
3039 * (fRedo is true).
3040 */
3041 DECLR3CALLBACKMEMBER(int, pfnSCSIRequestCompleted, (PPDMISCSIPORT pInterface, PPDMSCSIREQUEST pSCSIRequest,
3042 int rcCompletion, bool fRedo, int rcReq));
3043
3044 /**
3045 * Returns the storage controller name, instance and LUN of the attached medium.
3046 *
3047 * @returns VBox status.
3048 * @param pInterface Pointer to this interface.
3049 * @param ppcszController Where to store the name of the storage controller.
3050 * @param piInstance Where to store the instance number of the controller.
3051 * @param piLUN Where to store the LUN of the attached device.
3052 */
3053 DECLR3CALLBACKMEMBER(int, pfnQueryDeviceLocation, (PPDMISCSIPORT pInterface, const char **ppcszController,
3054 uint32_t *piInstance, uint32_t *piLUN));
3055
3056} PDMISCSIPORT;
3057/** PDMISCSIPORT interface ID. */
3058#define PDMISCSIPORT_IID "05d9fc3b-e38c-4b30-8344-a323feebcfe5"
3059
3060
3061/** Pointer to a SCSI connector interface. */
3062typedef struct PDMISCSICONNECTOR *PPDMISCSICONNECTOR;
3063/**
3064 * SCSI command execution connector interface (up).
3065 * Pair with PDMISCSIPORT.
3066 */
3067typedef struct PDMISCSICONNECTOR
3068{
3069
3070 /**
3071 * Submits a SCSI request for execution.
3072 *
3073 * @returns VBox status code.
3074 * @param pInterface Pointer to this interface.
3075 * @param pSCSIRequest Pointer to the SCSI request to execute.
3076 */
3077 DECLR3CALLBACKMEMBER(int, pfnSCSIRequestSend, (PPDMISCSICONNECTOR pInterface, PPDMSCSIREQUEST pSCSIRequest));
3078
3079} PDMISCSICONNECTOR;
3080/** PDMISCSICONNECTOR interface ID. */
3081#define PDMISCSICONNECTOR_IID "94465fbd-a2f2-447e-88c9-7366421bfbfe"
3082
3083
3084/** Pointer to a display VBVA callbacks interface. */
3085typedef struct PDMIDISPLAYVBVACALLBACKS *PPDMIDISPLAYVBVACALLBACKS;
3086/**
3087 * Display VBVA callbacks interface (up).
3088 */
3089typedef struct PDMIDISPLAYVBVACALLBACKS
3090{
3091
3092 /**
3093 * Informs guest about completion of processing the given Video HW Acceleration
3094 * command, does not wait for the guest to process the command.
3095 *
3096 * @returns ???
3097 * @param pInterface Pointer to this interface.
3098 * @param pCmd The Video HW Acceleration Command that was
3099 * completed.
3100 */
3101 DECLR3CALLBACKMEMBER(int, pfnVHWACommandCompleteAsync, (PPDMIDISPLAYVBVACALLBACKS pInterface,
3102 PVBOXVHWACMD pCmd));
3103
3104 DECLR3CALLBACKMEMBER(int, pfnCrHgsmiCommandCompleteAsync, (PPDMIDISPLAYVBVACALLBACKS pInterface,
3105 struct VBOXVDMACMD_CHROMIUM_CMD* pCmd, int rc));
3106
3107 DECLR3CALLBACKMEMBER(int, pfnCrHgsmiControlCompleteAsync, (PPDMIDISPLAYVBVACALLBACKS pInterface,
3108 struct VBOXVDMACMD_CHROMIUM_CTL* pCmd, int rc));
3109
3110 DECLR3CALLBACKMEMBER(int, pfnCrCtlSubmit, (PPDMIDISPLAYVBVACALLBACKS pInterface,
3111 struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
3112 PFNCRCTLCOMPLETION pfnCompletion,
3113 void *pvCompletion));
3114
3115 DECLR3CALLBACKMEMBER(int, pfnCrCtlSubmitSync, (PPDMIDISPLAYVBVACALLBACKS pInterface,
3116 struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd));
3117} PDMIDISPLAYVBVACALLBACKS;
3118/** PDMIDISPLAYVBVACALLBACKS */
3119#define PDMIDISPLAYVBVACALLBACKS_IID "ddac0bd0-332d-4671-8853-732921a80216"
3120
3121/** Pointer to a PCI raw connector interface. */
3122typedef struct PDMIPCIRAWCONNECTOR *PPDMIPCIRAWCONNECTOR;
3123/**
3124 * PCI raw connector interface (up).
3125 */
3126typedef struct PDMIPCIRAWCONNECTOR
3127{
3128
3129 /**
3130 *
3131 */
3132 DECLR3CALLBACKMEMBER(int, pfnDeviceConstructComplete, (PPDMIPCIRAWCONNECTOR pInterface, const char *pcszName,
3133 uint32_t uHostPciAddress, uint32_t uGuestPciAddress,
3134 int rc));
3135
3136} PDMIPCIRAWCONNECTOR;
3137/** PDMIPCIRAWCONNECTOR interface ID. */
3138#define PDMIPCIRAWCONNECTOR_IID "14aa9c6c-8869-4782-9dfc-910071a6aebf"
3139
3140/** @} */
3141
3142RT_C_DECLS_END
3143
3144#endif
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