OvmfPkg/VirtioLib: take VirtIo instance in VirtioRingInit/VirtioRingUninit
[mirror_edk2.git] / OvmfPkg / VirtioPciDeviceDxe / VirtioPciDevice.h
1 /** @file
2
3 Internal definitions for the VirtIo PCI Device driver
4
5 Copyright (C) 2013, ARM Ltd
6 Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
7
8 This program and the accompanying materials are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef _VIRTIO_PCI_DEVICE_DXE_H_
19 #define _VIRTIO_PCI_DEVICE_DXE_H_
20
21 #include <Protocol/ComponentName.h>
22 #include <Protocol/DriverBinding.h>
23 #include <Protocol/PciIo.h>
24 #include <Protocol/VirtioDevice.h>
25
26 #include <IndustryStandard/Virtio.h>
27
28 #define VIRTIO_PCI_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'P', 'C', 'I')
29
30 typedef struct {
31 UINT32 Signature;
32 VIRTIO_DEVICE_PROTOCOL VirtioDevice;
33 EFI_PCI_IO_PROTOCOL *PciIo;
34 UINT64 OriginalPciAttributes;
35 UINT32 DeviceSpecificConfigurationOffset;
36 } VIRTIO_PCI_DEVICE;
37
38 #define VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE(Device) \
39 CR (Device, VIRTIO_PCI_DEVICE, VirtioDevice, VIRTIO_PCI_DEVICE_SIGNATURE)
40
41
42 EFI_STATUS
43 EFIAPI
44 VirtioPciIoRead (
45 IN VIRTIO_PCI_DEVICE *Dev,
46 IN UINTN FieldOffset,
47 IN UINTN FieldSize,
48 IN UINTN BufferSize,
49 OUT VOID *Buffer
50 );
51
52 EFI_STATUS
53 EFIAPI
54 VirtioPciIoWrite (
55 IN VIRTIO_PCI_DEVICE *Dev,
56 IN UINTN FieldOffset,
57 IN UINTN FieldSize,
58 IN UINT64 Value
59 );
60
61 /********************************************
62 * PCI Functions for VIRTIO_DEVICE_PROTOCOL
63 *******************************************/
64 EFI_STATUS
65 EFIAPI
66 VirtioPciDeviceRead (
67 IN VIRTIO_DEVICE_PROTOCOL *This,
68 IN UINTN FieldOffset,
69 IN UINTN FieldSize,
70 IN UINTN BufferSize,
71 OUT VOID *Buffer
72 );
73
74 EFI_STATUS
75 EFIAPI
76 VirtioPciDeviceWrite (
77 IN VIRTIO_DEVICE_PROTOCOL *This,
78 IN UINTN FieldOffset,
79 IN UINTN FieldSize,
80 IN UINT64 Value
81 );
82
83 EFI_STATUS
84 EFIAPI
85 VirtioPciGetDeviceFeatures (
86 IN VIRTIO_DEVICE_PROTOCOL *This,
87 OUT UINT64 *DeviceFeatures
88 );
89
90 EFI_STATUS
91 EFIAPI
92 VirtioPciGetQueueSize (
93 IN VIRTIO_DEVICE_PROTOCOL *This,
94 OUT UINT16 *QueueNumMax
95 );
96
97 EFI_STATUS
98 EFIAPI
99 VirtioPciSetQueueAlignment (
100 IN VIRTIO_DEVICE_PROTOCOL *This,
101 IN UINT32 Alignment
102 );
103
104 EFI_STATUS
105 EFIAPI
106 VirtioPciSetPageSize (
107 IN VIRTIO_DEVICE_PROTOCOL *This,
108 IN UINT32 PageSize
109 );
110
111 EFI_STATUS
112 EFIAPI
113 VirtioPciGetDeviceStatus (
114 IN VIRTIO_DEVICE_PROTOCOL *This,
115 OUT UINT8 *DeviceStatus
116 );
117
118 EFI_STATUS
119 EFIAPI
120 VirtioPciSetGuestFeatures (
121 IN VIRTIO_DEVICE_PROTOCOL *This,
122 IN UINT64 Features
123 );
124
125 EFI_STATUS
126 EFIAPI
127 VirtioPciSetQueueAddress (
128 IN VIRTIO_DEVICE_PROTOCOL *This,
129 IN VRING *Ring
130 );
131
132 EFI_STATUS
133 EFIAPI
134 VirtioPciSetQueueSel (
135 IN VIRTIO_DEVICE_PROTOCOL *This,
136 IN UINT16 Sel
137 );
138
139 EFI_STATUS
140 EFIAPI
141 VirtioPciSetQueueNotify (
142 IN VIRTIO_DEVICE_PROTOCOL *This,
143 IN UINT16 Index
144 );
145
146 EFI_STATUS
147 EFIAPI
148 VirtioPciSetQueueSize (
149 IN VIRTIO_DEVICE_PROTOCOL *This,
150 IN UINT16 Size
151 );
152
153 EFI_STATUS
154 EFIAPI
155 VirtioPciSetDeviceStatus (
156 IN VIRTIO_DEVICE_PROTOCOL *This,
157 IN UINT8 DeviceStatus
158 );
159
160 EFI_STATUS
161 EFIAPI
162 VirtioPciAllocateSharedPages (
163 IN VIRTIO_DEVICE_PROTOCOL *This,
164 IN UINTN NumPages,
165 OUT VOID **HostAddress
166 );
167
168 VOID
169 EFIAPI
170 VirtioPciFreeSharedPages (
171 IN VIRTIO_DEVICE_PROTOCOL *This,
172 IN UINTN NumPages,
173 IN VOID *HostAddress
174 );
175
176 EFI_STATUS
177 EFIAPI
178 VirtioPciMapSharedBuffer (
179 IN VIRTIO_DEVICE_PROTOCOL *This,
180 IN VIRTIO_MAP_OPERATION Operation,
181 IN VOID *HostAddress,
182 IN OUT UINTN *NumberOfBytes,
183 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
184 OUT VOID **Mapping
185 );
186
187 EFI_STATUS
188 EFIAPI
189 VirtioPciUnmapSharedBuffer (
190 IN VIRTIO_DEVICE_PROTOCOL *This,
191 IN VOID *Mapping
192 );
193 #endif // _VIRTIO_PCI_DEVICE_DXE_H_