1 /** @file 2 3 Internal definitions for the VirtIo MMIO Device driver 4 5 Copyright (C) 2013, ARM Ltd 6 7 This program and the accompanying materials are licensed and made available 8 under the terms and conditions of the BSD License which accompanies this 9 distribution. The full text of the license may be found at 10 http://opensource.org/licenses/bsd-license.php 11 12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT 13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 15 **/ 16 17 #ifndef _VIRTIO_MMIO_DEVICE_INTERNAL_H_ 18 #define _VIRTIO_MMIO_DEVICE_INTERNAL_H_ 19 20 #include <Protocol/VirtioDevice.h> 21 22 #include <IndustryStandard/Virtio.h> 23 24 #include <Library/DebugLib.h> 25 #include <Library/IoLib.h> 26 #include <Library/UefiLib.h> 27 #include <Library/VirtioMmioDeviceLib.h> 28 29 #define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O') 30 31 typedef struct { 32 UINT32 Signature; 33 VIRTIO_DEVICE_PROTOCOL VirtioDevice; 34 PHYSICAL_ADDRESS BaseAddress; 35 } VIRTIO_MMIO_DEVICE; 36 37 #define VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE(Device) \ 38 CR (Device, VIRTIO_MMIO_DEVICE, VirtioDevice, VIRTIO_MMIO_DEVICE_SIGNATURE) 39 40 #define VIRTIO_CFG_WRITE(Device, Offset, Val) \ 41 (MmioWrite32 (Device->BaseAddress + (Offset), Val)) 42 #define VIRTIO_CFG_READ(Device, Offset) \ 43 (MmioRead32 (Device->BaseAddress + (Offset))) 44 45 EFI_STATUS 46 EFIAPI 47 VirtioMmioDeviceRead ( 48 IN VIRTIO_DEVICE_PROTOCOL *This, 49 IN UINTN FieldOFfset, 50 IN UINTN FieldSize, 51 IN UINTN BufferSize, 52 OUT VOID* Buffer 53 ); 54 55 EFI_STATUS 56 EFIAPI 57 VirtioMmioDeviceWrite ( 58 IN VIRTIO_DEVICE_PROTOCOL *This, 59 IN UINTN FieldOffset, 60 IN UINTN FieldSize, 61 IN UINT64 Value 62 ); 63 64 EFI_STATUS 65 EFIAPI 66 VirtioMmioGetDeviceFeatures ( 67 IN VIRTIO_DEVICE_PROTOCOL *This, 68 OUT UINT64 *DeviceFeatures 69 ); 70 71 EFI_STATUS 72 EFIAPI 73 VirtioMmioGetQueueSize ( 74 IN VIRTIO_DEVICE_PROTOCOL *This, 75 OUT UINT16 *QueueNumMax 76 ); 77 78 EFI_STATUS 79 EFIAPI 80 VirtioMmioGetDeviceStatus ( 81 IN VIRTIO_DEVICE_PROTOCOL *This, 82 OUT UINT8 *DeviceStatus 83 ); 84 85 EFI_STATUS 86 EFIAPI 87 VirtioMmioSetQueueSize ( 88 VIRTIO_DEVICE_PROTOCOL *This, 89 UINT16 QueueSize 90 ); 91 92 EFI_STATUS 93 EFIAPI 94 VirtioMmioSetDeviceStatus ( 95 VIRTIO_DEVICE_PROTOCOL *This, 96 UINT8 DeviceStatus 97 ); 98 99 EFI_STATUS 100 EFIAPI 101 VirtioMmioSetQueueNotify ( 102 VIRTIO_DEVICE_PROTOCOL *This, 103 UINT16 QueueNotify 104 ); 105 106 EFI_STATUS 107 EFIAPI 108 VirtioMmioSetQueueSel ( 109 VIRTIO_DEVICE_PROTOCOL *This, 110 UINT16 Sel 111 ); 112 113 EFI_STATUS 114 VirtioMmioSetQueueAddress ( 115 IN VIRTIO_DEVICE_PROTOCOL *This, 116 IN VRING *Ring 117 ); 118 119 EFI_STATUS 120 EFIAPI 121 VirtioMmioSetQueueAlignment ( 122 VIRTIO_DEVICE_PROTOCOL *This, 123 UINT32 Alignment 124 ); 125 126 EFI_STATUS 127 EFIAPI 128 VirtioMmioSetPageSize ( 129 VIRTIO_DEVICE_PROTOCOL *This, 130 UINT32 PageSize 131 ); 132 133 EFI_STATUS 134 EFIAPI 135 VirtioMmioSetGuestFeatures ( 136 VIRTIO_DEVICE_PROTOCOL *This, 137 UINT64 Features 138 ); 139 140 #endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_ 141