]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/Bds.c
ArmPlatformPkg/Bds: Clarify assert message with debug information
[mirror_edk2.git] / ArmPlatformPkg / Bds / Bds.c
index d2b62252ede023f2d4c538266460bb45836a5015..1fab43976f29c0940be607acd85db3a776b99f40 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011-2015, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
@@ -19,9 +19,9 @@
 \r
 #include <Protocol/Bds.h>\r
 \r
-#define EFI_SET_TIMER_TO_SECOND   10000000\r
+#include <Guid/EventGroup.h>\r
 \r
-EFI_HANDLE mImageHandle;\r
+#define EFI_SET_TIMER_TO_SECOND   10000000\r
 \r
 STATIC\r
 EFI_STATUS\r
@@ -155,8 +155,8 @@ InitializeConsolePipe (
       *Handle = Buffer[0];\r
       Status = gBS->HandleProtocol (*Handle, Protocol, Interface);\r
       ASSERT_EFI_ERROR(Status);\r
+      FreePool (Buffer);\r
     }\r
-    FreePool (Buffer);\r
   } else {\r
     Status = EFI_SUCCESS;\r
   }\r
@@ -258,7 +258,11 @@ DefineDefaultBootEntries (
       ASSERT_EFI_ERROR(Status);\r
       DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootDevicePath, TRUE, TRUE);\r
 \r
-      ASSERT (StrCmp ((CHAR16*)PcdGetPtr(PcdDefaultBootDevicePath), DevicePathTxt) == 0);\r
+      if (StrCmp ((CHAR16*)PcdGetPtr (PcdDefaultBootDevicePath), DevicePathTxt) != 0) {\r
+        DEBUG ((EFI_D_ERROR, "Device Path given: '%s' Device Path expected: '%s'\n",\r
+            (CHAR16*)PcdGetPtr (PcdDefaultBootDevicePath), DevicePathTxt));\r
+        ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);\r
+      }\r
 \r
       FreePool (DevicePathTxt);\r
     DEBUG_CODE_END();\r
@@ -337,7 +341,7 @@ DefineDefaultBootEntries (
 \r
       if (DefaultBootArgument == (CHAR16*)PcdGetPtr (PcdDefaultBootArgument)) {\r
         FreePool (AsciiDefaultBootArgument);\r
-      } else {\r
+      } else if (DefaultBootArgument != NULL) {\r
         FreePool (DefaultBootArgument);\r
       }\r
     } else {\r
@@ -345,7 +349,7 @@ DefineDefaultBootEntries (
     }\r
   }\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
@@ -393,7 +397,7 @@ StartDefaultBootOnTimeout (
       }\r
       // Discard key in the buffer\r
       do {\r
-       Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+        Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
       } while(!EFI_ERROR(Status));\r
       gBS->CloseEvent (WaitList[0]);\r
       Print(L"\n\r");\r
@@ -408,8 +412,8 @@ StartDefaultBootOnTimeout (
         UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BootOrder[Index]);\r
         Status = BdsStartBootOption (BootVariableName);\r
         if(!EFI_ERROR(Status)){\r
-               // Boot option returned successfully, hence don't need to start next boot option\r
-               break;\r
+          // Boot option returned successfully, hence don't need to start next boot option\r
+          break;\r
         }\r
         // In case of success, we should not return from this call.\r
       }\r
@@ -419,6 +423,24 @@ StartDefaultBootOnTimeout (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  An empty function to pass error checking of CreateEventEx ().\r
+\r
+  @param  Event                 Event whose notification function is being invoked.\r
+  @param  Context               Pointer to the notification function's context,\r
+                                which is implementation-dependent.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EmptyCallbackFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+{\r
+  return;\r
+}\r
+\r
 /**\r
   This function uses policy data from the platform to determine what operating\r
   system or system utility should be loaded and invoked.  This function call\r
@@ -451,6 +473,22 @@ BdsEntry (
   UINT16             *BootNext;\r
   UINTN               BootNextSize;\r
   CHAR16              BootVariableName[9];\r
+  EFI_EVENT           EndOfDxeEvent;\r
+\r
+  //\r
+  // Signal EndOfDxe PI Event\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+      EVT_NOTIFY_SIGNAL,\r
+      TPL_NOTIFY,\r
+      EmptyCallbackFunction,\r
+      NULL,\r
+      &gEfiEndOfDxeEventGroupGuid,\r
+      &EndOfDxeEvent\r
+      );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->SignalEvent (EndOfDxeEvent);\r
+  }\r
 \r
   PERF_END   (NULL, "DXE", NULL, 0);\r
 \r
@@ -542,8 +580,6 @@ BdsInitialize (
 {\r
   EFI_STATUS  Status;\r
 \r
-  mImageHandle = ImageHandle;\r
-\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &ImageHandle,\r
                   &gEfiBdsArchProtocolGuid, &gBdsProtocol,\r