mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
bf23b44d92
commit
15e277d5ac
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,12 +54,12 @@ SerialPortGetControl (
|
|||
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
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -66,12 +66,12 @@ SerialPortGetControl (
|
|||
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 RETURN_UNSUPPORTED;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
Copyright (c) 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
|
||||
|
@ -165,7 +166,7 @@ SerialSetAttributes (
|
|||
EFI_STATUS Status;
|
||||
EFI_TPL Tpl;
|
||||
|
||||
Status = SerialPortSetAttributes (BaudRate, ReceiveFifoDepth, Timeout, Parity, DataBits, StopBits);
|
||||
Status = SerialPortSetAttributes (&BaudRate, &ReceiveFifoDepth, &Timeout, &Parity, &DataBits, &StopBits);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue