EmbeddedPkg: Introduced a separate SerialPortExtLib library

Formerly only the header was defined and it was expecting the SerialPortExtLib
interface to be implemented by SerialPortLib if supported. This behaviour was
not conform to the EDK2 framework.

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@14173 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2013-03-12 00:40:11 +00:00
parent c9bf2a9e2d
commit d38c35f9f7
14 changed files with 273 additions and 200 deletions

View File

@ -67,6 +67,7 @@
EfiResetSystemLib|ArmPlatformPkg/ArmRealViewEbPkg/Library/ResetSystemLib/ResetSystemLib.inf
RealTimeClockLib|ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
SerialPortExtLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.inf
TimerLib|ArmPlatformPkg/Library/SP804TimerLib/SP804TimerLib.inf
# ARM PL011 UART Driver
PL011UartLib|ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf

View File

@ -77,6 +77,7 @@
# ARM PL011 UART Driver
PL011UartLib|ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
SerialPortExtLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.inf
# ARM SP804 Dual Timer Driver
TimerLib|ArmPlatformPkg/Library/SP804TimerLib/SP804TimerLib.inf

View File

@ -0,0 +1,103 @@
/** @file
Serial I/O Port library functions with no library constructor/destructor
Copyright (c) 2012, 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
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Base.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
#include <Library/SerialPortExtLib.h>
#include <Drivers/PL011Uart.h>
/**
Set new attributes to PL011.
@param BaudRate The baud rate of the serial device. If the baud rate is not supported,
the speed will be reduced down to the nearest supported one and the
variable's value will be updated accordingly.
@param ReceiveFifoDepth The number of characters the device will buffer on input. If the specified
value is not supported, the variable's value will be reduced down to the
nearest supported one.
@param Timeout If applicable, the number of microseconds the device will wait
before timing out a Read or a Write operation.
@param Parity If applicable, this is the EFI_PARITY_TYPE that is computed or checked
as each character is transmitted or received. If the device does not
support parity, the value is the default parity value.
@param DataBits The number of data bits in each character
@param StopBits If applicable, the EFI_STOP_BITS_TYPE number of stop bits per character.
If the device does not support stop bits, the value is the default stop
bit value.
@retval EFI_SUCCESS All attributes were set correctly on the serial device.
@retval EFI_INVALID_PARAMETERS One or more of the attributes has an unsupported value.
**/
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
)
{
return PL011UartInitializePort (
(UINTN)PcdGet64 (PcdSerialRegisterBase),
BaudRate,
ReceiveFifoDepth,
Parity,
DataBits,
StopBits);
}
/**
Set the serial device control bits.
@param Control Control bits which are to be set on the serial device.
@retval EFI_SUCCESS The new control bits were set on the serial device.
@retval EFI_UNSUPPORTED The serial device does not support this operation.
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
SerialPortSetControl (
IN UINT32 Control
)
{
return PL011UartSetControl ((UINTN)PcdGet64 (PcdSerialRegisterBase), Control);
}
/**
Get the serial device control bits.
@param Control Control signals read from the serial device.
@retval EFI_SUCCESS The control bits were read from the serial device.
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
SerialPortGetControl (
OUT UINT32 *Control
)
{
return PL011UartGetControl ((UINTN)PcdGet64 (PcdSerialRegisterBase), Control);
}

View File

@ -0,0 +1,43 @@
#/** @file
#
# Component description file for PL011SerialPortLib module
#
# Copyright (c) 2011-2012, 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
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PL011SerialPortExtLib
FILE_GUID = 2be281f1-c506-4558-bd98-d6930e6de9d6
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = SerialPortExtLib
[Sources.common]
PL011SerialPortExtLib.c
[LibraryClasses]
PL011UartLib
PcdLib
[Packages]
EmbeddedPkg/EmbeddedPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits

View File

@ -103,82 +103,3 @@ SerialPortPoll (
return PL011UartPoll ((UINTN)PcdGet64 (PcdSerialRegisterBase));
}
/**
Set new attributes to PL011.
@param BaudRate The baud rate of the serial device. If the baud rate is not supported,
the speed will be reduced down to the nearest supported one and the
variable's value will be updated accordingly.
@param ReceiveFifoDepth The number of characters the device will buffer on input. If the specified
value is not supported, the variable's value will be reduced down to the
nearest supported one.
@param Timeout If applicable, the number of microseconds the device will wait
before timing out a Read or a Write operation.
@param Parity If applicable, this is the EFI_PARITY_TYPE that is computer or checked
as each character is transmitted or received. If the device does not
support parity, the value is the default parity value.
@param DataBits The number of data bits in each character
@param StopBits If applicable, the EFI_STOP_BITS_TYPE number of stop bits per character.
If the device does not support stop bits, the value is the default stop
bit value.
@retval EFI_SUCCESS All attributes were set correctly on the serial device.
@retval EFI_INVALID_PARAMETERS One or more of the attributes has an unsupported value.
**/
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
)
{
return PL011UartInitializePort (
(UINTN)PcdGet64 (PcdSerialRegisterBase),
BaudRate,
ReceiveFifoDepth,
Parity,
DataBits,
StopBits);
}
/**
Set the serial device control bits.
@param Control Control bits which are to be set on the serial device.
@retval EFI_SUCCESS The new control bits were set on the serial device.
@retval EFI_UNSUPPORTED The serial device does not support this operation.
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
SerialPortSetControl (
IN UINT32 Control
)
{
return PL011UartSetControl((UINTN)PcdGet64 (PcdSerialRegisterBase), Control);
}
/**
Get the serial device control bits.
@param Control Control signals read from the serial device.
@retval EFI_SUCCESS The control bits were read from the serial device.
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
SerialPortGetControl (
OUT UINT32 *Control
)
{
return PL011UartGetControl((UINTN)PcdGet64 (PcdSerialRegisterBase), Control);
}

View File

@ -83,6 +83,7 @@
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
SerialPortLib|Omap35xxPkg/Library/SerialPortLib/SerialPortLib.inf
SerialPortExtLib|EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf
SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
RealTimeClockLib|Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.inf

View File

@ -3,6 +3,7 @@
#
#
# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2012, 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
@ -69,6 +70,7 @@
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
SerialPortLib|EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf
SerialPortExtLib|EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf
RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
EfiResetSystemLib|EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf
GdbSerialLib|EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf

View File

@ -0,0 +1,79 @@
/** @file
Extended Serial I/O Port library functions
Copyright (c) 2012, ARM Ltd. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Base.h>
#include <Library/SerialPortLib.h>
#include <Library/SerialPortExtLib.h>
/**
Set the serial device control bits.
@return Always return RETURN_UNSUPPORTED.
**/
RETURN_STATUS
EFIAPI
SerialPortSetControl (
IN UINT32 Control
)
{
return RETURN_UNSUPPORTED;
}
/**
Get the serial device control bits.
@param Control Control signals read from the serial device.
@retval EFI_SUCCESS The control bits were read from the serial device.
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
SerialPortGetControl (
OUT UINT32 *Control
)
{
if (SerialPortPoll ()) {
// If a character is pending don't set EFI_SERIAL_INPUT_BUFFER_EMPTY
*Control = EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
} else {
*Control = EFI_SERIAL_INPUT_BUFFER_EMPTY | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
}
return EFI_SUCCESS;
}
/**
Set the serial device attributes.
@return Always return RETURN_UNSUPPORTED.
**/
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
)
{
return RETURN_UNSUPPORTED;
}

