]>
Commit | Line | Data |
---|---|---|
1d5d0ae9 | 1 | /** @file |
2 | Serial I/O Port library functions with no library constructor/destructor | |
3 | ||
1d5d0ae9 | 4 | Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR> |
051e63bb | 5 | Copyright (c) 2012, ARM Ltd. All rights reserved.<BR> |
1d5d0ae9 | 6 | |
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 | |
11 | ||
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. | |
14 | ||
15 | **/ | |
16 | ||
051e63bb | 17 | #include <Include/Base.h> |
9dcfb8e5 | 18 | |
1d5d0ae9 | 19 | #include <Library/IoLib.h> |
9dcfb8e5 | 20 | #include <Library/PcdLib.h> |
21 | #include <Library/SerialPortLib.h> | |
22 | ||
1d5d0ae9 | 23 | #include <Drivers/PL011Uart.h> |
9dcfb8e5 | 24 | |
1d5d0ae9 | 25 | |
26 | /* | |
27 | ||
28 | Programmed hardware of Serial port. | |
29 | ||
051e63bb | 30 | @return Always return RETURN_UNSUPPORTED. |
1d5d0ae9 | 31 | |
32 | **/ | |
33 | RETURN_STATUS | |
34 | EFIAPI | |
35 | SerialPortInitialize ( | |
36 | VOID | |
37 | ) | |
38 | { | |
051e63bb | 39 | return PL011UartInitializePort ( |
9dcfb8e5 | 40 | (UINTN)PcdGet64 (PcdSerialRegisterBase), |
41 | (UINTN)PcdGet64 (PcdUartDefaultBaudRate), | |
051e63bb | 42 | 0, // Use the default value for Fifo depth |
43 | 0, // Use the default value for Timeout, | |
44 | (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity), | |
45 | PcdGet8 (PcdUartDefaultDataBits), | |
46 | (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits)); | |
1d5d0ae9 | 47 | } |
48 | ||
49 | /** | |
50 | Write data to serial device. | |
51 | ||
051e63bb | 52 | @param Buffer Point of data buffer which need to be written. |
1d5d0ae9 | 53 | @param NumberOfBytes Number of output bytes which are cached in Buffer. |
54 | ||
55 | @retval 0 Write data failed. | |
051e63bb | 56 | @retval !0 Actual number of bytes written to serial device. |
1d5d0ae9 | 57 | |
58 | **/ | |
59 | UINTN | |
60 | EFIAPI | |
61 | SerialPortWrite ( | |
62 | IN UINT8 *Buffer, | |
63 | IN UINTN NumberOfBytes | |
9dcfb8e5 | 64 | ) |
1d5d0ae9 | 65 | { |
9dcfb8e5 | 66 | return PL011UartWrite ((UINTN)PcdGet64 (PcdSerialRegisterBase), Buffer, NumberOfBytes); |
1d5d0ae9 | 67 | } |
68 | ||
69 | /** | |
051e63bb | 70 | Read data from serial device and save the data in buffer. |
1d5d0ae9 | 71 | |
051e63bb | 72 | @param Buffer Point of data buffer which need to be written. |
1d5d0ae9 | 73 | @param NumberOfBytes Number of output bytes which are cached in Buffer. |
74 | ||
75 | @retval 0 Read data failed. | |
051e63bb | 76 | @retval !0 Actual number of bytes read from serial device. |
1d5d0ae9 | 77 | |
78 | **/ | |
79 | UINTN | |
80 | EFIAPI | |
81 | SerialPortRead ( | |
82 | OUT UINT8 *Buffer, | |
83 | IN UINTN NumberOfBytes | |
84 | ) | |
85 | { | |
9dcfb8e5 | 86 | return PL011UartRead ((UINTN)PcdGet64 (PcdSerialRegisterBase), Buffer, NumberOfBytes); |
1d5d0ae9 | 87 | } |
88 | ||
89 | /** | |
051e63bb | 90 | Check to see if any data is available to be read from the debug device. |
1d5d0ae9 | 91 | |
051e63bb | 92 | @retval EFI_SUCCESS At least one byte of data is available to be read |
93 | @retval EFI_NOT_READY No data is available to be read | |
1d5d0ae9 | 94 | @retval EFI_DEVICE_ERROR The serial device is not functioning properly |
95 | ||
96 | **/ | |
97 | BOOLEAN | |
98 | EFIAPI | |
99 | SerialPortPoll ( | |
100 | VOID | |
101 | ) | |
102 | { | |
9dcfb8e5 | 103 | return PL011UartPoll ((UINTN)PcdGet64 (PcdSerialRegisterBase)); |
1d5d0ae9 | 104 | } |