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