ArmPkg: only attempt buildin MmCommunicationDxe for AArch64
[mirror_edk2.git] / OvmfPkg / Library / VirtioMmioDeviceLib / VirtioMmioDevice.h
1 /** @file
2
3 Internal definitions for the VirtIo MMIO Device driver
4
5 Copyright (C) 2013, ARM Ltd
6 Copyright (C) 2017, AMD Inc. All rights reserved.<BR>
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #ifndef _VIRTIO_MMIO_DEVICE_INTERNAL_H_
13 #define _VIRTIO_MMIO_DEVICE_INTERNAL_H_
14
15 #include <Protocol/VirtioDevice.h>
16
17 #include <IndustryStandard/Virtio.h>
18
19 #include <Library/DebugLib.h>
20 #include <Library/IoLib.h>
21 #include <Library/UefiLib.h>
22 #include <Library/VirtioMmioDeviceLib.h>
23 #include <Library/MemoryAllocationLib.h>
24
25 #define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O')
26
27 typedef struct {
28 UINT32 Signature;
29 VIRTIO_DEVICE_PROTOCOL VirtioDevice;
30 PHYSICAL_ADDRESS BaseAddress;
31 } VIRTIO_MMIO_DEVICE;
32
33 #define VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE(Device) \
34 CR (Device, VIRTIO_MMIO_DEVICE, VirtioDevice, VIRTIO_MMIO_DEVICE_SIGNATURE)
35
36 #define VIRTIO_CFG_WRITE(Device, Offset, Val) \
37 (MmioWrite32 (Device->BaseAddress + (Offset), Val))
38 #define VIRTIO_CFG_READ(Device, Offset) \
39 (MmioRead32 (Device->BaseAddress + (Offset)))
40
41 EFI_STATUS
42 EFIAPI
43 VirtioMmioDeviceRead (
44 IN VIRTIO_DEVICE_PROTOCOL *This,
45 IN UINTN FieldOFfset,
46 IN UINTN FieldSize,
47 IN UINTN BufferSize,
48 OUT VOID* Buffer
49 );
50
51 EFI_STATUS
52 EFIAPI
53 VirtioMmioDeviceWrite (
54 IN VIRTIO_DEVICE_PROTOCOL *This,
55 IN UINTN FieldOffset,
56 IN UINTN FieldSize,
57 IN UINT64 Value
58 );
59
60 EFI_STATUS
61 EFIAPI
62 VirtioMmioGetDeviceFeatures (
63 IN VIRTIO_DEVICE_PROTOCOL *This,
64 OUT UINT64 *DeviceFeatures
65 );
66
67 EFI_STATUS
68 EFIAPI
69 VirtioMmioGetQueueSize (
70 IN VIRTIO_DEVICE_PROTOCOL *This,
71 OUT UINT16 *QueueNumMax
72 );
73
74 EFI_STATUS
75 EFIAPI
76 VirtioMmioGetDeviceStatus (
77 IN VIRTIO_DEVICE_PROTOCOL *This,
78 OUT UINT8 *DeviceStatus
79 );
80
81 EFI_STATUS
82 EFIAPI
83 VirtioMmioSetQueueSize (
84 IN VIRTIO_DEVICE_PROTOCOL *This,
85 IN UINT16 QueueSize
86 );
87
88 EFI_STATUS
89 EFIAPI
90 VirtioMmioSetDeviceStatus (
91 IN VIRTIO_DEVICE_PROTOCOL *This,
92 IN UINT8 DeviceStatus
93 );
94
95 EFI_STATUS
96 EFIAPI
97 VirtioMmioSetQueueNotify (
98 IN VIRTIO_DEVICE_PROTOCOL *This,
99 IN UINT16 QueueNotify
100 );
101
102 EFI_STATUS
103 EFIAPI
104 VirtioMmioSetQueueSel (
105 IN VIRTIO_DEVICE_PROTOCOL *This,
106 IN UINT16 Sel
107 );
108
109 EFI_STATUS
110 VirtioMmioSetQueueAddress (
111 IN VIRTIO_DEVICE_PROTOCOL *This,
112 IN VRING *Ring,
113 IN UINT64 RingBaseShift
114 );
115
116 EFI_STATUS
117 EFIAPI
118 VirtioMmioSetQueueAlignment (
119 IN VIRTIO_DEVICE_PROTOCOL *This,
120 IN UINT32 Alignment
121 );
122
123 EFI_STATUS
124 EFIAPI
125 VirtioMmioSetPageSize (
126 IN VIRTIO_DEVICE_PROTOCOL *This,
127 IN UINT32 PageSize
128 );
129
130 EFI_STATUS
131 EFIAPI
132 VirtioMmioSetGuestFeatures (
133 IN VIRTIO_DEVICE_PROTOCOL *This,
134 IN UINT64 Features
135 );
136
137 EFI_STATUS
138 EFIAPI
139 VirtioMmioAllocateSharedPages (
140 IN VIRTIO_DEVICE_PROTOCOL *This,
141 IN UINTN NumPages,
142 OUT VOID **HostAddress
143 );
144
145 VOID
146 EFIAPI
147 VirtioMmioFreeSharedPages (
148 IN VIRTIO_DEVICE_PROTOCOL *This,
149 IN UINTN NumPages,
150 IN VOID *HostAddress
151 );
152
153 EFI_STATUS
154 EFIAPI
155 VirtioMmioMapSharedBuffer (
156 IN VIRTIO_DEVICE_PROTOCOL *This,
157 IN VIRTIO_MAP_OPERATION Operation,
158 IN VOID *HostAddress,
159 IN OUT UINTN *NumberOfBytes,
160 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
161 OUT VOID **Mapping
162 );
163
164 EFI_STATUS
165 EFIAPI
166 VirtioMmioUnmapSharedBuffer (
167 IN VIRTIO_DEVICE_PROTOCOL *This,
168 IN VOID *Mapping
169 );
170
171 #endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_