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 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
9 |
|
---|
10 | **/
|
---|
11 |
|
---|
12 | #ifndef _VIRTIO_PCI_DEVICE_DXE_H_
|
---|
13 | #define _VIRTIO_PCI_DEVICE_DXE_H_
|
---|
14 |
|
---|
15 | #include <Protocol/ComponentName.h>
|
---|
16 | #include <Protocol/DriverBinding.h>
|
---|
17 | #include <Protocol/PciIo.h>
|
---|
18 | #include <Protocol/VirtioDevice.h>
|
---|
19 |
|
---|
20 | #include <IndustryStandard/Virtio.h>
|
---|
21 |
|
---|
22 | #define VIRTIO_PCI_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'P', 'C', 'I')
|
---|
23 |
|
---|
24 | typedef struct {
|
---|
25 | UINT32 Signature;
|
---|
26 | VIRTIO_DEVICE_PROTOCOL VirtioDevice;
|
---|
27 | EFI_PCI_IO_PROTOCOL *PciIo;
|
---|
28 | UINT64 OriginalPciAttributes;
|
---|
29 | UINT32 DeviceSpecificConfigurationOffset;
|
---|
30 | } VIRTIO_PCI_DEVICE;
|
---|
31 |
|
---|
32 | #define VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE(Device) \
|
---|
33 | CR (Device, VIRTIO_PCI_DEVICE, VirtioDevice, VIRTIO_PCI_DEVICE_SIGNATURE)
|
---|
34 |
|
---|
35 |
|
---|
36 | EFI_STATUS
|
---|
37 | EFIAPI
|
---|
38 | VirtioPciIoRead (
|
---|
39 | IN VIRTIO_PCI_DEVICE *Dev,
|
---|
40 | IN UINTN FieldOffset,
|
---|
41 | IN UINTN FieldSize,
|
---|
42 | IN UINTN BufferSize,
|
---|
43 | OUT VOID *Buffer
|
---|
44 | );
|
---|
45 |
|
---|
46 | EFI_STATUS
|
---|
47 | EFIAPI
|
---|
48 | VirtioPciIoWrite (
|
---|
49 | IN VIRTIO_PCI_DEVICE *Dev,
|
---|
50 | IN UINTN FieldOffset,
|
---|
51 | IN UINTN FieldSize,
|
---|
52 | IN UINT64 Value
|
---|
53 | );
|
---|
54 |
|
---|
55 | /********************************************
|
---|
56 | * PCI Functions for VIRTIO_DEVICE_PROTOCOL
|
---|
57 | *******************************************/
|
---|
58 | EFI_STATUS
|
---|
59 | EFIAPI
|
---|
60 | VirtioPciDeviceRead (
|
---|
61 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
62 | IN UINTN FieldOffset,
|
---|
63 | IN UINTN FieldSize,
|
---|
64 | IN UINTN BufferSize,
|
---|
65 | OUT VOID *Buffer
|
---|
66 | );
|
---|
67 |
|
---|
68 | EFI_STATUS
|
---|
69 | EFIAPI
|
---|
70 | VirtioPciDeviceWrite (
|
---|
71 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
72 | IN UINTN FieldOffset,
|
---|
73 | IN UINTN FieldSize,
|
---|
74 | IN UINT64 Value
|
---|
75 | );
|
---|
76 |
|
---|
77 | EFI_STATUS
|
---|
78 | EFIAPI
|
---|
79 | VirtioPciGetDeviceFeatures (
|
---|
80 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
81 | OUT UINT64 *DeviceFeatures
|
---|
82 | );
|
---|
83 |
|
---|
84 | EFI_STATUS
|
---|
85 | EFIAPI
|
---|
86 | VirtioPciGetQueueSize (
|
---|
87 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
88 | OUT UINT16 *QueueNumMax
|
---|
89 | );
|
---|
90 |
|
---|
91 | EFI_STATUS
|
---|
92 | EFIAPI
|
---|
93 | VirtioPciSetQueueAlignment (
|
---|
94 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
95 | IN UINT32 Alignment
|
---|
96 | );
|
---|
97 |
|
---|
98 | EFI_STATUS
|
---|
99 | EFIAPI
|
---|
100 | VirtioPciSetPageSize (
|
---|
101 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
102 | IN UINT32 PageSize
|
---|
103 | );
|
---|
104 |
|
---|
105 | EFI_STATUS
|
---|
106 | EFIAPI
|
---|
107 | VirtioPciGetDeviceStatus (
|
---|
108 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
109 | OUT UINT8 *DeviceStatus
|
---|
110 | );
|
---|
111 |
|
---|
112 | EFI_STATUS
|
---|
113 | EFIAPI
|
---|
114 | VirtioPciSetGuestFeatures (
|
---|
115 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
116 | IN UINT64 Features
|
---|
117 | );
|
---|
118 |
|
---|
119 | EFI_STATUS
|
---|
120 | EFIAPI
|
---|
121 | VirtioPciSetQueueAddress (
|
---|
122 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
123 | IN VRING *Ring,
|
---|
124 | IN UINT64 RingBaseShift
|
---|
125 | );
|
---|
126 |
|
---|
127 | EFI_STATUS
|
---|
128 | EFIAPI
|
---|
129 | VirtioPciSetQueueSel (
|
---|
130 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
131 | IN UINT16 Sel
|
---|
132 | );
|
---|
133 |
|
---|
134 | EFI_STATUS
|
---|
135 | EFIAPI
|
---|
136 | VirtioPciSetQueueNotify (
|
---|
137 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
138 | IN UINT16 Index
|
---|
139 | );
|
---|
140 |
|
---|
141 | EFI_STATUS
|
---|
142 | EFIAPI
|
---|
143 | VirtioPciSetQueueSize (
|
---|
144 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
145 | IN UINT16 Size
|
---|
146 | );
|
---|
147 |
|
---|
148 | EFI_STATUS
|
---|
149 | EFIAPI
|
---|
150 | VirtioPciSetDeviceStatus (
|
---|
151 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
152 | IN UINT8 DeviceStatus
|
---|
153 | );
|
---|
154 |
|
---|
155 | EFI_STATUS
|
---|
156 | EFIAPI
|
---|
157 | VirtioPciAllocateSharedPages (
|
---|
158 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
159 | IN UINTN NumPages,
|
---|
160 | OUT VOID **HostAddress
|
---|
161 | );
|
---|
162 |
|
---|
163 | VOID
|
---|
164 | EFIAPI
|
---|
165 | VirtioPciFreeSharedPages (
|
---|
166 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
167 | IN UINTN NumPages,
|
---|
168 | IN VOID *HostAddress
|
---|
169 | );
|
---|
170 |
|
---|
171 | EFI_STATUS
|
---|
172 | EFIAPI
|
---|
173 | VirtioPciMapSharedBuffer (
|
---|
174 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
175 | IN VIRTIO_MAP_OPERATION Operation,
|
---|
176 | IN VOID *HostAddress,
|
---|
177 | IN OUT UINTN *NumberOfBytes,
|
---|
178 | OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
|
---|
179 | OUT VOID **Mapping
|
---|
180 | );
|
---|
181 |
|
---|
182 | EFI_STATUS
|
---|
183 | EFIAPI
|
---|
184 | VirtioPciUnmapSharedBuffer (
|
---|
185 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
186 | IN VOID *Mapping
|
---|
187 | );
|
---|
188 | #endif // _VIRTIO_PCI_DEVICE_DXE_H_
|
---|