OvmfPkg/VirtioMmioDeviceLib: implement IOMMU-like member functions
[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
OM
7\r
8 This program and the accompanying materials are licensed and made available\r
9 under the terms and conditions of the BSD License which accompanies this\r
10 distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#ifndef _VIRTIO_MMIO_DEVICE_INTERNAL_H_\r
19#define _VIRTIO_MMIO_DEVICE_INTERNAL_H_\r
20\r
21#include <Protocol/VirtioDevice.h>\r
22\r
23#include <IndustryStandard/Virtio.h>\r
24\r
25#include <Library/DebugLib.h>\r
26#include <Library/IoLib.h>\r
27#include <Library/UefiLib.h>\r
28#include <Library/VirtioMmioDeviceLib.h>\r
084cfc1a 29#include <Library/MemoryAllocationLib.h>\r
6fb4e772
OM
30\r
31#define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O')\r
32\r
33typedef struct {\r
34 UINT32 Signature;\r
35 VIRTIO_DEVICE_PROTOCOL VirtioDevice;\r
36 PHYSICAL_ADDRESS BaseAddress;\r
37} VIRTIO_MMIO_DEVICE;\r
38\r
39#define VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE(Device) \\r
40 CR (Device, VIRTIO_MMIO_DEVICE, VirtioDevice, VIRTIO_MMIO_DEVICE_SIGNATURE)\r
41\r
42#define VIRTIO_CFG_WRITE(Device, Offset, Val) \\r
43 (MmioWrite32 (Device->BaseAddress + (Offset), Val))\r
44#define VIRTIO_CFG_READ(Device, Offset) \\r
45 (MmioRead32 (Device->BaseAddress + (Offset)))\r
46\r
47EFI_STATUS\r
48EFIAPI\r
49VirtioMmioDeviceRead (\r
50 IN VIRTIO_DEVICE_PROTOCOL *This,\r
51 IN UINTN FieldOFfset,\r
52 IN UINTN FieldSize,\r
53 IN UINTN BufferSize,\r
54 OUT VOID* Buffer\r
55 );\r
56\r
57EFI_STATUS\r
58EFIAPI\r
59VirtioMmioDeviceWrite (\r
60 IN VIRTIO_DEVICE_PROTOCOL *This,\r
61 IN UINTN FieldOffset,\r
62 IN UINTN FieldSize,\r
63 IN UINT64 Value\r
64 );\r
65\r
66EFI_STATUS\r
67EFIAPI\r
68VirtioMmioGetDeviceFeatures (\r
69 IN VIRTIO_DEVICE_PROTOCOL *This,\r
bc8fde6f 70 OUT UINT64 *DeviceFeatures\r
6fb4e772
OM
71 );\r
72\r
6fb4e772
OM
73EFI_STATUS\r
74EFIAPI\r
75VirtioMmioGetQueueSize (\r
76 IN VIRTIO_DEVICE_PROTOCOL *This,\r
77 OUT UINT16 *QueueNumMax\r
78 );\r
79\r
80EFI_STATUS\r
81EFIAPI\r
82VirtioMmioGetDeviceStatus (\r
83 IN VIRTIO_DEVICE_PROTOCOL *This,\r
84 OUT UINT8 *DeviceStatus\r
85 );\r
86\r
87EFI_STATUS\r
88EFIAPI\r
89VirtioMmioSetQueueSize (\r
22701a3d
BS
90 IN VIRTIO_DEVICE_PROTOCOL *This,\r
91 IN UINT16 QueueSize\r
6fb4e772
OM
92 );\r
93\r
94EFI_STATUS\r
95EFIAPI\r
96VirtioMmioSetDeviceStatus (\r
22701a3d
BS
97 IN VIRTIO_DEVICE_PROTOCOL *This,\r
98 IN UINT8 DeviceStatus\r
6fb4e772
OM
99 );\r
100\r
101EFI_STATUS\r
102EFIAPI\r
103VirtioMmioSetQueueNotify (\r
22701a3d
BS
104 IN VIRTIO_DEVICE_PROTOCOL *This,\r
105 IN UINT16 QueueNotify\r
6fb4e772
OM
106 );\r
107\r
108EFI_STATUS\r
109EFIAPI\r
110VirtioMmioSetQueueSel (\r
22701a3d
BS
111 IN VIRTIO_DEVICE_PROTOCOL *This,\r
112 IN UINT16 Sel\r
6fb4e772
OM
113 );\r
114\r
115EFI_STATUS\r
116VirtioMmioSetQueueAddress (\r
07af4eee
LE
117 IN VIRTIO_DEVICE_PROTOCOL *This,\r
118 IN VRING *Ring\r
6fb4e772
OM
119 );\r
120\r
121EFI_STATUS\r
122EFIAPI\r
123VirtioMmioSetQueueAlignment (\r
22701a3d
BS
124 IN VIRTIO_DEVICE_PROTOCOL *This,\r
125 IN UINT32 Alignment\r
6fb4e772
OM
126 );\r
127\r
128EFI_STATUS\r
129EFIAPI\r
130VirtioMmioSetPageSize (\r
22701a3d
BS
131 IN VIRTIO_DEVICE_PROTOCOL *This,\r
132 IN UINT32 PageSize\r
6fb4e772
OM
133 );\r
134\r
135EFI_STATUS\r
136EFIAPI\r
137VirtioMmioSetGuestFeatures (\r
22701a3d
BS
138 IN VIRTIO_DEVICE_PROTOCOL *This,\r
139 IN UINT64 Features\r
6fb4e772
OM
140 );\r
141\r
084cfc1a
BS
142EFI_STATUS\r
143EFIAPI\r
144VirtioMmioAllocateSharedPages (\r
145 IN VIRTIO_DEVICE_PROTOCOL *This,\r
146 IN UINTN NumPages,\r
147 OUT VOID **HostAddress\r
148 );\r
149\r
150VOID\r
151EFIAPI\r
152VirtioMmioFreeSharedPages (\r
153 IN VIRTIO_DEVICE_PROTOCOL *This,\r
154 IN UINTN NumPages,\r
155 IN VOID *HostAddress\r
156 );\r
157\r
158EFI_STATUS\r
159EFIAPI\r
160VirtioMmioMapSharedBuffer (\r
161 IN VIRTIO_DEVICE_PROTOCOL *This,\r
162 IN VIRTIO_MAP_OPERATION Operation,\r
163 IN VOID *HostAddress,\r
164 IN OUT UINTN *NumberOfBytes,\r
165 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
166 OUT VOID **Mapping\r
167 );\r
168\r
169EFI_STATUS\r
170EFIAPI\r
171VirtioMmioUnmapSharedBuffer (\r
172 IN VIRTIO_DEVICE_PROTOCOL *This,\r
173 IN VOID *Mapping\r
174 );\r
175\r
6fb4e772 176#endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_\r