]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h
Back the wrong check in for MdeModulePkg.dsc.
[mirror_edk2.git] / Nt32Pkg / WinNtSerialIoDxe / WinNtSerialIo.h
1 /*++
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 EFI_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 STATIC
192 EFI_STATUS
193 EFIAPI
194 WinNtSerialIoDriverBindingSupported (
195 IN EFI_DRIVER_BINDING_PROTOCOL *This,
196 IN EFI_HANDLE Handle,
197 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
198 )
199 /*++
200
201 Routine Description:
202
203 TODO: Add function description
204
205 Arguments:
206
207 This - TODO: add argument description
208 Handle - TODO: add argument description
209 RemainingDevicePath - TODO: add argument description
210
211 Returns:
212
213 TODO: add return values
214
215 --*/
216 ;
217
218 STATIC
219 EFI_STATUS
220 EFIAPI
221 WinNtSerialIoDriverBindingStart (
222 IN EFI_DRIVER_BINDING_PROTOCOL *This,
223 IN EFI_HANDLE Handle,
224 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
225 )
226 /*++
227
228 Routine Description:
229
230 TODO: Add function description
231
232 Arguments:
233
234 This - TODO: add argument description
235 Handle - TODO: add argument description
236 RemainingDevicePath - TODO: add argument description
237
238 Returns:
239
240 TODO: add return values
241
242 --*/
243 ;
244
245 STATIC
246 EFI_STATUS
247 EFIAPI
248 WinNtSerialIoDriverBindingStop (
249 IN EFI_DRIVER_BINDING_PROTOCOL *This,
250 IN EFI_HANDLE Handle,
251 IN UINTN NumberOfChildren,
252 IN EFI_HANDLE *ChildHandleBuffer
253 )
254 /*++
255
256 Routine Description:
257
258 TODO: Add function description
259
260 Arguments:
261
262 This - TODO: add argument description
263 Handle - TODO: add argument description
264 NumberOfChildren - TODO: add argument description
265 ChildHandleBuffer - TODO: add argument description
266
267 Returns:
268
269 TODO: add return values
270
271 --*/
272 ;
273
274 STATIC
275 EFI_STATUS
276 EFIAPI
277 WinNtSerialIoReset (
278 IN EFI_SERIAL_IO_PROTOCOL *This
279 )
280 /*++
281
282 Routine Description:
283
284 TODO: Add function description
285
286 Arguments:
287
288 This - TODO: add argument description
289
290 Returns:
291
292 TODO: add return values
293
294 --*/
295 ;
296
297 STATIC
298 EFI_STATUS
299 EFIAPI
300 WinNtSerialIoSetAttributes (
301 IN EFI_SERIAL_IO_PROTOCOL *This,
302 IN UINT64 BaudRate,
303 IN UINT32 ReceiveFifoDepth,
304 IN UINT32 Timeout,
305 IN EFI_PARITY_TYPE Parity,
306 IN UINT8 DataBits,
307 IN EFI_STOP_BITS_TYPE StopBits
308 )
309 /*++
310
311 Routine Description:
312
313 TODO: Add function description
314
315 Arguments:
316
317 This - TODO: add argument description
318 BaudRate - TODO: add argument description
319 ReceiveFifoDepth - TODO: add argument description
320 Timeout - TODO: add argument description
321 Parity - TODO: add argument description
322 DataBits - TODO: add argument description
323 StopBits - TODO: add argument description
324
325 Returns:
326
327 TODO: add return values
328
329 --*/
330 ;
331
332 STATIC
333 EFI_STATUS
334 EFIAPI
335 WinNtSerialIoSetControl (
336 IN EFI_SERIAL_IO_PROTOCOL *This,
337 IN UINT32 Control
338 )
339 /*++
340
341 Routine Description:
342
343 TODO: Add function description
344
345 Arguments:
346
347 This - TODO: add argument description
348 Control - TODO: add argument description
349
350 Returns:
351
352 TODO: add return values
353
354 --*/
355 ;
356
357 STATIC
358 EFI_STATUS
359 EFIAPI
360 WinNtSerialIoGetControl (
361 IN EFI_SERIAL_IO_PROTOCOL *This,
362 OUT UINT32 *Control
363 )
364 /*++
365
366 Routine Description:
367
368 TODO: Add function description
369
370 Arguments:
371
372 This - TODO: add argument description
373 Control - TODO: add argument description
374
375 Returns:
376
377 TODO: add return values
378
379 --*/
380 ;
381
382 STATIC
383 EFI_STATUS
384 EFIAPI
385 WinNtSerialIoWrite (
386 IN EFI_SERIAL_IO_PROTOCOL *This,
387 IN OUT UINTN *BufferSize,
388 IN VOID *Buffer
389 )
390 /*++
391
392 Routine Description:
393
394 TODO: Add function description
395
396 Arguments:
397
398 This - TODO: add argument description
399 BufferSize - TODO: add argument description
400 Buffer - TODO: add argument description
401
402 Returns:
403
404 TODO: add return values
405
406 --*/
407 ;
408
409 STATIC
410 EFI_STATUS
411 EFIAPI
412 WinNtSerialIoRead (
413 IN EFI_SERIAL_IO_PROTOCOL *This,
414 IN OUT UINTN *BufferSize,
415 OUT VOID *Buffer
416 )
417 /*++
418
419 Routine Description:
420
421 TODO: Add function description
422
423 Arguments:
424
425 This - TODO: add argument description
426 BufferSize - TODO: add argument description
427 Buffer - TODO: add argument description
428
429 Returns:
430
431 TODO: add return values
432
433 --*/
434 ;
435
436 BOOLEAN
437 IsaSerialFifoFull (
438 IN SERIAL_DEV_FIFO *Fifo
439 )
440 /*++
441
442 Routine Description:
443
444 TODO: Add function description
445
446 Arguments:
447
448 Fifo - TODO: add argument description
449
450 Returns:
451
452 TODO: add return values
453
454 --*/
455 ;
456
457 BOOLEAN
458 IsaSerialFifoEmpty (
459 IN SERIAL_DEV_FIFO *Fifo
460 )
461 /*++
462
463 Routine Description:
464
465 TODO: Add function description
466
467 Arguments:
468
469 Fifo - TODO: add argument description
470
471 Returns:
472
473 TODO: add return values
474
475 --*/
476 ;
477
478 EFI_STATUS
479 IsaSerialFifoAdd (
480 IN SERIAL_DEV_FIFO *Fifo,
481 IN UINT8 Data
482 )
483 /*++
484
485 Routine Description:
486
487 TODO: Add function description
488
489 Arguments:
490
491 Fifo - TODO: add argument description
492 Data - TODO: add argument description
493
494 Returns:
495
496 TODO: add return values
497
498 --*/
499 ;
500
501 EFI_STATUS
502 IsaSerialFifoRemove (
503 IN SERIAL_DEV_FIFO *Fifo,
504 OUT UINT8 *Data
505 )
506 /*++
507
508 Routine Description:
509
510 TODO: Add function description
511
512 Arguments:
513
514 Fifo - TODO: add argument description
515 Data - TODO: add argument description
516
517 Returns:
518
519 TODO: add return values
520
521 --*/
522 ;
523
524 EFI_STATUS
525 IsaSerialReceiveTransmit (
526 WIN_NT_SERIAL_IO_PRIVATE_DATA *Private
527 )
528 /*++
529
530 Routine Description:
531
532 TODO: Add function description
533
534 Arguments:
535
536 Private - TODO: add argument description
537
538 Returns:
539
540 TODO: add return values
541
542 --*/
543 ;
544
545 #endif