]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h
Remove extra #includes where possible to make build more efficient
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaSerialDxe / Serial.h
CommitLineData
91c68197 1/** @file\r
637ff819 2 Include for Serial Driver\r
f8cd287b 3 \r
91c68197 4Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r
f8cd287b 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
637ff819 9\r
f8cd287b 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
637ff819 12\r
f8cd287b 13**/\r
637ff819 14\r
91c68197
LG
15#ifndef _SERIAL_H_\r
16#define _SERIAL_H_\r
637ff819 17\r
ed7748fe 18\r
79bc7a89 19#include <FrameworkDxe.h>\r
ed7748fe 20\r
637ff819 21#include <Protocol/IsaIo.h>\r
22#include <Protocol/SerialIo.h>\r
23#include <Protocol/DevicePath.h>\r
ed7748fe 24\r
637ff819 25#include <Library/DebugLib.h>\r
26#include <Library/UefiDriverEntryPoint.h>\r
27#include <Library/BaseLib.h>\r
28#include <Library/UefiLib.h>\r
29#include <Library/DevicePathLib.h>\r
30#include <Library/BaseMemoryLib.h>\r
31#include <Library/MemoryAllocationLib.h>\r
32#include <Library/UefiBootServicesTableLib.h>\r
33#include <Library/ReportStatusCodeLib.h>\r
34#include <Library/PcdLib.h>\r
91c68197 35\r
637ff819 36//\r
37// Driver Binding Externs\r
38//\r
f3d08ccf 39extern EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver;\r
40extern EFI_COMPONENT_NAME_PROTOCOL gIsaSerialComponentName;\r
41extern EFI_COMPONENT_NAME2_PROTOCOL gIsaSerialComponentName2;\r
637ff819 42\r
43//\r
44// Internal Data Structures\r
45//\r
f02bd376 46#define SERIAL_DEV_SIGNATURE SIGNATURE_32 ('s', 'e', 'r', 'd')\r
637ff819 47#define SERIAL_MAX_BUFFER_SIZE 16\r
48#define TIMEOUT_STALL_INTERVAL 10\r
49\r
50//\r
51// Name: SERIAL_DEV_FIFO\r
52// Purpose: To define Receive FIFO and Transmit FIFO\r
53// Context: Used by serial data transmit and receive\r
54// Fields:\r
55// First UINT32: The index of the first data in array Data[]\r
56// Last UINT32: The index, which you can put a new data into array Data[]\r
57// Surplus UINT32: Identify how many data you can put into array Data[]\r
58// Data[] UINT8 : An array, which used to store data\r
59//\r
60typedef struct {\r
61 UINT32 First;\r
62 UINT32 Last;\r
63 UINT32 Surplus;\r
64 UINT8 Data[SERIAL_MAX_BUFFER_SIZE];\r
65} SERIAL_DEV_FIFO;\r
66\r
67typedef enum {\r
91c68197
LG
68 Uart8250 = 0,\r
69 Uart16450 = 1,\r
70 Uart16550 = 2,\r
71 Uart16550A= 3\r
637ff819 72} EFI_UART_TYPE;\r
73\r
74//\r
75// Name: SERIAL_DEV\r
76// Purpose: To provide device specific information\r
77// Context:\r
78// Fields:\r
79// Signature UINTN: The identity of the serial device\r
80// SerialIo SERIAL_IO_PROTOCOL: Serial I/O protocol interface\r
81// SerialMode SERIAL_IO_MODE:\r
82// DevicePath EFI_DEVICE_PATH_PROTOCOL *: Device path of the serial device\r
83// Handle EFI_HANDLE: The handle instance attached to serial device\r
84// BaseAddress UINT16: The base address of specific serial device\r
85// Receive SERIAL_DEV_FIFO: The FIFO used to store data,\r
86// which is received by UART\r
87// Transmit SERIAL_DEV_FIFO: The FIFO used to store data,\r
88// which you want to transmit by UART\r
89// SoftwareLoopbackEnable BOOLEAN:\r
90// Type EFI_UART_TYPE: Specify the UART type of certain serial device\r
91//\r
92typedef struct {\r
93 UINTN Signature;\r
94\r
95 EFI_HANDLE Handle;\r
96 EFI_SERIAL_IO_PROTOCOL SerialIo;\r
97 EFI_SERIAL_IO_MODE SerialMode;\r
98 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
99\r
100 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
101 UART_DEVICE_PATH UartDevicePath;\r
102 EFI_ISA_IO_PROTOCOL *IsaIo;\r
103\r
104 UINT16 BaseAddress;\r
105 SERIAL_DEV_FIFO Receive;\r
106 SERIAL_DEV_FIFO Transmit;\r
107 BOOLEAN SoftwareLoopbackEnable;\r
108 BOOLEAN HardwareFlowControl;\r
109 EFI_UART_TYPE Type;\r
110 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
111} SERIAL_DEV;\r
112\r
637ff819 113#define SERIAL_DEV_FROM_THIS(a) CR (a, SERIAL_DEV, SerialIo, SERIAL_DEV_SIGNATURE)\r
114\r
637ff819 115//\r
116// Serial Driver Defaults\r
117//\r
637ff819 118#define SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH 1\r
119#define SERIAL_PORT_DEFAULT_TIMEOUT 1000000\r
637ff819 120#define SERIAL_PORT_DEFAULT_CONTROL_MASK 0\r
121\r
6b88ceec 122\r
637ff819 123//\r
124// (24000000/13)MHz input clock\r
125//\r
126#define SERIAL_PORT_INPUT_CLOCK 1843200\r
127\r
128//\r
129// 115200 baud with rounding errors\r
130//\r
131#define SERIAL_PORT_MAX_BAUD_RATE 115400\r
132#define SERIAL_PORT_MIN_BAUD_RATE 50\r
133\r
134#define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH 16\r
135#define SERIAL_PORT_MIN_TIMEOUT 1 // 1 uS\r
136#define SERIAL_PORT_MAX_TIMEOUT 100000000 // 100 seconds\r
137//\r
138// UART Registers\r
139//\r
140#define SERIAL_REGISTER_THR 0 // WO Transmit Holding Register\r
141#define SERIAL_REGISTER_RBR 0 // RO Receive Buffer Register\r
142#define SERIAL_REGISTER_DLL 0 // R/W Divisor Latch LSB\r
143#define SERIAL_REGISTER_DLM 1 // R/W Divisor Latch MSB\r
144#define SERIAL_REGISTER_IER 1 // R/W Interrupt Enable Register\r
145#define SERIAL_REGISTER_IIR 2 // RO Interrupt Identification Register\r
146#define SERIAL_REGISTER_FCR 2 // WO FIFO Cotrol Register\r
147#define SERIAL_REGISTER_LCR 3 // R/W Line Control Register\r
148#define SERIAL_REGISTER_MCR 4 // R/W Modem Control Register\r
149#define SERIAL_REGISTER_LSR 5 // R/W Line Status Register\r
150#define SERIAL_REGISTER_MSR 6 // R/W Modem Status Register\r
151#define SERIAL_REGISTER_SCR 7 // R/W Scratch Pad Register\r
152#pragma pack(1)\r
153//\r
154// Name: SERIAL_PORT_IER_BITS\r
155// Purpose: Define each bit in Interrupt Enable Register\r
156// Context:\r
157// Fields:\r
91c68197
LG
158// Ravie Bit0: Receiver Data Available Interrupt Enable\r
159// Theie Bit1: Transmistter Holding Register Empty Interrupt Enable\r
160// Rie Bit2: Receiver Interrupt Enable\r
161// Mie Bit3: Modem Interrupt Enable\r
637ff819 162// Reserved Bit4-Bit7: Reserved\r
163//\r
164typedef struct {\r
91c68197
LG
165 UINT8 Ravie : 1;\r
166 UINT8 Theie : 1;\r
167 UINT8 Rie : 1;\r
168 UINT8 Mie : 1;\r
637ff819 169 UINT8 Reserved : 4;\r
170} SERIAL_PORT_IER_BITS;\r
171\r
172//\r
173// Name: SERIAL_PORT_IER\r
174// Purpose:\r
175// Context:\r
176// Fields:\r
177// Bits SERIAL_PORT_IER_BITS: Bits of the IER\r
178// Data UINT8: the value of the IER\r
179//\r
180typedef union {\r
181 SERIAL_PORT_IER_BITS Bits;\r
182 UINT8 Data;\r
183} SERIAL_PORT_IER;\r
184\r
637ff819 185//\r
186// Name: SERIAL_PORT_FCR_BITS\r
187// Purpose: Define each bit in FIFO Control Register\r
188// Context:\r
189// Fields:\r
91c68197
LG
190// TrFIFOE Bit0: Transmit and Receive FIFO Enable\r
191// ResetRF Bit1: Reset Reciever FIFO\r
192// ResetTF Bit2: Reset Transmistter FIFO\r
193// Dms Bit3: DMA Mode Select\r
637ff819 194// Reserved Bit4-Bit5: Reserved\r
91c68197 195// Rtb Bit6-Bit7: Receive Trigger Bits\r
637ff819 196//\r
197typedef struct {\r
91c68197
LG
198 UINT8 TrFIFOE : 1;\r
199 UINT8 ResetRF : 1;\r
200 UINT8 ResetTF : 1;\r
201 UINT8 Dms : 1;\r
637ff819 202 UINT8 Reserved : 2;\r
91c68197 203 UINT8 Rtb : 2;\r
637ff819 204} SERIAL_PORT_FCR_BITS;\r
205\r
206//\r
207// Name: SERIAL_PORT_FCR\r
208// Purpose:\r
209// Context:\r
210// Fields:\r
211// Bits SERIAL_PORT_FCR_BITS: Bits of the FCR\r
212// Data UINT8: the value of the FCR\r
213//\r
214typedef union {\r
215 SERIAL_PORT_FCR_BITS Bits;\r
216 UINT8 Data;\r
217} SERIAL_PORT_FCR;\r
218\r
219//\r
220// Name: SERIAL_PORT_LCR_BITS\r
221// Purpose: Define each bit in Line Control Register\r
222// Context:\r
223// Fields:\r
91c68197
LG
224// SerialDB Bit0-Bit1: Number of Serial Data Bits\r
225// StopB Bit2: Number of Stop Bits\r
226// ParEn Bit3: Parity Enable\r
227// EvenPar Bit4: Even Parity Select\r
228// SticPar Bit5: Sticky Parity\r
229// BrCon Bit6: Break Control\r
230// DLab Bit7: Divisor Latch Access Bit\r
637ff819 231//\r
232typedef struct {\r
91c68197
LG
233 UINT8 SerialDB : 2;\r
234 UINT8 StopB : 1;\r
235 UINT8 ParEn : 1;\r
236 UINT8 EvenPar : 1;\r
237 UINT8 SticPar : 1;\r
238 UINT8 BrCon : 1;\r
239 UINT8 DLab : 1;\r
637ff819 240} SERIAL_PORT_LCR_BITS;\r
241\r
242//\r
243// Name: SERIAL_PORT_LCR\r
244// Purpose:\r
245// Context:\r
246// Fields:\r
247// Bits SERIAL_PORT_LCR_BITS: Bits of the LCR\r
248// Data UINT8: the value of the LCR\r
249//\r
250typedef union {\r
251 SERIAL_PORT_LCR_BITS Bits;\r
252 UINT8 Data;\r
253} SERIAL_PORT_LCR;\r
254\r
255//\r
256// Name: SERIAL_PORT_MCR_BITS\r
257// Purpose: Define each bit in Modem Control Register\r
258// Context:\r
259// Fields:\r
91c68197
LG
260// DtrC Bit0: Data Terminal Ready Control\r
261// Rts Bit1: Request To Send Control\r
262// Out1 Bit2: Output1\r
263// Out2 Bit3: Output2, used to disable interrupt\r
264// Lme; Bit4: Loopback Mode Enable\r
637ff819 265// Reserved Bit5-Bit7: Reserved\r
266//\r
267typedef struct {\r
91c68197
LG
268 UINT8 DtrC : 1;\r
269 UINT8 Rts : 1;\r
270 UINT8 Out1 : 1;\r
271 UINT8 Out2 : 1;\r
272 UINT8 Lme : 1;\r
637ff819 273 UINT8 Reserved : 3;\r
274} SERIAL_PORT_MCR_BITS;\r
275\r
276//\r
277// Name: SERIAL_PORT_MCR\r
278// Purpose:\r
279// Context:\r
280// Fields:\r
281// Bits SERIAL_PORT_MCR_BITS: Bits of the MCR\r
282// Data UINT8: the value of the MCR\r
283//\r
284typedef union {\r
285 SERIAL_PORT_MCR_BITS Bits;\r
286 UINT8 Data;\r
287} SERIAL_PORT_MCR;\r
288\r
289//\r
290// Name: SERIAL_PORT_LSR_BITS\r
291// Purpose: Define each bit in Line Status Register\r
292// Context:\r
293// Fields:\r
91c68197
LG
294// Dr Bit0: Receiver Data Ready Status\r
295// Oe Bit1: Overrun Error Status\r
296// Pe Bit2: Parity Error Status\r
297// Fe Bit3: Framing Error Status\r
298// Bi Bit4: Break Interrupt Status\r
299// Thre Bit5: Transmistter Holding Register Status\r
300// Temt Bit6: Transmitter Empty Status\r
301// FIFOe Bit7: FIFO Error Status\r
637ff819 302//\r
303typedef struct {\r
91c68197
LG
304 UINT8 Dr : 1;\r
305 UINT8 Oe : 1;\r
306 UINT8 Pe : 1;\r
307 UINT8 Fe : 1;\r
308 UINT8 Bi : 1;\r
309 UINT8 Thre : 1;\r
310 UINT8 Temt : 1;\r
311 UINT8 FIFOe : 1;\r
637ff819 312} SERIAL_PORT_LSR_BITS;\r
313\r
314//\r
315// Name: SERIAL_PORT_LSR\r
316// Purpose:\r
317// Context:\r
318// Fields:\r
319// Bits SERIAL_PORT_LSR_BITS: Bits of the LSR\r
320// Data UINT8: the value of the LSR\r
321//\r
322typedef union {\r
323 SERIAL_PORT_LSR_BITS Bits;\r
324 UINT8 Data;\r
325} SERIAL_PORT_LSR;\r
326\r
327//\r
328// Name: SERIAL_PORT_MSR_BITS\r
329// Purpose: Define each bit in Modem Status Register\r
330// Context:\r
331// Fields:\r
332// DeltaCTS Bit0: Delta Clear To Send Status\r
333// DeltaDSR Bit1: Delta Data Set Ready Status\r
334// TrailingEdgeRI Bit2: Trailing Edge of Ring Indicator Status\r
335// DeltaDCD Bit3: Delta Data Carrier Detect Status\r
91c68197
LG
336// Cts Bit4: Clear To Send Status\r
337// Dsr Bit5: Data Set Ready Status\r
338// Ri Bit6: Ring Indicator Status\r
339// Dcd Bit7: Data Carrier Detect Status\r
637ff819 340//\r
341typedef struct {\r
342 UINT8 DeltaCTS : 1;\r
343 UINT8 DeltaDSR : 1;\r
344 UINT8 TrailingEdgeRI : 1;\r
345 UINT8 DeltaDCD : 1;\r
91c68197
LG
346 UINT8 Cts : 1;\r
347 UINT8 Dsr : 1;\r
348 UINT8 Ri : 1;\r
349 UINT8 Dcd : 1;\r
637ff819 350} SERIAL_PORT_MSR_BITS;\r
351\r
352//\r
353// Name: SERIAL_PORT_MSR\r
354// Purpose:\r
355// Context:\r
356// Fields:\r
357// Bits SERIAL_PORT_MSR_BITS: Bits of the MSR\r
358// Data UINT8: the value of the MSR\r
359//\r
360typedef union {\r
361 SERIAL_PORT_MSR_BITS Bits;\r
362 UINT8 Data;\r
363} SERIAL_PORT_MSR;\r
364\r
365#pragma pack()\r
366//\r
367// Define serial register I/O macros\r
368//\r
369#define READ_RBR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_RBR)\r
370#define READ_DLL(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLL)\r
371#define READ_DLM(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLM)\r
372#define READ_IER(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_IER)\r
373#define READ_IIR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_IIR)\r
374#define READ_LCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_LCR)\r
375#define READ_MCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_MCR)\r
376#define READ_LSR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_LSR)\r
377#define READ_MSR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_MSR)\r
378#define READ_SCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_SCR)\r
379\r
380#define WRITE_THR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_THR, D)\r
381#define WRITE_DLL(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLL, D)\r
382#define WRITE_DLM(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLM, D)\r
383#define WRITE_IER(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_IER, D)\r
384#define WRITE_FCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_FCR, D)\r
385#define WRITE_LCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LCR, D)\r
386#define WRITE_MCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MCR, D)\r
387#define WRITE_LSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LSR, D)\r
388#define WRITE_MSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MSR, D)\r
389#define WRITE_SCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_SCR, D)\r
390\r
391//\r
392// Prototypes\r
393// Driver model protocol interface\r
394//\r
91c68197
LG
395/**\r
396 Check to see if this driver supports the given controller\r
637ff819 397\r
91c68197
LG
398 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
399 @param Controller The handle of the controller to test.\r
400 @param RemainingDevicePath A pointer to the remaining portion of a device path.\r
401\r
402 @return EFI_SUCCESS This driver can support the given controller\r
403\r
404**/\r
637ff819 405EFI_STATUS\r
406EFIAPI\r
407SerialControllerDriverSupported (\r
408 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
409 IN EFI_HANDLE Controller,\r
410 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
411 );\r
412\r
91c68197
LG
413/**\r
414 Start to management the controller passed in\r
415\r
416 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
417 @param Controller The handle of the controller to test.\r
418 @param RemainingDevicePath A pointer to the remaining portion of a device path.\r
419\r
420 @return EFI_SUCCESS Driver is started successfully\r
421**/\r
637ff819 422EFI_STATUS\r
423EFIAPI\r
424SerialControllerDriverStart (\r
425 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
426 IN EFI_HANDLE Controller,\r
427 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
428 );\r
429\r
91c68197
LG
430/**\r
431 Disconnect this driver with the controller, uninstall related protocol instance\r
432\r
433 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
434 @param Controller The handle of the controller to test.\r
435 @param NumberOfChildren Number of child device.\r
436 @param ChildHandleBuffer A pointer to the remaining portion of a device path.\r
437\r
438 @retval EFI_SUCCESS Operation successfully\r
439 @retval EFI_DEVICE_ERROR Cannot stop the driver successfully\r
440\r
441**/\r
637ff819 442EFI_STATUS\r
443EFIAPI\r
444SerialControllerDriverStop (\r
445 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
446 IN EFI_HANDLE Controller,\r
447 IN UINTN NumberOfChildren,\r
448 IN EFI_HANDLE *ChildHandleBuffer\r
449 );\r
450\r
451//\r
452// Serial I/O Protocol Interface\r
453//\r
91c68197
LG
454/**\r
455 Reset serial device.\r
456\r
457 @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r
458\r
459 @retval EFI_SUCCESS Reset successfully\r
460 @retval EFI_DEVICE_ERROR Failed to reset\r
461\r
462**/\r
637ff819 463EFI_STATUS\r
464EFIAPI\r
465IsaSerialReset (\r
466 IN EFI_SERIAL_IO_PROTOCOL *This\r
467 );\r
468\r
91c68197
LG
469/**\r
470 Set new attributes to a serial device.\r
471\r
472 @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r
473 @param BaudRate The baudrate of the serial device\r
474 @param ReceiveFifoDepth The depth of receive FIFO buffer\r
475 @param Timeout The request timeout for a single char\r
476 @param Parity The type of parity used in serial device\r
477 @param DataBits Number of databits used in serial device\r
478 @param StopBits Number of stopbits used in serial device\r
479\r
480 @retval EFI_SUCCESS The new attributes were set\r
481 @retval EFI_INVALID_PARAMETERS One or more attributes have an unsupported value\r
482 @retval EFI_UNSUPPORTED Data Bits can not set to 5 or 6\r
483 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly (no return)\r
484\r
485**/\r
637ff819 486EFI_STATUS\r
487EFIAPI\r
488IsaSerialSetAttributes (\r
489 IN EFI_SERIAL_IO_PROTOCOL *This,\r
490 IN UINT64 BaudRate,\r
491 IN UINT32 ReceiveFifoDepth,\r
492 IN UINT32 Timeout,\r
493 IN EFI_PARITY_TYPE Parity,\r
494 IN UINT8 DataBits,\r
495 IN EFI_STOP_BITS_TYPE StopBits\r
496 );\r
497\r
91c68197
LG
498/**\r
499 Set Control Bits.\r
500\r
501 @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r
502 @param Control Control bits that can be settable\r
503\r
504 @retval EFI_SUCCESS New Control bits were set successfully\r
505 @retval EFI_UNSUPPORTED The Control bits wanted to set are not supported\r
506\r
507**/\r
637ff819 508EFI_STATUS\r
509EFIAPI\r
510IsaSerialSetControl (\r
511 IN EFI_SERIAL_IO_PROTOCOL *This,\r
512 IN UINT32 Control\r
513 );\r
514\r
91c68197
LG
515/**\r
516 Get ControlBits.\r
517\r
518 @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r
519 @param Control Control signals of the serial device\r
520\r
521 @retval EFI_SUCCESS Get Control signals successfully\r
522\r
523**/\r
637ff819 524EFI_STATUS\r
525EFIAPI\r
526IsaSerialGetControl (\r
527 IN EFI_SERIAL_IO_PROTOCOL *This,\r
528 OUT UINT32 *Control\r
529 );\r
530\r
91c68197
LG
531/**\r
532 Write the specified number of bytes to serial device.\r
533\r
534 @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r
535 @param BufferSize On input the size of Buffer, on output the amount of\r
536 data actually written\r
537 @param Buffer The buffer of data to write\r
538\r
539 @retval EFI_SUCCESS The data were written successfully\r
540 @retval EFI_DEVICE_ERROR The device reported an error\r
541 @retval EFI_TIMEOUT The write operation was stopped due to timeout\r
542\r
543**/\r
637ff819 544EFI_STATUS\r
545EFIAPI\r
546IsaSerialWrite (\r
547 IN EFI_SERIAL_IO_PROTOCOL *This,\r
548 IN OUT UINTN *BufferSize,\r
549 IN VOID *Buffer\r
550 );\r
551\r
91c68197
LG
552/**\r
553 Read the specified number of bytes from serial device.\r
554\r
555 @param This Pointer to EFI_SERIAL_IO_PROTOCOL\r
556 @param BufferSize On input the size of Buffer, on output the amount of\r
557 data returned in buffer\r
558 @param Buffer The buffer to return the data into\r
559\r
560 @retval EFI_SUCCESS The data were read successfully\r
561 @retval EFI_DEVICE_ERROR The device reported an error\r
562 @retval EFI_TIMEOUT The read operation was stopped due to timeout\r
563\r
564**/\r
637ff819 565EFI_STATUS\r
566EFIAPI\r
567IsaSerialRead (\r
568 IN EFI_SERIAL_IO_PROTOCOL *This,\r
569 IN OUT UINTN *BufferSize,\r
570 OUT VOID *Buffer\r
571 );\r
572\r
573//\r
574// Internal Functions\r
575//\r
91c68197
LG
576/**\r
577 Use scratchpad register to test if this serial port is present.\r
578\r
579 @param SerialDevice Pointer to serial device structure\r
580\r
581 @return if this serial port is present\r
582**/\r
637ff819 583BOOLEAN\r
584IsaSerialPortPresent (\r
585 IN SERIAL_DEV *SerialDevice\r
586 );\r
587\r
91c68197
LG
588/**\r
589 Detect whether specific FIFO is full or not.\r
590\r
591 @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO\r
592\r
593 @return whether specific FIFO is full or not\r
594\r
595**/\r
637ff819 596BOOLEAN\r
597IsaSerialFifoFull (\r
598 IN SERIAL_DEV_FIFO *Fifo\r
599 );\r
600\r
91c68197
LG
601/**\r
602 Detect whether specific FIFO is empty or not.\r
603 \r
604 @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO\r
605\r
606 @return whether specific FIFO is empty or not\r
607\r
608**/\r
637ff819 609BOOLEAN\r
610IsaSerialFifoEmpty (\r
611 IN SERIAL_DEV_FIFO *Fifo\r
612 );\r
613\r
91c68197
LG
614/**\r
615 Add data to specific FIFO.\r
616\r
617 @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO\r
618 @param Data the data added to FIFO\r
619\r
620 @retval EFI_SUCCESS Add data to specific FIFO successfully\r
621 @retval EFI_OUT_OF_RESOURCE Failed to add data because FIFO is already full\r
622\r
623**/\r
637ff819 624EFI_STATUS\r
625IsaSerialFifoAdd (\r
626 IN SERIAL_DEV_FIFO *Fifo,\r
627 IN UINT8 Data\r
628 );\r
629\r
91c68197
LG
630/**\r
631 Remove data from specific FIFO.\r
632\r
633 @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO\r
634 @param Data the data removed from FIFO\r
635\r
636 @retval EFI_SUCCESS Remove data from specific FIFO successfully\r
637 @retval EFI_OUT_OF_RESOURCE Failed to remove data because FIFO is empty\r
638\r
639**/\r
637ff819 640EFI_STATUS\r
641IsaSerialFifoRemove (\r
642 IN SERIAL_DEV_FIFO *Fifo,\r
643 OUT UINT8 *Data\r
644 );\r
645\r
91c68197
LG
646/**\r
647 Reads and writes all avaliable data.\r
648\r
649 @param SerialDevice The device to flush\r
650\r
651 @retval EFI_SUCCESS Data was read/written successfully.\r
652 @retval EFI_OUT_OF_RESOURCE Failed because software receive FIFO is full. Note, when\r
653 this happens, pending writes are not done.\r
654\r
655**/\r
637ff819 656EFI_STATUS\r
657IsaSerialReceiveTransmit (\r
658 IN SERIAL_DEV *SerialDevice\r
659 );\r
660\r
91c68197
LG
661/**\r
662 Use IsaIo protocol to read serial port.\r
663\r
664 @param IsaIo Pointer to EFI_ISA_IO_PROTOCOL instance\r
665 @param BaseAddress Serial port register group base address\r
666 @param Offset Offset in register group\r
667\r
668 @return Data read from serial port\r
669\r
670**/\r
637ff819 671UINT8\r
672IsaSerialReadPort (\r
673 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
674 IN UINT16 BaseAddress,\r
675 IN UINT32 Offset\r
676 );\r
677\r
91c68197
LG
678/**\r
679 Use IsaIo protocol to write serial port.\r
680\r
681 @param IsaIo Pointer to EFI_ISA_IO_PROTOCOL instance\r
682 @param BaseAddress Serial port register group base address\r
683 @param Offset Offset in register group\r
684 @param Data data which is to be written to some serial port register\r
685\r
686**/\r
637ff819 687VOID\r
688IsaSerialWritePort (\r
689 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
690 IN UINT16 BaseAddress,\r
691 IN UINT32 Offset,\r
692 IN UINT8 Data\r
693 );\r
694\r
91c68197
LG
695\r
696//\r
697// EFI Component Name Functions\r
698//\r
699/**\r
700 Retrieves a Unicode string that is the user readable name of the driver.\r
701\r
702 This function retrieves the user readable name of a driver in the form of a\r
703 Unicode string. If the driver specified by This has a user readable name in\r
704 the language specified by Language, then a pointer to the driver name is\r
705 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
706 by This does not support the language specified by Language,\r
707 then EFI_UNSUPPORTED is returned.\r
708\r
709 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
710 EFI_COMPONENT_NAME_PROTOCOL instance.\r
711\r
712 @param Language[in] A pointer to a Null-terminated ASCII string\r
713 array indicating the language. This is the\r
714 language of the driver name that the caller is\r
715 requesting, and it must match one of the\r
716 languages specified in SupportedLanguages. The\r
717 number of languages supported by a driver is up\r
718 to the driver writer. Language is specified\r
719 in RFC 4646 or ISO 639-2 language code format.\r
720\r
721 @param DriverName[out] A pointer to the Unicode string to return.\r
722 This Unicode string is the name of the\r
723 driver specified by This in the language\r
724 specified by Language.\r
725\r
726 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
727 This and the language specified by Language was\r
728 returned in DriverName.\r
729\r
730 @retval EFI_INVALID_PARAMETER Language is NULL.\r
731\r
732 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
733\r
734 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
735 the language specified by Language.\r
736\r
737**/\r
738EFI_STATUS\r
739EFIAPI\r
740IsaSerialComponentNameGetDriverName (\r
741 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
742 IN CHAR8 *Language,\r
743 OUT CHAR16 **DriverName\r
744 );\r
745\r
746\r
747/**\r
748 Retrieves a Unicode string that is the user readable name of the controller\r
749 that is being managed by a driver.\r
750\r
751 This function retrieves the user readable name of the controller specified by\r
752 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
753 driver specified by This has a user readable name in the language specified by\r
754 Language, then a pointer to the controller name is returned in ControllerName,\r
755 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
756 managing the controller specified by ControllerHandle and ChildHandle,\r
757 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
758 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
759\r
760 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
761 EFI_COMPONENT_NAME_PROTOCOL instance.\r
762\r
763 @param ControllerHandle[in] The handle of a controller that the driver\r
764 specified by This is managing. This handle\r
765 specifies the controller whose name is to be\r
766 returned.\r
767\r
768 @param ChildHandle[in] The handle of the child controller to retrieve\r
769 the name of. This is an optional parameter that\r
770 may be NULL. It will be NULL for device\r
771 drivers. It will also be NULL for a bus drivers\r
772 that wish to retrieve the name of the bus\r
773 controller. It will not be NULL for a bus\r
774 driver that wishes to retrieve the name of a\r
775 child controller.\r
776\r
777 @param Language[in] A pointer to a Null-terminated ASCII string\r
778 array indicating the language. This is the\r
779 language of the driver name that the caller is\r
780 requesting, and it must match one of the\r
781 languages specified in SupportedLanguages. The\r
782 number of languages supported by a driver is up\r
783 to the driver writer. Language is specified in\r
784 RFC 4646 or ISO 639-2 language code format.\r
785\r
786 @param ControllerName[out] A pointer to the Unicode string to return.\r
787 This Unicode string is the name of the\r
788 controller specified by ControllerHandle and\r
789 ChildHandle in the language specified by\r
790 Language from the point of view of the driver\r
791 specified by This.\r
792\r
793 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
794 the language specified by Language for the\r
795 driver specified by This was returned in\r
796 DriverName.\r
797\r
798 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
799\r
800 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
801 EFI_HANDLE.\r
802\r
803 @retval EFI_INVALID_PARAMETER Language is NULL.\r
804\r
805 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
806\r
807 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
808 managing the controller specified by\r
809 ControllerHandle and ChildHandle.\r
810\r
811 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
812 the language specified by Language.\r
813\r
814**/\r
815EFI_STATUS\r
816EFIAPI\r
817IsaSerialComponentNameGetControllerName (\r
818 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
819 IN EFI_HANDLE ControllerHandle,\r
820 IN EFI_HANDLE ChildHandle OPTIONAL,\r
821 IN CHAR8 *Language,\r
822 OUT CHAR16 **ControllerName\r
823 );\r
824\r
825/**\r
826 Add the component name for the serial io device\r
827\r
828 @param SerialDevice A pointer to the SERIAL_DEV instance.\r
829\r
830 @param IsaIo A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
831\r
832**/\r
833VOID\r
834AddName (\r
835 IN SERIAL_DEV *SerialDevice,\r
836 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
837 );\r
838\r
637ff819 839#endif\r