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