]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFspPkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
IntelFspPkg BaseFspDebugLibSerialPort: Use safe string functions
[mirror_edk2.git] / IntelFspPkg / Library / BaseFspDebugLibSerialPort / DebugLib.c
index 471659072cce174914a67308daed88f6c92c2c6f..73bb08e3574d67e9cc862b46318927ddbd389101 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\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
@@ -148,7 +148,12 @@ DebugAssertInternal (
   //\r
   // Generate the ASSERT() message in Ascii format\r
   //\r
-  AsciiStrnCpy (Buffer, "-> EBP:0x00000000  EIP:0x00000000\n", sizeof(Buffer));\r
+  AsciiStrnCpyS (\r
+    Buffer,\r
+    sizeof(Buffer) / sizeof(CHAR8),\r
+    "-> EBP:0x00000000  EIP:0x00000000\n",\r
+    sizeof(Buffer) / sizeof(CHAR8) - 1\r
+    );\r
   SerialPortWrite ((UINT8 *)"ASSERT DUMP:\n", 13);\r
   while (Frame != NULL) {\r
     FillHex ((UINT32)Frame, Buffer + 9);\r
@@ -303,3 +308,21 @@ DebugClearMemoryEnabled (
 {\r
   return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
 }\r
+\r
+/**\r
+  Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
+\r
+  This function compares the bit mask of ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
+\r
+  @retval  TRUE    Current ErrorLevel is supported.\r
+  @retval  FALSE   Current ErrorLevel is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugPrintLevelEnabled (\r
+  IN  CONST UINTN        ErrorLevel\r
+  )\r
+{\r
+  return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);\r
+}\r