]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c
BeagleBoardPkg: Use SerialDxe in MdeModulePkg instead of EmbeddedPkg
[mirror_edk2.git] / ArmPlatformPkg / Library / PL011SerialPortLib / PL011SerialPortExtLib.c
CommitLineData
d38c35f9 1/** @file\r
2 Serial I/O Port library functions with no library constructor/destructor\r
3\r
ab716191 4 Copyright (c) 2012-2014, ARM Ltd. All rights reserved.<BR>\r
3402aac7 5\r
d38c35f9 6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <Base.h>\r
17\r
18#include <Library/IoLib.h>\r
19#include <Library/PcdLib.h>\r
20#include <Library/SerialPortExtLib.h>\r
21\r
22#include <Drivers/PL011Uart.h>\r
23\r
24/**\r
25 Set new attributes to PL011.\r
26\r
27 @param BaudRate The baud rate of the serial device. If the baud rate is not supported,\r
28 the speed will be reduced down to the nearest supported one and the\r
29 variable's value will be updated accordingly.\r
30 @param ReceiveFifoDepth The number of characters the device will buffer on input. If the specified\r
31 value is not supported, the variable's value will be reduced down to the\r
32 nearest supported one.\r
33 @param Timeout If applicable, the number of microseconds the device will wait\r
34 before timing out a Read or a Write operation.\r
35 @param Parity If applicable, this is the EFI_PARITY_TYPE that is computed or checked\r
36 as each character is transmitted or received. If the device does not\r
37 support parity, the value is the default parity value.\r
38 @param DataBits The number of data bits in each character\r
39 @param StopBits If applicable, the EFI_STOP_BITS_TYPE number of stop bits per character.\r
40 If the device does not support stop bits, the value is the default stop\r
41 bit value.\r
42\r
43 @retval EFI_SUCCESS All attributes were set correctly on the serial device.\r
44 @retval EFI_INVALID_PARAMETERS One or more of the attributes has an unsupported value.\r
45\r
46**/\r
47RETURN_STATUS\r
48EFIAPI\r
49SerialPortSetAttributes (\r
15e277d5 50 IN OUT UINT64 *BaudRate,\r
51 IN OUT UINT32 *ReceiveFifoDepth,\r
52 IN OUT UINT32 *Timeout,\r
53 IN OUT EFI_PARITY_TYPE *Parity,\r
54 IN OUT UINT8 *DataBits,\r
55 IN OUT EFI_STOP_BITS_TYPE *StopBits\r
d38c35f9 56 )\r
57{\r
58 return PL011UartInitializePort (\r
59 (UINTN)PcdGet64 (PcdSerialRegisterBase),\r
60 BaudRate,\r
61 ReceiveFifoDepth,\r
62 Parity,\r
63 DataBits,\r
64 StopBits);\r
65}\r
66\r
67/**\r
d38c35f9 68\r
ab716191
RC
69 Assert or deassert the control signals on a serial port.\r
70 The following control signals are set according their bit settings :\r
71 . Request to Send\r
72 . Data Terminal Ready\r
73\r
74 @param[in] Control The following bits are taken into account :\r
75 . EFI_SERIAL_REQUEST_TO_SEND : assert/deassert the\r
76 "Request To Send" control signal if this bit is\r
77 equal to one/zero.\r
78 . EFI_SERIAL_DATA_TERMINAL_READY : assert/deassert\r
79 the "Data Terminal Ready" control signal if this\r
80 bit is equal to one/zero.\r
81 . EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE : enable/disable\r
82 the hardware loopback if this bit is equal to\r
83 one/zero.\r
84 . EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE : not supported.\r
85 . EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE : enable/\r
86 disable the hardware flow control based on CTS (Clear\r
87 To Send) and RTS (Ready To Send) control signals.\r
88\r
89 @retval RETURN_SUCCESS The new control bits were set on the serial device.\r
90 @retval RETURN_UNSUPPORTED The serial device does not support this operation.\r
d38c35f9 91\r
92**/\r
93RETURN_STATUS\r
94EFIAPI\r
95SerialPortSetControl (\r
ab716191 96 IN UINT32 Control\r
d38c35f9 97 )\r
98{\r
99 return PL011UartSetControl ((UINTN)PcdGet64 (PcdSerialRegisterBase), Control);\r
100}\r
101\r
102/**\r
d38c35f9 103\r
d2e7e385
RC
104 Retrieve the status of the control bits on a serial device.\r
105\r
106 @param[out] Control Status of the control bits on a serial device :\r
107\r
108 . EFI_SERIAL_DATA_CLEAR_TO_SEND, EFI_SERIAL_DATA_SET_READY,\r
109 EFI_SERIAL_RING_INDICATE, EFI_SERIAL_CARRIER_DETECT,\r
110 EFI_SERIAL_REQUEST_TO_SEND, EFI_SERIAL_DATA_TERMINAL_READY\r
111 are all related to the DTE (Data Terminal Equipment) and\r
112 DCE (Data Communication Equipment) modes of operation of\r
113 the serial device.\r
114 . EFI_SERIAL_INPUT_BUFFER_EMPTY : equal to one if the receive\r
115 buffer is empty, 0 otherwise.\r
116 . EFI_SERIAL_OUTPUT_BUFFER_EMPTY : equal to one if the transmit\r
117 buffer is empty, 0 otherwise.\r
118 . EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE : equal to one if the\r
119 hardware loopback is enabled (the ouput feeds the receive\r
120 buffer), 0 otherwise.\r
121 . EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE : equal to one if a\r
122 loopback is accomplished by software, 0 otherwise.\r
123 . EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE : equal to one if the\r
124 hardware flow control based on CTS (Clear To Send) and RTS\r
125 (Ready To Send) control signals is enabled, 0 otherwise.\r
126\r
127 @retval RETURN_SUCCESS The control bits were read from the serial device.\r
d38c35f9 128\r
129**/\r
130RETURN_STATUS\r
131EFIAPI\r
132SerialPortGetControl (\r
d2e7e385 133 OUT UINT32 *Control\r
d38c35f9 134 )\r
135{\r
136 return PL011UartGetControl ((UINTN)PcdGet64 (PcdSerialRegisterBase), Control);\r
137}\r