summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-05-15 08:44:59 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-05-15 08:44:59 +0000
commit15e277d5ac9dfda1120cb135f635486704b156bb (patch)
treec0de9974bbfba576aecc371930842128e64299e0 /ArmPlatformPkg
parentbf23b44d926982dfc9ecc7785cea17e0889a9297 (diff)
downloadedk2-platforms-15e277d5ac9dfda1120cb135f635486704b156bb.tar.xz
EmbeddedPkg/SerialPortExtLib.h: Changed SerialPortSetAttributes() prototype to return the set value(s)
To be compliant with the UEFI specification it is required to update SERIAL_IO_MODE with the values set. This prototype change allows to get the value used inside SerialPortSetAttributes(). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <Olivier.martin@arm.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14365 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg')
-rw-r--r--ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c38
-rw-r--r--ArmPlatformPkg/Include/Drivers/PL011Uart.h12
-rw-r--r--ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c14
-rw-r--r--ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c20
4 files changed, 48 insertions, 36 deletions
diff --git a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
index d9280cd0bb..fdb9ff490e 100644
--- a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
+++ b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
@@ -31,12 +31,12 @@
RETURN_STATUS
EFIAPI
PL011UartInitializePort (
- IN UINTN UartBase,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
+ IN OUT UINTN UartBase,
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
)
{
UINT32 LineControl;
@@ -47,19 +47,21 @@ PL011UartInitializePort (
// The PL011 supports a buffer of either 1 or 32 chars. Therefore we can accept
// 1 char buffer as the minimum fifo size. Because everything can be rounded down,
// there is no maximum fifo size.
- if (ReceiveFifoDepth == 0) {
+ if ((*ReceiveFifoDepth == 0) || (*ReceiveFifoDepth >= 32)) {
LineControl |= PL011_UARTLCR_H_FEN;
- } else if (ReceiveFifoDepth < 32) {
+ *ReceiveFifoDepth = 32;
+ } else {
+ ASSERT (*ReceiveFifoDepth < 32);
// Nothing else to do. 1 byte fifo is default.
- } else if (ReceiveFifoDepth >= 32) {
- LineControl |= PL011_UARTLCR_H_FEN;
+ *ReceiveFifoDepth = 1;
}
//
// Parity
//
- switch (Parity) {
+ switch (*Parity) {
case DefaultParity:
+ *Parity = NoParity;
case NoParity:
// Nothing to do. Parity is disabled by default.
break;
@@ -82,8 +84,9 @@ PL011UartInitializePort (
//
// Data Bits
//
- switch (DataBits) {
+ switch (*DataBits) {
case 0:
+ *DataBits = 8;
case 8:
LineControl |= PL011_UARTLCR_H_WLEN_8;
break;
@@ -103,8 +106,9 @@ PL011UartInitializePort (
//
// Stop Bits
//
- switch (StopBits) {
+ switch (*StopBits) {
case DefaultStopBits:
+ *StopBits = OneStopBit;
case OneStopBit:
// Nothing to do. One stop bit is enabled by default.
break;
@@ -132,14 +136,14 @@ PL011UartInitializePort (
MmioWrite32 (UartBase + UARTIBRD, PcdGet32 (PL011UartInteger));
MmioWrite32 (UartBase + UARTFBRD, PcdGet32 (PL011UartFractional));
} else {
- BaudRate = PcdGet32 (PcdSerialBaudRate);
- ASSERT (BaudRate != 0);
+ *BaudRate = PcdGet32 (PcdSerialBaudRate);
+ ASSERT (*BaudRate != 0);
}
}
// If BaudRate != 0 then we must calculate the divisor from the value
- if (BaudRate != 0) {
- Divisor = (PcdGet32 (PL011UartClkInHz) * 4) / BaudRate;
+ if (*BaudRate != 0) {
+ Divisor = (PcdGet32 (PL011UartClkInHz) * 4) / *BaudRate;
MmioWrite32 (UartBase + UARTIBRD, Divisor >> 6);
MmioWrite32 (UartBase + UARTFBRD, Divisor & 0x3F);
}
diff --git a/ArmPlatformPkg/Include/Drivers/PL011Uart.h b/ArmPlatformPkg/Include/Drivers/PL011Uart.h
index 354f111032..23e9a94347 100644
--- a/ArmPlatformPkg/Include/Drivers/PL011Uart.h
+++ b/ArmPlatformPkg/Include/Drivers/PL011Uart.h
@@ -91,12 +91,12 @@
RETURN_STATUS
EFIAPI
PL011UartInitializePort (
- IN UINTN UartBase,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
+ IN OUT UINTN UartBase,
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
);
/**
diff --git a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c
index 9bfe42e60c..57f3fa0eea 100644
--- a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c
+++ b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c
@@ -1,7 +1,7 @@
/** @file
Serial I/O Port library functions with no library constructor/destructor
- Copyright (c) 2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2012-2013, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -47,12 +47,12 @@
RETURN_STATUS
EFIAPI
SerialPortSetAttributes (
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
)
{
return PL011UartInitializePort (
diff --git a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
index 09033dbd76..4f628086ac 100644
--- a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
+++ b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
@@ -2,7 +2,7 @@
Serial I/O Port library functions with no library constructor/destructor
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2012 - 2013, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -37,13 +37,21 @@ SerialPortInitialize (
VOID
)
{
+ UINT64 BaudRate;
+ UINT32 ReceiveFifoDepth;
+ EFI_PARITY_TYPE Parity;
+ UINT8 DataBits;
+ EFI_STOP_BITS_TYPE StopBits;
+
+ BaudRate = (UINTN)PcdGet64 (PcdUartDefaultBaudRate);
+ ReceiveFifoDepth = 0; // Use the default value for Fifo depth
+ Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);
+ DataBits = PcdGet8 (PcdUartDefaultDataBits);
+ StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits);
+
return PL011UartInitializePort (
(UINTN)PcdGet64 (PcdSerialRegisterBase),
- (UINTN)PcdGet64 (PcdUartDefaultBaudRate),
- 0, // Use the default value for Fifo depth
- (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity),
- PcdGet8 (PcdUartDefaultDataBits),
- (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits));
+ &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, &StopBits);
}
/**