]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
ArmPkg: Move ARM Platform drivers from ArmPkg/Drivers/ to ArmPlatformPkg/Drivers/
[mirror_edk2.git] / ArmPlatformPkg / Library / PL011SerialPortLib / PL011SerialPortLib.c
CommitLineData
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**/
33RETURN_STATUS
34EFIAPI
35SerialPortInitialize (
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**/
56UINTN
57EFIAPI
58SerialPortWrite (
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**/
76UINTN
77EFIAPI
78SerialPortRead (
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**/
94BOOLEAN
95EFIAPI
96SerialPortPoll (
97 VOID
98 )
99{
9dcfb8e5 100 return PL011UartPoll ((UINTN)PcdGet64 (PcdSerialRegisterBase));
1d5d0ae9 101}