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/PcdLib.h>
21 #include <Library/IoLib.h>
22 #include <Library/OmapLib.h>
23 #include <Omap3530/Omap3530.h>
27 Programmed hardware of Serial port.
29 @return Always return EFI_UNSUPPORTED.
34 SerialPortInitialize (
38 // assume assembly code at reset vector has setup UART
39 return RETURN_SUCCESS
;
43 Write data to serial device.
45 @param Buffer Point of data buffer which need to be writed.
46 @param NumberOfBytes Number of output bytes which are cached in Buffer.
48 @retval 0 Write data failed.
49 @retval !0 Actual number of bytes writed to serial device.
56 IN UINTN NumberOfBytes
59 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
60 UINT32 THR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_THR_REG
;
63 for (Count
= 0; Count
< NumberOfBytes
; Count
++, Buffer
++) {
64 while ((MmioRead8(LSR
) & UART_LSR_TX_FIFO_E_MASK
) == UART_LSR_TX_FIFO_E_NOT_EMPTY
);
65 MmioWrite8(THR
, *Buffer
);
73 Read data from serial device and save the datas in buffer.
75 @param Buffer Point of data buffer which need to be writed.
76 @param NumberOfBytes Number of output bytes which are cached in Buffer.
78 @retval 0 Read data failed.
79 @retval !0 Aactual number of bytes read from serial device.
86 IN UINTN NumberOfBytes
89 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
90 UINT32 RBR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_RBR_REG
;
93 for (Count
= 0; Count
< NumberOfBytes
; Count
++, Buffer
++) {
94 while ((MmioRead8(LSR
) & UART_LSR_RX_FIFO_E_MASK
) == UART_LSR_RX_FIFO_E_EMPTY
);
95 *Buffer
= MmioRead8(RBR
);
103 Check to see if any data is avaiable to be read from the debug device.
105 @retval EFI_SUCCESS At least one byte of data is avaiable to be read
106 @retval EFI_NOT_READY No data is avaiable to be read
107 @retval EFI_DEVICE_ERROR The serial device is not functioning properly
116 UINT32 LSR
= UartBase(PcdGet32(PcdOmap35xxConsoleUart
)) + UART_LSR_REG
;
118 if ((MmioRead8(LSR
) & UART_LSR_RX_FIFO_E_MASK
) == UART_LSR_RX_FIFO_E_NOT_EMPTY
) {