VirtualBox

source: vbox/trunk/include/VBox/pdmifs.h@ 5999

Last change on this file since 5999 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 76.9 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Interfaces.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (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_pdmifs_h
27#define ___VBox_pdmifs_h
28
29#include <VBox/types.h>
30#include <VBox/hgcmsvc.h>
31
32__BEGIN_DECLS
33
34/** @defgroup grp_pdm_interfaces Interfaces
35 * @ingroup grp_pdm
36 * @{
37 */
38
39/**
40 * Driver interface identficators.
41 *
42 * @remark All interfaces have to be declared here. There is no such thing as
43 * private interface identifiers since they must be unique.
44 *
45 * That said, interface structures and other stuff can be put elsewhere,
46 * actually, it is best if this file is not flooded with structures that
47 * could be put closer to home.
48 */
49typedef enum PDMINTERFACE
50{
51 /** PDMIBASE - The interface everyone supports. */
52 PDMINTERFACE_BASE = 1,
53 /** PDMIMOUSEPORT - The mouse port interface. (Down) Coupled with PDMINTERFACE_MOUSE_CONNECTOR. */
54 PDMINTERFACE_MOUSE_PORT,
55 /** PDMIMOUSECONNECTOR - The mouse connector interface. (Up) Coupled with PDMINTERFACE_MOUSE_PORT. */
56 PDMINTERFACE_MOUSE_CONNECTOR,
57 /** PDMIKEYBOARDPORT - The keyboard port interface. (Down) Coupled with PDMINTERFACE_KEYBOARD_CONNECTOR. */
58 PDMINTERFACE_KEYBOARD_PORT,
59 /** PDMIKEYBOARDCONNECTOR - The keyboard connector interface. (Up) Coupled with PDMINTERFACE_KEYBOARD_PORT. */
60 PDMINTERFACE_KEYBOARD_CONNECTOR,
61 /** PDMIDISPLAYPORT - The display port interface. (Down) Coupled with PDMINTERFACE_DISPLAY_CONNECTOR. */
62 PDMINTERFACE_DISPLAY_PORT,
63 /** PDMIDISPLAYCONNECTOR - The display connector interface. (Up) Coupled with PDMINTERFACE_DISPLAY_PORT. */
64 PDMINTERFACE_DISPLAY_CONNECTOR,
65 /** PDMICHARPORT - The char notify interface. (Down) Coupled with PDMINTERFACE_CHAR. */
66 PDMINTERFACE_CHAR_PORT,
67 /** PDMICHAR - The char driver interface. (Up) Coupled with PDMINTERFACE_CHAR_PORT. */
68 PDMINTERFACE_CHAR,
69 /** PDMISTREAM - The stream driver interface (Up) No coupling.
70 * Used by a char driver to implement PDMINTERFACE_CHAR. */
71 PDMINTERFACE_STREAM,
72 /** PDMIBLOCKPORT - The block notify interface (Down) Coupled with PDMINTERFACE_BLOCK. */
73 PDMINTERFACE_BLOCK_PORT,
74 /** PDMIBLOCK - The block driver interface (Up) Coupled with PDMINTERFACE_BLOCK_PORT. */
75 PDMINTERFACE_BLOCK,
76 /** PDMIBLOCKBIOS - The block bios interface. (External) */
77 PDMINTERFACE_BLOCK_BIOS,
78 /** PDMIMOUNTNOTIFY - The mountable notification interface. (Down) Coupled with PDMINTERFACE_MOUNT. */
79 PDMINTERFACE_MOUNT_NOTIFY,
80 /** PDMIMOUNT - The mountable interface. (Up) Coupled with PDMINTERFACE_MOUNT_NOTIFY. */
81 PDMINTERFACE_MOUNT,
82 /** PDMIMEDIA - The media interface. (Up) No coupling.
83 * Used by a block unit driver to implement PDMINTERFACE_BLOCK and PDMINTERFACE_BLOCK_BIOS. */
84 PDMINTERFACE_MEDIA,
85 /** PDMIISCSITRANSPORT - The iSCSI transport interface (Up) No coupling.
86 * used by the iSCSI media driver. */
87 PDMINTERFACE_ISCSITRANSPORT,
88
89 /** PDMINETWORKPORT - The network port interface. (Down) Coupled with PDMINTERFACE_NETWORK_CONNECTOR. */
90 PDMINTERFACE_NETWORK_PORT,
91 /** PDMINETWORKPORT - The network connector interface. (Up) Coupled with PDMINTERFACE_NETWORK_PORT. */
92 PDMINTERFACE_NETWORK_CONNECTOR,
93 /** PDMINETWORKCONFIG - The network configuartion interface. (Main) Used by the managment api. */
94 PDMINTERFACE_NETWORK_CONFIG,
95
96 /** PDMIAUDIOCONNECTOR - The audio driver interface. (Up) No coupling. */
97 PDMINTERFACE_AUDIO_CONNECTOR,
98
99 /** PDMIAUDIOSNIFFERPORT - The Audio Sniffer Device port interface. */
100 PDMINTERFACE_AUDIO_SNIFFER_PORT,
101 /** PDMIAUDIOSNIFFERCONNECTOR - The Audio Sniffer Driver connector interface. */
102 PDMINTERFACE_AUDIO_SNIFFER_CONNECTOR,
103
104 /** PDMIVMMDEVPORT - The VMM Device port interface. */
105 PDMINTERFACE_VMMDEV_PORT,
106 /** PDMIVMMDEVCONNECTOR - The VMM Device connector interface. */
107 PDMINTERFACE_VMMDEV_CONNECTOR,
108
109 /** PDMILEDPORTS - The generic LED port interface. (Down) Coupled with PDMINTERFACE_LED_CONNECTORS. */
110 PDMINTERFACE_LED_PORTS,
111 /** PDMILEDCONNECTORS - The generic LED connector interface. (Up) Coupled with PDMINTERFACE_LED_PORTS. */
112 PDMINTERFACE_LED_CONNECTORS,
113
114 /** PDMIACPIPORT - ACPI port interface. (Down) Coupled with PDMINTERFACE_ACPI_CONNECTOR. */
115 PDMINTERFACE_ACPI_PORT,
116 /** PDMIACPICONNECTOR - ACPI connector interface. (Up) Coupled with PDMINTERFACE_ACPI_PORT. */
117 PDMINTERFACE_ACPI_CONNECTOR,
118
119 /** PDMIHGCMPORT - The Host-Guest communication manager port interface. Normally implemented by VMMDev. */
120 PDMINTERFACE_HGCM_PORT,
121 /** PDMIHGCMCONNECTOR - The Host-Guest communication manager connector interface. Normally implemented by Main::VMMDevInterface. */
122 PDMINTERFACE_HGCM_CONNECTOR,
123
124 /** VUSBIROOTHUBPORT - VUSB RootHub port interface. (Down) Coupled with PDMINTERFACE_USB_RH_CONNECTOR. */
125 PDMINTERFACE_VUSB_RH_PORT,
126 /** VUSBIROOTHUBCONNECTOR - VUSB RootHub connector interface. (Up) Coupled with PDMINTERFACE_USB_RH_PORT. */
127 PDMINTERFACE_VUSB_RH_CONNECTOR,
128 /** VUSBIRHCONFIG - VUSB RootHub configuration interface. (Main) Used by the managment api. */
129 PDMINTERFACE_VUSB_RH_CONFIG,
130
131 /** VUSBROOTHUBCONNECTOR - VUSB Device interface. (Up) No coupling. */
132 PDMINTERFACE_VUSB_DEVICE,
133
134 /** PDMIHOSTDEVICEPORT - The Host Device port interface. (Down) Coupled with PDMINTERFACE_HOST_DEVICE_CONNECTOR. */
135 PDMINTERFACE_HOST_DEVICE_PORT,
136 /** PDMIHOSTDEVICECONNECTOR - The Host device connector interface (Up) Coupled with PDMINTERFACE_HOST_DEVICE_PORT. */
137 PDMINTERFACE_HOST_DEVICE_CONNECTOR,
138
139 /** Maximum interface number. */
140 PDMINTERFACE_MAX
141} PDMINTERFACE;
142
143
144/**
145 * PDM Driver Base Interface.
146 */
147typedef struct PDMIBASE
148{
149 /**
150 * Queries an interface to the driver.
151 *
152 * @returns Pointer to interface.
153 * @returns NULL if the interface was not supported by the driver.
154 * @param pInterface Pointer to this interface structure.
155 * @param enmInterface The requested interface identification.
156 * @thread Any thread.
157 */
158 DECLR3CALLBACKMEMBER(void *, pfnQueryInterface,(struct PDMIBASE *pInterface, PDMINTERFACE enmInterface));
159} PDMIBASE;
160
161
162/**
163 * Dummy interface.
164 *
165 * This is used to typedef other dummy interfaces. The purpose of a dummy
166 * interface is to validate the logical function of a driver/device and
167 * full a natural interface pair.
168 */
169typedef struct PDMIDUMMY
170{
171 RTHCPTR pvDummy;
172} PDMIDUMMY;
173
174
175/** Pointer to a mouse port interface. */
176typedef struct PDMIMOUSEPORT *PPDMIMOUSEPORT;
177/**
178 * Mouse port interface.
179 * Pair with PDMIMOUSECONNECTOR.
180 */
181typedef struct PDMIMOUSEPORT
182{
183 /**
184 * Puts a mouse event.
185 * This is called by the source of mouse events. The event will be passed up until the
186 * topmost driver, which then calls the registered event handler.
187 *
188 * @returns VBox status code.
189 * @param pInterface Pointer to this interface structure.
190 * @param i32DeltaX The X delta.
191 * @param i32DeltaY The Y delta.
192 * @param i32DeltaZ The Z delta.
193 * @param fButtonStates The button states, see the PDMIMOUSEPORT_BUTTON_* \#defines.
194 * @thread The emulation thread.
195 */
196 DECLR3CALLBACKMEMBER(int, pfnPutEvent,(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, uint32_t fButtonStates));
197} PDMIMOUSEPORT;
198
199/** Mouse button defines for PDMIMOUSEPORT::pfnPutEvent.
200 * @{ */
201#define PDMIMOUSEPORT_BUTTON_LEFT RT_BIT(0)
202#define PDMIMOUSEPORT_BUTTON_RIGHT RT_BIT(1)
203#define PDMIMOUSEPORT_BUTTON_MIDDLE RT_BIT(2)
204/** @} */
205
206
207/**
208 * Mouse connector interface.
209 * Pair with PDMIMOUSEPORT.
210 */
211typedef PDMIDUMMY PDMIMOUSECONNECTOR;
212 /** Pointer to a mouse connector interface. */
213typedef PDMIMOUSECONNECTOR *PPDMIMOUSECONNECTOR;
214
215
216/** Pointer to a keyboard port interface. */
217typedef struct PDMIKEYBOARDPORT *PPDMIKEYBOARDPORT;
218/**
219 * Keyboard port interface.
220 * Pair with PDMIKEYBOARDCONNECTOR.
221 */
222typedef struct PDMIKEYBOARDPORT
223{
224 /**
225 * Puts a keyboard event.
226 * This is called by the source of keyboard events. The event will be passed up until the
227 * topmost driver, which then calls the registered event handler.
228 *
229 * @returns VBox status code.
230 * @param pInterface Pointer to this interface structure.
231 * @param u8KeyCode The keycode to queue.
232 * @thread The emulation thread.
233 */
234 DECLR3CALLBACKMEMBER(int, pfnPutEvent,(PPDMIKEYBOARDPORT pInterface, uint8_t u8KeyCode));
235} PDMIKEYBOARDPORT;
236
237/**
238 * Keyboard LEDs.
239 */
240typedef enum PDMKEYBLEDS
241{
242 /** No leds. */
243 PDMKEYBLEDS_NONE = 0x0000,
244 /** Num Lock */
245 PDMKEYBLEDS_NUMLOCK = 0x0001,
246 /** Caps Lock */
247 PDMKEYBLEDS_CAPSLOCK = 0x0002,
248 /** Scroll Lock */
249 PDMKEYBLEDS_SCROLLLOCK = 0x0004
250} PDMKEYBLEDS;
251
252/** Pointer to keyboard connector interface. */
253typedef struct PDMIKEYBOARDCONNECTOR *PPDMIKEYBOARDCONNECTOR;
254
255
256/**
257 * Keyboard connector interface.
258 * Pair with PDMIKEYBOARDPORT
259 */
260typedef struct PDMIKEYBOARDCONNECTOR
261{
262 /**
263 * Notifies the the downstream driver about an LED change initiated by the guest.
264 *
265 * @param pInterface Pointer to the this interface.
266 * @param enmLeds The new led mask.
267 */
268 DECLR3CALLBACKMEMBER(void, pfnLedStatusChange,(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds));
269
270} PDMIKEYBOARDCONNECTOR;
271
272
273
274/** Pointer to a display port interface. */
275typedef struct PDMIDISPLAYPORT *PPDMIDISPLAYPORT;
276/**
277 * Display port interface.
278 * Pair with PDMIDISPLAYCONNECTOR.
279 */
280typedef struct PDMIDISPLAYPORT
281{
282 /**
283 * Update the display with any changed regions.
284 *
285 * Flushes any display changes to the memory pointed to by the
286 * PDMIDISPLAYCONNECTOR interface and calles PDMIDISPLAYCONNECTOR::pfnUpdateRect()
287 * while doing so.
288 *
289 * @returns VBox status code.
290 * @param pInterface Pointer to this interface.
291 * @thread The emulation thread.
292 */
293 DECLR3CALLBACKMEMBER(int, pfnUpdateDisplay,(PPDMIDISPLAYPORT pInterface));
294
295 /**
296 * Update the entire display.
297 *
298 * Flushes the entire display content to the memory pointed to by the
299 * PDMIDISPLAYCONNECTOR interface and calles PDMIDISPLAYCONNECTOR::pfnUpdateRect().
300 *
301 * @returns VBox status code.
302 * @param pInterface Pointer to this interface.
303 * @thread The emulation thread.
304 */
305 DECLR3CALLBACKMEMBER(int, pfnUpdateDisplayAll,(PPDMIDISPLAYPORT pInterface));
306
307 /**
308 * Return the current guest color depth in bits per pixel (bpp).
309 *
310 * As the graphics card is able to provide display updates with the bpp
311 * requested by the host, this method can be used to query the actual
312 * guest color depth.
313 *
314 * @returns VBox status code.
315 * @param pInterface Pointer to this interface.
316 * @param pcBits Where to store the current guest color depth.
317 * @thread Any thread.
318 */
319 DECLR3CALLBACKMEMBER(int, pfnQueryColorDepth,(PPDMIDISPLAYPORT pInterface, uint32_t *pcBits));
320
321 /**
322 * Sets the refresh rate and restart the timer.
323 * The rate is defined as the minimum interval between the return of
324 * one PDMIDISPLAYPORT::pfnRefresh() call to the next one.
325 *
326 * The interval timer will be restarted by this call. So at VM startup
327 * this function must be called to start the refresh cycle. The refresh
328 * rate is not saved, but have to be when resuming a loaded VM state.
329 *
330 * @returns VBox status code.
331 * @param pInterface Pointer to this interface.
332 * @param cMilliesInterval Number of millies between two refreshes.
333 * @thread Any thread.
334 */
335 DECLR3CALLBACKMEMBER(int, pfnSetRefreshRate,(PPDMIDISPLAYPORT pInterface, uint32_t cMilliesInterval));
336
337 /**
338 * Create a 32-bbp snapshot of the display.
339 *
340 * This will create a 32-bbp bitmap with dword aligned scanline length. Because
341 * of a wish for no locks in the graphics device, this must be called from the
342 * emulation thread.
343 *
344 * @param pInterface Pointer to this interface.
345 * @param pvData Pointer the buffer to copy the bits to.
346 * @param cbData Size of the buffer.
347 * @param pcx Where to store the width of the bitmap. (optional)
348 * @param pcy Where to store the height of the bitmap. (optional)
349 * @param pcbData Where to store the actual size of the bitmap. (optional)
350 * @thread The emulation thread.
351 */
352 DECLR3CALLBACKMEMBER(int, pfnSnapshot,(PPDMIDISPLAYPORT pInterface, void *pvData, size_t cbData, uint32_t *pcx, uint32_t *pcy, size_t *pcbData));
353
354 /**
355 * Copy bitmap to the display.
356 *
357 * This will convert and copy a 32-bbp bitmap (with dword aligned scanline length) to
358 * the memory pointed to by the PDMIDISPLAYCONNECTOR interface.
359 *
360 * @param pInterface Pointer to this interface.
361 * @param pvData Pointer to the bitmap bits.
362 * @param x The upper left corner x coordinate of the destination rectangle.
363 * @param y The upper left corner y coordinate of the destination rectangle.
364 * @param cx The width of the source and destination rectangles.
365 * @param cy The height of the source and destination rectangles.
366 * @thread The emulation thread.
367 * @remark This is just a convenience for using the bitmap conversions of the
368 * graphics device.
369 */
370 DECLR3CALLBACKMEMBER(int, pfnDisplayBlt,(PPDMIDISPLAYPORT pInterface, const void *pvData, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy));
371
372 /**
373 * Render a rectangle from guest VRAM to Framebuffer.
374 *
375 * @param pInterface Pointer to this interface.
376 * @param x The upper left corner x coordinate of the rectangle to be updated.
377 * @param y The upper left corner y coordinate of the rectangle to be updated.
378 * @param cx The width of the rectangle to be updated.
379 * @param cy The height of the rectangle to be updated.
380 * @thread The emulation thread.
381 */
382 DECLR3CALLBACKMEMBER(void, pfnUpdateDisplayRect,(PPDMIDISPLAYPORT pInterface, int32_t x, int32_t y, uint32_t cx, uint32_t cy));
383
384 /**
385 * Inform the VGA device whether the Display is directly using the guest VRAM and there is no need
386 * to render the VRAM to the framebuffer memory.
387 *
388 * @param pInterface Pointer to this interface.
389 * @param fRender Whether the VRAM content must be rendered to the framebuffer.
390 * @thread The emulation thread.
391 */
392 DECLR3CALLBACKMEMBER(void, pfnSetRenderVRAM,(PPDMIDISPLAYPORT pInterface, bool fRender));
393
394} PDMIDISPLAYPORT;
395
396
397/** Pointer to a display connector interface. */
398typedef struct PDMIDISPLAYCONNECTOR *PPDMIDISPLAYCONNECTOR;
399/**
400 * Display connector interface.
401 * Pair with PDMIDISPLAYPORT.
402 */
403typedef struct PDMIDISPLAYCONNECTOR
404{
405 /**
406 * Resize the display.
407 * This is called when the resolution changes. This usually happens on
408 * request from the guest os, but may also happen as the result of a reset.
409 * If the callback returns VINF_VGA_RESIZE_IN_PROGRESS, the caller (VGA device)
410 * must not access the connector and return.
411 *
412 * @returns VINF_SUCCESS if the framebuffer resize was completed,
413 * VINF_VGA_RESIZE_IN_PROGRESS if resize takes time and not yet finished.
414 * @param pInterface Pointer to this interface.
415 * @param cBits Color depth (bits per pixel) of the new video mode.
416 * @param pvVRAM Address of the guest VRAM.
417 * @param cbLine Size in bytes of a single scan line.
418 * @param cx New display width.
419 * @param cy New display height.
420 * @thread The emulation thread.
421 */
422 DECLR3CALLBACKMEMBER(int, pfnResize,(PPDMIDISPLAYCONNECTOR pInterface, uint32_t cBits, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy));
423
424 /**
425 * Update a rectangle of the display.
426 * PDMIDISPLAYPORT::pfnUpdateDisplay is the caller.
427 *
428 * @param pInterface Pointer to this interface.
429 * @param x The upper left corner x coordinate of the rectangle.
430 * @param y The upper left corner y coordinate of the rectangle.
431 * @param cx The width of the rectangle.
432 * @param cy The height of the rectangle.
433 * @thread The emulation thread.
434 */
435 DECLR3CALLBACKMEMBER(void, pfnUpdateRect,(PPDMIDISPLAYCONNECTOR pInterface, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy));
436
437 /**
438 * Refresh the display.
439 *
440 * The interval between these calls is set by
441 * PDMIDISPLAYPORT::pfnSetRefreshRate(). The driver should call
442 * PDMIDISPLAYPORT::pfnUpdateDisplay() if it wishes to refresh the
443 * display. PDMIDISPLAYPORT::pfnUpdateDisplay calls pfnUpdateRect with
444 * the changed rectangles.
445 *
446 * @param pInterface Pointer to this interface.
447 * @thread The emulation thread.
448 */
449 DECLR3CALLBACKMEMBER(void, pfnRefresh,(PPDMIDISPLAYCONNECTOR pInterface));
450
451 /**
452 * Reset the display.
453 *
454 * Notification message when the graphics card has been reset.
455 *
456 * @param pInterface Pointer to this interface.
457 * @thread The emulation thread.
458 */
459 DECLR3CALLBACKMEMBER(void, pfnReset,(PPDMIDISPLAYCONNECTOR pInterface));
460
461 /**
462 * LFB video mode enter/exit.
463 *
464 * Notification message when LinearFrameBuffer video mode is enabled/disabled.
465 *
466 * @param pInterface Pointer to this interface.
467 * @param fEnabled false - LFB mode was disabled,
468 * true - an LFB mode was disabled
469 * @thread The emulation thread.
470 */
471 DECLR3CALLBACKMEMBER(void, pfnLFBModeChange, (PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled));
472
473 /**
474 * Process the guest graphics adapter information.
475 *
476 * Direct notification from guest to the display connector.
477 *
478 * @param pInterface Pointer to this interface.
479 * @param pvVRAM Address of the guest VRAM.
480 * @param u32VRAMSize Size of the guest VRAM.
481 * @thread The emulation thread.
482 */
483 DECLR3CALLBACKMEMBER(void, pfnProcessAdapterData, (PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize));
484
485 /**
486 * Process the guest display information.
487 *
488 * Direct notification from guest to the display connector.
489 *
490 * @param pInterface Pointer to this interface.
491 * @param pvVRAM Address of the guest VRAM.
492 * @param uScreenId The index of the guest display to be processed.
493 * @thread The emulation thread.
494 */
495 DECLR3CALLBACKMEMBER(void, pfnProcessDisplayData, (PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId));
496
497
498 /** Read-only attributes.
499 * For preformance reasons some readonly attributes are kept in the interface.
500 * We trust the interface users to respect the readonlyness of these.
501 * @{
502 */
503 /** Pointer to the display data buffer. */
504 uint8_t *pu8Data;
505 /** Size of a scanline in the data buffer. */
506 uint32_t cbScanline;
507 /** The color depth (in bits) the graphics card is supposed to provide. */
508 uint32_t cBits;
509 /** The display width. */
510 uint32_t cx;
511 /** The display height. */
512 uint32_t cy;
513 /** @} */
514} PDMIDISPLAYCONNECTOR;
515
516
517
518/**
519 * Block drive type.
520 */
521typedef enum PDMBLOCKTYPE
522{
523 /** Error (for the query function). */
524 PDMBLOCKTYPE_ERROR = 1,
525 /** 360KB 5 1/4" floppy drive. */
526 PDMBLOCKTYPE_FLOPPY_360,
527 /** 720KB 3 1/2" floppy drive. */
528 PDMBLOCKTYPE_FLOPPY_720,
529 /** 1.2MB 5 1/4" floppy drive. */
530 PDMBLOCKTYPE_FLOPPY_1_20,
531 /** 1.44MB 3 1/2" floppy drive. */
532 PDMBLOCKTYPE_FLOPPY_1_44,
533 /** 2.88MB 3 1/2" floppy drive. */
534 PDMBLOCKTYPE_FLOPPY_2_88,
535 /** CDROM drive. */
536 PDMBLOCKTYPE_CDROM,
537 /** DVD drive. */
538 PDMBLOCKTYPE_DVD,
539 /** Hard disk drive. */
540 PDMBLOCKTYPE_HARD_DISK
541} PDMBLOCKTYPE;
542
543
544/**
545 * Block raw command data transfer direction.
546 */
547typedef enum PDMBLOCKTXDIR
548{
549 PDMBLOCKTXDIR_NONE = 0,
550 PDMBLOCKTXDIR_FROM_DEVICE,
551 PDMBLOCKTXDIR_TO_DEVICE
552} PDMBLOCKTXDIR;
553
554/**
555 * Block notify interface.
556 * Pair with PDMIBLOCK.
557 */
558typedef PDMIDUMMY PDMIBLOCKPORT;
559/** Pointer to a block notify interface (dummy). */
560typedef PDMIBLOCKPORT *PPDMIBLOCKPORT;
561
562/** Pointer to a block interface. */
563typedef struct PDMIBLOCK *PPDMIBLOCK;
564/**
565 * Block interface.
566 * Pair with PDMIBLOCKPORT.
567 */
568typedef struct PDMIBLOCK
569{
570 /**
571 * Read bits.
572 *
573 * @returns VBox status code.
574 * @param pInterface Pointer to the interface structure containing the called function pointer.
575 * @param off Offset to start reading from.
576 * @param pvBuf Where to store the read bits.
577 * @param cbRead Number of bytes to read.
578 * @thread Any thread.
579 */
580 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIBLOCK pInterface, uint64_t off, void *pvBuf, size_t cbRead));
581
582 /**
583 * Write bits.
584 *
585 * @returns VBox status code.
586 * @param pInterface Pointer to the interface structure containing the called function pointer.
587 * @param off Offset to start writing at.
588 * @param pvBuf Where to store the write bits.
589 * @param cbWrite Number of bytes to write.
590 * @thread Any thread.
591 */
592 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIBLOCK pInterface, uint64_t off, const void *pvBuf, size_t cbWrite));
593
594 /**
595 * Make sure that the bits written are actually on the storage medium.
596 *
597 * @returns VBox status code.
598 * @param pInterface Pointer to the interface structure containing the called function pointer.
599 * @thread Any thread.
600 */
601 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIBLOCK pInterface));
602
603 /**
604 * Send a raw command to the underlying device (CDROM).
605 * This method is optional (i.e. the function pointer may be NULL).
606 *
607 * @returns VBox status code.
608 * @param pInterface Pointer to the interface structure containing the called function pointer.
609 * @param pbCmd Offset to start reading from.
610 * @param enmTxDir Direction of transfer.
611 * @param pvBuf Pointer tp the transfer buffer.
612 * @param cbBuf Size of the transfer buffer.
613 * @param pbSenseKey Status of the command (when return value is VERR_DEV_IO_ERROR).
614 * @param cTimeoutMillies Command timeout in milliseconds.
615 * @thread Any thread.
616 */
617 DECLR3CALLBACKMEMBER(int, pfnSendCmd,(PPDMIBLOCK pInterface, const uint8_t *pbCmd, PDMBLOCKTXDIR enmTxDir, void *pvBuf, size_t *pcbBuf, uint8_t *pbSenseKey, uint32_t cTimeoutMillies));
618
619 /**
620 * Check if the media is readonly or not.
621 *
622 * @returns true if readonly.
623 * @returns false if read/write.
624 * @param pInterface Pointer to the interface structure containing the called function pointer.
625 * @thread Any thread.
626 */
627 DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIBLOCK pInterface));
628
629 /**
630 * Gets the media size in bytes.
631 *
632 * @returns Media size in bytes.
633 * @param pInterface Pointer to the interface structure containing the called function pointer.
634 * @thread Any thread.
635 */
636 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIBLOCK pInterface));
637
638 /**
639 * Gets the block drive type.
640 *
641 * @returns block drive type.
642 * @param pInterface Pointer to the interface structure containing the called function pointer.
643 * @thread Any thread.
644 */
645 DECLR3CALLBACKMEMBER(PDMBLOCKTYPE, pfnGetType,(PPDMIBLOCK pInterface));
646
647 /**
648 * Gets the UUID of the block drive.
649 * Don't return the media UUID if it's removable.
650 *
651 * @returns VBox status code.
652 * @param pInterface Pointer to the interface structure containing the called function pointer.
653 * @param pUuid Where to store the UUID on success.
654 * @thread Any thread.
655 */
656 DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIBLOCK pInterface, PRTUUID pUuid));
657} PDMIBLOCK;
658
659
660/** Pointer to a mount interface. */
661typedef struct PDMIMOUNTNOTIFY *PPDMIMOUNTNOTIFY;
662/**
663 * Block interface.
664 * Pair with PDMIMOUNT.
665 */
666typedef struct PDMIMOUNTNOTIFY
667{
668 /**
669 * Called when a media is mounted.
670 *
671 * @param pInterface Pointer to the interface structure containing the called function pointer.
672 * @thread The emulation thread.
673 */
674 DECLR3CALLBACKMEMBER(void, pfnMountNotify,(PPDMIMOUNTNOTIFY pInterface));
675
676 /**
677 * Called when a media is unmounted
678 * @param pInterface Pointer to the interface structure containing the called function pointer.
679 * @thread The emulation thread.
680 */
681 DECLR3CALLBACKMEMBER(void, pfnUnmountNotify,(PPDMIMOUNTNOTIFY pInterface));
682} PDMIMOUNTNOTIFY;
683
684
685/* Pointer to mount interface. */
686typedef struct PDMIMOUNT *PPDMIMOUNT;
687/**
688 * Mount interface.
689 * Pair with PDMIMOUNTNOTIFY.
690 */
691typedef struct PDMIMOUNT
692{
693 /**
694 * Mount a media.
695 *
696 * This will not unmount any currently mounted media!
697 *
698 * @returns VBox status code.
699 * @param pInterface Pointer to the interface structure containing the called function pointer.
700 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have
701 * constructed a configuration which can be attached to the bottom driver.
702 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL.
703 * @thread The emulation thread.
704 */
705 DECLR3CALLBACKMEMBER(int, pfnMount,(PPDMIMOUNT pInterface, const char *pszFilename, const char *pszCoreDriver));
706
707 /**
708 * Unmount the media.
709 *
710 * The driver will validate and pass it on. On the rebounce it will decide whether or not to detach it self.
711 *
712 * @returns VBox status code.
713 * @param pInterface Pointer to the interface structure containing the called function pointer.
714 * @thread The emulation thread.
715 * @param fForce Force the unmount, even for locked media.
716 * @thread The emulation thread.
717 */
718 DECLR3CALLBACKMEMBER(int, pfnUnmount,(PPDMIMOUNT pInterface, bool fForce));
719
720 /**
721 * Checks if a media is mounted.
722 *
723 * @returns true if mounted.
724 * @returns false if not mounted.
725 * @param pInterface Pointer to the interface structure containing the called function pointer.
726 * @thread Any thread.
727 */
728 DECLR3CALLBACKMEMBER(bool, pfnIsMounted,(PPDMIMOUNT pInterface));
729
730 /**
731 * Locks the media, preventing any unmounting of it.
732 *
733 * @returns VBox status code.
734 * @param pInterface Pointer to the interface structure containing the called function pointer.
735 * @thread The emulation thread.
736 */
737 DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMIMOUNT pInterface));
738
739 /**
740 * Unlocks the media, canceling previous calls to pfnLock().
741 *
742 * @returns VBox status code.
743 * @param pInterface Pointer to the interface structure containing the called function pointer.
744 * @thread The emulation thread.
745 */
746 DECLR3CALLBACKMEMBER(int, pfnUnlock,(PPDMIMOUNT pInterface));
747
748 /**
749 * Checks if a media is locked.
750 *
751 * @returns true if locked.
752 * @returns false if not locked.
753 * @param pInterface Pointer to the interface structure containing the called function pointer.
754 * @thread Any thread.
755 */
756 DECLR3CALLBACKMEMBER(bool, pfnIsLocked,(PPDMIMOUNT pInterface));
757} PDMIBLOCKMOUNT;
758
759/**
760 * BIOS translation mode.
761 */
762typedef enum PDMBIOSTRANSLATION
763{
764 /** No translation. */
765 PDMBIOSTRANSLATION_NONE = 1,
766 /** LBA translation. */
767 PDMBIOSTRANSLATION_LBA,
768 /** Automatic select mode. */
769 PDMBIOSTRANSLATION_AUTO
770} PDMBIOSTRANSLATION;
771
772/** Pointer to BIOS translation mode. */
773typedef PDMBIOSTRANSLATION *PPDMBIOSTRANSLATION;
774
775/** Pointer to a media interface. */
776typedef struct PDMIMEDIA *PPDMIMEDIA;
777/**
778 * Media interface.
779 * Makes up the fundation for PDMIBLOCK and PDMIBLOCKBIOS.
780 */
781typedef struct PDMIMEDIA
782{
783 /**
784 * Read bits.
785 *
786 * @returns VBox status code.
787 * @param pInterface Pointer to the interface structure containing the called function pointer.
788 * @param off Offset to start reading from.
789 * @param pvBuf Where to store the read bits.
790 * @param cbRead Number of bytes to read.
791 * @thread Any thread.
792 */
793 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead));
794
795 /**
796 * Write bits.
797 *
798 * @returns VBox status code.
799 * @param pInterface Pointer to the interface structure containing the called function pointer.
800 * @param off Offset to start writing at.
801 * @param pvBuf Where to store the write bits.
802 * @param cbWrite Number of bytes to write.
803 * @thread Any thread.
804 */
805 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite));
806
807 /**
808 * Make sure that the bits written are actually on the storage medium.
809 *
810 * @returns VBox status code.
811 * @param pInterface Pointer to the interface structure containing the called function pointer.
812 * @thread Any thread.
813 */
814 DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIMEDIA pInterface));
815
816 /**
817 * Get the media size in bytes.
818 *
819 * @returns Media size in bytes.
820 * @param pInterface Pointer to the interface structure containing the called function pointer.
821 * @thread Any thread.
822 */
823 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIMEDIA pInterface));
824
825 /**
826 * Check if the media is readonly or not.
827 *
828 * @returns true if readonly.
829 * @returns false if read/write.
830 * @param pInterface Pointer to the interface structure containing the called function pointer.
831 * @thread Any thread.
832 */
833 DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIMEDIA pInterface));
834
835 /**
836 * Get stored media geometry - BIOS property.
837 * This is an optional feature of a media.
838 *
839 * @returns VBox status code.
840 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
841 * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnBiosSetGeometry() yet.
842 * @param pInterface Pointer to the interface structure containing the called function pointer.
843 * @param pcCylinders Number of cylinders.
844 * @param pcHeads Number of heads.
845 * @param pcSectors Number of sectors. This number is 1-based.
846 * @remark This have no influence on the read/write operations.
847 * @thread Any thread.
848 */
849 DECLR3CALLBACKMEMBER(int, pfnBiosGetGeometry,(PPDMIMEDIA pInterface, uint32_t *pcCylinders, uint32_t *pcHeads, uint32_t *pcSectors));
850
851 /**
852 * Store the media geometry - BIOS property.
853 * This is an optional feature of a media.
854 *
855 * @returns VBox status code.
856 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
857 * @param pInterface Pointer to the interface structure containing the called function pointer.
858 * @param cCylinders Number of cylinders.
859 * @param cHeads Number of heads.
860 * @param cSectors Number of sectors. This number is 1-based.
861 * @remark This have no influence on the read/write operations.
862 * @thread The emulation thread.
863 */
864 DECLR3CALLBACKMEMBER(int, pfnBiosSetGeometry,(PPDMIMEDIA pInterface, uint32_t cCylinders, uint32_t cHeads, uint32_t cSectors));
865
866 /**
867 * Get stored geometry translation mode - BIOS property.
868 * This is an optional feature of a media.
869 *
870 * @returns VBox status code.
871 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry translation mode.
872 * @returns VERR_PDM_TRANSLATION_NOT_SET if the translation hasn't been set using pfnBiosSetTranslation() yet.
873 * @param pInterface Pointer to the interface structure containing the called function pointer.
874 * @param penmTranslation Where to store the translation type.
875 * @remark This have no influence on the read/write operations.
876 * @thread Any thread.
877 */
878 DECLR3CALLBACKMEMBER(int, pfnBiosGetTranslation,(PPDMIMEDIA pInterface, PPDMBIOSTRANSLATION penmTranslation));
879
880 /**
881 * Store media geometry - BIOS property.
882 * This is an optional feature of a media.
883 *
884 * @returns VBox status code.
885 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
886 * @param pInterface Pointer to the interface structure containing the called function pointer.
887 * @param enmTranslation The translation type.
888 * @remark This have no influence on the read/write operations.
889 * @thread The emulation thread.
890 */
891 DECLR3CALLBACKMEMBER(int, pfnBiosSetTranslation,(PPDMIMEDIA pInterface, PDMBIOSTRANSLATION enmTranslation));
892
893 /**
894 * Gets the UUID of the media drive.
895 *
896 * @returns VBox status code.
897 * @param pInterface Pointer to the interface structure containing the called function pointer.
898 * @param pUuid Where to store the UUID on success.
899 * @thread Any thread.
900 */
901 DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIMEDIA pInterface, PRTUUID pUuid));
902
903} PDMIMEDIA;
904
905
906/** Pointer to a block BIOS interface. */
907typedef struct PDMIBLOCKBIOS *PPDMIBLOCKBIOS;
908/**
909 * Media BIOS interface.
910 * The interface the getting and setting properties which the BIOS/CMOS care about.
911 */
912typedef struct PDMIBLOCKBIOS
913{
914 /**
915 * Get stored media geometry - BIOS property.
916 * This is an optional feature of a media.
917 *
918 * @returns VBox status code.
919 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
920 * @param pInterface Pointer to the interface structure containing the called function pointer.
921 * @param pcCylinders Number of cylinders.
922 * @param pcHeads Number of heads.
923 * @param pcSectors Number of sectors. This number is 1-based.
924 * @remark This have no influence on the read/write operations.
925 * @thread Any thread.
926 */
927 DECLR3CALLBACKMEMBER(int, pfnGetGeometry,(PPDMIBLOCKBIOS pInterface, uint32_t *pcCylinders, uint32_t *pcHeads, uint32_t *pcSectors));
928
929 /**
930 * Store the media geometry - BIOS property.
931 * This is an optional feature of a media.
932 *
933 * @returns VBox status code.
934 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
935 * @param pInterface Pointer to the interface structure containing the called function pointer.
936 * @param cCylinders Number of cylinders.
937 * @param cHeads Number of heads.
938 * @param cSectors Number of sectors. This number is 1-based.
939 * @remark This have no influence on the read/write operations.
940 * @thread The emulation thread.
941 */
942 DECLR3CALLBACKMEMBER(int, pfnSetGeometry,(PPDMIBLOCKBIOS pInterface, uint32_t cCylinders, uint32_t cHeads, uint32_t cSectors));
943
944 /**
945 * Get stored geometry translation mode - BIOS property.
946 * This is an optional feature of a media.
947 *
948 * @returns VBox status code.
949 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry translation mode.
950 * @param pInterface Pointer to the interface structure containing the called function pointer.
951 * @param penmTranslation Where to store the translation type.
952 * @remark This have no influence on the read/write operations.
953 * @thread Any thread.
954 */
955 DECLR3CALLBACKMEMBER(int, pfnGetTranslation,(PPDMIBLOCKBIOS pInterface, PPDMBIOSTRANSLATION penmTranslation));
956
957 /**
958 * Store media geometry - BIOS property.
959 * This is an optional feature of a media.
960 *
961 * @returns VBox status code.
962 * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
963 * @param pInterface Pointer to the interface structure containing the called function pointer.
964 * @param enmTranslation The translation type.
965 * @remark This have no influence on the read/write operations.
966 * @thread The emulation thread.
967 */
968 DECLR3CALLBACKMEMBER(int, pfnSetTranslation,(PPDMIBLOCKBIOS pInterface, PDMBIOSTRANSLATION enmTranslation));
969
970 /**
971 * Checks if the device should be visible to the BIOS or not.
972 *
973 * @returns true if the device is visible to the BIOS.
974 * @returns false if the device is not visible to the BIOS.
975 * @param pInterface Pointer to the interface structure containing the called function pointer.
976 * @thread Any thread.
977 */
978 DECLR3CALLBACKMEMBER(bool, pfnIsVisible,(PPDMIBLOCKBIOS pInterface));
979
980 /**
981 * Gets the block drive type.
982 *
983 * @returns block drive type.
984 * @param pInterface Pointer to the interface structure containing the called function pointer.
985 * @thread Any thread.
986 */
987 DECLR3CALLBACKMEMBER(PDMBLOCKTYPE, pfnGetType,(PPDMIBLOCKBIOS pInterface));
988
989} PDMIBLOCKBIOS;
990
991
992/** Pointer to a static block core driver interface. */
993typedef struct PDMIMEDIASTATIC *PPDMIMEDIASTATIC;
994/**
995 * Static block core driver interface.
996 */
997typedef struct PDMIMEDIASTATIC
998{
999 /**
1000 * Check if the specified file is a format which the core driver can handle.
1001 *
1002 * @returns true / false accordingly.
1003 * @param pInterface Pointer to the interface structure containing the called function pointer.
1004 * @param pszFilename Name of the file to probe.
1005 */
1006 DECLR3CALLBACKMEMBER(bool, pfnCanHandle,(PPDMIMEDIASTATIC pInterface, const char *pszFilename));
1007} PDMIMEDIASTATIC;
1008
1009
1010/** Pointer to an iSCSI Request PDU buffer. */
1011typedef struct ISCSIREQ *PISCSIREQ;
1012/**
1013 * iSCSI Request PDU buffer (gather).
1014 */
1015typedef struct ISCSIREQ
1016{
1017 /** Length of PDU segment in bytes. */
1018 size_t cbSeg;
1019 /** Pointer to PDU segment. */
1020 const void *pcvSeg;
1021} ISCSIREQ;
1022
1023/** Pointer to an iSCSI Response PDU buffer. */
1024typedef struct ISCSIRES *PISCSIRES;
1025/**
1026 * iSCSI Response PDU buffer (scatter).
1027 */
1028typedef struct ISCSIRES
1029{
1030 /** Length of PDU segment. */
1031 size_t cbSeg;
1032 /** Pointer to PDU segment. */
1033 void *pvSeg;
1034} ISCSIRES;
1035
1036/** Pointer to an iSCSI transport driver interface. */
1037typedef struct PDMIISCSITRANSPORT *PPDMIISCSITRANSPORT;
1038/**
1039 * iSCSI transport driver interface.
1040 */
1041typedef struct PDMIISCSITRANSPORT
1042{
1043 /**
1044 * Read bytes from an iSCSI transport stream. If the connection fails, it is automatically
1045 * reopened on the next call after the error is signalled. Error recovery in this case is
1046 * the duty of the caller.
1047 *
1048 * @returns VBox status code.
1049 * @param pTransport Pointer to the interface structure containing the called function pointer.
1050 * @param pvBuf Where to store the read bits.
1051 * @param cbBuf Number of bytes to read.
1052 * @param pcbRead Actual number of bytes read.
1053 * @thread Any thread.
1054 * @todo Correct the docs.
1055 */
1056 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIISCSITRANSPORT pTransport, PISCSIRES prgResponse, unsigned int cnResponse));
1057
1058 /**
1059 * Write bytes to an iSCSI transport stream. Padding is performed when necessary. If the connection
1060 * fails, it is automatically reopened on the next call after the error is signalled. Error recovery
1061 * in this case is the duty of the caller.
1062 *
1063 * @returns VBox status code.
1064 * @param pTransport Pointer to the interface structure containing the called function pointer.
1065 * @param pvBuf Where the write bits are stored.
1066 * @param cbWrite Number of bytes to write.
1067 * @thread Any thread.
1068 * @todo Correct the docs.
1069 */
1070 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIISCSITRANSPORT pTransport, PISCSIREQ prgRequest, unsigned int cnRequest));
1071
1072 /**
1073 * Open the iSCSI transport stream.
1074 *
1075 * @returns VBox status code.
1076 * @param pTransport Pointer to the interface structure containing the called function pointer.
1077 * @param pszTargetAddress Pointer to string of the format address:port.
1078 * @thread Any thread.
1079 */
1080 DECLR3CALLBACKMEMBER(int, pfnOpen,(PPDMIISCSITRANSPORT pTransport, const char *pszTargetAddress));
1081
1082 /**
1083 * Close the iSCSI transport stream.
1084 *
1085 * @returns VBox status code.
1086 * @param pTransport Pointer to the interface structure containing the called function pointer.
1087 * @thread Any thread.
1088 */
1089 DECLR3CALLBACKMEMBER(int, pfnClose,(PPDMIISCSITRANSPORT pTransport));
1090} PDMIISCSITRANSPORT;
1091
1092
1093/** Pointer to a char port interface. */
1094typedef struct PDMICHARPORT *PPDMICHARPORT;
1095/**
1096 * Char port interface.
1097 * Pair with PDMICHAR.
1098 */
1099typedef struct PDMICHARPORT
1100{
1101 /**
1102 * Deliver data read to the device/driver.
1103 *
1104 * @returns VBox status code.
1105 * @param pInterface Pointer to the interface structure containing the called function pointer.
1106 * @param pvBuf Where the read bits are stored.
1107 * @param pcbRead Number of bytes available for reading/having been read.
1108 * @thread Any thread.
1109 */
1110 DECLR3CALLBACKMEMBER(int, pfnNotifyRead,(PPDMICHARPORT pInterface, const void *pvBuf, size_t *pcbRead));
1111} PDMICHARPORT;
1112
1113/** Pointer to a char interface. */
1114typedef struct PDMICHAR *PPDMICHAR;
1115/**
1116 * Char interface.
1117 * Pair with PDMICHARPORT.
1118 */
1119typedef struct PDMICHAR
1120{
1121 /**
1122 * Write bits.
1123 *
1124 * @returns VBox status code.
1125 * @param pInterface Pointer to the interface structure containing the called function pointer.
1126 * @param pvBuf Where to store the write bits.
1127 * @param cbWrite Number of bytes to write.
1128 * @thread Any thread.
1129 */
1130 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMICHAR pInterface, const void *pvBuf, size_t cbWrite));
1131
1132 /**
1133 * Set device parameters.
1134 *
1135 * @returns VBox status code.
1136 * @param pInterface Pointer to the interface structure containing the called function pointer.
1137 * @param Bps Speed of the serial connection. (bits per second)
1138 * @param chParity Parity method: 'E' - even, 'O' - odd, 'N' - none.
1139 * @param cDataBits Number of data bits.
1140 * @param cStopBits Number of stop bits.
1141 * @thread Any thread.
1142 */
1143 DECLR3CALLBACKMEMBER(int, pfnSetParameters,(PPDMICHAR pInterface, unsigned Bps, char chParity, unsigned cDataBits, unsigned cStopBits));
1144
1145} PDMICHAR;
1146
1147
1148/** Pointer to a stream interface. */
1149typedef struct PDMISTREAM *PPDMISTREAM;
1150/**
1151 * Stream interface.
1152 * Makes up the fundation for PDMICHAR.
1153 */
1154typedef struct PDMISTREAM
1155{
1156 /**
1157 * Read bits.
1158 *
1159 * @returns VBox status code.
1160 * @param pInterface Pointer to the interface structure containing the called function pointer.
1161 * @param pvBuf Where to store the read bits.
1162 * @param cbRead Number of bytes to read/bytes actually read.
1163 * @thread Any thread.
1164 */
1165 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMISTREAM pInterface, void *pvBuf, size_t *cbRead));
1166
1167 /**
1168 * Write bits.
1169 *
1170 * @returns VBox status code.
1171 * @param pInterface Pointer to the interface structure containing the called function pointer.
1172 * @param pvBuf Where to store the write bits.
1173 * @param cbWrite Number of bytes to write/bytes actually written.
1174 * @thread Any thread.
1175 */
1176 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMISTREAM pInterface, const void *pvBuf, size_t *cbWrite));
1177} PDMISTREAM;
1178
1179
1180/** Pointer to a host device port interface. */
1181typedef struct PDMIHOSTDEVICEPORT *PPDMIHOSTDEVICEPORT;
1182
1183/**
1184 * Char port interface.
1185 * Pair with PDMIHOSTDEVICECONNECTOR.
1186 */
1187typedef struct PDMIHOSTDEVICEPORT
1188{
1189 /**
1190 * Deliver data read to the device/driver.
1191 *
1192 * @returns VBox status code.
1193 * @param pInterface Pointer to the interface structure containing the called function pointer.
1194 * @param pvBuf Where the read bits are stored.
1195 * @param pcbRead Number of bytes available for reading/having been read.
1196 * @thread Any thread.
1197 */
1198 DECLR3CALLBACKMEMBER(int, pfnNotifyRead,(PPDMIHOSTDEVICEPORT pInterface, const void *pvBuf, size_t *pcbRead));
1199} PDMIHOSTDEVICEPORT;
1200
1201/** Pointer to a Host Device connector interface. */
1202typedef struct PDMIHOSTDEVICECONNECTOR *PPDMIHOSTDEVICECONNECTOR;
1203
1204/**
1205 * Host device connector interface
1206 * Pair with PDMIHOSTDEVICEPORT.
1207 */
1208typedef struct PDMIHOSTDEVICECONNECTOR
1209{
1210 /**
1211 * Write bits.
1212 *
1213 * @returns VBox status code.
1214 * @param pInterface Pointer to the interface structure containing the called function pointer.
1215 * @param pvBuf Where to store the write bits.
1216 * @param pcbWrite Number of bytes to write/bytes actually written.
1217 * @thread Any thread.
1218 */
1219 DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIHOSTDEVICECONNECTOR pInterface, const void *pvBuf, size_t *pcbWrite));
1220
1221 /**
1222 * Read bits.
1223 *
1224 * @returns VBox status code.
1225 * @param pInterface Pointer to the interface structure containing the called function pointer.
1226 * @param pvBuf Where to store the read bits.
1227 * @param pcbRead Number of bytes to read/bytes actually read.
1228 * @thread Any thread.
1229 */
1230 DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIHOSTDEVICECONNECTOR pInterface, void *pvBuf, size_t *pcbRead));
1231
1232 /**
1233 * Perform IO control on the host device.
1234 *
1235 * @returns VBox status code.
1236 * @param pInterface Pointer to the interface structure containing the called function pointer.
1237 * @param uCommand The number of the command to set or get data
1238 * @param pvData Where to store the command data.
1239 * @thread Any thread.
1240 */
1241 DECLR3CALLBACKMEMBER(int, pfnIOCtl,(PPDMIHOSTDEVICECONNECTOR pInterface, RTUINT uCommand, void *pvData));
1242} PDMIHOSTDEVICECONNECTOR;
1243
1244
1245/** ACPI power source identifier */
1246typedef enum PDMACPIPOWERSOURCE
1247{
1248 PDM_ACPI_POWER_SOURCE_UNKNOWN = 0,
1249 PDM_ACPI_POWER_SOURCE_OUTLET,
1250 PDM_ACPI_POWER_SOURCE_BATTERY
1251} PDMACPIPOWERSOURCE;
1252/** Pointer to ACPI battery state. */
1253typedef PDMACPIPOWERSOURCE *PPDMACPIPOWERSOURCE;
1254
1255/** ACPI battey capacity */
1256typedef enum PDMACPIBATCAPACITY
1257{
1258 PDM_ACPI_BAT_CAPACITY_MIN = 0,
1259 PDM_ACPI_BAT_CAPACITY_MAX = 100,
1260 PDM_ACPI_BAT_CAPACITY_UNKNOWN = 255
1261} PDMACPIBATCAPACITY;
1262/** Pointer to ACPI battery capacity. */
1263typedef PDMACPIBATCAPACITY *PPDMACPIBATCAPACITY;
1264
1265/** ACPI battery state. See ACPI 3.0 spec '_BST (Battery Status)' */
1266typedef enum PDMACPIBATSTATE
1267{
1268 PDM_ACPI_BAT_STATE_CHARGED = 0x00,
1269 PDM_ACPI_BAT_STATE_CHARGING = 0x01,
1270 PDM_ACPI_BAT_STATE_DISCHARGING = 0x02,
1271 PDM_ACPI_BAT_STATE_CRITICAL = 0x04
1272} PDMACPIBATSTATE;
1273/** Pointer to ACPI battery state. */
1274typedef PDMACPIBATSTATE *PPDMACPIBATSTATE;
1275
1276/** Pointer to an ACPI port interface. */
1277typedef struct PDMIACPIPORT *PPDMIACPIPORT;
1278/**
1279 * ACPI port interface.
1280 */
1281typedef struct PDMIACPIPORT
1282{
1283 /**
1284 * Send an ACPI power off event.
1285 *
1286 * @returns VBox status code
1287 * @param pInterface Pointer to the interface structure containing the called function pointer.
1288 */
1289 DECLR3CALLBACKMEMBER(int, pfnPowerButtonPress,(PPDMIACPIPORT pInterface));
1290} PDMIACPIPORT;
1291
1292/** Pointer to an ACPI connector interface. */
1293typedef struct PDMIACPICONNECTOR *PPDMIACPICONNECTOR;
1294/**
1295 * ACPI connector interface.
1296 */
1297typedef struct PDMIACPICONNECTOR
1298{
1299 /**
1300 * Get the current power source of the host system.
1301 *
1302 * @returns VBox status code
1303 * @param pInterface Pointer to the interface structure containing the called function pointer.
1304 * @param penmPowerSource Pointer to the power source result variable.
1305 */
1306 DECLR3CALLBACKMEMBER(int, pfnQueryPowerSource,(PPDMIACPICONNECTOR, PPDMACPIPOWERSOURCE penmPowerSource));
1307
1308 /**
1309 * Query the current battery status of the host system.
1310 *
1311 * @returns VBox status code?
1312 * @param pInterface Pointer to the interface structure containing the called function pointer.
1313 * @param pfPresent Is set to true if battery is present, false otherwise.
1314 * @param penmRemainingCapacity Pointer to the battery remaining capacity (0 - 100 or 255 for unknown).
1315 * @param penmBatteryState Pointer to the battery status.
1316 * @param pu32PresentRate Pointer to the present rate (0..1000 of the total capacity).
1317 */
1318 DECLR3CALLBACKMEMBER(int, pfnQueryBatteryStatus,(PPDMIACPICONNECTOR, bool *pfPresent, PPDMACPIBATCAPACITY penmRemainingCapacity,
1319 PPDMACPIBATSTATE penmBatteryState, uint32_t *pu32PresentRate));
1320} PDMIACPICONNECTOR;
1321
1322
1323/** Pointer to a VMMDevice port interface. */
1324typedef struct PDMIVMMDEVPORT *PPDMIVMMDEVPORT;
1325/**
1326 * VMMDevice port interface.
1327 */
1328typedef struct PDMIVMMDEVPORT
1329{
1330 /**
1331 * Return the current absolute mouse position in pixels
1332 *
1333 * @returns VBox status code
1334 * @param pAbsX Pointer of result value, can be NULL
1335 * @param pAbsY Pointer of result value, can be NULL
1336 */
1337 DECLR3CALLBACKMEMBER(int, pfnQueryAbsoluteMouse,(PPDMIVMMDEVPORT pInterface, uint32_t *pAbsX, uint32_t *pAbsY));
1338
1339 /**
1340 * Set the new absolute mouse position in pixels
1341 *
1342 * @returns VBox status code
1343 * @param absX New absolute X position
1344 * @param absY New absolute Y position
1345 */
1346 DECLR3CALLBACKMEMBER(int, pfnSetAbsoluteMouse,(PPDMIVMMDEVPORT pInterface, uint32_t absX, uint32_t absY));
1347
1348 /**
1349 * Return the current mouse capability flags
1350 *
1351 * @returns VBox status code
1352 * @param pCapabilities Pointer of result value
1353 */
1354 DECLR3CALLBACKMEMBER(int, pfnQueryMouseCapabilities,(PPDMIVMMDEVPORT pInterface, uint32_t *pCapabilities));
1355
1356 /**
1357 * Set the current mouse capability flag (host side)
1358 *
1359 * @returns VBox status code
1360 * @param capabilities Capability mask
1361 */
1362 DECLR3CALLBACKMEMBER(int, pfnSetMouseCapabilities,(PPDMIVMMDEVPORT pInterface, uint32_t capabilities));
1363
1364 /**
1365 * Issue a display resolution change request.
1366 *
1367 * Note that there can only one request in the queue and that in case the guest does
1368 * not process it, issuing another request will overwrite the previous.
1369 *
1370 * @returns VBox status code
1371 * @param cx Horizontal pixel resolution (0 = do not change).
1372 * @param cy Vertical pixel resolution (0 = do not change).
1373 * @param cBits Bits per pixel (0 = do not change).
1374 * @param display The display index.
1375 */
1376 DECLR3CALLBACKMEMBER(int, pfnRequestDisplayChange,(PPDMIVMMDEVPORT pInterface, uint32_t cx, uint32_t cy, uint32_t cBits, uint32_t display));
1377
1378 /**
1379 * Pass credentials to guest.
1380 *
1381 * Note that there can only be one set of credentials and the guest may or may not
1382 * query them and may do whatever it wants with them.
1383 *
1384 * @returns VBox status code
1385 * @param pszUsername User name, may be empty (UTF-8)
1386 * @param pszPassword Password, may be empty (UTF-8)
1387 * @param pszDomain Domain name, may be empty (UTF-8)
1388 * @param fFlags Bitflags
1389 */
1390 DECLR3CALLBACKMEMBER(int, pfnSetCredentials,(PPDMIVMMDEVPORT pInterface, const char *pszUsername,
1391 const char *pszPassword, const char *pszDomain,
1392 uint32_t fFlags));
1393
1394 /**
1395 * Notify the driver about a VBVA status change.
1396 *
1397 * @returns Nothing. Because it is informational callback.
1398 * @param fEnabled Current VBVA status.
1399 */
1400 DECLR3CALLBACKMEMBER(void, pfnVBVAChange, (PPDMIVMMDEVPORT pInterface, bool fEnabled));
1401
1402 /**
1403 * Issue a seamless mode change request.
1404 *
1405 * Note that there can only one request in the queue and that in case the guest does
1406 * not process it, issuing another request will overwrite the previous.
1407 *
1408 * @returns VBox status code
1409 * @param fEnabled Seamless mode enabled or not
1410 */
1411 DECLR3CALLBACKMEMBER(int, pfnRequestSeamlessChange,(PPDMIVMMDEVPORT pInterface, bool fEnabled));
1412
1413 /**
1414 * Issue a memory balloon change request.
1415 *
1416 * Note that there can only one request in the queue and that in case the guest does
1417 * not process it, issuing another request will overwrite the previous.
1418 *
1419 * @returns VBox status code
1420 * @param ulBalloonSize Balloon size in megabytes
1421 */
1422 DECLR3CALLBACKMEMBER(int, pfnSetMemoryBalloon,(PPDMIVMMDEVPORT pInterface, uint32_t ulBalloonSize));
1423
1424 /**
1425 * Issue a statistcs interval change request.
1426 *
1427 * Note that there can only one request in the queue and that in case the guest does
1428 * not process it, issuing another request will overwrite the previous.
1429 *
1430 * @returns VBox status code
1431 * @param ulStatInterval Statistics query interval in seconds (0=disable)
1432 */
1433 DECLR3CALLBACKMEMBER(int, pfnSetStatisticsInterval,(PPDMIVMMDEVPORT pInterface, uint32_t ulStatInterval));
1434
1435 /**
1436 * Notify the guest about a VRDP status change.
1437 *
1438 * @returns VBox status code
1439 * @param fVRDPEnabled Current VRDP status.
1440 * @param u32VRDPExperienceLevel Which visual effects to be disabled in the guest.
1441 */
1442 DECLR3CALLBACKMEMBER(int, pfnVRDPChange, (PPDMIVMMDEVPORT pInterface, bool fVRDPEnabled, uint32_t u32VRDPExperienceLevel));
1443
1444} PDMIVMMDEVPORT;
1445
1446/** Forward declaration of the video accelerator command memory. */
1447struct _VBVAMEMORY;
1448/** Forward declaration of the guest information structure. */
1449struct VBoxGuestInfo;
1450/** Forward declaration of the guest statistics structure */
1451struct VBoxGuestStatistics;
1452/** Pointer to video accelerator command memory. */
1453typedef struct _VBVAMEMORY *PVBVAMEMORY;
1454
1455/** Pointer to a VMMDev connector interface. */
1456typedef struct PDMIVMMDEVCONNECTOR *PPDMIVMMDEVCONNECTOR;
1457/**
1458 * VMMDev connector interface.
1459 * Pair with PDMIVMMDEVPORT.
1460 */
1461typedef struct PDMIVMMDEVCONNECTOR
1462{
1463 /**
1464 * Report guest OS version.
1465 * Called whenever the Additions issue a guest version report request.
1466 *
1467 * @param pInterface Pointer to this interface.
1468 * @param pGuestInfo Pointer to guest information structure
1469 * @thread The emulation thread.
1470 */
1471 DECLR3CALLBACKMEMBER(void, pfnUpdateGuestVersion,(PPDMIVMMDEVCONNECTOR pInterface, struct VBoxGuestInfo *pGuestInfo));
1472
1473 /**
1474 * Update the guest additions capabilities.
1475 * This is called when the guest additions capabilities change. The new capabilities
1476 * are given and the connector should update its internal state.
1477 *
1478 * @param pInterface Pointer to this interface.
1479 * @param newCapabilities New capabilities.
1480 * @thread The emulation thread.
1481 */
1482 DECLR3CALLBACKMEMBER(void, pfnUpdateGuestCapabilities,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities));
1483
1484 /**
1485 * Update the mouse capabilities.
1486 * This is called when the mouse capabilities change. The new capabilities
1487 * are given and the connector should update its internal state.
1488 *
1489 * @param pInterface Pointer to this interface.
1490 * @param newCapabilities New capabilities.
1491 * @thread The emulation thread.
1492 */
1493 DECLR3CALLBACKMEMBER(void, pfnUpdateMouseCapabilities,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities));
1494
1495 /**
1496 * Update the pointer shape.
1497 * This is called when the mouse pointer shape changes. The new shape
1498 * is passed as a caller allocated buffer that will be freed after returning
1499 *
1500 * @param pInterface Pointer to this interface.
1501 * @param fVisible Visibility indicator (if false, the other parameters are undefined).
1502 * @param fAlpha Flag whether alpha channel is being passed.
1503 * @param xHot Pointer hot spot x coordinate.
1504 * @param yHot Pointer hot spot y coordinate.
1505 * @param x Pointer new x coordinate on screen.
1506 * @param y Pointer new y coordinate on screen.
1507 * @param cx Pointer width in pixels.
1508 * @param cy Pointer height in pixels.
1509 * @param cbScanline Size of one scanline in bytes.
1510 * @param pvShape New shape buffer.
1511 * @thread The emulation thread.
1512 */
1513 DECLR3CALLBACKMEMBER(void, pfnUpdatePointerShape,(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
1514 uint32_t xHot, uint32_t yHot,
1515 uint32_t cx, uint32_t cy,
1516 void *pvShape));
1517
1518 /**
1519 * Enable or disable video acceleration on behalf of guest.
1520 *
1521 * @param pInterface Pointer to this interface.
1522 * @param fEnable Whether to enable acceleration.
1523 * @param pVbvaMemory Video accelerator memory.
1524
1525 * @return VBox rc. VINF_SUCCESS if VBVA was enabled.
1526 * @thread The emulation thread.
1527 */
1528 DECLR3CALLBACKMEMBER(int, pfnVideoAccelEnable,(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, PVBVAMEMORY pVbvaMemory));
1529
1530 /**
1531 * Force video queue processing.
1532 *
1533 * @param pInterface Pointer to this interface.
1534 * @thread The emulation thread.
1535 */
1536 DECLR3CALLBACKMEMBER(void, pfnVideoAccelFlush,(PPDMIVMMDEVCONNECTOR pInterface));
1537
1538 /**
1539 * Return whether the given video mode is supported/wanted by the host.
1540 *
1541 * @returns VBox status code
1542 * @param pInterface Pointer to this interface.
1543 * @param cy Video mode horizontal resolution in pixels.
1544 * @param cx Video mode vertical resolution in pixels.
1545 * @param cBits Video mode bits per pixel.
1546 * @param pfSupported Where to put the indicator for whether this mode is supported. (output)
1547 * @thread The emulation thread.
1548 */
1549 DECLR3CALLBACKMEMBER(int, pfnVideoModeSupported,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cx, uint32_t cy, uint32_t cBits, bool *pfSupported));
1550
1551 /**
1552 * Queries by how many pixels the height should be reduced when calculating video modes
1553 *
1554 * @returns VBox status code
1555 * @param pInterface Pointer to this interface.
1556 * @param pcyReduction Pointer to the result value.
1557 * @thread The emulation thread.
1558 */
1559 DECLR3CALLBACKMEMBER(int, pfnGetHeightReduction,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcyReduction));
1560
1561 /**
1562 * Informs about a credentials judgement result from the guest.
1563 *
1564 * @returns VBox status code
1565 * @param pInterface Pointer to this interface.
1566 * @param fFlags Judgement result flags.
1567 * @thread The emulation thread.
1568 */
1569 DECLR3CALLBACKMEMBER(int, pfnSetCredentialsJudgementResult,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fFlags));
1570
1571 /**
1572 * Set the visible region of the display
1573 *
1574 * @returns VBox status code.
1575 * @param pInterface Pointer to this interface.
1576 * @param cRect Number of rectangles in pRect
1577 * @param pRect Rectangle array
1578 * @thread The emulation thread.
1579 */
1580 DECLR3CALLBACKMEMBER(int, pfnSetVisibleRegion,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect));
1581
1582 /**
1583 * Query the visible region of the display
1584 *
1585 * @returns VBox status code.
1586 * @param pInterface Pointer to this interface.
1587 * @param pcRect Number of rectangles in pRect
1588 * @param pRect Rectangle array (set to NULL to query the number of rectangles)
1589 * @thread The emulation thread.
1590 */
1591 DECLR3CALLBACKMEMBER(int, pfnQueryVisibleRegion,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect));
1592
1593 /**
1594 * Request the statistics interval
1595 *
1596 * @returns VBox status code.
1597 * @param pInterface Pointer to this interface.
1598 * @param pulInterval Pointer to interval in seconds
1599 * @thread The emulation thread.
1600 */
1601 DECLR3CALLBACKMEMBER(int, pfnQueryStatisticsInterval,(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval));
1602
1603 /**
1604 * Report new guest statistics
1605 *
1606 * @returns VBox status code.
1607 * @param pInterface Pointer to this interface.
1608 * @param pGuestStats Guest statistics
1609 * @thread The emulation thread.
1610 */
1611 DECLR3CALLBACKMEMBER(int, pfnReportStatistics,(PPDMIVMMDEVCONNECTOR pInterface, struct VBoxGuestStatistics *pGuestStats));
1612
1613 /**
1614 * Inflate or deflate the memory balloon
1615 *
1616 * @returns VBox status code.
1617 * @param pInterface Pointer to this interface.
1618 * @param fInflate Inflate or deflate
1619 * @param cPages Number of physical pages (must be 256 as we allocate in 1 MB chunks)
1620 * @param aPhysPage Array of physical page addresses
1621 * @thread The emulation thread.
1622 */
1623 DECLR3CALLBACKMEMBER(int, pfnChangeMemoryBalloon, (PPDMIVMMDEVCONNECTOR pInterface, bool fInflate, uint32_t cPages, RTGCPHYS *aPhysPage));
1624
1625} PDMIVMMDEVCONNECTOR;
1626
1627
1628/**
1629 * MAC address.
1630 * (The first 24 bits are the 'company id', where the first bit seems to have a special meaning if set.)
1631 */
1632typedef union PDMMAC
1633{
1634 /** 8-bit view. */
1635 uint8_t au8[6];
1636 /** 16-bit view. */
1637 uint16_t au16[3];
1638} PDMMAC;
1639/** Pointer to a MAC address. */
1640typedef PDMMAC *PPDMMAC;
1641/** Pointer to a const MAC address. */
1642typedef const PDMMAC *PCPDMMAC;
1643
1644
1645/** Pointer to a network port interface */
1646typedef struct PDMINETWORKPORT *PPDMINETWORKPORT;
1647/**
1648 * Network port interface.
1649 */
1650typedef struct PDMINETWORKPORT
1651{
1652 /**
1653 * Check how much data the device/driver can receive data now.
1654 * This must be called before the pfnRecieve() method is called.
1655 *
1656 * @returns Number of bytes the device can receive now.
1657 * @param pInterface Pointer to the interface structure containing the called function pointer.
1658 * @thread EMT
1659 */
1660 DECLR3CALLBACKMEMBER(size_t, pfnCanReceive,(PPDMINETWORKPORT pInterface));
1661
1662 /**
1663 * Receive data from the network.
1664 *
1665 * @returns VBox status code.
1666 * @param pInterface Pointer to the interface structure containing the called function pointer.
1667 * @param pvBuf The available data.
1668 * @param cb Number of bytes available in the buffer.
1669 * @thread EMT
1670 */
1671 DECLR3CALLBACKMEMBER(int, pfnReceive,(PPDMINETWORKPORT pInterface, const void *pvBuf, size_t cb));
1672
1673} PDMINETWORKPORT;
1674
1675
1676/**
1677 * Network link state.
1678 */
1679typedef enum PDMNETWORKLINKSTATE
1680{
1681 /** Invalid state. */
1682 PDMNETWORKLINKSTATE_INVALID = 0,
1683 /** The link is up. */
1684 PDMNETWORKLINKSTATE_UP,
1685 /** The link is down. */
1686 PDMNETWORKLINKSTATE_DOWN,
1687 /** The link is temporarily down while resuming. */
1688 PDMNETWORKLINKSTATE_DOWN_RESUME
1689} PDMNETWORKLINKSTATE;
1690
1691
1692/** Pointer to a network connector interface */
1693typedef struct PDMINETWORKCONNECTOR *PPDMINETWORKCONNECTOR;
1694/**
1695 * Network connector interface.
1696 */
1697typedef struct PDMINETWORKCONNECTOR
1698{
1699 /**
1700 * Send data to the network.
1701 *
1702 * @returns VBox status code.
1703 * @param pInterface Pointer to the interface structure containing the called function pointer.
1704 * @param pvBuf Data to send.
1705 * @param cb Number of bytes to send.
1706 * @thread EMT
1707 */
1708 DECLR3CALLBACKMEMBER(int, pfnSend,(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb));
1709
1710 /**
1711 * Set promiscuous mode.
1712 *
1713 * This is called when the promiscuous mode is set. This means that there doesn't have
1714 * to be a mode change when it's called.
1715 *
1716 * @param pInterface Pointer to the interface structure containing the called function pointer.
1717 * @param fPromiscuous Set if the adaptor is now in promiscuous mode. Clear if it is not.
1718 * @thread EMT
1719 */
1720 DECLR3CALLBACKMEMBER(void, pfnSetPromiscuousMode,(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous));
1721
1722 /**
1723 * Notification on link status changes.
1724 *
1725 * @param pInterface Pointer to the interface structure containing the called function pointer.
1726 * @param enmLinkState The new link state.
1727 * @thread EMT
1728 */
1729 DECLR3CALLBACKMEMBER(void, pfnNotifyLinkChanged,(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState));
1730
1731 /**
1732 * More receive buffer has become available.
1733 *
1734 * This is called when the NIC frees up receive buffers.
1735 *
1736 * @param pInterface Pointer to the interface structure containing the called function pointer.
1737 * @thread EMT
1738 */
1739 DECLR3CALLBACKMEMBER(void, pfnNotifyCanReceive,(PPDMINETWORKCONNECTOR pInterface));
1740
1741} PDMINETWORKCONNECTOR;
1742
1743
1744/** Pointer to a network config port interface */
1745typedef struct PDMINETWORKCONFIG *PPDMINETWORKCONFIG;
1746/**
1747 * Network config port interface.
1748 */
1749typedef struct PDMINETWORKCONFIG
1750{
1751 /**
1752 * Gets the current Media Access Control (MAC) address.
1753 *
1754 * @returns VBox status code.
1755 * @param pInterface Pointer to the interface structure containing the called function pointer.
1756 * @param pMac Where to store the MAC address.
1757 * @thread EMT
1758 */
1759 DECLR3CALLBACKMEMBER(int, pfnGetMac,(PPDMINETWORKCONFIG pInterface, PPDMMAC *pMac));
1760
1761 /**
1762 * Gets the new link state.
1763 *
1764 * @returns The current link state.
1765 * @param pInterface Pointer to the interface structure containing the called function pointer.
1766 * @thread EMT
1767 */
1768 DECLR3CALLBACKMEMBER(PDMNETWORKLINKSTATE, pfnGetLinkState,(PPDMINETWORKCONFIG pInterface));
1769
1770 /**
1771 * Sets the new link state.
1772 *
1773 * @returns VBox status code.
1774 * @param pInterface Pointer to the interface structure containing the called function pointer.
1775 * @param enmState The new link state
1776 * @thread EMT
1777 */
1778 DECLR3CALLBACKMEMBER(int, pfnSetLinkState,(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState));
1779
1780} PDMINETWORKCONFIG;
1781
1782
1783/** Pointer to a network connector interface */
1784typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
1785/**
1786 * Audio connector interface.
1787 */
1788typedef struct PDMIAUDIOCONNECTOR
1789{
1790 DECLR3CALLBACKMEMBER(void, pfnRun,(PPDMIAUDIOCONNECTOR pInterface));
1791
1792/* DECLR3CALLBACKMEMBER(int, pfnSetRecordSource,(PPDMIAUDIOINCONNECTOR pInterface, AUDIORECSOURCE)); */
1793
1794} PDMIAUDIOCONNECTOR;
1795
1796
1797/** @todo r=bird: the two following interfaces are hacks to work around the missing audio driver
1798 * interface. This should be addressed rather than making more temporary hacks. */
1799
1800/** Pointer to a Audio Sniffer Device port interface. */
1801typedef struct PDMIAUDIOSNIFFERPORT *PPDMIAUDIOSNIFFERPORT;
1802
1803/**
1804 * Audio Sniffer port interface.
1805 */
1806typedef struct PDMIAUDIOSNIFFERPORT
1807{
1808 /**
1809 * Enables or disables sniffing. If sniffing is being enabled also sets a flag
1810 * whether the audio must be also left on the host.
1811 *
1812 * @returns VBox status code
1813 * @param pInterface Pointer to this interface.
1814 * @param fEnable 'true' for enable sniffing, 'false' to disable.
1815 * @param fKeepHostAudio Indicates whether host audio should also present
1816 * 'true' means that sound should not be played
1817 * by the audio device.
1818 */
1819 DECLR3CALLBACKMEMBER(int, pfnSetup,(PPDMIAUDIOSNIFFERPORT pInterface, bool fEnable, bool fKeepHostAudio));
1820
1821} PDMIAUDIOSNIFFERPORT;
1822
1823/** Pointer to a Audio Sniffer connector interface. */
1824typedef struct PDMIAUDIOSNIFFERCONNECTOR *PPDMIAUDIOSNIFFERCONNECTOR;
1825
1826/**
1827 * Audio Sniffer connector interface.
1828 * Pair with PDMIAUDIOSNIFFERPORT.
1829 */
1830typedef struct PDMIAUDIOSNIFFERCONNECTOR
1831{
1832 /**
1833 * AudioSniffer device calls this method when audio samples
1834 * are about to be played and sniffing is enabled.
1835 *
1836 * @param pInterface Pointer to this interface.
1837 * @param pvSamples Audio samples buffer.
1838 * @param cSamples How many complete samples are in the buffer.
1839 * @param iSampleHz The sample frequency in Hz.
1840 * @param cChannels Number of channels. 1 for mono, 2 for stereo.
1841 * @param cBits How many bits a sample for a single channel has. Normally 8 or 16.
1842 * @param fUnsigned Whether samples are unsigned values.
1843 * @thread The emulation thread.
1844 */
1845 DECLR3CALLBACKMEMBER(void, pfnAudioSamplesOut,(PPDMIAUDIOSNIFFERCONNECTOR pInterface, void *pvSamples, uint32_t cSamples,
1846 int iSampleHz, int cChannels, int cBits, bool fUnsigned));
1847
1848 /**
1849 * AudioSniffer device calls this method when output volume is changed.
1850 *
1851 * @param pInterface Pointer to this interface.
1852 * @param u16LeftVolume 0..0xFFFF volume level for left channel.
1853 * @param u16RightVolume 0..0xFFFF volume level for right channel.
1854 * @thread The emulation thread.
1855 */
1856 DECLR3CALLBACKMEMBER(void, pfnAudioVolumeOut,(PPDMIAUDIOSNIFFERCONNECTOR pInterface, uint16_t u16LeftVolume, uint16_t u16RightVolume));
1857
1858} PDMIAUDIOSNIFFERCONNECTOR;
1859
1860
1861/**
1862 * Generic status LED core.
1863 * Note that a unit doesn't have to support all the indicators.
1864 */
1865typedef union PDMLEDCORE
1866{
1867 /** 32-bit view. */
1868 uint32_t volatile u32;
1869 /** Bit view. */
1870 struct
1871 {
1872 /** Reading/Receiving indicator. */
1873 uint32_t fReading : 1;
1874 /** Writing/Sending indicator. */
1875 uint32_t fWriting : 1;
1876 /** Busy indicator. */
1877 uint32_t fBusy : 1;
1878 /** Error indicator. */
1879 uint32_t fError : 1;
1880 } s;
1881} PDMLEDCORE;
1882
1883/** LED bit masks for the u32 view.
1884 * @{ */
1885/** Reading/Receiving indicator. */
1886#define PDMLED_READING RT_BIT(0)
1887/** Writing/Sending indicator. */
1888#define PDMLED_WRITING RT_BIT(1)
1889/** Busy indicator. */
1890#define PDMLED_BUSY RT_BIT(2)
1891/** Error indicator. */
1892#define PDMLED_ERROR RT_BIT(3)
1893/** @} */
1894
1895
1896/**
1897 * Generic status LED.
1898 * Note that a unit doesn't have to support all the indicators.
1899 */
1900typedef struct PDMLED
1901{
1902 /** Just a magic for sanity checking. */
1903 uint32_t u32Magic;
1904 uint32_t u32Alignment; /**< structure size alignment. */
1905 /** The actual LED status.
1906 * Only the device is allowed to change this. */
1907 PDMLEDCORE Actual;
1908 /** The asserted LED status which is cleared by the reader.
1909 * The device will assert the bits but never clear them.
1910 * The driver clears them as it sees fit. */
1911 PDMLEDCORE Asserted;
1912} PDMLED;
1913
1914/** Pointer to an LED. */
1915typedef PDMLED *PPDMLED;
1916/** Pointer to a const LED. */
1917typedef const PDMLED *PCPDMLED;
1918
1919#define PDMLED_MAGIC ( 0x11335577 )
1920
1921/** Pointer to an LED ports interface. */
1922typedef struct PDMILEDPORTS *PPDMILEDPORTS;
1923/**
1924 * Interface for exporting LEDs.
1925 */
1926typedef struct PDMILEDPORTS
1927{
1928 /**
1929 * Gets the pointer to the status LED of a unit.
1930 *
1931 * @returns VBox status code.
1932 * @param pInterface Pointer to the interface structure containing the called function pointer.
1933 * @param iLUN The unit which status LED we desire.
1934 * @param ppLed Where to store the LED pointer.
1935 */
1936 DECLR3CALLBACKMEMBER(int, pfnQueryStatusLed,(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed));
1937
1938} PDMILEDPORTS;
1939
1940
1941/** Pointer to an LED connectors interface. */
1942typedef struct PDMILEDCONNECTORS *PPDMILEDCONNECTORS;
1943/**
1944 * Interface for reading LEDs.
1945 */
1946typedef struct PDMILEDCONNECTORS
1947{
1948 /**
1949 * Notification about a unit which have been changed.
1950 *
1951 * The driver must discard any pointers to data owned by
1952 * the unit and requery it.
1953 *
1954 * @param pInterface Pointer to the interface structure containing the called function pointer.
1955 * @param iLUN The unit number.
1956 */
1957 DECLR3CALLBACKMEMBER(void, pfnUnitChanged,(PPDMILEDCONNECTORS pInterface, unsigned iLUN));
1958} PDMILEDCONNECTORS;
1959
1960
1961/** The special status unit number */
1962#define PDM_STATUS_LUN 999
1963
1964
1965#ifdef VBOX_HGCM
1966
1967/** Abstract HGCM command structure. Used only to define a typed pointer. */
1968struct VBOXHGCMCMD;
1969
1970/** Pointer to HGCM command structure. This pointer is unique and identifies
1971 * the command being processed. The pointer is passed to HGCM connector methods,
1972 * and must be passed back to HGCM port when command is completed.
1973 */
1974typedef struct VBOXHGCMCMD *PVBOXHGCMCMD;
1975
1976/** Pointer to a HGCM port interface. */
1977typedef struct PDMIHGCMPORT *PPDMIHGCMPORT;
1978
1979/**
1980 * HGCM port interface. Normally implemented by VMMDev.
1981 */
1982typedef struct PDMIHGCMPORT
1983{
1984 /**
1985 * Notify the guest on a command completion.
1986 *
1987 * @param pInterface Pointer to this interface.
1988 * @param rc The return code (VBox error code).
1989 * @param pCmd A pointer that identifies the completed command.
1990 *
1991 * @returns VBox status code
1992 */
1993 DECLR3CALLBACKMEMBER(void, pfnCompleted,(PPDMIHGCMPORT pInterface, int32_t rc, PVBOXHGCMCMD pCmd));
1994
1995} PDMIHGCMPORT;
1996
1997
1998/** Pointer to a HGCM connector interface. */
1999typedef struct PDMIHGCMCONNECTOR *PPDMIHGCMCONNECTOR;
2000
2001/** Pointer to a HGCM service location structure. */
2002typedef struct HGCMSERVICELOCATION *PHGCMSERVICELOCATION;
2003
2004/**
2005 * HGCM connector interface.
2006 * Pair with PDMIHGCMPORT.
2007 */
2008typedef struct PDMIHGCMCONNECTOR
2009{
2010 /**
2011 * Locate a service and inform it about a client connection.
2012 *
2013 * @param pInterface Pointer to this interface.
2014 * @param pCmd A pointer that identifies the command.
2015 * @param pServiceLocation Pointer to the service location structure.
2016 * @param pu32ClientID Where to store the client id for the connection.
2017 * @return VBox status code.
2018 * @thread The emulation thread.
2019 */
2020 DECLR3CALLBACKMEMBER(int, pfnConnect,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID));
2021
2022 /**
2023 * Disconnect from service.
2024 *
2025 * @param pInterface Pointer to this interface.
2026 * @param pCmd A pointer that identifies the command.
2027 * @param u32ClientID The client id returned by the pfnConnect call.
2028 * @return VBox status code.
2029 * @thread The emulation thread.
2030 */
2031 DECLR3CALLBACKMEMBER(int, pfnDisconnect,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID));
2032
2033 /**
2034 * Process a guest issued command.
2035 *
2036 * @param pInterface Pointer to this interface.
2037 * @param pCmd A pointer that identifies the command.
2038 * @param u32ClientID The client id returned by the pfnConnect call.
2039 * @param u32Function Function to be performed by the service.
2040 * @param cParms Number of parameters in the array pointed to by paParams.
2041 * @param paParms Pointer to an array of parameters.
2042 * @return VBox status code.
2043 * @thread The emulation thread.
2044 */
2045 DECLR3CALLBACKMEMBER(int, pfnCall,(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
2046 uint32_t cParms, PVBOXHGCMSVCPARM paParms));
2047
2048} PDMIHGCMCONNECTOR;
2049
2050#endif
2051
2052/** @} */
2053
2054__END_DECLS
2055
2056#endif
Note: See TracBrowser for help on using the repository browser.

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