View File

@ -0,0 +1,36 @@
#/** @file
# Template for Extended Serial Port Library for UEFI drivers
#
# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2012, 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
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = TemplateSerialPortExtLib
FILE_GUID = 231fe752-40ac-40b0-8d23-4e341309b964
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = SerialPortExtLib
#
# VALID_ARCHITECTURES = ARM IA32 X64 IPF EBC
#
[Sources.common]
TemplateSerialPortExtLib.c
[Packages]
MdePkg/MdePkg.dec
EmbeddedPkg/EmbeddedPkg.dec

View File

@ -18,7 +18,6 @@
#include <Library/SerialPortLib.h>
#include <Library/SerialPortExtLib.h>
/**
@ -36,65 +35,6 @@ SerialPortInitialize (
return RETURN_UNSUPPORTED;
}
/**
Set the serial device control bits.
@return Always return EFI_UNSUPPORTED.
**/
RETURN_STATUS
EFIAPI
SerialPortSetControl (
IN UINT32 Control
)
{
return RETURN_UNSUPPORTED;
}
/**
Get the serial device control bits.
@param Control Control signals read from the serial device.
@retval EFI_SUCCESS The control bits were read from the serial device.
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
SerialPortGetControl (
OUT UINT32 *Control
)
{
if (SerialPortPoll ()) {
// If a character is pending don't set EFI_SERIAL_INPUT_BUFFER_EMPTY
*Control = EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
} else {
*Control = EFI_SERIAL_INPUT_BUFFER_EMPTY | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
}
return EFI_SUCCESS;
}
/**
Set the serial device attributes.
@return Always return EFI_UNSUPPORTED.
**/
RETURN_STATUS
EFIAPI
SerialPortSetAttributes (
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;
}
/**
Write data to serial device.

View File

@ -1,8 +1,8 @@
#/** @file
# Memory Status Code Library for UEFI drivers
# Template for Serial Port Library for UEFI drivers
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2012, 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
@ -18,13 +18,13 @@
INF_VERSION = 0x00010005
BASE_NAME = TemplateSerialPortLib
FILE_GUID = A9133571-AD4B-4457-94A8-A9CC2CE7574F
MODULE_TYPE = PEIM
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = SerialPortLib
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
# VALID_ARCHITECTURES = ARM IA32 X64 IPF EBC
#
[Sources.common]

View File

@ -39,6 +39,7 @@
DebugLib
UefiDriverEntryPoint
SerialPortLib
SerialPortExtLib
[Protocols]
gEfiSerialIoProtocolGuid

View File

@ -17,7 +17,6 @@
#include <Base.h>
#include <Library/DebugLib.h>
#include <Library/SerialPortLib.h>
#include <Library/SerialPortExtLib.h>
#include <Library/PcdLib.h>
#include <Library/IoLib.h>
#include <Library/OmapLib.h>
@ -123,57 +122,3 @@ SerialPortPoll (
}
}
/**
Set the serial device control bits.
@return Always return EFI_UNSUPPORTED.
**/
RETURN_STATUS
EFIAPI
SerialPortSetControl (
IN UINT32 Control
)
{
return RETURN_SUCCESS;
}
/**
Get the serial device control bits.
@param Control Control signals read from the serial device.
@retval EFI_SUCCESS The control bits were read from the serial device.
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
SerialPortGetControl (
OUT UINT32 *Control
)
{
return RETURN_SUCCESS;
}
/**
Set the serial device attributes.
@return Always return EFI_UNSUPPORTED.
**/
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
)
{
return RETURN_SUCCESS;
}

View File

@ -17,13 +17,13 @@
INF_VERSION = 0x00010005
BASE_NAME = BeagleBoardSerialPortLib
FILE_GUID = 97546cbd-c0ff-4c48-ab0b-e4f58862acd3
MODULE_TYPE = PEIM
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = SerialPortLib
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
# VALID_ARCHITECTURES = ARM IA32 X64 IPF EBC
#
[Sources.common]