VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/VirtioSerialDxe/VirtioSerial.h

最後變更 在這個檔案是 101291,由 vboxsync 提交於 14 月 前

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 4.8 KB
 
1/** @file
2
3 Private definitions of the VirtioRng RNG driver
4
5 Copyright (C) 2016, Linaro Ltd.
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9**/
10
11#ifndef _VIRTIO_SERIAL_DXE_H_
12#define _VIRTIO_SERIAL_DXE_H_
13
14#include <Protocol/ComponentName.h>
15#include <Protocol/DriverBinding.h>
16#include <Protocol/SerialIo.h>
17
18#include <IndustryStandard/Virtio.h>
19#include <IndustryStandard/VirtioSerial.h>
20
21#define VIRTIO_SERIAL_SIG SIGNATURE_32 ('V', 'S', 'I', 'O')
22
23#define MAX_PORTS 8
24#define MAX_RINGS (MAX_PORTS * 2 + 2)
25
26#define CTRL_RX_BUFSIZE 128
27#define CTRL_TX_BUFSIZE sizeof(VIRTIO_SERIAL_CONTROL)
28#define PORT_RX_BUFSIZE 128
29#define PORT_TX_BUFSIZE 128
30
31//
32// Data structures
33//
34
35typedef struct _VIRTIO_SERIAL_DEV VIRTIO_SERIAL_DEV;
36typedef struct _VIRTIO_SERIAL_RING VIRTIO_SERIAL_RING;
37typedef struct _VIRTIO_SERIAL_PORT VIRTIO_SERIAL_PORT;
38typedef struct _VIRTIO_SERIAL_IO_PROTOCOL VIRTIO_SERIAL_IO_PROTOCOL;
39
40struct _VIRTIO_SERIAL_RING {
41 VRING Ring;
42 VOID *RingMap;
43 DESC_INDICES Indices; /* Avail Ring */
44 UINT16 LastUsedIdx; /* Used Ring */
45
46 UINT32 BufferSize;
47 UINT32 BufferCount;
48 UINT32 BufferPages;
49 UINT8 *Buffers;
50 VOID *BufferMap;
51 EFI_PHYSICAL_ADDRESS DeviceAddress;
52
53 BOOLEAN Ready;
54};
55
56struct _VIRTIO_SERIAL_PORT {
57 BOOLEAN Ready;
58 BOOLEAN Console;
59 BOOLEAN DeviceOpen;
60
61 CHAR16 Name[32];
62
63 VIRTIO_SERIAL_IO_PROTOCOL *SerialIo;
64};
65
66struct _VIRTIO_SERIAL_DEV {
67 UINT32 Signature;
68 LIST_ENTRY Link;
69
70 EFI_HANDLE DriverBindingHandle;
71 EFI_HANDLE DeviceHandle;
72 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
73
74 VIRTIO_DEVICE_PROTOCOL *VirtIo;
75 EFI_EVENT ExitBoot;
76 VIRTIO_SERIAL_CONFIG Config;
77 VIRTIO_SERIAL_PORT Ports[MAX_PORTS];
78 VIRTIO_SERIAL_RING Rings[MAX_RINGS];
79 EFI_EVENT Timer;
80
81 UINT32 NumPorts;
82 UINT32 NumConsoles;
83 UINT32 NumNamedPorts;
84};
85
86struct _VIRTIO_SERIAL_IO_PROTOCOL {
87 EFI_SERIAL_IO_PROTOCOL SerialIo;
88 EFI_SERIAL_IO_MODE SerialIoMode;
89
90 EFI_HANDLE DeviceHandle;
91 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
92
93 VIRTIO_SERIAL_DEV *Dev;
94 UINT32 PortId;
95
96 UINT8 ReadBuffer[PORT_RX_BUFSIZE];
97 UINT32 ReadOffset;
98 UINT32 ReadSize;
99
100 UINT8 WriteBuffer[PORT_TX_BUFSIZE];
101 UINT32 WriteOffset;
102};
103
104//
105// VirtioSerial.c
106//
107
108VOID
109EFIAPI
110LogDevicePath (
111 UINT32 Level,
112 const CHAR8 *Func,
113 CHAR16 *Note,
114 EFI_DEVICE_PATH_PROTOCOL *DevicePath
115 );
116
117EFI_STATUS
118EFIAPI
119VirtioSerialTxControl (
120 IN OUT VIRTIO_SERIAL_DEV *Dev,
121 IN UINT32 Id,
122 IN UINT16 Event,
123 IN UINT16 Value
124 );
125
126//
127// VirtioSerialRing.c
128//
129
130EFI_STATUS
131EFIAPI
132VirtioSerialInitRing (
133 IN OUT VIRTIO_SERIAL_DEV *Dev,
134 IN UINT16 Index,
135 IN UINT32 BufferSize
136 );
137
138VOID
139EFIAPI
140VirtioSerialUninitRing (
141 IN OUT VIRTIO_SERIAL_DEV *Dev,
142 IN UINT16 Index
143 );
144
145VOID
146EFIAPI
147VirtioSerialRingFillRx (
148 IN OUT VIRTIO_SERIAL_DEV *Dev,
149 IN UINT16 Index
150 );
151
152VOID
153EFIAPI
154VirtioSerialRingClearTx (
155 IN OUT VIRTIO_SERIAL_DEV *Dev,
156 IN UINT16 Index
157 );
158
159EFI_STATUS
160EFIAPI
161VirtioSerialRingSendBuffer (
162 IN OUT VIRTIO_SERIAL_DEV *Dev,
163 IN UINT16 Index,
164 IN VOID *Data,
165 IN UINT32 DataSize,
166 IN BOOLEAN Notify
167 );
168
169BOOLEAN
170EFIAPI
171VirtioSerialRingHasBuffer (
172 IN OUT VIRTIO_SERIAL_DEV *Dev,
173 IN UINT16 Index
174 );
175
176BOOLEAN
177EFIAPI
178VirtioSerialRingGetBuffer (
179 IN OUT VIRTIO_SERIAL_DEV *Dev,
180 IN UINT16 Index,
181 OUT VOID *Data,
182 OUT UINT32 *DataSize
183 );
184
185//
186// VirtioSerialPort.c
187//
188
189EFI_STATUS
190EFIAPI
191VirtioSerialPortAdd (
192 IN OUT VIRTIO_SERIAL_DEV *Dev,
193 IN UINT32 PortId
194 );
195
196VOID
197EFIAPI
198VirtioSerialPortSetConsole (
199 IN OUT VIRTIO_SERIAL_DEV *Dev,
200 IN UINT32 PortId
201 );
202
203VOID
204EFIAPI
205VirtioSerialPortSetName (
206 IN OUT VIRTIO_SERIAL_DEV *Dev,
207 IN UINT32 PortId,
208 IN UINT8 *Name
209 );
210
211VOID
212EFIAPI
213VirtioSerialPortSetDeviceOpen (
214 IN OUT VIRTIO_SERIAL_DEV *Dev,
215 IN UINT32 PortId,
216 IN UINT16 Value
217 );
218
219VOID
220EFIAPI
221VirtioSerialPortRemove (
222 IN OUT VIRTIO_SERIAL_DEV *Dev,
223 IN UINT32 PortId
224 );
225
226#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette