]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/DxeIpl/SerialStatusCode.c
UefiCpuPkg/PiSmmCpuDxeSmm: patch "gSmbase" with PatchInstructionX86()
[mirror_edk2.git] / DuetPkg / DxeIpl / SerialStatusCode.c
index 5bab29a1aa6a14ee5dcf232da260c8842e17839e..15959323834760e9796dbcb50caa9d4c5661cd4b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2011, 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
@@ -18,16 +18,9 @@ Revision History:
 \r
 **/\r
 \r
+#include <Library/SerialPortLib.h>\r
 #include "SerialStatusCode.h"\r
 \r
-\r
-UINT16  gComBase = 0x3f8;\r
-UINTN   gBps = 115200;\r
-UINT8   gData = 8;\r
-UINT8   gStop = 1;\r
-UINT8   gParity = 0;\r
-UINT8   gBreakSet = 0;\r
-\r
 //\r
 // All of the lookup tables are only needed in debug.\r
 //\r
@@ -602,68 +595,6 @@ Returns:
 }\r
 \r
 \r
-\r
-VOID\r
-DebugSerialWrite (\r
-  IN UINT8  Character\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- DebugSerialWrite - Outputs a character to the Serial port\r
-\r
-  Repeatedly polls the TXRDY bit of the Line Status Register\r
-  until the Transmitter Holding Register is empty.  The character\r
-  is then written to the Serial port.\r
-\r
-Arguments:\r
-\r
-  Character   - Character to write\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT8   Data;\r
-\r
-  //\r
-  // Wait for the serail port to be ready.\r
-  //\r
-  do {\r
-    Data = IoRead8 (gComBase + LSR_OFFSET);\r
-  } while ((Data & LSR_TXRDY) == 0);\r
-    \r
-  IoWrite8 (gComBase, Character);\r
-}\r
-\r
-VOID\r
-DebugSerialPrint (\r
-  IN CHAR8    *OutputString\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Prints a string to the Serial port\r
-\r
-Arguments:\r
-\r
-  OutputString - Ascii string to print to serial port.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  for ( ; *OutputString != 0; OutputString++) {\r
-    DebugSerialWrite (*OutputString);\r
-  }\r
-}\r
-\r
 EFI_STATUS\r
 EFIAPI \r
 SerialReportStatusCode (\r
@@ -697,7 +628,7 @@ Returns:
   CHAR8                   *Format;\r
   BASE_LIST               Marker;\r
   UINT32                  ErrorLevel;\r
-  UINTN                   CharCount;\r
+  UINTN                   CharCount = 0;\r
 \r
   Buffer[0] = '\0';\r
 \r
@@ -706,7 +637,7 @@ Returns:
     //\r
     // Processes PEI_ASSERT ()\r
     //\r
-    AsciiSPrint (\r
+    CharCount = AsciiSPrint (\r
       Buffer,\r
       sizeof (Buffer),\r
       "\nPEI_ASSERT!: %a (%d): %a\n",\r
@@ -720,7 +651,7 @@ Returns:
     //\r
     // Process PEI_DEBUG () macro to Serial\r
     //\r
-    AsciiBSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
+    CharCount = AsciiBSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
 \r
   } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { \r
     //\r
@@ -744,7 +675,7 @@ Returns:
     //\r
     // Callout to platform Lib function to do print.\r
     //\r
-    DebugSerialPrint (Buffer);\r
+    SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
   }\r
 \r
   //\r
@@ -786,7 +717,7 @@ Returns:
         //\r
         // Concatenate the instance\r
         //\r
-        AsciiSPrint (\r
+        CharCount = AsciiSPrint (\r
           Buffer,\r
           sizeof (Buffer),\r
           "%a:%a:%a:%d\n",\r
@@ -796,7 +727,7 @@ Returns:
           Instance\r
           );\r
 \r
-        DebugSerialPrint (Buffer);\r
+        SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
       }\r
     }\r
 \r
@@ -812,15 +743,11 @@ InstallSerialStatusCode (
 \r
 Routine Description:\r
 \r
-  Initialize Serial Port\r
-\r
-    The Baud Rate Divisor registers are programmed and the LCR \r
-    is used to configure the communications format. Hard coded\r
-    UART config comes from globals in DebugSerialPlatform lib.\r
+  Initialize Serial Port and Status Code Handler\r
 \r
 Arguments: \r
 \r
-  None\r
+  ReportStatusCode - A pointer to the handler\r
 \r
 Returns: \r
 \r
@@ -828,41 +755,6 @@ Returns:
 \r
 --*/\r
 {\r
-  UINTN           Divisor;\r
-  UINT8           OutputData;\r
-  UINT8           Data;\r
-\r
-  //\r
-  // Some init is done by the platform status code initialization.\r
-  //\r
-  \r
-  //\r
-  // Map 5..8 to 0..3\r
-  //\r
-  Data = (UINT8) (gData - (UINT8)5);\r
-\r
-  //\r
-  // Calculate divisor for baud generator\r
-  //\r
-  Divisor = 115200 / gBps; \r
-  \r
-  //\r
-  // Set communications format\r
-  //\r
-  OutputData = (UINT8)((DLAB << 7) | ((gBreakSet << 6) | ((gParity << 3) | ((gStop << 2) | Data))));\r
-  IoWrite8 (gComBase + LCR_OFFSET, OutputData);\r
-\r
-  //\r
-  // Configure baud rate\r
-  //\r
-  IoWrite8 (gComBase + BAUD_HIGH_OFFSET, (UINT8)(Divisor >> 8));\r
-  IoWrite8 (gComBase + BAUD_LOW_OFFSET, (UINT8)(Divisor & 0xff));\r
-\r
-  //\r
-  // Switch back to bank 0\r
-  //\r
-  OutputData = (UINT8)((~DLAB<<7)|((gBreakSet<<6)|((gParity<<3)|((gStop<<2)| Data))));\r
-  IoWrite8 (gComBase + LCR_OFFSET, OutputData);\r
-\r
+  SerialPortInitialize();\r
   *ReportStatusCode = SerialReportStatusCode;\r
 }\r