]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CorebootPayloadPkg: Use SerialDxe in MdeModulePkg
authorStar Zeng <star.zeng@intel.com>
Thu, 26 Nov 2015 08:49:26 +0000 (08:49 +0000)
committerlzeng14 <lzeng14@Edk2>
Thu, 26 Nov 2015 08:49:26 +0000 (08:49 +0000)
1. Update fdf and dsc to use SerialDxe in MdeModulePkg.
2. Separate the code that gets SerialRegBase and SerialRegAccessType
   by CbParseLib from CorebootPayloadPkg/Library/SerialPortLib to
   PlatformHookLib, and then leverage BaseSerialPortLib16550 in
   MdeModulePkg.
3. Remove CorebootPayloadPkg/SerialDxe and
   CorebootPayloadPkg/Library/SerialPortLib.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18968 6f19259b-4bc3-4df7-8a09-765794883524

CorebootPayloadPkg/CorebootPayloadPkg.fdf
CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc
CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc
CorebootPayloadPkg/Library/PlatformBdsLib/BdsPlatform.h
CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c [new file with mode: 0644]
CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf [new file with mode: 0644]
CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.c [deleted file]
CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf [deleted file]
CorebootPayloadPkg/SerialDxe/SerialDxe.inf [deleted file]
CorebootPayloadPkg/SerialDxe/SerialIo.c [deleted file]

index 810dcb1655e6f671fffe5b7ea30277af55b8dfdb..c160e434618768abc3126e3f9a8094601a95eb73 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 # Provides drivers and definitions to create uefi payload for coreboot. \r
 #\r
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials are licensed and made available under \r
 # the terms and conditions of the BSD License that accompanies this distribution.  \r
 # The full text of the license may be found at\r
@@ -116,7 +116,7 @@ INF DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf
 #\r
 # ISA Support\r
 #\r
-INF CorebootPayloadPkg/SerialDxe/SerialDxe.inf\r
+INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf\r
 \r
 #\r
 # Console Support\r
index 00a584234f2f610909236f9721efef128bb087cf..2c37e443fa780db5ccfe9426728ff0f25f7e634e 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 # Provides drivers and definitions to create uefi payload for coreboot. \r
 #\r
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials are licensed and made available under \r
 # the terms and conditions of the BSD License that accompanies this distribution.  \r
 # The full text of the license may be found at\r
   #\r
   TimerLib|CorebootPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
   ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf\r
-  SerialPortLib|CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf\r
+  SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf\r
+  PlatformHookLib|CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf\r
   PlatformBdsLib|CorebootPayloadPkg/Library/PlatformBdsLib/PlatformBdsLib.inf\r
   \r
   #\r
   gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2\r
 !endif\r
 \r
+[PcdsPatchableInModule.common]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x03F8\r
+\r
 ################################################################################\r
 #\r
 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform\r
   #\r
   # ISA Support\r
   #\r
-  CorebootPayloadPkg/SerialDxe/SerialDxe.inf\r
+  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf\r
   \r
   #\r
   # Console Support\r
index ecd12fbf8514ce5febc56556f7e8d01e162aa8bb..cfaf3048f8defbe871c133906edcb0e68a43aed2 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 # Provides drivers and definitions to create uefi payload for coreboot. \r
 #\r
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials are licensed and made available under \r
 # the terms and conditions of the BSD License that accompanies this distribution.  \r
 # The full text of the license may be found at\r
   #\r
   TimerLib|CorebootPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
   ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf\r
-  SerialPortLib|CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf\r
+  SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf\r
+  PlatformHookLib|CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf\r
   PlatformBdsLib|CorebootPayloadPkg/Library/PlatformBdsLib/PlatformBdsLib.inf\r
   \r
   #\r
   gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2\r
 !endif\r
 \r
+[PcdsPatchableInModule.common]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x03F8\r
+\r
 ################################################################################\r
 #\r
 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform\r
   #\r
   # ISA Support\r
   #\r
-  CorebootPayloadPkg/SerialDxe/SerialDxe.inf\r
+  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf\r
   \r
   #\r
   # Console Support\r
index 975a7718678ef89e004d29275651419a2d349464..641e1cbf01bca7b06ab4973375d5870abee872ba 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Head file for BDS Platform specific code\r
 \r
-Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2014 - 2015, 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
@@ -29,7 +29,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DevicePathLib.h>\r
 \r
 #include <Protocol/PciIo.h>\r
-#include <Protocol/SerialIo.h>\r
 \r
 #include <Guid/GlobalVariable.h>\r
 extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];\r
@@ -94,7 +93,7 @@ extern VENDOR_DEVICE_PATH         gUartDeviceVenderNode;
         (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \\r
       } \\r
     }, \\r
-    EFI_SERIAL_IO_PROTOCOL_GUID \\r
+    {0xD3987D4B, 0x971A, 0x435F, {0x8C, 0xAF, 0x49, 0x67, 0xEB, 0x62, 0x72, 0x41}} \\r
   }\r
     \r
 #define gUart \\r
diff --git a/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c b/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c
new file mode 100644 (file)
index 0000000..10fd332
--- /dev/null
@@ -0,0 +1,56 @@
+/** @file\r
+  Platform Hook Library instance for UART device upon coreboot.\r
+\r
+  Copyright (c) 2015, 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
+#include <Base.h>\r
+#include <Uefi/UefiBaseType.h>\r
+#include <Library/PlatformHookLib.h>\r
+#include <Library/CbParseLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+/**\r
+  Performs platform specific initialization required for the CPU to access\r
+  the hardware associated with a SerialPortLib instance.  This function does\r
+  not intiailzie the serial port hardware itself.  Instead, it initializes\r
+  hardware devices that are required for the CPU to access the serial port\r
+  hardware.  This function may be called more than once.\r
+\r
+  @retval RETURN_SUCCESS       The platform specific initialization succeeded.\r
+  @retval RETURN_DEVICE_ERROR  The platform specific initialization could not be completed.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PlatformHookSerialPortInitialize (\r
+  VOID\r
+  )\r
+{\r
+  RETURN_STATUS     Status;\r
+  UINT32            SerialRegBase;\r
+  UINT32            SerialRegAccessType;\r
+\r
+  Status = CbParseSerialInfo (&SerialRegBase, &SerialRegAccessType, NULL);\r
+  if (RETURN_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (SerialRegAccessType == 2) { //MMIO\r
+    PcdSetBoolS (PcdSerialUseMmio, TRUE);\r
+  } else { //IO\r
+    PcdSetBoolS (PcdSerialUseMmio, FALSE);\r
+  }\r
+  PcdSet64S (PcdSerialRegisterBase, (UINT64) SerialRegBase);\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
diff --git a/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf b/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf
new file mode 100644 (file)
index 0000000..e5db75f
--- /dev/null
@@ -0,0 +1,38 @@
+## @file\r
+#  Platform Hook Library instance for UART device upon coreboot.\r
+#\r
+#  Copyright (c) 2015, Intel Corporation. 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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PlatformHookLib\r
+  FILE_GUID                      = 40A2CBC6-CFB8-447b-A90E-198E88FD345E\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PlatformHookLib\r
+\r
+[Sources]\r
+  PlatformHookLib.c\r
+\r
+[LibraryClasses]\r
+  CbParseLib\r
+  PcdLib\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  CorebootModulePkg/CorebootModulePkg.dec\r
+\r
+[Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio       ## PRODUCES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase  ## PRODUCES\r
+\r
diff --git a/CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.c b/CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.c
deleted file mode 100644 (file)
index 0d87e62..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-/** @file\r
-  SerialPortLib instance for UART device upon coreboot\r
-\r
-  Copyright (c) 2014, 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
-#include <Uefi/UefiBaseType.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/CbParseLib.h>\r
-\r
-//\r
-// 16550 UART register offsets and bitfields\r
-//\r
-#define R_UART_RXBUF          0\r
-#define R_UART_TXBUF          0\r
-#define R_UART_BAUD_LOW       0\r
-#define R_UART_BAUD_HIGH      1\r
-#define R_UART_FCR            2\r
-#define   B_UART_FCR_FIFOE    BIT0\r
-#define   B_UART_FCR_FIFO64   BIT5\r
-#define R_UART_LCR            3\r
-#define   B_UART_LCR_DLAB     BIT7\r
-#define R_UART_MCR            4\r
-#define   B_UART_MCR_RTS      BIT1\r
-#define R_UART_LSR            5\r
-#define   B_UART_LSR_RXRDY    BIT0\r
-#define   B_UART_LSR_TXRDY    BIT5\r
-#define   B_UART_LSR_TEMT     BIT6\r
-#define R_UART_MSR            6\r
-#define   B_UART_MSR_CTS      BIT4\r
-#define   B_UART_MSR_DSR      BIT5\r
-\r
-UINT32 mSerialRegBase = 0;\r
-UINT32 mSerialRegAccessType = 0;\r
-\r
-/**\r
-  Read an 8-bit 16550 register.  If PcdSerialUseMmio is TRUE, then the value is read from \r
-  MMIO space.  If PcdSerialUseMmio is FALSE, then the value is read from I/O space.  The\r
-  parameter Offset is added to the base address of the 16550 registers that is specified \r
-  by PcdSerialRegisterBase. \r
-  \r
-  @param  Offset  The offset of the 16550 register to read.\r
-\r
-  @return The value read from the 16550 register.\r
-\r
-**/\r
-UINT8\r
-SerialPortReadRegister (\r
-  UINTN  Offset\r
-  )\r
-{\r
-  if (mSerialRegAccessType == 2) { //MMIO\r
-    return MmioRead8 (mSerialRegBase + Offset);\r
-  } else { //IO\r
-    return IoRead8 ((UINT16)mSerialRegBase + Offset);\r
-  }\r
-}\r
-\r
-/**\r
-  Write an 8-bit 16550 register.  If PcdSerialUseMmio is TRUE, then the value is written to\r
-  MMIO space.  If PcdSerialUseMmio is FALSE, then the value is written to I/O space.  The\r
-  parameter Offset is added to the base address of the 16550 registers that is specified \r
-  by PcdSerialRegisterBase. \r
-  \r
-  @param  Offset  The offset of the 16550 register to write.\r
-  @param  Value   The value to write to the 16550 register specified by Offset.\r
-\r
-  @return The value written to the 16550 register.\r
-\r
-**/\r
-UINT8\r
-SerialPortWriteRegister (\r
-  UINTN  Offset,\r
-  UINT8  Value\r
-  )\r
-{\r
-  if (mSerialRegAccessType == 2) { //MMIO\r
-    return MmioWrite8 (mSerialRegBase + Offset, Value);\r
-  } else {// IO\r
-    return IoWrite8 ((UINT16)mSerialRegBase + Offset, Value);\r
-  }\r
-}\r
-\r
-/**\r
-  Initialize the serial device hardware.\r
-  \r
-  If no initialization is required, then return RETURN_SUCCESS.\r
-  If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
-  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
-  \r
-  @retval RETURN_SUCCESS        The serial device was initialized.\r
-  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortInitialize (\r
-  VOID\r
-  )\r
-{\r
-  RETURN_STATUS  Status;\r
-  UINTN          Divisor;\r
-  BOOLEAN        Initialized;\r
-  \r
-  Status = CbParseSerialInfo (&mSerialRegBase, &mSerialRegAccessType, NULL);\r
-  if (RETURN_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // See if the serial port is already initialized\r
-  //\r
-  Initialized = TRUE;\r
-  if ((SerialPortReadRegister (R_UART_FCR) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64)) !=\r
-      (PcdGet8 (PcdSerialFifoControl)      & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64))     ) {\r
-    Initialized = FALSE;\r
-  }\r
-\r
-  if ((SerialPortReadRegister (R_UART_LCR) & 0x3F) != (PcdGet8 (PcdSerialLineControl) & 0x3F)) {\r
-    Initialized = FALSE;\r
-  }\r
-  SerialPortWriteRegister (R_UART_LCR, (UINT8)(SerialPortReadRegister (R_UART_LCR) | B_UART_LCR_DLAB));\r
-  Divisor =  SerialPortReadRegister (R_UART_BAUD_HIGH) << 8;\r
-  Divisor |= SerialPortReadRegister (R_UART_BAUD_LOW);\r
-  SerialPortWriteRegister (R_UART_LCR, (UINT8)(SerialPortReadRegister (R_UART_LCR) & ~B_UART_LCR_DLAB));\r
-  if (Divisor != 115200 / PcdGet32 (PcdSerialBaudRate)) {\r
-    Initialized = FALSE;\r
-  }\r
-  if (Initialized) {\r
-    return RETURN_SUCCESS;\r
-  }\r
-  \r
-  //\r
-  // Configure baud rate\r
-  //\r
-  Divisor = 115200 / PcdGet32 (PcdSerialBaudRate);\r
-  SerialPortWriteRegister (R_UART_LCR, B_UART_LCR_DLAB);\r
-  SerialPortWriteRegister (R_UART_BAUD_HIGH, (UINT8) (Divisor >> 8));\r
-  SerialPortWriteRegister (R_UART_BAUD_LOW, (UINT8) (Divisor & 0xff));\r
-\r
-  //\r
-  // Clear DLAB and configure Data Bits, Parity, and Stop Bits.\r
-  // Strip reserved bits from PcdSerialLineControl\r
-  //\r
-  SerialPortWriteRegister (R_UART_LCR, (UINT8)(PcdGet8 (PcdSerialLineControl) & 0x3F));\r
-\r
-  //\r
-  // Enable and reset FIFOs\r
-  // Strip reserved bits from PcdSerialFifoControl\r
-  //\r
-  SerialPortWriteRegister (R_UART_FCR, (UINT8)(PcdGet8 (PcdSerialFifoControl) & 0x27));\r
-\r
-  //\r
-  // Put Modem Control Register(MCR) into its reset state of 0x00.\r
-  //  \r
-  SerialPortWriteRegister (R_UART_MCR, 0x00);\r
-  \r
-  return RETURN_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write data from buffer to serial device. \r
\r
-  Writes NumberOfBytes data bytes from Buffer to the serial device.  \r
-  The number of bytes actually written to the serial device is returned.\r
-  If the return value is less than NumberOfBytes, then the write operation failed.\r
-\r
-  If Buffer is NULL, then ASSERT(). \r
-\r
-  If NumberOfBytes is zero, then return 0.\r
-\r
-  @param  Buffer           Pointer to the data buffer to be written.\r
-  @param  NumberOfBytes    Number of bytes to written to the serial device.\r
-\r
-  @retval 0                NumberOfBytes is 0.\r
-  @retval >0               The number of bytes written to the serial device.  \r
-                           If this value is less than NumberOfBytes, then the read operation failed.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortWrite (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-)\r
-{\r
-  UINTN    Result;\r
-  UINTN    Index;\r
-  UINTN    FifoSize;\r
-\r
-  if (Buffer == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  if (NumberOfBytes == 0) {\r
-    //\r
-    // Flush the hardware\r
-    //\r
-\r
-    //\r
-    // Wait for both the transmit FIFO and shift register empty.\r
-    //\r
-    while ((SerialPortReadRegister (R_UART_LSR) & B_UART_LSR_TEMT) == 0);\r
-\r
-    return 0;\r
-  }\r
-\r
-  //\r
-  // Compute the maximum size of the Tx FIFO\r
-  //\r
-  FifoSize = 1;\r
-  if ((PcdGet8 (PcdSerialFifoControl) & B_UART_FCR_FIFOE) != 0) {\r
-    if ((PcdGet8 (PcdSerialFifoControl) & B_UART_FCR_FIFO64) == 0) {\r
-      FifoSize = 16;\r
-    } else {\r
-      FifoSize = 64;\r
-    }\r
-  }\r
-\r
-  Result = NumberOfBytes;\r
-  while (NumberOfBytes != 0) {\r
-    //\r
-    // Wait for the serial port to be ready, to make sure both the transmit FIFO\r
-    // and shift register empty.\r
-    //\r
-    while ((SerialPortReadRegister (R_UART_LSR) & B_UART_LSR_TEMT) == 0);\r
-\r
-    //\r
-    // Fill then entire Tx FIFO\r
-    //\r
-    for (Index = 0; Index < FifoSize && NumberOfBytes != 0; Index++, NumberOfBytes--, Buffer++) {\r
-\r
-      //\r
-      // Write byte to the transmit buffer.\r
-      //\r
-      SerialPortWriteRegister (R_UART_TXBUF, *Buffer);\r
-    }\r
-  }\r
-  return Result;\r
-}\r
-\r
-/**\r
-  Reads data from a serial device into a buffer.\r
-\r
-  @param  Buffer           Pointer to the data buffer to store the data read from the serial device.\r
-  @param  NumberOfBytes    Number of bytes to read from the serial device.\r
-\r
-  @retval 0                NumberOfBytes is 0.\r
-  @retval >0               The number of bytes read from the serial device.  \r
-                           If this value is less than NumberOfBytes, then the read operation failed.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortRead (\r
-  OUT UINT8     *Buffer,\r
-  IN  UINTN     NumberOfBytes\r
-)\r
-{\r
-  UINTN  Result;\r
-\r
-  if (NULL == Buffer) {\r
-    return 0;\r
-  }\r
-  \r
-  for (Result = 0; NumberOfBytes-- != 0; Result++, Buffer++) {\r
-    //\r
-    // Wait for the serial port to have some data.\r
-    //\r
-    while ((SerialPortReadRegister (R_UART_LSR) & B_UART_LSR_RXRDY) == 0);\r
-        \r
-    //\r
-    // Read byte from the receive buffer.\r
-    //\r
-    *Buffer = SerialPortReadRegister (R_UART_RXBUF);\r
-  }\r
-  \r
-  return Result;\r
-}\r
-\r
-/**\r
-  Polls a serial device to see if there is any data waiting to be read.\r
-\r
-  Polls aserial device to see if there is any data waiting to be read.\r
-  If there is data waiting to be read from the serial device, then TRUE is returned.\r
-  If there is no data waiting to be read from the serial device, then FALSE is returned.\r
-\r
-  @retval TRUE             Data is waiting to be read from the serial device.\r
-  @retval FALSE            There is no data waiting to be read from the serial device.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-SerialPortPoll (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Read the serial port status\r
-  //\r
-  if ((SerialPortReadRegister (R_UART_LSR) & B_UART_LSR_RXRDY) != 0) {\r
-    return TRUE;\r
-  }  \r
-  \r
-  return FALSE;\r
-}\r
diff --git a/CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf b/CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf
deleted file mode 100644 (file)
index c7e48f8..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-## @file\r
-#   SerialPortLib instance for UART device upon coreboot\r
-#\r
-#  Copyright (c) 2014, 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                      = SerialPortLib\r
-  FILE_GUID                      = 40A2CBC6-CFB8-447b-A90E-198E88FD345E\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = SerialPortLib\r
-  \r
-  CONSTRUCTOR                    = SerialPortInitialize\r
-  \r
-[Sources]\r
-  SerialPortLib.c\r
-  \r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  CorebootModulePkg/CorebootModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  PcdLib\r
-  IoLib\r
-  CbParseLib\r
-  \r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialLineControl\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl
\ No newline at end of file
diff --git a/CorebootPayloadPkg/SerialDxe/SerialDxe.inf b/CorebootPayloadPkg/SerialDxe/SerialDxe.inf
deleted file mode 100644 (file)
index 04d9935..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#/** @file\r
-#  \r
-#  Convert SerialLib into SerialIo protocol\r
-#  \r
-#  Copyright (c) 2008 - 2014, 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
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  ReportStatusCodeLib\r
-  MemoryAllocationLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  UefiDriverEntryPoint\r
-  SerialPortLib\r
-  \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
diff --git a/CorebootPayloadPkg/SerialDxe/SerialIo.c b/CorebootPayloadPkg/SerialDxe/SerialIo.c
deleted file mode 100644 (file)
index cdede32..0000000
+++ /dev/null
@@ -1,392 +0,0 @@
-/** @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
-\r
-  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-  Copyright (c) 2013, ARM Ltd. All rights reserved.<BR>\r
-  Copyright (c) 2014, Intel Corporation. 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/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_SERIAL_IO_PROTOCOL_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
-  EFI_STATUS  Status;\r
-  EFI_TPL     Tpl;\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 EFI_UNSUPPORTED;\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
-  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 EFI_SUCCESS;\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