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