Initial import.
[mirror_edk2.git] / EdkNt32Pkg / Dxe / WinNtThunk / Bus / SerialIo / WinNtSerialIo.h
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 WinNtSerialIo.h\r
15\r
16Abstract:\r
17\r
18\r
19--*/\r
20\r
21#ifndef _WIN_NT_SERIAL_IO_\r
22#define _WIN_NT_SERIAL_IO_\r
23\r
24\r
25\r
26#define SERIAL_MAX_BUFFER_SIZE 256\r
27#define TIMEOUT_STALL_INTERVAL 10\r
28\r
29typedef struct {\r
30 UINT32 First;\r
31 UINT32 Last;\r
32 UINT32 Surplus;\r
33 UINT8 Data[SERIAL_MAX_BUFFER_SIZE];\r
34} SERIAL_DEV_FIFO;\r
35\r
36#define WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 's', 'i')\r
37typedef struct {\r
38 UINT64 Signature;\r
39\r
40 //\r
41 // Protocol data for the new handle we are going to add\r
42 //\r
43 EFI_HANDLE Handle;\r
44 EFI_SERIAL_IO_PROTOCOL SerialIo;\r
45 EFI_SERIAL_IO_MODE SerialIoMode;\r
46 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
47\r
48 //\r
49 // Private Data\r
50 //\r
51 EFI_HANDLE ControllerHandle;\r
52 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
53 UART_DEVICE_PATH UartDevicePath;\r
54 EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;\r
55\r
56 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
57\r
58 //\r
59 // Private NT type Data;\r
60 //\r
61 HANDLE NtHandle;\r
62 DCB NtDCB;\r
63 DWORD NtError;\r
64 COMSTAT NtComStatus;\r
65\r
66 BOOLEAN SoftwareLoopbackEnable;\r
67 BOOLEAN HardwareFlowControl;\r
68 BOOLEAN HardwareLoopbackEnable;\r
69\r
70 SERIAL_DEV_FIFO Fifo;\r
71\r
72} WIN_NT_SERIAL_IO_PRIVATE_DATA;\r
73\r
74#define WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS(a) \\r
75 CR(a, WIN_NT_SERIAL_IO_PRIVATE_DATA, SerialIo, WIN_NT_SERIAL_IO_PRIVATE_DATA_SIGNATURE)\r
76\r
77//\r
78// Global Protocol Variables\r
79//\r
80extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSerialIoDriverBinding;\r
81extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName;\r
82\r
83//\r
84// Macros to convert EFI serial types to NT serial types.\r
85//\r
86\r
87//\r
88// one second\r
89//\r
90#define SERIAL_TIMEOUT_DEFAULT (1000 * 1000) \r
91#define SERIAL_BAUD_DEFAULT 115200\r
92#define SERIAL_FIFO_DEFAULT 14\r
93#define SERIAL_DATABITS_DEFAULT 8\r
94#define SERIAL_PARITY_DEFAULT DefaultParity\r
95#define SERIAL_STOPBITS_DEFAULT DefaultStopBits\r
96\r
97#define SERIAL_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \\r
98 EFI_SERIAL_DATA_SET_READY | \\r
99 EFI_SERIAL_RING_INDICATE | \\r
100 EFI_SERIAL_CARRIER_DETECT | \\r
101 EFI_SERIAL_REQUEST_TO_SEND | \\r
102 EFI_SERIAL_DATA_TERMINAL_READY | \\r
103 EFI_SERIAL_INPUT_BUFFER_EMPTY)\r
104\r
105#define ConvertBaud2Nt(x) (DWORD) x\r
106#define ConvertData2Nt(x) (BYTE) x\r
107\r
108#define ConvertParity2Nt(x) \\r
109 (BYTE) ( \\r
110 x == DefaultParity ? NOPARITY : \\r
111 x == NoParity ? NOPARITY : \\r
112 x == EvenParity ? EVENPARITY : \\r
113 x == OddParity ? ODDPARITY : \\r
114 x == MarkParity ? MARKPARITY : \\r
115 x == SpaceParity ? SPACEPARITY : 0 \\r
116 )\r
117\r
118#define ConvertStop2Nt(x) \\r
119 (BYTE) ( \\r
120 x == DefaultParity ? ONESTOPBIT : \\r
121 x == OneFiveStopBits ? ONE5STOPBITS : \\r
122 x == TwoStopBits ? TWOSTOPBITS : 0 \\r
123 )\r
124\r
125#define ConvertTime2Nt(x) ((x) / 1000)\r
126\r
127//\r
128// 115400 baud with rounding errors\r
129//\r
130#define SERIAL_PORT_MAX_BAUD_RATE 115400 \r
131\r
132//\r
133// Function Prototypes\r
134//\r
135EFI_STATUS\r
136EFIAPI\r
137InitializeWinNtSerialIo (\r
138 IN EFI_HANDLE ImageHandle,\r
139 IN EFI_SYSTEM_TABLE *SystemTable\r
140 )\r
141/*++\r
142\r
143Routine Description:\r
144\r
145 TODO: Add function description\r
146\r
147Arguments:\r
148\r
149 ImageHandle - TODO: add argument description\r
150 SystemTable - TODO: add argument description\r
151\r
152Returns:\r
153\r
154 TODO: add return values\r
155\r
156--*/\r
157;\r
158\r
159STATIC\r
160EFI_STATUS\r
161EFIAPI\r
162WinNtSerialIoDriverBindingSupported (\r
163 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
164 IN EFI_HANDLE Handle,\r
165 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
166 )\r
167/*++\r
168\r
169Routine Description:\r
170\r
171 TODO: Add function description\r
172\r
173Arguments:\r
174\r
175 This - TODO: add argument description\r
176 Handle - TODO: add argument description\r
177 RemainingDevicePath - TODO: add argument description\r
178\r
179Returns:\r
180\r
181 TODO: add return values\r
182\r
183--*/\r
184;\r
185\r
186STATIC\r
187EFI_STATUS\r
188EFIAPI\r
189WinNtSerialIoDriverBindingStart (\r
190 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
191 IN EFI_HANDLE Handle,\r
192 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
193 )\r
194/*++\r
195\r
196Routine Description:\r
197\r
198 TODO: Add function description\r
199\r
200Arguments:\r
201\r
202 This - TODO: add argument description\r
203 Handle - TODO: add argument description\r
204 RemainingDevicePath - TODO: add argument description\r
205\r
206Returns:\r
207\r
208 TODO: add return values\r
209\r
210--*/\r
211;\r
212\r
213STATIC\r
214EFI_STATUS\r
215EFIAPI\r
216WinNtSerialIoDriverBindingStop (\r
217 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
218 IN EFI_HANDLE Handle,\r
219 IN UINTN NumberOfChildren,\r
220 IN EFI_HANDLE *ChildHandleBuffer\r
221 )\r
222/*++\r
223\r
224Routine Description:\r
225\r
226 TODO: Add function description\r
227\r
228Arguments:\r
229\r
230 This - TODO: add argument description\r
231 Handle - TODO: add argument description\r
232 NumberOfChildren - TODO: add argument description\r
233 ChildHandleBuffer - TODO: add argument description\r
234\r
235Returns:\r
236\r
237 TODO: add return values\r
238\r
239--*/\r
240;\r
241\r
242STATIC\r
243EFI_STATUS\r
244EFIAPI\r
245WinNtSerialIoReset (\r
246 IN EFI_SERIAL_IO_PROTOCOL *This\r
247 )\r
248/*++\r
249\r
250Routine Description:\r
251\r
252 TODO: Add function description\r
253\r
254Arguments:\r
255\r
256 This - TODO: add argument description\r
257\r
258Returns:\r
259\r
260 TODO: add return values\r
261\r
262--*/\r
263;\r
264\r
265STATIC\r
266EFI_STATUS\r
267EFIAPI\r
268WinNtSerialIoSetAttributes (\r
269 IN EFI_SERIAL_IO_PROTOCOL *This,\r
270 IN UINT64 BaudRate,\r
271 IN UINT32 ReceiveFifoDepth,\r
272 IN UINT32 Timeout,\r
273 IN EFI_PARITY_TYPE Parity,\r
274 IN UINT8 DataBits,\r
275 IN EFI_STOP_BITS_TYPE StopBits\r
276 )\r
277/*++\r
278\r
279Routine Description:\r
280\r
281 TODO: Add function description\r
282\r
283Arguments:\r
284\r
285 This - TODO: add argument description\r
286 BaudRate - TODO: add argument description\r
287 ReceiveFifoDepth - TODO: add argument description\r
288 Timeout - TODO: add argument description\r
289 Parity - TODO: add argument description\r
290 DataBits - TODO: add argument description\r
291 StopBits - TODO: add argument description\r
292\r
293Returns:\r
294\r
295 TODO: add return values\r
296\r
297--*/\r
298;\r
299\r
300STATIC\r
301EFI_STATUS\r
302EFIAPI\r
303WinNtSerialIoSetControl (\r
304 IN EFI_SERIAL_IO_PROTOCOL *This,\r
305 IN UINT32 Control\r
306 )\r
307/*++\r
308\r
309Routine Description:\r
310\r
311 TODO: Add function description\r
312\r
313Arguments:\r
314\r
315 This - TODO: add argument description\r
316 Control - TODO: add argument description\r
317\r
318Returns:\r
319\r
320 TODO: add return values\r
321\r
322--*/\r
323;\r
324\r
325STATIC\r
326EFI_STATUS\r
327EFIAPI\r
328WinNtSerialIoGetControl (\r
329 IN EFI_SERIAL_IO_PROTOCOL *This,\r
330 OUT UINT32 *Control\r
331 )\r
332/*++\r
333\r
334Routine Description:\r
335\r
336 TODO: Add function description\r
337\r
338Arguments:\r
339\r
340 This - TODO: add argument description\r
341 Control - TODO: add argument description\r
342\r
343Returns:\r
344\r
345 TODO: add return values\r
346\r
347--*/\r
348;\r
349\r
350STATIC\r
351EFI_STATUS\r
352EFIAPI\r
353WinNtSerialIoWrite (\r
354 IN EFI_SERIAL_IO_PROTOCOL *This,\r
355 IN OUT UINTN *BufferSize,\r
356 IN VOID *Buffer\r
357 )\r
358/*++\r
359\r
360Routine Description:\r
361\r
362 TODO: Add function description\r
363\r
364Arguments:\r
365\r
366 This - TODO: add argument description\r
367 BufferSize - TODO: add argument description\r
368 Buffer - TODO: add argument description\r
369\r
370Returns:\r
371\r
372 TODO: add return values\r
373\r
374--*/\r
375;\r
376\r
377STATIC\r
378EFI_STATUS\r
379EFIAPI\r
380WinNtSerialIoRead (\r
381 IN EFI_SERIAL_IO_PROTOCOL *This,\r
382 IN OUT UINTN *BufferSize,\r
383 OUT VOID *Buffer\r
384 )\r
385/*++\r
386\r
387Routine Description:\r
388\r
389 TODO: Add function description\r
390\r
391Arguments:\r
392\r
393 This - TODO: add argument description\r
394 BufferSize - TODO: add argument description\r
395 Buffer - TODO: add argument description\r
396\r
397Returns:\r
398\r
399 TODO: add return values\r
400\r
401--*/\r
402;\r
403\r
404BOOLEAN\r
405IsaSerialFifoFull (\r
406 IN SERIAL_DEV_FIFO *Fifo\r
407 )\r
408/*++\r
409\r
410Routine Description:\r
411\r
412 TODO: Add function description\r
413\r
414Arguments:\r
415\r
416 Fifo - TODO: add argument description\r
417\r
418Returns:\r
419\r
420 TODO: add return values\r
421\r
422--*/\r
423;\r
424\r
425BOOLEAN\r
426IsaSerialFifoEmpty (\r
427 IN SERIAL_DEV_FIFO *Fifo\r
428 )\r
429/*++\r
430\r
431Routine Description:\r
432\r
433 TODO: Add function description\r
434\r
435Arguments:\r
436\r
437 Fifo - TODO: add argument description\r
438\r
439Returns:\r
440\r
441 TODO: add return values\r
442\r
443--*/\r
444;\r
445\r
446EFI_STATUS\r
447IsaSerialFifoAdd (\r
448 IN SERIAL_DEV_FIFO *Fifo,\r
449 IN UINT8 Data\r
450 )\r
451/*++\r
452\r
453Routine Description:\r
454\r
455 TODO: Add function description\r
456\r
457Arguments:\r
458\r
459 Fifo - TODO: add argument description\r
460 Data - TODO: add argument description\r
461\r
462Returns:\r
463\r
464 TODO: add return values\r
465\r
466--*/\r
467;\r
468\r
469EFI_STATUS\r
470IsaSerialFifoRemove (\r
471 IN SERIAL_DEV_FIFO *Fifo,\r
472 OUT UINT8 *Data\r
473 )\r
474/*++\r
475\r
476Routine Description:\r
477\r
478 TODO: Add function description\r
479\r
480Arguments:\r
481\r
482 Fifo - TODO: add argument description\r
483 Data - TODO: add argument description\r
484\r
485Returns:\r
486\r
487 TODO: add return values\r
488\r
489--*/\r
490;\r
491\r
492EFI_STATUS\r
493IsaSerialReceiveTransmit (\r
494 WIN_NT_SERIAL_IO_PRIVATE_DATA *Private\r
495 )\r
496/*++\r
497\r
498Routine Description:\r
499\r
500 TODO: Add function description\r
501\r
502Arguments:\r
503\r
504 Private - TODO: add argument description\r
505\r
506Returns:\r
507\r
508 TODO: add return values\r
509\r
510--*/\r
511;\r
512\r
513#endif\r