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