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