]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.h
affc392b511dbf1bf09c49fecf4aca92bdf2ed1e
[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
108 //
109 // Macros to convert EFI serial types to NT serial types.
110 //
111
112 //
113 // one second
114 //
115 #define SERIAL_TIMEOUT_DEFAULT (1000 * 1000)
116 #define SERIAL_BAUD_DEFAULT 115200
117 #define SERIAL_FIFO_DEFAULT 14
118 #define SERIAL_DATABITS_DEFAULT 8
119 #define SERIAL_PARITY_DEFAULT DefaultParity
120 #define SERIAL_STOPBITS_DEFAULT DefaultStopBits
121
122 #define SERIAL_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \
123 EFI_SERIAL_DATA_SET_READY | \
124 EFI_SERIAL_RING_INDICATE | \
125 EFI_SERIAL_CARRIER_DETECT | \
126 EFI_SERIAL_REQUEST_TO_SEND | \
127 EFI_SERIAL_DATA_TERMINAL_READY | \
128 EFI_SERIAL_INPUT_BUFFER_EMPTY)
129
130 #define ConvertBaud2Nt(x) (DWORD) x
131 #define ConvertData2Nt(x) (BYTE) x
132
133 #define ConvertParity2Nt(x) \
134 (BYTE) ( \
135 x == DefaultParity ? NOPARITY : \
136 x == NoParity ? NOPARITY : \
137 x == EvenParity ? EVENPARITY : \
138 x == OddParity ? ODDPARITY : \
139 x == MarkParity ? MARKPARITY : \
140 x == SpaceParity ? SPACEPARITY : 0 \
141 )
142
143 #define ConvertStop2Nt(x) \
144 (BYTE) ( \
145 x == DefaultParity ? ONESTOPBIT : \
146 x == OneFiveStopBits ? ONE5STOPBITS : \
147 x == TwoStopBits ? TWOSTOPBITS : 0 \
148 )
149
150 #define ConvertTime2Nt(x) ((x) / 1000)
151
152 //
153 // 115400 baud with rounding errors
154 //
155 #define SERIAL_PORT_MAX_BAUD_RATE 115400
156
157 //
158 // Function Prototypes
159 //
160 EFI_STATUS
161 EFIAPI
162 InitializeWinNtSerialIo (
163 IN EFI_HANDLE ImageHandle,
164 IN EFI_SYSTEM_TABLE *SystemTable
165 )
166 /*++
167
168 Routine Description:
169
170 TODO: Add function description
171
172 Arguments:
173
174 ImageHandle - TODO: add argument description
175 SystemTable - TODO: add argument description
176
177 Returns:
178
179 TODO: add return values
180
181 --*/
182 ;
183
184 STATIC
185 EFI_STATUS
186 EFIAPI
187 WinNtSerialIoDriverBindingSupported (
188 IN EFI_DRIVER_BINDING_PROTOCOL *This,
189 IN EFI_HANDLE Handle,
190 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
191 )
192 /*++
193
194 Routine Description:
195
196 TODO: Add function description
197
198 Arguments:
199
200 This - TODO: add argument description
201 Handle - TODO: add argument description
202 RemainingDevicePath - TODO: add argument description
203
204 Returns:
205
206 TODO: add return values
207
208 --*/
209 ;
210
211 STATIC
212 EFI_STATUS
213 EFIAPI
214 WinNtSerialIoDriverBindingStart (
215 IN EFI_DRIVER_BINDING_PROTOCOL *This,
216 IN EFI_HANDLE Handle,
217 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
218 )
219 /*++
220
221 Routine Description:
222
223 TODO: Add function description
224
225 Arguments:
226
227 This - TODO: add argument description
228 Handle - TODO: add argument description
229 RemainingDevicePath - TODO: add argument description
230
231 Returns:
232
233 TODO: add return values
234
235 --*/
236 ;
237
238 STATIC
239 EFI_STATUS
240 EFIAPI
241 WinNtSerialIoDriverBindingStop (
242 IN EFI_DRIVER_BINDING_PROTOCOL *This,
243 IN EFI_HANDLE Handle,
244 IN UINTN NumberOfChildren,
245 IN EFI_HANDLE *ChildHandleBuffer
246 )
247 /*++
248
249 Routine Description:
250
251 TODO: Add function description
252
253 Arguments:
254
255 This - TODO: add argument description
256 Handle - TODO: add argument description
257 NumberOfChildren - TODO: add argument description
258 ChildHandleBuffer - TODO: add argument description
259
260 Returns:
261
262 TODO: add return values
263
264 --*/
265 ;
266
267 STATIC
268 EFI_STATUS
269 EFIAPI
270 WinNtSerialIoReset (
271 IN EFI_SERIAL_IO_PROTOCOL *This
272 )
273 /*++
274
275 Routine Description:
276
277 TODO: Add function description
278
279 Arguments:
280
281 This - TODO: add argument description
282
283 Returns:
284
285 TODO: add return values
286
287 --*/
288 ;
289
290 STATIC
291 EFI_STATUS
292 EFIAPI
293 WinNtSerialIoSetAttributes (
294 IN EFI_SERIAL_IO_PROTOCOL *This,
295 IN UINT64 BaudRate,
296 IN UINT32 ReceiveFifoDepth,
297 IN UINT32 Timeout,
298 IN EFI_PARITY_TYPE Parity,
299 IN UINT8 DataBits,
300 IN EFI_STOP_BITS_TYPE StopBits
301 )
302 /*++
303
304 Routine Description:
305
306 TODO: Add function description
307
308 Arguments:
309
310 This - TODO: add argument description
311 BaudRate - TODO: add argument description
312 ReceiveFifoDepth - TODO: add argument description
313 Timeout - TODO: add argument description
314 Parity - TODO: add argument description
315 DataBits - TODO: add argument description
316 StopBits - TODO: add argument description
317
318 Returns:
319
320 TODO: add return values
321
322 --*/
323 ;
324
325 STATIC
326 EFI_STATUS
327 EFIAPI
328 WinNtSerialIoSetControl (
329 IN EFI_SERIAL_IO_PROTOCOL *This,
330 IN UINT32 Control
331 )
332 /*++
333
334 Routine Description:
335
336 TODO: Add function description
337
338 Arguments:
339
340 This - TODO: add argument description
341 Control - TODO: add argument description
342
343 Returns:
344
345 TODO: add return values
346
347 --*/
348 ;
349
350 STATIC
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 STATIC
376 EFI_STATUS
377 EFIAPI
378 WinNtSerialIoWrite (
379 IN EFI_SERIAL_IO_PROTOCOL *This,
380 IN OUT UINTN *BufferSize,
381 IN VOID *Buffer
382 )
383 /*++
384
385 Routine Description:
386
387 TODO: Add function description
388
389 Arguments:
390
391 This - TODO: add argument description
392 BufferSize - TODO: add argument description
393 Buffer - TODO: add argument description
394
395 Returns:
396
397 TODO: add return values
398
399 --*/
400 ;
401
402 STATIC
403 EFI_STATUS
404 EFIAPI
405 WinNtSerialIoRead (
406 IN EFI_SERIAL_IO_PROTOCOL *This,
407 IN OUT UINTN *BufferSize,
408 OUT VOID *Buffer
409 )
410 /*++
411
412 Routine Description:
413
414 TODO: Add function description
415
416 Arguments:
417
418 This - TODO: add argument description
419 BufferSize - TODO: add argument description
420 Buffer - TODO: add argument description
421
422 Returns:
423
424 TODO: add return values
425
426 --*/
427 ;
428
429 BOOLEAN
430 IsaSerialFifoFull (
431 IN SERIAL_DEV_FIFO *Fifo
432 )
433 /*++
434
435 Routine Description:
436
437 TODO: Add function description
438
439 Arguments:
440
441 Fifo - TODO: add argument description
442
443 Returns:
444
445 TODO: add return values
446
447 --*/
448 ;
449
450 BOOLEAN
451 IsaSerialFifoEmpty (
452 IN SERIAL_DEV_FIFO *Fifo
453 )
454 /*++
455
456 Routine Description:
457
458 TODO: Add function description
459
460 Arguments:
461
462 Fifo - TODO: add argument description
463
464 Returns:
465
466 TODO: add return values
467
468 --*/
469 ;
470
471 EFI_STATUS
472 IsaSerialFifoAdd (
473 IN SERIAL_DEV_FIFO *Fifo,
474 IN UINT8 Data
475 )
476 /*++
477
478 Routine Description:
479
480 TODO: Add function description
481
482 Arguments:
483
484 Fifo - TODO: add argument description
485 Data - TODO: add argument description
486
487 Returns:
488
489 TODO: add return values
490
491 --*/
492 ;
493
494 EFI_STATUS
495 IsaSerialFifoRemove (
496 IN SERIAL_DEV_FIFO *Fifo,
497 OUT UINT8 *Data
498 )
499 /*++
500
501 Routine Description:
502
503 TODO: Add function description
504
505 Arguments:
506
507 Fifo - TODO: add argument description
508 Data - TODO: add argument description
509
510 Returns:
511
512 TODO: add return values
513
514 --*/
515 ;
516
517 EFI_STATUS
518 IsaSerialReceiveTransmit (
519 WIN_NT_SERIAL_IO_PRIVATE_DATA *Private
520 )
521 /*++
522
523 Routine Description:
524
525 TODO: Add function description
526
527 Arguments:
528
529 Private - TODO: add argument description
530
531 Returns:
532
533 TODO: add return values
534
535 --*/
536 ;
537
538 #endif