VirtualBox

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

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

AHCI: Remove temporary buffer, map the pages of the guest in R3 and use scatter gather I/O instead.

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