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