]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c
MdeModulePkg/Universal/StatusCodeHandler: Fix a bug about log lost
[mirror_edk2.git] / MdeModulePkg / Universal / StatusCodeHandler / RuntimeDxe / SerialStatusCodeWorker.c
index 45986fcae38adf23600608bca0ea5d36c14540b0..348f55edba544c44ca18dd04c5e99f3e925a3f1c 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Serial I/O status code reporting worker.\r
 \r
-  Copyright (c) 2006 - 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
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -16,7 +10,7 @@
 \r
 /**\r
   Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
\r
+\r
   @param  CodeType         Indicates the type of status code being reported.\r
   @param  Value            Describes the current status of a hardware or software entity.\r
                            This included information about the class and subclass that is used to\r
@@ -73,9 +67,9 @@ SerialStatusCodeReportWorker (
     // Print DEBUG() information into output buffer.\r
     //\r
     CharCount = AsciiBSPrint (\r
-                  Buffer, \r
-                  sizeof (Buffer), \r
-                  Format, \r
+                  Buffer,\r
+                  sizeof (Buffer),\r
+                  Format,\r
                   Marker\r
                   );\r
   } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
@@ -83,15 +77,15 @@ SerialStatusCodeReportWorker (
     // Print ERROR information into output buffer.\r
     //\r
     CharCount = AsciiSPrint (\r
-                  Buffer, \r
-                  sizeof (Buffer), \r
-                  "ERROR: C%08x:V%08x I%x", \r
-                  CodeType, \r
-                  Value, \r
+                  Buffer,\r
+                  sizeof (Buffer),\r
+                  "ERROR: C%08x:V%08x I%x",\r
+                  CodeType,\r
+                  Value,\r
                   Instance\r
                   );\r
     ASSERT (CharCount > 0);\r
-   \r
+\r
     if (CallerId != NULL) {\r
       CharCount += AsciiSPrint (\r
                      &Buffer[CharCount],\r
@@ -120,10 +114,10 @@ SerialStatusCodeReportWorker (
     // Print PROGRESS information into output buffer.\r
     //\r
     CharCount = AsciiSPrint (\r
-                  Buffer, \r
-                  sizeof (Buffer), \r
-                  "PROGRESS CODE: V%08x I%x\n\r", \r
-                  Value, \r
+                  Buffer,\r
+                  sizeof (Buffer),\r
+                  "PROGRESS CODE: V%08x I%x\n\r",\r
+                  Value,\r
                   Instance\r
                   );\r
   } else if (Data != NULL &&\r
@@ -135,7 +129,7 @@ SerialStatusCodeReportWorker (
     CharCount = AsciiSPrint (\r
                   Buffer,\r
                   sizeof (Buffer),\r
-                  "%a\n\r",\r
+                  "%a",\r
                   ((EFI_STATUS_CODE_STRING_DATA *) Data)->String.Ascii\r
                   );\r
   } else {\r
@@ -143,11 +137,11 @@ SerialStatusCodeReportWorker (
     // Code type is not defined.\r
     //\r
     CharCount = AsciiSPrint (\r
-                  Buffer, \r
-                  sizeof (Buffer), \r
-                  "Undefined: C%08x:V%08x I%x\n\r", \r
-                  CodeType, \r
-                  Value, \r
+                  Buffer,\r
+                  sizeof (Buffer),\r
+                  "Undefined: C%08x:V%08x I%x\n\r",\r
+                  CodeType,\r
+                  Value,\r
                   Instance\r
                   );\r
   }\r
@@ -157,6 +151,16 @@ SerialStatusCodeReportWorker (
   //\r
   SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
 \r
+  //\r
+  // If register an unregister function of gEfiEventExitBootServicesGuid,\r
+  // then some log called in ExitBootServices() will be lost,\r
+  // so unregister the handler after receive the value of exit boot service.\r
+  //\r
+  if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE &&\r
+      Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) {\r
+    UnregisterSerialBootTimeHandlers();\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r