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