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 | IN UINT64 RingBaseShift
|
---|
131 | );
|
---|
132 |
|
---|
133 | EFI_STATUS
|
---|
134 | EFIAPI
|
---|
135 | VirtioPciSetQueueSel (
|
---|
136 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
137 | IN UINT16 Sel
|
---|
138 | );
|
---|
139 |
|
---|
140 | EFI_STATUS
|
---|
141 | EFIAPI
|
---|
142 | VirtioPciSetQueueNotify (
|
---|
143 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
144 | IN UINT16 Index
|
---|
145 | );
|
---|
146 |
|
---|
147 | EFI_STATUS
|
---|
148 | EFIAPI
|
---|
149 | VirtioPciSetQueueSize (
|
---|
150 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
151 | IN UINT16 Size
|
---|
152 | );
|
---|
153 |
|
---|
154 | EFI_STATUS
|
---|
155 | EFIAPI
|
---|
156 | VirtioPciSetDeviceStatus (
|
---|
157 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
158 | IN UINT8 DeviceStatus
|
---|
159 | );
|
---|
160 |
|
---|
161 | EFI_STATUS
|
---|
162 | EFIAPI
|
---|
163 | VirtioPciAllocateSharedPages (
|
---|
164 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
165 | IN UINTN NumPages,
|
---|
166 | OUT VOID **HostAddress
|
---|
167 | );
|
---|
168 |
|
---|
169 | VOID
|
---|
170 | EFIAPI
|
---|
171 | VirtioPciFreeSharedPages (
|
---|
172 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
173 | IN UINTN NumPages,
|
---|
174 | IN VOID *HostAddress
|
---|
175 | );
|
---|
176 |
|
---|
177 | EFI_STATUS
|
---|
178 | EFIAPI
|
---|
179 | VirtioPciMapSharedBuffer (
|
---|
180 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
181 | IN VIRTIO_MAP_OPERATION Operation,
|
---|
182 | IN VOID *HostAddress,
|
---|
183 | IN OUT UINTN *NumberOfBytes,
|
---|
184 | OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
|
---|
185 | OUT VOID **Mapping
|
---|
186 | );
|
---|
187 |
|
---|
188 | EFI_STATUS
|
---|
189 | EFIAPI
|
---|
190 | VirtioPciUnmapSharedBuffer (
|
---|
191 | IN VIRTIO_DEVICE_PROTOCOL *This,
|
---|
192 | IN VOID *Mapping
|
---|
193 | );
|
---|
194 | #endif // _VIRTIO_PCI_DEVICE_DXE_H_
|
---|