TianoCore EDK2 master
Loading...
Searching...
No Matches
VirtioDevice.h
Go to the documentation of this file.
1
14#ifndef __VIRTIO_DEVICE_H__
15#define __VIRTIO_DEVICE_H__
16
18
19//
20// VirtIo Specification Revision: Major[31:24].Minor[23:16].Revision[15:0]
21//
22#define VIRTIO_SPEC_REVISION(major, minor, revision) \
23 ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF))
24
25#define VIRTIO_DEVICE_PROTOCOL_GUID {\
26 0xfa920010, 0x6785, 0x4941, {0xb6, 0xec, 0x49, 0x8c, 0x57, 0x9f, 0x16, 0x0a }\
27 }
28
30
31//
32// VIRTIO Operation for VIRTIO_MAP_SHARED
33//
34typedef enum {
35 //
36 // A read operation from system memory by a bus master
37 //
38 VirtioOperationBusMasterRead,
39 //
40 // A write operation to system memory by a bus master
41 //
42 VirtioOperationBusMasterWrite,
43 //
44 // Provides both read and write access to system memory by both the
45 // processor and a bus master
46 //
47 VirtioOperationBusMasterCommonBuffer,
48} VIRTIO_MAP_OPERATION;
49
73typedef
75(EFIAPI *VIRTIO_DEVICE_READ)(
77 IN UINTN FieldOffset,
78 IN UINTN FieldSize,
79 IN UINTN BufferSize,
80 OUT VOID *Buffer
81 );
82
104typedef
106(EFIAPI *VIRTIO_DEVICE_WRITE)(
108 IN UINTN FieldOffset,
109 IN UINTN FieldSize,
110 IN UINT64 Value
111 );
112
125typedef
129 OUT UINT64 *DeviceFeatures
130 );
131
140typedef
144 IN UINT64 Features
145 );
146
173typedef
177 IN VRING *Ring,
178 IN UINT64 RingBaseShift
179 );
180
196typedef
198(EFIAPI *VIRTIO_SET_QUEUE_SEL)(
200 IN UINT16 Index
201 );
202
215typedef
219 IN UINT16 Index
220 );
221
240typedef
242(EFIAPI *VIRTIO_SET_QUEUE_ALIGN)(
244 IN UINT32 Alignment
245 );
246
262typedef
264(EFIAPI *VIRTIO_SET_PAGE_SIZE)(
266 IN UINT32 PageSize
267 );
268
285typedef
289 OUT UINT16 *QueueNumMax
290 );
291
307typedef
309(EFIAPI *VIRTIO_SET_QUEUE_NUM)(
311 IN UINT16 QueueSize
312 );
313
327typedef
331 OUT UINT8 *DeviceStatus
332 );
333
346typedef
350 IN UINT8 DeviceStatus
351 );
352
372typedef
374(EFIAPI *VIRTIO_ALLOCATE_SHARED)(
376 IN UINTN Pages,
377 IN OUT VOID **HostAddress
378 );
379
391typedef
392VOID
393(EFIAPI *VIRTIO_FREE_SHARED)(
395 IN UINTN Pages,
396 IN VOID *HostAddress
397 );
398
435typedef
437(EFIAPI *VIRTIO_MAP_SHARED)(
439 IN VIRTIO_MAP_OPERATION Operation,
440 IN VOID *HostAddress,
441 IN OUT UINTN *NumberOfBytes,
442 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
443 OUT VOID **Mapping
444 );
445
462typedef
464(EFIAPI *VIRTIO_UNMAP_SHARED)(
466 IN VOID *Mapping
467 );
468
476 //
477 // VirtIo Specification Revision encoded with VIRTIO_SPEC_REVISION()
478 //
479 UINT32 Revision;
480 //
481 // From the Virtio Spec
482 //
483 INT32 SubSystemDeviceId;
484
485 VIRTIO_GET_DEVICE_FEATURES GetDeviceFeatures;
486 VIRTIO_SET_GUEST_FEATURES SetGuestFeatures;
487
488 VIRTIO_SET_QUEUE_ADDRESS SetQueueAddress;
489
490 VIRTIO_SET_QUEUE_SEL SetQueueSel;
491
492 VIRTIO_SET_QUEUE_NOTIFY SetQueueNotify;
493
494 VIRTIO_SET_QUEUE_ALIGN SetQueueAlign;
495 VIRTIO_SET_PAGE_SIZE SetPageSize;
496
497 VIRTIO_GET_QUEUE_NUM_MAX GetQueueNumMax;
498 VIRTIO_SET_QUEUE_NUM SetQueueNum;
499
500 VIRTIO_GET_DEVICE_STATUS GetDeviceStatus;
501 VIRTIO_SET_DEVICE_STATUS SetDeviceStatus;
502
503 //
504 // Functions to read/write Device Specific headers
505 //
506 VIRTIO_DEVICE_WRITE WriteDevice;
507 VIRTIO_DEVICE_READ ReadDevice;
508
509 //
510 // Functions to allocate, free, map and unmap shared buffer
511 //
512 VIRTIO_ALLOCATE_SHARED AllocateSharedPages;
513 VIRTIO_FREE_SHARED FreeSharedPages;
514 VIRTIO_MAP_SHARED MapSharedBuffer;
515 VIRTIO_UNMAP_SHARED UnmapSharedBuffer;
516};
517
518extern EFI_GUID gVirtioDeviceProtocolGuid;
519
520#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_STATUS(EFIAPI * VIRTIO_SET_QUEUE_NOTIFY)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 Index)
Definition: VirtioDevice.h:217
VOID(EFIAPI * VIRTIO_FREE_SHARED)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN Pages, IN VOID *HostAddress)
Definition: VirtioDevice.h:393
EFI_STATUS(EFIAPI * VIRTIO_GET_DEVICE_FEATURES)(IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT64 *DeviceFeatures)
Definition: VirtioDevice.h:127
EFI_STATUS(EFIAPI * VIRTIO_GET_QUEUE_NUM_MAX)(IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT16 *QueueNumMax)
Definition: VirtioDevice.h:287
EFI_STATUS(EFIAPI * VIRTIO_GET_DEVICE_STATUS)(IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT8 *DeviceStatus)
Definition: VirtioDevice.h:329
EFI_STATUS(EFIAPI * VIRTIO_SET_QUEUE_ALIGN)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT32 Alignment)
Definition: VirtioDevice.h:242
EFI_STATUS(EFIAPI * VIRTIO_DEVICE_READ)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINTN BufferSize, OUT VOID *Buffer)
Definition: VirtioDevice.h:75
EFI_STATUS(EFIAPI * VIRTIO_SET_PAGE_SIZE)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT32 PageSize)
Definition: VirtioDevice.h:264
EFI_STATUS(EFIAPI * VIRTIO_DEVICE_WRITE)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINT64 Value)
Definition: VirtioDevice.h:106
EFI_STATUS(EFIAPI * VIRTIO_SET_DEVICE_STATUS)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT8 DeviceStatus)
Definition: VirtioDevice.h:348
EFI_STATUS(EFIAPI * VIRTIO_SET_QUEUE_NUM)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 QueueSize)
Definition: VirtioDevice.h:309
EFI_STATUS(EFIAPI * VIRTIO_UNMAP_SHARED)(IN VIRTIO_DEVICE_PROTOCOL *This, IN VOID *Mapping)
Definition: VirtioDevice.h:464
EFI_STATUS(EFIAPI * VIRTIO_SET_GUEST_FEATURES)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT64 Features)
Definition: VirtioDevice.h:142
EFI_STATUS(EFIAPI * VIRTIO_SET_QUEUE_SEL)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 Index)
Definition: VirtioDevice.h:198
EFI_STATUS(EFIAPI * VIRTIO_SET_QUEUE_ADDRESS)(IN VIRTIO_DEVICE_PROTOCOL *This, IN VRING *Ring, IN UINT64 RingBaseShift)
Definition: VirtioDevice.h:175
EFI_STATUS(EFIAPI * VIRTIO_ALLOCATE_SHARED)(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN Pages, IN OUT VOID **HostAddress)
Definition: VirtioDevice.h:374
EFI_STATUS(EFIAPI * VIRTIO_MAP_SHARED)(IN VIRTIO_DEVICE_PROTOCOL *This, IN VIRTIO_MAP_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
Definition: VirtioDevice.h:437
Definition: Base.h:213