# Embedded Package\r
#\r
#\r
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
# Copyright (c) 2012-2015, ARM Ltd. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials\r
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf\r
\r
SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf\r
- SerialPortExtLib|EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf\r
RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf\r
EfiResetSystemLib|EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf\r
GdbSerialLib|EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf\r
EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf\r
EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf\r
EmbeddedPkg/Library/PrePiLib/PrePiLib.inf\r
- MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf\r
- EmbeddedPkg/Library/SerialPortExtLibNull/SerialPortExtLibNull.inf\r
EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf\r
EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf\r
EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf\r
EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf\r
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf\r
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf\r
- EmbeddedPkg/SerialDxe/SerialDxe.inf\r
EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf\r
EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf {\r
<LibraryClasses>\r
+++ /dev/null
-/** @file\r
-\r
- Serial I/O port control interface extension.\r
-\r
- This library provides an extension to the library providing common\r
- serial I/O port functions that is defined in MdePkg. The aim is to\r
- provide more control over the functionalities of a serial port. The\r
- extension covers all the needs of the UEFI Serial I/O Protocol.\r
- Though, its use is not restricted to the UEFI Serial I/O Protocol.\r
- It could for example be used in the PEI phase of the boot sequence\r
- as well.\r
-\r
- Copyright (c) 2012 - 2014, ARM Ltd. All rights reserved.\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __SERIAL_PORT_EXT_LIB_H__\r
-#define __SERIAL_PORT_EXT_LIB_H__\r
-\r
-#include <Uefi/UefiBaseType.h>\r
-#include <Protocol/SerialIo.h>\r
-\r
-/**\r
-\r
- Assert or deassert the control signals on a serial port.\r
- The following control signals are set according their bit settings :\r
- . Request to Send\r
- . Data Terminal Ready\r
-\r
- @param[in] Control The following bits are taken into account :\r
- . EFI_SERIAL_REQUEST_TO_SEND : assert/deassert the\r
- "Request To Send" control signal if this bit is\r
- equal to one/zero.\r
- . EFI_SERIAL_DATA_TERMINAL_READY : assert/deassert\r
- the "Data Terminal Ready" control signal if this\r
- bit is equal to one/zero.\r
- . EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE : enable/disable\r
- the hardware loopback if this bit is equal to\r
- one/zero.\r
- . EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE : not supported.\r
- . EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE : enable/\r
- disable the hardware flow control based on CTS (Clear\r
- To Send) and RTS (Ready To Send) control signals.\r
-\r
- @retval RETURN_SUCCESS The new control bits were set on the serial device.\r
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortSetControl (\r
- IN UINT32 Control\r
- );\r
-\r
-/**\r
-\r
- Retrieve the status of the control bits on a serial device.\r
-\r
- @param[out] Control Status of the control bits on a serial device :\r
-\r
- . EFI_SERIAL_DATA_CLEAR_TO_SEND, EFI_SERIAL_DATA_SET_READY,\r
- EFI_SERIAL_RING_INDICATE, EFI_SERIAL_CARRIER_DETECT,\r
- EFI_SERIAL_REQUEST_TO_SEND, EFI_SERIAL_DATA_TERMINAL_READY\r
- are all related to the DTE (Data Terminal Equipment) and\r
- DCE (Data Communication Equipment) modes of operation of\r
- the serial device.\r
- . EFI_SERIAL_INPUT_BUFFER_EMPTY : equal to one if the receive\r
- buffer is empty, 0 otherwise.\r
- . EFI_SERIAL_OUTPUT_BUFFER_EMPTY : equal to one if the transmit\r
- buffer is empty, 0 otherwise.\r
- . EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE : equal to one if the\r
- hardware loopback is enabled (the ouput feeds the receive\r
- buffer), 0 otherwise.\r
- . EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE : equal to one if a\r
- loopback is accomplished by software, 0 otherwise.\r
- . EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE : equal to one if the\r
- hardware flow control based on CTS (Clear To Send) and RTS\r
- (Ready To Send) control signals is enabled, 0 otherwise.\r
-\r
- @retval RETURN_SUCCESS The control bits were read from the serial device.\r
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortGetControl (\r
- OUT UINT32 *Control\r
- );\r
-\r
-/**\r
- Set the serial device attributes.\r
-\r
- @return Always return EFI_UNSUPPORTED.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortSetAttributes (\r
- IN OUT UINT64 *BaudRate,\r
- IN OUT UINT32 *ReceiveFifoDepth,\r
- IN OUT UINT32 *Timeout,\r
- IN OUT EFI_PARITY_TYPE *Parity,\r
- IN OUT UINT8 *DataBits,\r
- IN OUT EFI_STOP_BITS_TYPE *StopBits\r
- );\r
-\r
-#endif\r
-\r
+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Library/SerialPortExtLib.h>\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortSetAttributes (\r
- IN OUT UINT64 *BaudRate,\r
- IN OUT UINT32 *ReceiveFifoDepth,\r
- IN OUT UINT32 *Timeout,\r
- IN OUT EFI_PARITY_TYPE *Parity,\r
- IN OUT UINT8 *DataBits,\r
- IN OUT EFI_STOP_BITS_TYPE *StopBits\r
- )\r
-{\r
- return RETURN_SUCCESS;\r
-}\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortSetControl (\r
- IN UINT32 Control\r
- )\r
-{\r
- return RETURN_SUCCESS;\r
-}\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortGetControl (\r
- OUT UINT32 *Control\r
- )\r
-{\r
- *Control = 0;\r
- return RETURN_SUCCESS;\r
-}\r
+++ /dev/null
-#/** @file\r
-#\r
-# Component description file for PL011SerialPortLib module\r
-#\r
-# Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = SerialPortExtLibNull\r
- FILE_GUID = BD396D28-085E-477A-A5DE-A8D91DD1F752\r
- MODULE_TYPE = BASE\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = SerialPortExtLib\r
-\r
-[Sources.common]\r
- SerialPortExtLibNull.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
+++ /dev/null
-/** @file\r
- Extended Serial I/O Port library functions\r
-\r
- Copyright (c) 2012, ARM Ltd. All rights reserved.\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Base.h>\r
-\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/SerialPortExtLib.h>\r
-\r
-/**\r
- Set the serial device control bits.\r
-\r
- @return Always return RETURN_UNSUPPORTED.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortSetControl (\r
- IN UINT32 Control\r
- )\r
-{\r
- return RETURN_UNSUPPORTED;\r
-}\r
-\r
-/**\r
- Get the serial device control bits.\r
-\r
- @param Control Control signals read from the serial device.\r
-\r
- @retval EFI_SUCCESS The control bits were read from the serial device.\r
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortGetControl (\r
- OUT UINT32 *Control\r
- )\r
-{\r
- if (SerialPortPoll ()) {\r
- // If a character is pending don't set EFI_SERIAL_INPUT_BUFFER_EMPTY\r
- *Control = EFI_SERIAL_OUTPUT_BUFFER_EMPTY;\r
- } else {\r
- *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;\r
- }\r
- return RETURN_SUCCESS;\r
-}\r
-\r
-/**\r
- Set the serial device attributes.\r
-\r
- @return Always return RETURN_UNSUPPORTED.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortSetAttributes (\r
- IN OUT UINT64 *BaudRate,\r
- IN OUT UINT32 *ReceiveFifoDepth,\r
- IN OUT UINT32 *Timeout,\r
- IN OUT EFI_PARITY_TYPE *Parity,\r
- IN OUT UINT8 *DataBits,\r
- IN OUT EFI_STOP_BITS_TYPE *StopBits\r
- )\r
-{\r
- return RETURN_UNSUPPORTED;\r
-}\r
-\r
+++ /dev/null
-#/** @file\r
-# Template for Extended Serial Port Library for UEFI drivers\r
-#\r
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-# Copyright (c) 2012, ARM Ltd. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = TemplateSerialPortExtLib\r
- FILE_GUID = 231fe752-40ac-40b0-8d23-4e341309b964\r
- MODULE_TYPE = BASE\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = SerialPortExtLib\r
-\r
-\r
-#\r
-# VALID_ARCHITECTURES = ARM IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
- TemplateSerialPortExtLib.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
-\r
+++ /dev/null
-#/** @file\r
-#\r
-# Convert SerialLib into SerialIo protocol\r
-#\r
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = SerialDxe\r
- FILE_GUID = D3987D4B-971A-435F-8CAF-4967EB627241\r
- MODULE_TYPE = DXE_DRIVER\r
- VERSION_STRING = 1.0\r
-\r
- ENTRY_POINT = SerialDxeInitialize\r
-\r
-[Sources.common]\r
- SerialIo.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
-\r
-[LibraryClasses]\r
- BaseLib\r
- ReportStatusCodeLib\r
- MemoryAllocationLib\r
- UefiLib\r
- UefiBootServicesTableLib\r
- BaseMemoryLib\r
- DebugLib\r
- UefiDriverEntryPoint\r
- SerialPortLib\r
- SerialPortExtLib\r
-\r
-[Protocols]\r
- gEfiSerialIoProtocolGuid\r
- gEfiDevicePathProtocolGuid\r
-\r
-[FixedPcd]\r
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate\r
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits\r
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity\r
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits\r
-\r
-[Depex]\r
- TRUE\r
+++ /dev/null
-/** @file\r
- Serial IO Abstraction for GDB stub. This allows an EFI consoles that shows up on the system\r
- running GDB. One console for error information and another console for user input/output.\r
-\r
- Basic packet format is $packet-data#checksum. So every command has 4 bytes of overhead: $,\r
- #, 0, 0. The 0 and 0 are the ascii characters for the checksum.\r
-\r
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/SerialPortExtLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-#include <Protocol/SerialIo.h>\r
-\r
-typedef struct {\r
- VENDOR_DEVICE_PATH Guid;\r
- UART_DEVICE_PATH Uart;\r
- EFI_DEVICE_PATH_PROTOCOL End;\r
-} SIMPLE_TEXT_OUT_DEVICE_PATH;\r
-\r
-SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {\r
- {\r
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0} },\r
- EFI_CALLER_ID_GUID // Use the drivers GUID\r
- },\r
- {\r
- { MESSAGING_DEVICE_PATH, MSG_UART_DP, { sizeof (UART_DEVICE_PATH), 0} },\r
- 0, // Reserved\r
- FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate\r
- FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits\r
- FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)\r
- FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits\r
- },\r
- { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } }\r
-};\r
-\r
-EFI_HANDLE gHandle = NULL;\r
-\r
-/**\r
- Reset the serial device.\r
-\r
- @param This Protocol instance pointer.\r
-\r
- @retval EFI_SUCCESS The device was reset.\r
- @retval EFI_DEVICE_ERROR The serial device could not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialReset (\r
- IN EFI_SERIAL_IO_PROTOCOL *This\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_TPL Tpl;\r
-\r
- Status = SerialPortInitialize ();\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Set the Serial I/O mode and update the device path\r
- //\r
-\r
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
- //\r
- // Set the Serial I/O mode\r
- //\r
- This->Mode->ReceiveFifoDepth = 0;\r
- This->Mode->Timeout = 1000000;\r
- This->Mode->BaudRate = PcdGet64 (PcdUartDefaultBaudRate);\r
- This->Mode->DataBits = (UINT32)PcdGet8 (PcdUartDefaultDataBits);\r
- This->Mode->Parity = (UINT32)PcdGet8 (PcdUartDefaultParity);\r
- This->Mode->StopBits = (UINT32)PcdGet8 (PcdUartDefaultStopBits);\r
-\r
- //\r
- // Check if the device path has actually changed\r
- //\r
- if (mDevicePath.Uart.BaudRate == This->Mode->BaudRate &&\r
- mDevicePath.Uart.DataBits == (UINT8)This->Mode->DataBits &&\r
- mDevicePath.Uart.Parity == (UINT8)This->Mode->Parity &&\r
- mDevicePath.Uart.StopBits == (UINT8)This->Mode->StopBits\r
- ) {\r
- gBS->RestoreTPL (Tpl);\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Update the device path\r
- //\r
- mDevicePath.Uart.BaudRate = This->Mode->BaudRate;\r
- mDevicePath.Uart.DataBits = (UINT8)This->Mode->DataBits;\r
- mDevicePath.Uart.Parity = (UINT8)This->Mode->Parity;\r
- mDevicePath.Uart.StopBits = (UINT8)This->Mode->StopBits;\r
-\r
- Status = gBS->ReinstallProtocolInterface (\r
- gHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- &mDevicePath,\r
- &mDevicePath\r
- );\r
-\r
- gBS->RestoreTPL (Tpl);\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,\r
- data buts, and stop bits on a serial device.\r
-\r
- @param This Protocol instance pointer.\r
- @param BaudRate The requested baud rate. A BaudRate value of 0 will use the the\r
- device's default interface speed.\r
- @param ReceiveFifoDepth The requested depth of the FIFO on the receive side of the\r
- serial interface. A ReceiveFifoDepth value of 0 will use\r
- the device's default FIFO depth.\r
- @param Timeout The requested time out for a single character in microseconds.\r
- This timeout applies to both the transmit and receive side of the\r
- interface. A Timeout value of 0 will use the device's default time\r
- out value.\r
- @param Parity The type of parity to use on this serial device. A Parity value of\r
- DefaultParity will use the device's default parity value.\r
- @param DataBits The number of data bits to use on the serial device. A DataBits\r
- value of 0 will use the device's default data bit setting.\r
- @param StopBits The number of stop bits to use on this serial device. A StopBits\r
- value of DefaultStopBits will use the device's default number of\r
- stop bits.\r
-\r
- @retval EFI_SUCCESS The device was reset.\r
- @retval EFI_DEVICE_ERROR The serial device could not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialSetAttributes (\r
- IN EFI_SERIAL_IO_PROTOCOL *This,\r
- IN UINT64 BaudRate,\r
- IN UINT32 ReceiveFifoDepth,\r
- IN UINT32 Timeout,\r
- IN EFI_PARITY_TYPE Parity,\r
- IN UINT8 DataBits,\r
- IN EFI_STOP_BITS_TYPE StopBits\r
- )\r
-{\r
- RETURN_STATUS ReturnStatus;\r
- EFI_STATUS Status;\r
- EFI_TPL Tpl;\r
-\r
- ReturnStatus = SerialPortSetAttributes (&BaudRate, &ReceiveFifoDepth, &Timeout, &Parity, &DataBits, &StopBits);\r
- if (RETURN_ERROR (ReturnStatus)) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- //\r
- // Set the Serial I/O mode and update the device path\r
- //\r
-\r
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
- //\r
- // Set the Serial I/O mode\r
- //\r
- This->Mode->BaudRate = BaudRate;\r
- This->Mode->ReceiveFifoDepth = ReceiveFifoDepth;\r
- This->Mode->Timeout = Timeout;\r
- This->Mode->Parity = (UINT32)Parity;\r
- This->Mode->DataBits = (UINT32)DataBits;\r
- This->Mode->StopBits = (UINT32)StopBits;\r
-\r
- //\r
- // Check if the device path has actually changed\r
- //\r
- if (mDevicePath.Uart.BaudRate == BaudRate &&\r
- mDevicePath.Uart.Parity == (UINT8)Parity &&\r
- mDevicePath.Uart.DataBits == DataBits &&\r
- mDevicePath.Uart.StopBits == (UINT8)StopBits\r
- ) {\r
- gBS->RestoreTPL (Tpl);\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Update the device path\r
- //\r
- mDevicePath.Uart.BaudRate = BaudRate;\r
- mDevicePath.Uart.DataBits = DataBits;\r
- mDevicePath.Uart.Parity = (UINT8) Parity;\r
- mDevicePath.Uart.StopBits = (UINT8) StopBits;\r
-\r
- Status = gBS->ReinstallProtocolInterface (\r
- gHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- &mDevicePath,\r
- &mDevicePath\r
- );\r
-\r
- gBS->RestoreTPL (Tpl);\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Set the control bits on a serial device\r
-\r
- @param This Protocol instance pointer.\r
- @param Control Set the bits of Control that are settable.\r
-\r
- @retval EFI_SUCCESS The new control bits were set on the serial device.\r
- @retval EFI_UNSUPPORTED The serial device does not support this operation.\r
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialSetControl (\r
- IN EFI_SERIAL_IO_PROTOCOL *This,\r
- IN UINT32 Control\r
- )\r
-{\r
- return SerialPortSetControl(Control);\r
-}\r
-\r
-\r
-/**\r
- Retrieves the status of the control bits on a serial device\r
-\r
- @param This Protocol instance pointer.\r
- @param Control A pointer to return the current Control signals from the serial device.\r
-\r
- @retval EFI_SUCCESS The control bits were read from the serial device.\r
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialGetControl (\r
- IN EFI_SERIAL_IO_PROTOCOL *This,\r
- OUT UINT32 *Control\r
- )\r
-{\r
- return SerialPortGetControl(Control);\r
-}\r
-\r
-\r
-/**\r
- Writes data to a serial device.\r
-\r
- @param This Protocol instance pointer.\r
- @param BufferSize On input, the size of the Buffer. On output, the amount of\r
- data actually written.\r
- @param Buffer The buffer of data to write\r
-\r
- @retval EFI_SUCCESS The data was written.\r
- @retval EFI_DEVICE_ERROR The device reported an error.\r
- @retval EFI_TIMEOUT The data write was stopped due to a timeout.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialWrite (\r
- IN EFI_SERIAL_IO_PROTOCOL *This,\r
- IN OUT UINTN *BufferSize,\r
- IN VOID *Buffer\r
- )\r
-{\r
- UINTN Count;\r
-\r
- Count = SerialPortWrite (Buffer, *BufferSize);\r
-\r
- if (Count != *BufferSize) {\r
- *BufferSize = Count;\r
- return EFI_TIMEOUT;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Reads data from a serial device.\r
-\r
- @param This Protocol instance pointer.\r
- @param BufferSize On input, the size of the Buffer. On output, the amount of\r
- data returned in Buffer.\r
- @param Buffer The buffer to return the data into.\r
-\r
- @retval EFI_SUCCESS The data was read.\r
- @retval EFI_DEVICE_ERROR The device reported an error.\r
- @retval EFI_TIMEOUT The data write was stopped due to a timeout.\r
-\r
-**/\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SerialRead (\r
- IN EFI_SERIAL_IO_PROTOCOL *This,\r
- IN OUT UINTN *BufferSize,\r
- OUT VOID *Buffer\r
- )\r
-{\r
- UINTN Count = 0;\r
-\r
- if (SerialPortPoll()) {\r
- Count = SerialPortRead (Buffer, *BufferSize);\r
- }\r
-\r
- if (Count != *BufferSize) {\r
- *BufferSize = Count;\r
- return EFI_TIMEOUT;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// Template used to initialize the GDB Serial IO protocols\r
-//\r
-EFI_SERIAL_IO_MODE gSerialIoMode = {\r
- 0, // ControlMask\r
- 0, // Timeout\r
- FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate\r
- 1, // ReceiveFifoDepth\r
- FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits\r
- FixedPcdGet8 (PcdUartDefaultParity), // Parity\r
- FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits\r
-};\r
-\r
-\r
-EFI_SERIAL_IO_PROTOCOL gSerialIoTemplate = {\r
- SERIAL_IO_INTERFACE_REVISION,\r
- SerialReset,\r
- SerialSetAttributes,\r
- SerialSetControl,\r
- SerialGetControl,\r
- SerialWrite,\r
- SerialRead,\r
- &gSerialIoMode\r
-};\r
-\r
-/**\r
- Initialize the state information for the Serial Io Protocol\r
-\r
- @param ImageHandle of the loaded driver\r
- @param SystemTable Pointer to the System Table\r
-\r
- @retval EFI_SUCCESS Protocol registered\r
- @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure\r
- @retval EFI_DEVICE_ERROR Hardware problems\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SerialDxeInitialize (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- // Make a new handle with Serial IO protocol and its device path on it.\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &gHandle,\r
- &gEfiSerialIoProtocolGuid, &gSerialIoTemplate,\r
- &gEfiDevicePathProtocolGuid, &mDevicePath,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return Status;\r
-}\r
-\r