OvmfPkg/VirtioMmioDeviceLib: list "VirtioMmioDevice.h" in the INF file
[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 117 IN VIRTIO_DEVICE_PROTOCOL *This,\r
53a4c604
BS
118 IN VRING *Ring,\r
119 IN UINT64 RingBaseShift\r
6fb4e772
OM
120 );\r
121\r
122EFI_STATUS\r
123EFIAPI\r
124VirtioMmioSetQueueAlignment (\r
22701a3d
BS
125 IN VIRTIO_DEVICE_PROTOCOL *This,\r
126 IN UINT32 Alignment\r
6fb4e772
OM
127 );\r
128\r
129EFI_STATUS\r
130EFIAPI\r
131VirtioMmioSetPageSize (\r
22701a3d
BS
132 IN VIRTIO_DEVICE_PROTOCOL *This,\r
133 IN UINT32 PageSize\r
6fb4e772
OM
134 );\r
135\r
136EFI_STATUS\r
137EFIAPI\r
138VirtioMmioSetGuestFeatures (\r
22701a3d
BS
139 IN VIRTIO_DEVICE_PROTOCOL *This,\r
140 IN UINT64 Features\r
6fb4e772
OM
141 );\r
142\r
084cfc1a
BS
143EFI_STATUS\r
144EFIAPI\r
145VirtioMmioAllocateSharedPages (\r
146 IN VIRTIO_DEVICE_PROTOCOL *This,\r
147 IN UINTN NumPages,\r
148 OUT VOID **HostAddress\r
149 );\r
150\r
151VOID\r
152EFIAPI\r
153VirtioMmioFreeSharedPages (\r
154 IN VIRTIO_DEVICE_PROTOCOL *This,\r
155 IN UINTN NumPages,\r
156 IN VOID *HostAddress\r
157 );\r
158\r
159EFI_STATUS\r
160EFIAPI\r
161VirtioMmioMapSharedBuffer (\r
162 IN VIRTIO_DEVICE_PROTOCOL *This,\r
163 IN VIRTIO_MAP_OPERATION Operation,\r
164 IN VOID *HostAddress,\r
165 IN OUT UINTN *NumberOfBytes,\r
166 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
167 OUT VOID **Mapping\r
168 );\r
169\r
170EFI_STATUS\r
171EFIAPI\r
172VirtioMmioUnmapSharedBuffer (\r
173 IN VIRTIO_DEVICE_PROTOCOL *This,\r
174 IN VOID *Mapping\r
175 );\r
176\r
6fb4e772 177#endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_\r