2 Serial I/O Port library functions with no library constructor/destructor
5 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/DebugLib.h>
14 #include <Library/SerialPortLib.h>
15 #include <Library/PcdLib.h>
16 #include <Library/IoLib.h>
17 #include <Library/OmapLib.h>
18 #include <Omap3530/Omap3530.h>
22 Programmed hardware of Serial port.
24 @return Always return EFI_UNSUPPORTED.
29 SerialPortInitialize (
33 // assume assembly code at reset vector has setup UART
34 return RETURN_SUCCESS
;
38 Write data to serial device.
40 @param Buffer Point of data buffer which need to be writed.
41 @param NumberOfBytes Number of output bytes which are cached in Buffer.
43 @retval 0 Write data failed.
44 @retval !0 Actual number of bytes writed to serial device.
51 IN UINTN NumberOfBytes
54 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
55 UINT32 THR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_THR_REG
;
58 for (Count
= 0; Count
< NumberOfBytes
; Count
++, Buffer
++) {
59 while ((MmioRead8(LSR
) & UART_LSR_TX_FIFO_E_MASK
) == UART_LSR_TX_FIFO_E_NOT_EMPTY
);
60 MmioWrite8(THR
, *Buffer
);
68 Read data from serial device and save the datas in buffer.
70 @param Buffer Point of data buffer which need to be writed.
71 @param NumberOfBytes Number of output bytes which are cached in Buffer.
73 @retval 0 Read data failed.
74 @retval !0 Aactual number of bytes read from serial device.
81 IN UINTN NumberOfBytes
84 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
85 UINT32 RBR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_RBR_REG
;
88 for (Count
= 0; Count
< NumberOfBytes
; Count
++, Buffer
++) {
89 while ((MmioRead8(LSR
) & UART_LSR_RX_FIFO_E_MASK
) == UART_LSR_RX_FIFO_E_EMPTY
);
90 *Buffer
= MmioRead8(RBR
);
98 Check to see if any data is avaiable to be read from the debug device.
100 @retval EFI_SUCCESS At least one byte of data is avaiable to be read
101 @retval EFI_NOT_READY No data is avaiable to be read
102 @retval EFI_DEVICE_ERROR The serial device is not functioning properly
111 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
113 if ((MmioRead8(LSR
) & UART_LSR_RX_FIFO_E_MASK
) == UART_LSR_RX_FIFO_E_NOT_EMPTY
) {
121 Sets the control bits on a serial device.
123 @param[in] Control Sets the bits of Control that are settable.
125 @retval RETURN_SUCCESS The new control bits were set on the serial device.
126 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
127 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
132 SerialPortSetControl (
136 return RETURN_UNSUPPORTED
;
140 Retrieve the status of the control bits on a serial device.
142 @param[out] Control A pointer to return the current control signals from the serial device.
144 @retval RETURN_SUCCESS The control bits were read from the serial device.
145 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
146 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
151 SerialPortGetControl (
156 if (!SerialPortPoll ()) {
157 *Control
= EFI_SERIAL_INPUT_BUFFER_EMPTY
;
159 return RETURN_SUCCESS
;
163 Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
164 data bits, and stop bits on a serial device.
166 @param BaudRate The requested baud rate. A BaudRate value of 0 will use the
167 device's default interface speed.
168 On output, the value actually set.
169 @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
170 serial interface. A ReceiveFifoDepth value of 0 will use
171 the device's default FIFO depth.
172 On output, the value actually set.
173 @param Timeout The requested time out for a single character in microseconds.
174 This timeout applies to both the transmit and receive side of the
175 interface. A Timeout value of 0 will use the device's default time
177 On output, the value actually set.
178 @param Parity The type of parity to use on this serial device. A Parity value of
179 DefaultParity will use the device's default parity value.
180 On output, the value actually set.
181 @param DataBits The number of data bits to use on the serial device. A DataBits
182 vaule of 0 will use the device's default data bit setting.
183 On output, the value actually set.
184 @param StopBits The number of stop bits to use on this serial device. A StopBits
185 value of DefaultStopBits will use the device's default number of
187 On output, the value actually set.
189 @retval RETURN_SUCCESS The new attributes were set on the serial device.
190 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
191 @retval RETURN_INVALID_PARAMETER One or more of the attributes has an unsupported value.
192 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
197 SerialPortSetAttributes (
198 IN OUT UINT64
*BaudRate
,
199 IN OUT UINT32
*ReceiveFifoDepth
,
200 IN OUT UINT32
*Timeout
,
201 IN OUT EFI_PARITY_TYPE
*Parity
,
202 IN OUT UINT8
*DataBits
,
203 IN OUT EFI_STOP_BITS_TYPE
*StopBits
206 return RETURN_UNSUPPORTED
;