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 UINT32 *DeviceFeatures 69 ); 70 71 EFI_STATUS 72 EFIAPI 73 VirtioMmioGetQueueAddress ( 74 IN VIRTIO_DEVICE_PROTOCOL *This, 75 OUT UINT32 *QueueAddress 76 ); 77 78 EFI_STATUS 79 EFIAPI 80 VirtioMmioGetQueueSize ( 81 IN VIRTIO_DEVICE_PROTOCOL *This, 82 OUT UINT16 *QueueNumMax 83 ); 84 85 EFI_STATUS 86 EFIAPI 87 VirtioMmioGetDeviceStatus ( 88 IN VIRTIO_DEVICE_PROTOCOL *This, 89 OUT UINT8 *DeviceStatus 90 ); 91 92 EFI_STATUS 93 EFIAPI 94 VirtioMmioSetQueueSize ( 95 VIRTIO_DEVICE_PROTOCOL *This, 96 UINT16 QueueSize 97 ); 98 99 EFI_STATUS 100 EFIAPI 101 VirtioMmioSetDeviceStatus ( 102 VIRTIO_DEVICE_PROTOCOL *This, 103 UINT8 DeviceStatus 104 ); 105 106 EFI_STATUS 107 EFIAPI 108 VirtioMmioSetQueueNotify ( 109 VIRTIO_DEVICE_PROTOCOL *This, 110 UINT16 QueueNotify 111 ); 112 113 EFI_STATUS 114 EFIAPI 115 VirtioMmioSetQueueSel ( 116 VIRTIO_DEVICE_PROTOCOL *This, 117 UINT16 Sel 118 ); 119 120 EFI_STATUS 121 VirtioMmioSetQueueAddress ( 122 VIRTIO_DEVICE_PROTOCOL *This, 123 UINT32 Address 124 ); 125 126 EFI_STATUS 127 EFIAPI 128 VirtioMmioSetQueueAlignment ( 129 VIRTIO_DEVICE_PROTOCOL *This, 130 UINT32 Alignment 131 ); 132 133 EFI_STATUS 134 EFIAPI 135 VirtioMmioSetPageSize ( 136 VIRTIO_DEVICE_PROTOCOL *This, 137 UINT32 PageSize 138 ); 139 140 EFI_STATUS 141 EFIAPI 142 VirtioMmioSetGuestFeatures ( 143 VIRTIO_DEVICE_PROTOCOL *This, 144 UINT32 Features 145 ); 146 147 #endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_ 148