+++ /dev/null
-/** @file\r
- Serial I/O Port library functions with no library constructor/destructor\r
-\r
-\r
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <Base.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/OmapLib.h>\r
-#include <Omap3530/Omap3530.h>\r
-\r
-/*\r
-\r
- Programmed hardware of Serial port.\r
-\r
- @return Always return EFI_UNSUPPORTED.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortInitialize (\r
- VOID\r
- )\r
-{\r
- // assume assembly code at reset vector has setup UART\r
- return RETURN_SUCCESS;\r
-}\r
-\r
-/**\r
- Write data to serial device.\r
-\r
- @param Buffer Point of data buffer which need to be writed.\r
- @param NumberOfBytes Number of output bytes which are cached in Buffer.\r
-\r
- @retval 0 Write data failed.\r
- @retval !0 Actual number of bytes writed to serial device.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortWrite (\r
- IN UINT8 *Buffer,\r
- IN UINTN NumberOfBytes\r
-)\r
-{\r
- UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;\r
- UINT32 THR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_THR_REG;\r
- UINTN Count;\r
-\r
- for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {\r
- while ((MmioRead8(LSR) & UART_LSR_TX_FIFO_E_MASK) == UART_LSR_TX_FIFO_E_NOT_EMPTY);\r
- MmioWrite8(THR, *Buffer);\r
- }\r
-\r
- return NumberOfBytes;\r
-}\r
-\r
-\r
-/**\r
- Read data from serial device and save the datas in buffer.\r
-\r
- @param Buffer Point of data buffer which need to be writed.\r
- @param NumberOfBytes Number of output bytes which are cached in Buffer.\r
-\r
- @retval 0 Read data failed.\r
- @retval !0 Aactual number of bytes read from serial device.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortRead (\r
- OUT UINT8 *Buffer,\r
- IN UINTN NumberOfBytes\r
-)\r
-{\r
- UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;\r
- UINT32 RBR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_RBR_REG;\r
- UINTN Count;\r
-\r
- for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {\r
- while ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_EMPTY);\r
- *Buffer = MmioRead8(RBR);\r
- }\r
-\r
- return NumberOfBytes;\r
-}\r
-\r
-\r
-/**\r
- Check to see if any data is avaiable to be read from the debug device.\r
-\r
- @retval EFI_SUCCESS At least one byte of data is avaiable to be read\r
- @retval EFI_NOT_READY No data is avaiable to be read\r
- @retval EFI_DEVICE_ERROR The serial device is not functioning properly\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-SerialPortPoll (\r
- VOID\r
- )\r
-{\r
- UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;\r
-\r
- if ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_NOT_EMPTY) {\r
- return TRUE;\r
- } else {\r
- return FALSE;\r
- }\r
-}\r
-\r
-/**\r
- Sets the control bits on a serial device.\r
-\r
- @param[in] Control Sets the bits of Control that are settable.\r
-\r
- @retval RETURN_SUCCESS The new control bits were set on the serial device.\r
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.\r
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortSetControl (\r
- IN UINT32 Control\r
- )\r
-{\r
- return RETURN_UNSUPPORTED;\r
-}\r
-\r
-/**\r
- Retrieve the status of the control bits on a serial device.\r
-\r
- @param[out] Control A pointer to return the current control signals from the serial device.\r
-\r
- @retval RETURN_SUCCESS The control bits were read from the serial device.\r
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.\r
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortGetControl (\r
- OUT UINT32 *Control\r
- )\r
-{\r
- *Control = 0;\r
- if (!SerialPortPoll ()) {\r
- *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY;\r
- }\r
- return RETURN_SUCCESS;\r
-}\r
-\r
-/**\r
- Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,\r
- data bits, and stop bits on a serial device.\r
-\r
- @param BaudRate The requested baud rate. A BaudRate value of 0 will use the\r
- device's default interface speed.\r
- On output, the value actually set.\r
- @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the\r
- serial interface. A ReceiveFifoDepth value of 0 will use\r
- the device's default FIFO depth.\r
- On output, the value actually set.\r
- @param Timeout The requested time out for a single character in microseconds.\r
- This timeout applies to both the transmit and receive side of the\r
- interface. A Timeout value of 0 will use the device's default time\r
- out value.\r
- On output, the value actually set.\r
- @param Parity The type of parity to use on this serial device. A Parity value of\r
- DefaultParity will use the device's default parity value.\r
- On output, the value actually set.\r
- @param DataBits The number of data bits to use on the serial device. A DataBits\r
- vaule of 0 will use the device's default data bit setting.\r
- On output, the value actually set.\r
- @param StopBits The number of stop bits to use on this serial device. A StopBits\r
- value of DefaultStopBits will use the device's default number of\r
- stop bits.\r
- On output, the value actually set.\r
-\r
- @retval RETURN_SUCCESS The new attributes were set on the serial device.\r
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.\r
- @retval RETURN_INVALID_PARAMETER One or more of the attributes has an unsupported value.\r
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortSetAttributes (\r
- IN OUT UINT64 *BaudRate,\r
- IN OUT UINT32 *ReceiveFifoDepth,\r
- IN OUT UINT32 *Timeout,\r
- IN OUT EFI_PARITY_TYPE *Parity,\r
- IN OUT UINT8 *DataBits,\r
- IN OUT EFI_STOP_BITS_TYPE *StopBits\r
- )\r
-{\r
- return RETURN_UNSUPPORTED;\r
-}\r
-\r