]>
Commit | Line | Data |
---|---|---|
1d5d0ae9 | 1 | /** @file |
2 | Serial I/O Port library functions with no library constructor/destructor | |
3 | ||
4 | ||
5 | Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR> | |
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 | ||
17 | #include <Include/Uefi.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 | ||
30 | @return Always return EFI_UNSUPPORTED. | |
31 | ||
32 | **/ | |
33 | RETURN_STATUS | |
34 | EFIAPI | |
35 | SerialPortInitialize ( | |
36 | VOID | |
37 | ) | |
38 | { | |
1d5d0ae9 | 39 | // No parity, 1 stop, no fifo, 8 data bits |
9dcfb8e5 | 40 | return PL011UartInitialize ( |
41 | (UINTN)PcdGet64 (PcdSerialRegisterBase), | |
42 | (UINTN)PcdGet64 (PcdUartDefaultBaudRate), | |
43 | PL011_UARTLCR_H_WLEN_8); | |
1d5d0ae9 | 44 | } |
45 | ||
46 | /** | |
47 | Write data to serial device. | |
48 | ||
49 | @param Buffer Point of data buffer which need to be writed. | |
50 | @param NumberOfBytes Number of output bytes which are cached in Buffer. | |
51 | ||
52 | @retval 0 Write data failed. | |
53 | @retval !0 Actual number of bytes writed to serial device. | |
54 | ||
55 | **/ | |
56 | UINTN | |
57 | EFIAPI | |
58 | SerialPortWrite ( | |
59 | IN UINT8 *Buffer, | |
60 | IN UINTN NumberOfBytes | |
9dcfb8e5 | 61 | ) |
1d5d0ae9 | 62 | { |
9dcfb8e5 | 63 | return PL011UartWrite ((UINTN)PcdGet64 (PcdSerialRegisterBase), Buffer, NumberOfBytes); |
1d5d0ae9 | 64 | } |
65 | ||
66 | /** | |
67 | Read data from serial device and save the datas in buffer. | |
68 | ||
69 | @param Buffer Point of data buffer which need to be writed. | |
70 | @param NumberOfBytes Number of output bytes which are cached in Buffer. | |
71 | ||
72 | @retval 0 Read data failed. | |
73 | @retval !0 Aactual number of bytes read from serial device. | |
74 | ||
75 | **/ | |
76 | UINTN | |
77 | EFIAPI | |
78 | SerialPortRead ( | |
79 | OUT UINT8 *Buffer, | |
80 | IN UINTN NumberOfBytes | |
81 | ) | |
82 | { | |
9dcfb8e5 | 83 | return PL011UartRead ((UINTN)PcdGet64 (PcdSerialRegisterBase), Buffer, NumberOfBytes); |
1d5d0ae9 | 84 | } |
85 | ||
86 | /** | |
87 | Check to see if any data is avaiable to be read from the debug device. | |
88 | ||
89 | @retval EFI_SUCCESS At least one byte of data is avaiable to be read | |
90 | @retval EFI_NOT_READY No data is avaiable to be read | |
91 | @retval EFI_DEVICE_ERROR The serial device is not functioning properly | |
92 | ||
93 | **/ | |
94 | BOOLEAN | |
95 | EFIAPI | |
96 | SerialPortPoll ( | |
97 | VOID | |
98 | ) | |
99 | { | |
9dcfb8e5 | 100 | return PL011UartPoll ((UINTN)PcdGet64 (PcdSerialRegisterBase)); |
1d5d0ae9 | 101 | } |