]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Library / PeiDebugLibDebugPpi / DebugLib.c
index dad6c351ff9a8a192e3097e29970924ac3189b74..4fb0ad8b843a029f7b594aed3225bc0c93534e98 100644 (file)
@@ -3,13 +3,7 @@
 \r
   Copyright (c) 2019, 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
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -46,14 +40,13 @@ DebugPrint (
   ...\r
   )\r
 {\r
-  VA_LIST         Marker;\r
+  VA_LIST  Marker;\r
 \r
   VA_START (Marker, Format);\r
   DebugVPrint (ErrorLevel, Format, Marker);\r
   VA_END (Marker);\r
 }\r
 \r
-\r
 /**\r
   Prints a debug message to the debug output device if the specified\r
   error level is enabled.\r
@@ -74,13 +67,13 @@ DebugPrint (
 VOID\r
 EFIAPI\r
 DebugBPrint (\r
-  IN  UINTN         ErrorLevel,\r
-  IN  CONST CHAR8   *Format,\r
-  IN  BASE_LIST     BaseListMarker\r
+  IN  UINTN        ErrorLevel,\r
+  IN  CONST CHAR8  *Format,\r
+  IN  BASE_LIST    BaseListMarker\r
   )\r
 {\r
-  EFI_STATUS      Status;\r
-  EDKII_DEBUG_PPI *DebugPpi;\r
+  EFI_STATUS       Status;\r
+  EDKII_DEBUG_PPI  *DebugPpi;\r
 \r
   //\r
   // If Format is NULL, then ASSERT().\r
@@ -95,11 +88,11 @@ DebugBPrint (
   }\r
 \r
   Status = PeiServicesLocatePpi (\r
-              &gEdkiiDebugPpiGuid,\r
-              0,\r
-              NULL,\r
-              (VOID **)&DebugPpi\r
-              );\r
+             &gEdkiiDebugPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&DebugPpi\r
+             );\r
   if (EFI_ERROR (Status)) {\r
     return;\r
   }\r
@@ -111,7 +104,6 @@ DebugBPrint (
               );\r
 }\r
 \r
-\r
 /**\r
   Worker function that convert a VA_LIST to a BASE_LIST based on a\r
   Null-terminated format string.\r
@@ -135,8 +127,8 @@ VaListToBaseList (
   IN  UINTN        Size\r
   )\r
 {\r
-  BASE_LIST       BaseListStart;\r
-  BOOLEAN         Long;\r
+  BASE_LIST  BaseListStart;\r
+  BOOLEAN    Long;\r
 \r
   ASSERT (Format != NULL);\r
 \r
@@ -144,7 +136,7 @@ VaListToBaseList (
 \r
   BaseListStart = BaseListMarker;\r
 \r
-  for (; *Format != '\0'; Format++) {\r
+  for ( ; *Format != '\0'; Format++) {\r
     //\r
     // Only format with prefix % is processed.\r
     //\r
@@ -158,25 +150,28 @@ VaListToBaseList (
     // Parse Flags and Width\r
     //\r
     for (Format++; TRUE; Format++) {\r
-      if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') {\r
+      if ((*Format == '.') || (*Format == '-') || (*Format == '+') || (*Format == ' ')) {\r
         //\r
         // These characters in format field are omitted.\r
         //\r
         continue;\r
       }\r
-      if (*Format >= '0' && *Format <= '9') {\r
+\r
+      if ((*Format >= '0') && (*Format <= '9')) {\r
         //\r
         // These characters in format field are omitted.\r
         //\r
         continue;\r
       }\r
-      if (*Format == 'L' || *Format == 'l') {\r
+\r
+      if ((*Format == 'L') || (*Format == 'l')) {\r
         //\r
         // 'L" or "l" in format field means the number being printed is a UINT64\r
         //\r
         Long = TRUE;\r
         continue;\r
       }\r
+\r
       if (*Format == '*') {\r
         //\r
         // '*' in format field means the precision of the field is specified by\r
@@ -185,6 +180,7 @@ VaListToBaseList (
         BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);\r
         continue;\r
       }\r
+\r
       if (*Format == '\0') {\r
         //\r
         // Make no output if Format string terminates unexpectedly when\r
@@ -192,6 +188,7 @@ VaListToBaseList (
         //\r
         Format--;\r
       }\r
+\r
       //\r
       // When valid argument type detected or format string terminates unexpectedly,\r
       // the inner loop is done.\r
@@ -205,13 +202,14 @@ VaListToBaseList (
     if ((*Format == 'p') && (sizeof (VOID *) > 4)) {\r
       Long = TRUE;\r
     }\r
-    if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {\r
+\r
+    if ((*Format == 'p') || (*Format == 'X') || (*Format == 'x') || (*Format == 'd') || (*Format == 'u')) {\r
       if (Long) {\r
         BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);\r
       } else {\r
         BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);\r
       }\r
-    } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {\r
+    } else if ((*Format == 's') || (*Format == 'S') || (*Format == 'a') || (*Format == 'g') || (*Format == 't')) {\r
       BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);\r
     } else if (*Format == 'c') {\r
       BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);\r
@@ -230,7 +228,6 @@ VaListToBaseList (
   return TRUE;\r
 }\r
 \r
-\r
 /**\r
   Prints a debug message to the debug output device if the specified\r
   error level is enabled.\r
@@ -249,13 +246,13 @@ VaListToBaseList (
 VOID\r
 EFIAPI\r
 DebugVPrint (\r
-  IN  UINTN         ErrorLevel,\r
-  IN  CONST CHAR8   *Format,\r
-  IN  VA_LIST       VaListMarker\r
+  IN  UINTN        ErrorLevel,\r
+  IN  CONST CHAR8  *Format,\r
+  IN  VA_LIST      VaListMarker\r
   )\r
 {\r
-  UINT64            BaseListMarker[256 / sizeof (UINT64)];\r
-  BOOLEAN           Converted;\r
+  UINT64   BaseListMarker[256 / sizeof (UINT64)];\r
+  BOOLEAN  Converted;\r
 \r
   //\r
   // Convert the VaList to BaseList\r
@@ -274,7 +271,6 @@ DebugVPrint (
   DebugBPrint (ErrorLevel, Format, (BASE_LIST)BaseListMarker);\r
 }\r
 \r
-\r
 /**\r
   Prints an assert message containing a filename, line number, and description.\r
   This may be followed by a breakpoint or a dead loop.\r
@@ -304,15 +300,15 @@ DebugAssert (
   IN CONST CHAR8  *Description\r
   )\r
 {\r
-  EFI_STATUS      Status;\r
-  EDKII_DEBUG_PPI *DebugPpi;\r
+  EFI_STATUS       Status;\r
+  EDKII_DEBUG_PPI  *DebugPpi;\r
 \r
   Status = PeiServicesLocatePpi (\r
-              &gEdkiiDebugPpiGuid,\r
-              0,\r
-              NULL,\r
-              (VOID **)&DebugPpi\r
-              );\r
+             &gEdkiiDebugPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&DebugPpi\r
+             );\r
   if (EFI_ERROR (Status)) {\r
     //\r
     // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r
@@ -331,7 +327,6 @@ DebugAssert (
   }\r
 }\r
 \r
-\r
 /**\r
   Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r
 \r
@@ -359,7 +354,6 @@ DebugClearMemory (
   return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));\r
 }\r
 \r
-\r
 /**\r
   Returns TRUE if ASSERT() macros are enabled.\r
 \r
@@ -376,10 +370,9 @@ DebugAssertEnabled (
   VOID\r
   )\r
 {\r
-  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
+  return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
 }\r
 \r
-\r
 /**\r
   Returns TRUE if DEBUG() macros are enabled.\r
 \r
@@ -396,10 +389,9 @@ DebugPrintEnabled (
   VOID\r
   )\r
 {\r
-  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
+  return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
 }\r
 \r
-\r
 /**\r
   Returns TRUE if DEBUG_CODE() macros are enabled.\r
 \r
@@ -416,10 +408,9 @@ DebugCodeEnabled (
   VOID\r
   )\r
 {\r
-  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+  return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
 }\r
 \r
-\r
 /**\r
   Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.\r
 \r
@@ -436,10 +427,9 @@ DebugClearMemoryEnabled (
   VOID\r
   )\r
 {\r
-  return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
+  return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
 }\r
 \r
-\r
 /**\r
   Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
 \r
@@ -452,9 +442,8 @@ DebugClearMemoryEnabled (
 BOOLEAN\r
 EFIAPI\r
 DebugPrintLevelEnabled (\r
-  IN  CONST UINTN        ErrorLevel\r
+  IN  CONST UINTN  ErrorLevel\r
   )\r
 {\r
-  return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);\r
+  return (BOOLEAN)((ErrorLevel & PcdGet32 (PcdFixedDebugPrintErrorLevel)) != 0);\r
 }\r
-\r