diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc index 52b324c603..bc4807f3f1 100644 --- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc +++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc @@ -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 diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc index bbd00fdd26..47dc0ff762 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc @@ -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 diff --git a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c new file mode 100644 index 0000000000..9bfe42e60c --- /dev/null +++ b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c @@ -0,0 +1,103 @@ +/** @file + Serial I/O Port library functions with no library constructor/destructor + + 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 + +#include +#include +#include + +#include + +/** + 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); +} + diff --git a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.inf b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.inf new file mode 100644 index 0000000000..89c8c9c119 --- /dev/null +++ b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.inf @@ -0,0 +1,43 @@ +#/** @file +# +# Component description file for PL011SerialPortLib module +# +# Copyright (c) 2011-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. +# +#**/ + +[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 diff --git a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c index 20e8882713..09033dbd76 100644 --- a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c +++ b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c @@ -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); -} diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc b/BeagleBoardPkg/BeagleBoardPkg.dsc index 0ae815075c..1223944bed 100644 --- a/BeagleBoardPkg/BeagleBoardPkg.dsc +++ b/BeagleBoardPkg/BeagleBoardPkg.dsc @@ -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 diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc index e1a4c225e6..64b220c3c1 100644 --- a/EmbeddedPkg/EmbeddedPkg.dsc +++ b/EmbeddedPkg/EmbeddedPkg.dsc @@ -3,6 +3,7 @@ # # # Copyright (c) 2007, Intel Corporation. All rights reserved.
+# 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 @@ -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 diff --git a/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c b/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c new file mode 100644 index 0000000000..5a007c25f6 --- /dev/null +++ b/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c @@ -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 + +#include +#include + +/** + 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; +} + diff --git a/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf b/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf new file mode 100644 index 0000000000..2e95405af4 --- /dev/null +++ b/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf @@ -0,0 +1,36 @@ +#/** @file +# Template for Extended Serial Port Library for UEFI drivers +# +# Copyright (c) 2006, Intel Corporation. All rights reserved.
+# 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. +# +# +#**/ + +[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 + diff --git a/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c b/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c index 0110189abd..5d9bb073c7 100644 --- a/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c +++ b/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c @@ -18,7 +18,6 @@ #include -#include /** @@ -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. diff --git a/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf b/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf index 1bc1fc0ee6..f1ece19624 100644 --- a/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf +++ b/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf @@ -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.
+# 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 @@ -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] diff --git a/EmbeddedPkg/SerialDxe/SerialDxe.inf b/EmbeddedPkg/SerialDxe/SerialDxe.inf index 37e8e0e008..ed7f377351 100644 --- a/EmbeddedPkg/SerialDxe/SerialDxe.inf +++ b/EmbeddedPkg/SerialDxe/SerialDxe.inf @@ -39,6 +39,7 @@ DebugLib UefiDriverEntryPoint SerialPortLib + SerialPortExtLib [Protocols] gEfiSerialIoProtocolGuid diff --git a/Omap35xxPkg/Library/SerialPortLib/SerialPortLib.c b/Omap35xxPkg/Library/SerialPortLib/SerialPortLib.c index 9a70593dbf..2f93140e4c 100644 --- a/Omap35xxPkg/Library/SerialPortLib/SerialPortLib.c +++ b/Omap35xxPkg/Library/SerialPortLib/SerialPortLib.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -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; -} - diff --git a/Omap35xxPkg/Library/SerialPortLib/SerialPortLib.inf b/Omap35xxPkg/Library/SerialPortLib/SerialPortLib.inf index a7d4fadcef..340f4a6a4d 100644 --- a/Omap35xxPkg/Library/SerialPortLib/SerialPortLib.inf +++ b/Omap35xxPkg/Library/SerialPortLib/SerialPortLib.inf @@ -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]