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