2 Serial I/O Port library functions with no library constructor/destructor
5 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/DebugLib.h>
19 #include <Library/SerialPortLib.h>
20 #include <Library/SerialPortExtLib.h>
21 #include <Library/PcdLib.h>
22 #include <Library/IoLib.h>
23 #include <Library/OmapLib.h>
24 #include <Omap3530/Omap3530.h>
28 Programmed hardware of Serial port.
30 @return Always return EFI_UNSUPPORTED.
35 SerialPortInitialize (
39 // assume assembly code at reset vector has setup UART
40 return RETURN_SUCCESS
;
44 Write data to serial device.
46 @param Buffer Point of data buffer which need to be writed.
47 @param NumberOfBytes Number of output bytes which are cached in Buffer.
49 @retval 0 Write data failed.
50 @retval !0 Actual number of bytes writed to serial device.
57 IN UINTN NumberOfBytes
60 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
61 UINT32 THR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_THR_REG
;
64 for (Count
= 0; Count
< NumberOfBytes
; Count
++, Buffer
++) {
65 while ((MmioRead8(LSR
) & UART_LSR_TX_FIFO_E_MASK
) == UART_LSR_TX_FIFO_E_NOT_EMPTY
);
66 MmioWrite8(THR
, *Buffer
);
74 Read data from serial device and save the datas in buffer.
76 @param Buffer Point of data buffer which need to be writed.
77 @param NumberOfBytes Number of output bytes which are cached in Buffer.
79 @retval 0 Read data failed.
80 @retval !0 Aactual number of bytes read from serial device.
87 IN UINTN NumberOfBytes
90 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
91 UINT32 RBR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_RBR_REG
;
94 for (Count
= 0; Count
< NumberOfBytes
; Count
++, Buffer
++) {
95 while ((MmioRead8(LSR
) & UART_LSR_RX_FIFO_E_MASK
) == UART_LSR_RX_FIFO_E_EMPTY
);
96 *Buffer
= MmioRead8(RBR
);
104 Check to see if any data is avaiable to be read from the debug device.
106 @retval EFI_SUCCESS At least one byte of data is avaiable to be read
107 @retval EFI_NOT_READY No data is avaiable to be read
108 @retval EFI_DEVICE_ERROR The serial device is not functioning properly
117 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
119 if ((MmioRead8(LSR
) & UART_LSR_RX_FIFO_E_MASK
) == UART_LSR_RX_FIFO_E_NOT_EMPTY
) {
127 Set the serial device control bits.
129 @return Always return EFI_UNSUPPORTED.
134 SerialPortSetControl (
138 return RETURN_SUCCESS
;
142 Get the serial device control bits.
144 @param Control Control signals read from the serial device.
146 @retval EFI_SUCCESS The control bits were read from the serial device.
147 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
152 SerialPortGetControl (
156 return RETURN_SUCCESS
;
161 Set the serial device attributes.
163 @return Always return EFI_UNSUPPORTED.
168 SerialPortSetAttributes (
170 IN UINT32 ReceiveFifoDepth
,
172 IN EFI_PARITY_TYPE Parity
,
174 IN EFI_STOP_BITS_TYPE StopBits
177 return RETURN_SUCCESS
;