]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
ArmPlatformPkg/PL031RealTimeClockLib: Fixed the conditions in LibSetTime()
[mirror_edk2.git] / ArmPlatformPkg / Library / PL011SerialPortLib / PL011SerialPortLib.c
CommitLineData
1e57a462 1/** @file\r
2 Serial I/O Port library functions with no library constructor/destructor\r
3\r
4 Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
15e277d5 5 Copyright (c) 2012 - 2013, ARM Ltd. All rights reserved.<BR>\r
1e57a462 6 \r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include <Base.h>\r
18\r
19#include <Library/IoLib.h>\r
20#include <Library/PcdLib.h>\r
21#include <Library/SerialPortLib.h>\r
22#include <Library/SerialPortExtLib.h>\r
23\r
24#include <Drivers/PL011Uart.h>\r
25\r
26\r
27/**\r
28\r
29 Programmed hardware of Serial port.\r
30\r
31 @return Always return RETURN_UNSUPPORTED.\r
32\r
33**/\r
34RETURN_STATUS\r
35EFIAPI\r
36SerialPortInitialize (\r
37 VOID\r
38 )\r
39{\r
15e277d5 40 UINT64 BaudRate;\r
41 UINT32 ReceiveFifoDepth;\r
42 EFI_PARITY_TYPE Parity;\r
43 UINT8 DataBits;\r
44 EFI_STOP_BITS_TYPE StopBits;\r
45\r
46 BaudRate = (UINTN)PcdGet64 (PcdUartDefaultBaudRate);\r
47 ReceiveFifoDepth = 0; // Use the default value for Fifo depth\r
48 Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);\r
49 DataBits = PcdGet8 (PcdUartDefaultDataBits);\r
50 StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits);\r
51\r
1e57a462 52 return PL011UartInitializePort (\r
53 (UINTN)PcdGet64 (PcdSerialRegisterBase),\r
15e277d5 54 &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, &StopBits);\r
1e57a462 55}\r
56\r
57/**\r
58 Write data to serial device.\r
59\r
60 @param Buffer Point of data buffer which need to be written.\r
61 @param NumberOfBytes Number of output bytes which are cached in Buffer.\r
62\r
63 @retval 0 Write data failed.\r
64 @retval !0 Actual number of bytes written to serial device.\r
65\r
66**/\r
67UINTN\r
68EFIAPI\r
69SerialPortWrite (\r
70 IN UINT8 *Buffer,\r
71 IN UINTN NumberOfBytes\r
72 )\r
73{\r
74 return PL011UartWrite ((UINTN)PcdGet64 (PcdSerialRegisterBase), Buffer, NumberOfBytes);\r
75}\r
76\r
77/**\r
78 Read data from serial device and save the data in buffer.\r
79\r
80 @param Buffer Point of data buffer which need to be written.\r
81 @param NumberOfBytes Number of output bytes which are cached in Buffer.\r
82\r
83 @retval 0 Read data failed.\r
84 @retval !0 Actual number of bytes read from serial device.\r
85\r
86**/\r
87UINTN\r
88EFIAPI\r
89SerialPortRead (\r
90 OUT UINT8 *Buffer,\r
91 IN UINTN NumberOfBytes\r
92)\r
93{\r
94 return PL011UartRead ((UINTN)PcdGet64 (PcdSerialRegisterBase), Buffer, NumberOfBytes);\r
95}\r
96\r
97/**\r
98 Check to see if any data is available to be read from the debug device.\r
99\r
100 @retval EFI_SUCCESS At least one byte of data is available to be read\r
101 @retval EFI_NOT_READY No data is available to be read\r
102 @retval EFI_DEVICE_ERROR The serial device is not functioning properly\r
103\r
104**/\r
105BOOLEAN\r
106EFIAPI\r
107SerialPortPoll (\r
108 VOID\r
109 )\r
110{\r
111 return PL011UartPoll ((UINTN)PcdGet64 (PcdSerialRegisterBase));\r
112}\r
113\r