]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
IntelFrameworkModulePkg BdsDxe: Fix ASSERT in BdsMemoryTest
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / MemoryTest.c
index 09d1bc1ea5f6e579f478ad9bf9f9901cbf0de1d1..fedb151a0c63bb3195a70af2e81d6fb7c0ccb3f9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Perform the platform memory test\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 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
@@ -230,11 +230,13 @@ BdsMemoryTest (
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL     Color;\r
   BOOLEAN                           IsFirstBoot;\r
   UINT32                            TempData;\r
+  UINTN                             StrTotalMemorySize;\r
 \r
   ReturnStatus = EFI_SUCCESS;\r
   ZeroMem (&Key, sizeof (EFI_INPUT_KEY));\r
 \r
-  Pos = AllocatePool (128);\r
+  StrTotalMemorySize = 128;\r
+  Pos = AllocateZeroPool (StrTotalMemorySize);\r
 \r
   if (Pos == NULL) {\r
     return ReturnStatus;\r
@@ -322,7 +324,12 @@ BdsMemoryTest (
           //\r
           // TmpStr size is 64, StrPercent is reserved to 16.\r
           //\r
-          StrCat (StrPercent, TmpStr);\r
+          StrnCatS (\r
+            StrPercent,\r
+            sizeof (StrPercent) / sizeof (CHAR16), \r
+            TmpStr,\r
+            sizeof (StrPercent) / sizeof (CHAR16) - StrLen (StrPercent) - 1\r
+            );\r
           PrintXY (10, 10, NULL, NULL, StrPercent);\r
           FreePool (TmpStr);\r
         }\r
@@ -346,30 +353,32 @@ BdsMemoryTest (
       DEBUG ((EFI_D_INFO, "Perform memory test (ESC to skip).\n"));\r
     }\r
 \r
-    KeyStatus     = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-    if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {\r
-      if (!RequireSoftECCInit) {\r
-        if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-          TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
-          if (TmpStr != NULL) {\r
-            PlatformBdsShowProgress (\r
-              Foreground,\r
-              Background,\r
-              TmpStr,\r
-              Color,\r
-              100,\r
-              (UINTN) PreviousValue\r
-              );\r
-            FreePool (TmpStr);\r
+    if (!PcdGetBool (PcdConInConnectOnDemand)) {\r
+      KeyStatus     = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+      if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {\r
+        if (!RequireSoftECCInit) {\r
+          if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
+            TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
+            if (TmpStr != NULL) {\r
+              PlatformBdsShowProgress (\r
+                Foreground,\r
+                Background,\r
+                TmpStr,\r
+                Color,\r
+                100,\r
+                (UINTN) PreviousValue\r
+                );\r
+              FreePool (TmpStr);\r
+            }\r
+\r
+            PrintXY (10, 10, NULL, NULL, L"100");\r
           }\r
-\r
-          PrintXY (10, 10, NULL, NULL, L"100");\r
+          Status = GenMemoryTest->Finished (GenMemoryTest);\r
+          goto Done;\r
         }\r
-        Status = GenMemoryTest->Finished (GenMemoryTest);\r
-        goto Done;\r
-      }\r
 \r
-      TestAbort = TRUE;\r
+        TestAbort = TRUE;\r
+      }\r
     }\r
   } while (Status != EFI_NOT_FOUND);\r
 \r
@@ -380,11 +389,17 @@ Done:
     UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize, 0);\r
     if (StrTotalMemory[0] == L',') {\r
       StrTotalMemory++;\r
+      StrTotalMemorySize -= sizeof (CHAR16);\r
     }\r
 \r
     TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));\r
     if (TmpStr != NULL) {\r
-      StrCat (StrTotalMemory, TmpStr);\r
+      StrnCatS (\r
+        StrTotalMemory,\r
+        StrTotalMemorySize / sizeof (CHAR16),\r
+        TmpStr,\r
+        StrTotalMemorySize / sizeof (CHAR16) - StrLen (StrTotalMemory) - 1\r
+        );\r
       FreePool (TmpStr);\r
     }\r
 \r