TianoCore EDK2 master
Loading...
Searching...
No Matches
VirtioSerial.h
Go to the documentation of this file.
1
11#ifndef _VIRTIO_SERIAL_DXE_H_
12#define _VIRTIO_SERIAL_DXE_H_
13
16#include <Protocol/SerialIo.h>
17
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
39
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
57 BOOLEAN Ready;
58 BOOLEAN Console;
59 BOOLEAN DeviceOpen;
60
61 CHAR16 Name[32];
62
64};
65
67 UINT32 Signature;
68 LIST_ENTRY Link;
69
70 EFI_HANDLE DriverBindingHandle;
71 EFI_HANDLE DeviceHandle;
72 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
73
75 EFI_EVENT ExitBoot;
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
88 EFI_SERIAL_IO_MODE SerialIoMode;
89
90 EFI_HANDLE DeviceHandle;
91 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
92
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
118EFIAPI
119VirtioSerialTxControl (
121 IN UINT32 Id,
122 IN UINT16 Event,
123 IN UINT16 Value
124 );
125
126//
127// VirtioSerialRing.c
128//
129
131EFIAPI
132VirtioSerialInitRing (
134 IN UINT16 Index,
135 IN UINT32 BufferSize
136 );
137
138VOID
139EFIAPI
140VirtioSerialUninitRing (
142 IN UINT16 Index
143 );
144
145VOID
146EFIAPI
147VirtioSerialRingFillRx (
149 IN UINT16 Index
150 );
151
152VOID
153EFIAPI
154VirtioSerialRingClearTx (
156 IN UINT16 Index
157 );
158
160EFIAPI
161VirtioSerialRingSendBuffer (
163 IN UINT16 Index,
164 IN VOID *Data,
165 IN UINT32 DataSize,
166 IN BOOLEAN Notify
167 );
168
169BOOLEAN
170EFIAPI
171VirtioSerialRingHasBuffer (
173 IN UINT16 Index
174 );
175
176BOOLEAN
177EFIAPI
178VirtioSerialRingGetBuffer (
180 IN UINT16 Index,
181 OUT VOID *Data,
182 OUT UINT32 *DataSize
183 );
184
185//
186// VirtioSerialPort.c
187//
188
190EFIAPI
191VirtioSerialPortAdd (
193 IN UINT32 PortId
194 );
195
196VOID
197EFIAPI
198VirtioSerialPortSetConsole (
200 IN UINT32 PortId
201 );
202
203VOID
204EFIAPI
205VirtioSerialPortSetName (
207 IN UINT32 PortId,
208 IN UINT8 *Name
209 );
210
211VOID
212EFIAPI
213VirtioSerialPortSetDeviceOpen (
215 IN UINT32 PortId,
216 IN UINT16 Value
217 );
218
219VOID
220EFIAPI
221VirtioSerialPortRemove (
223 IN UINT32 PortId
224 );
225
226#endif
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33