On 17 November 2015 at 12:07, Star Zeng <star.z...@intel.com> wrote: > Cc: Michael D Kinney <michael.d.kin...@intel.com> > Cc: Liming Gao <liming....@intel.com> > Cc: Leif Lindholm <leif.lindh...@linaro.org> > Cc: Ard Biesheuvel <ard.biesheu...@linaro.org> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Star Zeng <star.z...@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheu...@linaro.org> > --- > EmbeddedPkg/EmbeddedPkg.dsc | 6 +- > EmbeddedPkg/Include/Library/SerialPortExtLib.h | 116 ------ > .../SerialPortExtLibNull/SerialPortExtLibNull.c | 48 --- > .../SerialPortExtLibNull/SerialPortExtLibNull.inf | 30 -- > .../TemplateSerialPortExtLib.c | 79 ----- > .../TemplateSerialPortExtLib.inf | 36 -- > EmbeddedPkg/SerialDxe/SerialDxe.inf | 55 --- > EmbeddedPkg/SerialDxe/SerialIo.c | 391 > --------------------- > 8 files changed, 1 insertion(+), 760 deletions(-) > delete mode 100644 EmbeddedPkg/Include/Library/SerialPortExtLib.h > delete mode 100644 > EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.c > delete mode 100644 > EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.inf > delete mode 100644 > EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c > delete mode 100644 > EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf > delete mode 100644 EmbeddedPkg/SerialDxe/SerialDxe.inf > delete mode 100644 EmbeddedPkg/SerialDxe/SerialIo.c > > diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc > index 6719eea..a5507ed 100644 > --- a/EmbeddedPkg/EmbeddedPkg.dsc > +++ b/EmbeddedPkg/EmbeddedPkg.dsc > @@ -2,7 +2,7 @@ > # Embedded Package > # > # > -# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR> > +# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> > # Copyright (c) 2012-2015, ARM Ltd. All rights reserved.<BR> > # > # This program and the accompanying materials > @@ -68,7 +68,6 @@ [LibraryClasses.common] > PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf > > > SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.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 > @@ -249,8 +248,6 @@ [Components.common] > EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf > > EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf > EmbeddedPkg/Library/PrePiLib/PrePiLib.inf > - MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf > - EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.inf > EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf > EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf > > EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf > @@ -261,7 +258,6 @@ [Components.common] > EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf > EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf > EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf > - EmbeddedPkg/SerialDxe/SerialDxe.inf > EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf > EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf { > <LibraryClasses> > diff --git a/EmbeddedPkg/Include/Library/SerialPortExtLib.h > b/EmbeddedPkg/Include/Library/SerialPortExtLib.h > deleted file mode 100644 > index 0d0abb3..0000000 > --- a/EmbeddedPkg/Include/Library/SerialPortExtLib.h > +++ /dev/null > @@ -1,116 +0,0 @@ > -/** @file > - > - Serial I/O port control interface extension. > - > - This library provides an extension to the library providing common > - serial I/O port functions that is defined in MdePkg. The aim is to > - provide more control over the functionalities of a serial port. The > - extension covers all the needs of the UEFI Serial I/O Protocol. > - Though, its use is not restricted to the UEFI Serial I/O Protocol. > - It could for example be used in the PEI phase of the boot sequence > - as well. > - > - Copyright (c) 2012 - 2014, 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. > - > -**/ > - > -#ifndef __SERIAL_PORT_EXT_LIB_H__ > -#define __SERIAL_PORT_EXT_LIB_H__ > - > -#include <Uefi/UefiBaseType.h> > -#include <Protocol/SerialIo.h> > - > -/** > - > - Assert or deassert the control signals on a serial port. > - The following control signals are set according their bit settings : > - . Request to Send > - . Data Terminal Ready > - > - @param[in] Control The following bits are taken into account : > - . EFI_SERIAL_REQUEST_TO_SEND : assert/deassert the > - "Request To Send" control signal if this bit is > - equal to one/zero. > - . EFI_SERIAL_DATA_TERMINAL_READY : assert/deassert > - the "Data Terminal Ready" control signal if this > - bit is equal to one/zero. > - . EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE : enable/disable > - the hardware loopback if this bit is equal to > - one/zero. > - . EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE : not supported. > - . EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE : enable/ > - disable the hardware flow control based on CTS > (Clear > - To Send) and RTS (Ready To Send) control signals. > - > - @retval RETURN_SUCCESS The new control bits were set on the serial > device. > - @retval RETURN_UNSUPPORTED The serial device does not support this > operation. > - > -**/ > -RETURN_STATUS > -EFIAPI > -SerialPortSetControl ( > - IN UINT32 Control > - ); > - > -/** > - > - Retrieve the status of the control bits on a serial device. > - > - @param[out] Control Status of the control bits on a serial device : > - > - . EFI_SERIAL_DATA_CLEAR_TO_SEND, > EFI_SERIAL_DATA_SET_READY, > - EFI_SERIAL_RING_INDICATE, > EFI_SERIAL_CARRIER_DETECT, > - EFI_SERIAL_REQUEST_TO_SEND, > EFI_SERIAL_DATA_TERMINAL_READY > - are all related to the DTE (Data Terminal > Equipment) and > - DCE (Data Communication Equipment) modes of > operation of > - the serial device. > - . EFI_SERIAL_INPUT_BUFFER_EMPTY : equal to one if > the receive > - buffer is empty, 0 otherwise. > - . EFI_SERIAL_OUTPUT_BUFFER_EMPTY : equal to one if > the transmit > - buffer is empty, 0 otherwise. > - . EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE : equal to one > if the > - hardware loopback is enabled (the ouput feeds the > receive > - buffer), 0 otherwise. > - . EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE : equal to one > if a > - loopback is accomplished by software, 0 otherwise. > - . EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE : equal to > one if the > - hardware flow control based on CTS (Clear To Send) > and RTS > - (Ready To Send) control signals is enabled, 0 > otherwise. > - > - @retval RETURN_SUCCESS The control bits were read from the serial > device. > - @retval RETURN_DEVICE_ERROR The serial device is not functioning > correctly. > - > -**/ > -RETURN_STATUS > -EFIAPI > -SerialPortGetControl ( > - OUT UINT32 *Control > - ); > - > -/** > - 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 > - ); > - > -#endif > - > diff --git a/EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.c > b/EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.c > deleted file mode 100644 > index fb7dea5..0000000 > --- a/EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.c > +++ /dev/null > @@ -1,48 +0,0 @@ > -/** @file > - > - Copyright (c) 2014, Linaro 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 <Library/SerialPortExtLib.h> > - > -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_SUCCESS; > -} > - > -RETURN_STATUS > -EFIAPI > -SerialPortSetControl ( > - IN UINT32 Control > - ) > -{ > - return RETURN_SUCCESS; > -} > - > -RETURN_STATUS > -EFIAPI > -SerialPortGetControl ( > - OUT UINT32 *Control > - ) > -{ > - *Control = 0; > - return RETURN_SUCCESS; > -} > diff --git > a/EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.inf > b/EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.inf > deleted file mode 100644 > index a1ac3fe..0000000 > --- a/EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.inf > +++ /dev/null > @@ -1,30 +0,0 @@ > -#/** @file > -# > -# Component description file for PL011SerialPortLib module > -# > -# Copyright (c) 2011-2014, 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 = SerialPortExtLibNull > - FILE_GUID = BD396D28-085E-477A-A5DE-A8D91DD1F752 > - MODULE_TYPE = BASE > - VERSION_STRING = 1.0 > - LIBRARY_CLASS = SerialPortExtLib > - > -[Sources.common] > - SerialPortExtLibNull.c > - > -[Packages] > - MdePkg/MdePkg.dec > - EmbeddedPkg/EmbeddedPkg.dec > diff --git > a/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c > b/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c > deleted file mode 100644 > index f0f8465..0000000 > --- a/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c > +++ /dev/null > @@ -1,79 +0,0 @@ > -/** @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 RETURN_SUCCESS; > -} > - > -/** > - Set the serial device attributes. > - > - @return Always return RETURN_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; > -} > - > diff --git > a/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf > b/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf > deleted file mode 100644 > index 2e95405..0000000 > --- > a/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf > +++ /dev/null > @@ -1,36 +0,0 @@ > -#/** @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 > - > diff --git a/EmbeddedPkg/SerialDxe/SerialDxe.inf > b/EmbeddedPkg/SerialDxe/SerialDxe.inf > deleted file mode 100644 > index aed458d..0000000 > --- a/EmbeddedPkg/SerialDxe/SerialDxe.inf > +++ /dev/null > @@ -1,55 +0,0 @@ > -#/** @file > -# > -# Convert SerialLib into SerialIo protocol > -# > -# Copyright (c) 2008, Intel Corporation. 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 = SerialDxe > - FILE_GUID = D3987D4B-971A-435F-8CAF-4967EB627241 > - MODULE_TYPE = DXE_DRIVER > - VERSION_STRING = 1.0 > - > - ENTRY_POINT = SerialDxeInitialize > - > -[Sources.common] > - SerialIo.c > - > -[Packages] > - MdePkg/MdePkg.dec > - EmbeddedPkg/EmbeddedPkg.dec > - > -[LibraryClasses] > - BaseLib > - ReportStatusCodeLib > - MemoryAllocationLib > - UefiLib > - UefiBootServicesTableLib > - BaseMemoryLib > - DebugLib > - UefiDriverEntryPoint > - SerialPortLib > - SerialPortExtLib > - > -[Protocols] > - gEfiSerialIoProtocolGuid > - gEfiDevicePathProtocolGuid > - > -[FixedPcd] > - gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate > - gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits > - gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity > - gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits > - > -[Depex] > - TRUE > diff --git a/EmbeddedPkg/SerialDxe/SerialIo.c > b/EmbeddedPkg/SerialDxe/SerialIo.c > deleted file mode 100644 > index 7a849b7..0000000 > --- a/EmbeddedPkg/SerialDxe/SerialIo.c > +++ /dev/null > @@ -1,391 +0,0 @@ > -/** @file > - Serial IO Abstraction for GDB stub. This allows an EFI consoles that shows > up on the system > - running GDB. One console for error information and another console for > user input/output. > - > - Basic packet format is $packet-data#checksum. So every command has 4 bytes > of overhead: $, > - #, 0, 0. The 0 and 0 are the ascii characters for the checksum. > - > - Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> > - Copyright (c) 2013-2014, 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 <PiDxe.h> > -#include <Library/UefiLib.h> > -#include <Library/UefiBootServicesTableLib.h> > -#include <Library/DebugLib.h> > -#include <Library/SerialPortLib.h> > -#include <Library/SerialPortExtLib.h> > -#include <Library/PcdLib.h> > - > -#include <Protocol/SerialIo.h> > - > -typedef struct { > - VENDOR_DEVICE_PATH Guid; > - UART_DEVICE_PATH Uart; > - EFI_DEVICE_PATH_PROTOCOL End; > -} SIMPLE_TEXT_OUT_DEVICE_PATH; > - > -SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = { > - { > - { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0} > }, > - EFI_CALLER_ID_GUID // Use the drivers GUID > - }, > - { > - { MESSAGING_DEVICE_PATH, MSG_UART_DP, { sizeof (UART_DEVICE_PATH), 0} }, > - 0, // Reserved > - FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate > - FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits > - FixedPcdGet8 (PcdUartDefaultParity), // Parity (N) > - FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits > - }, > - { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof > (EFI_DEVICE_PATH_PROTOCOL), 0 } } > -}; > - > -EFI_HANDLE gHandle = NULL; > - > -/** > - Reset the serial device. > - > - @param This Protocol instance pointer. > - > - @retval EFI_SUCCESS The device was reset. > - @retval EFI_DEVICE_ERROR The serial device could not be reset. > - > -**/ > -EFI_STATUS > -EFIAPI > -SerialReset ( > - IN EFI_SERIAL_IO_PROTOCOL *This > - ) > -{ > - EFI_STATUS Status; > - EFI_TPL Tpl; > - > - Status = SerialPortInitialize (); > - if (EFI_ERROR(Status)) { > - return Status; > - } > - > - // > - // Set the Serial I/O mode and update the device path > - // > - > - Tpl = gBS->RaiseTPL (TPL_NOTIFY); > - > - // > - // Set the Serial I/O mode > - // > - This->Mode->ReceiveFifoDepth = 0; > - This->Mode->Timeout = 1000000; > - This->Mode->BaudRate = PcdGet64 (PcdUartDefaultBaudRate); > - This->Mode->DataBits = (UINT32)PcdGet8 (PcdUartDefaultDataBits); > - This->Mode->Parity = (UINT32)PcdGet8 (PcdUartDefaultParity); > - This->Mode->StopBits = (UINT32)PcdGet8 (PcdUartDefaultStopBits); > - > - // > - // Check if the device path has actually changed > - // > - if (mDevicePath.Uart.BaudRate == This->Mode->BaudRate && > - mDevicePath.Uart.DataBits == (UINT8)This->Mode->DataBits && > - mDevicePath.Uart.Parity == (UINT8)This->Mode->Parity && > - mDevicePath.Uart.StopBits == (UINT8)This->Mode->StopBits > - ) { > - gBS->RestoreTPL (Tpl); > - return EFI_SUCCESS; > - } > - > - // > - // Update the device path > - // > - mDevicePath.Uart.BaudRate = This->Mode->BaudRate; > - mDevicePath.Uart.DataBits = (UINT8)This->Mode->DataBits; > - mDevicePath.Uart.Parity = (UINT8)This->Mode->Parity; > - mDevicePath.Uart.StopBits = (UINT8)This->Mode->StopBits; > - > - Status = gBS->ReinstallProtocolInterface ( > - gHandle, > - &gEfiDevicePathProtocolGuid, > - &mDevicePath, > - &mDevicePath > - ); > - > - gBS->RestoreTPL (Tpl); > - > - return Status; > -} > - > - > -/** > - Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, > - data buts, and stop bits on a serial device. > - > - @param This Protocol instance pointer. > - @param BaudRate The requested baud rate. A BaudRate value of 0 > will use the the > - device's default interface speed. > - @param ReceiveFifoDepth The requested depth of the FIFO on the receive > side of the > - serial interface. A ReceiveFifoDepth value of 0 > will use > - the device's default FIFO depth. > - @param Timeout The requested time out for a single character in > microseconds. > - This timeout applies to both the transmit and > receive side of the > - interface. A Timeout value of 0 will use the > device's default time > - out value. > - @param Parity The type of parity to use on this serial device. > A Parity value of > - DefaultParity will use the device's default > parity value. > - @param DataBits The number of data bits to use on the serial > device. A DataBits > - value of 0 will use the device's default data bit > setting. > - @param StopBits The number of stop bits to use on this serial > device. A StopBits > - value of DefaultStopBits will use the device's > default number of > - stop bits. > - > - @retval EFI_SUCCESS The device was reset. > - @retval EFI_DEVICE_ERROR The serial device could not be reset. > - > -**/ > -EFI_STATUS > -EFIAPI > -SerialSetAttributes ( > - IN EFI_SERIAL_IO_PROTOCOL *This, > - IN UINT64 BaudRate, > - IN UINT32 ReceiveFifoDepth, > - IN UINT32 Timeout, > - IN EFI_PARITY_TYPE Parity, > - IN UINT8 DataBits, > - IN EFI_STOP_BITS_TYPE StopBits > - ) > -{ > - RETURN_STATUS ReturnStatus; > - EFI_STATUS Status; > - EFI_TPL Tpl; > - > - ReturnStatus = SerialPortSetAttributes (&BaudRate, &ReceiveFifoDepth, > &Timeout, &Parity, &DataBits, &StopBits); > - if (RETURN_ERROR (ReturnStatus)) { > - return EFI_DEVICE_ERROR; > - } > - > - // > - // Set the Serial I/O mode and update the device path > - // > - > - Tpl = gBS->RaiseTPL (TPL_NOTIFY); > - > - // > - // Set the Serial I/O mode > - // > - This->Mode->BaudRate = BaudRate; > - This->Mode->ReceiveFifoDepth = ReceiveFifoDepth; > - This->Mode->Timeout = Timeout; > - This->Mode->Parity = (UINT32)Parity; > - This->Mode->DataBits = (UINT32)DataBits; > - This->Mode->StopBits = (UINT32)StopBits; > - > - // > - // Check if the device path has actually changed > - // > - if (mDevicePath.Uart.BaudRate == BaudRate && > - mDevicePath.Uart.Parity == (UINT8)Parity && > - mDevicePath.Uart.DataBits == DataBits && > - mDevicePath.Uart.StopBits == (UINT8)StopBits > - ) { > - gBS->RestoreTPL (Tpl); > - return EFI_SUCCESS; > - } > - > - // > - // Update the device path > - // > - mDevicePath.Uart.BaudRate = BaudRate; > - mDevicePath.Uart.DataBits = DataBits; > - mDevicePath.Uart.Parity = (UINT8) Parity; > - mDevicePath.Uart.StopBits = (UINT8) StopBits; > - > - Status = gBS->ReinstallProtocolInterface ( > - gHandle, > - &gEfiDevicePathProtocolGuid, > - &mDevicePath, > - &mDevicePath > - ); > - > - gBS->RestoreTPL (Tpl); > - > - return Status; > -} > - > - > -/** > - Set the control bits on a serial device > - > - @param This Protocol instance pointer. > - @param Control Set the bits of Control that are settable. > - > - @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. > - > -**/ > -EFI_STATUS > -EFIAPI > -SerialSetControl ( > - IN EFI_SERIAL_IO_PROTOCOL *This, > - IN UINT32 Control > - ) > -{ > - return SerialPortSetControl(Control); > -} > - > - > -/** > - Retrieves the status of the control bits on a serial device > - > - @param This Protocol instance pointer. > - @param Control A pointer to return the current Control signals > 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. > - > -**/ > -EFI_STATUS > -EFIAPI > -SerialGetControl ( > - IN EFI_SERIAL_IO_PROTOCOL *This, > - OUT UINT32 *Control > - ) > -{ > - return SerialPortGetControl(Control); > -} > - > - > -/** > - Writes data to a serial device. > - > - @param This Protocol instance pointer. > - @param BufferSize On input, the size of the Buffer. On output, the > amount of > - data actually written. > - @param Buffer The buffer of data to write > - > - @retval EFI_SUCCESS The data was written. > - @retval EFI_DEVICE_ERROR The device reported an error. > - @retval EFI_TIMEOUT The data write was stopped due to a timeout. > - > -**/ > -EFI_STATUS > -EFIAPI > -SerialWrite ( > - IN EFI_SERIAL_IO_PROTOCOL *This, > - IN OUT UINTN *BufferSize, > - IN VOID *Buffer > - ) > -{ > - UINTN Count; > - > - Count = SerialPortWrite (Buffer, *BufferSize); > - > - if (Count != *BufferSize) { > - *BufferSize = Count; > - return EFI_TIMEOUT; > - } > - > - return EFI_SUCCESS; > -} > - > -/** > - Reads data from a serial device. > - > - @param This Protocol instance pointer. > - @param BufferSize On input, the size of the Buffer. On output, the > amount of > - data returned in Buffer. > - @param Buffer The buffer to return the data into. > - > - @retval EFI_SUCCESS The data was read. > - @retval EFI_DEVICE_ERROR The device reported an error. > - @retval EFI_TIMEOUT The data write was stopped due to a timeout. > - > -**/ > - > -EFI_STATUS > -EFIAPI > -SerialRead ( > - IN EFI_SERIAL_IO_PROTOCOL *This, > - IN OUT UINTN *BufferSize, > - OUT VOID *Buffer > - ) > -{ > - UINTN Count = 0; > - > - if (SerialPortPoll()) { > - Count = SerialPortRead (Buffer, *BufferSize); > - } > - > - if (Count != *BufferSize) { > - *BufferSize = Count; > - return EFI_TIMEOUT; > - } > - > - return EFI_SUCCESS; > -} > - > -// > -// Template used to initialize the GDB Serial IO protocols > -// > -EFI_SERIAL_IO_MODE gSerialIoMode = { > - 0, // ControlMask > - 0, // Timeout > - FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate > - 1, // ReceiveFifoDepth > - FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits > - FixedPcdGet8 (PcdUartDefaultParity), // Parity > - FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits > -}; > - > - > -EFI_SERIAL_IO_PROTOCOL gSerialIoTemplate = { > - SERIAL_IO_INTERFACE_REVISION, > - SerialReset, > - SerialSetAttributes, > - SerialSetControl, > - SerialGetControl, > - SerialWrite, > - SerialRead, > - &gSerialIoMode > -}; > - > -/** > - Initialize the state information for the Serial Io Protocol > - > - @param ImageHandle of the loaded driver > - @param SystemTable Pointer to the System Table > - > - @retval EFI_SUCCESS Protocol registered > - @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure > - @retval EFI_DEVICE_ERROR Hardware problems > - > -**/ > -EFI_STATUS > -EFIAPI > -SerialDxeInitialize ( > - IN EFI_HANDLE ImageHandle, > - IN EFI_SYSTEM_TABLE *SystemTable > - ) > -{ > - EFI_STATUS Status; > - > - // Make a new handle with Serial IO protocol and its device path on it. > - Status = gBS->InstallMultipleProtocolInterfaces ( > - &gHandle, > - &gEfiSerialIoProtocolGuid, &gSerialIoTemplate, > - &gEfiDevicePathProtocolGuid, &mDevicePath, > - NULL > - ); > - ASSERT_EFI_ERROR (Status); > - > - return Status; > -} > - > -- > 1.9.5.msysgit.0 > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel