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