]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
Enhance InitializeLanguage() to set PcdUefiVariableDefaultPlatformLang to PlatformLan...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BdsEntry.c
index def572d2d5a00cb9b5177290601dedef56222755..6eaec886f2317d484021538260a6ba5b0dfc8897 100644 (file)
@@ -5,7 +5,7 @@
   After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked\r
   to enter BDS phase.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2013, 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
@@ -72,6 +72,24 @@ BdsInitialize (
   return Status;\r
 }\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
+BdsEmptyCallbackFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+{\r
+}\r
+\r
 /**\r
 \r
   This function attempts to boot for the boot order specified\r
@@ -93,12 +111,14 @@ BdsBootDeviceSelect (
   CHAR16            Buffer[20];\r
   BOOLEAN           BootNextExist;\r
   LIST_ENTRY        *LinkBootNext;\r
+  EFI_EVENT         ConnectConInEvent;\r
 \r
   //\r
   // Got the latest boot option\r
   //\r
   BootNextExist = FALSE;\r
   LinkBootNext  = NULL;\r
+  ConnectConInEvent = NULL;\r
   InitializeListHead (&BootLists);\r
 \r
   //\r
@@ -106,6 +126,23 @@ BdsBootDeviceSelect (
   //\r
   ZeroMem (Buffer, sizeof (Buffer));\r
 \r
+  //\r
+  // Create Event to signal ConIn connection request\r
+  //\r
+  if (PcdGetBool (PcdConInConnectOnDemand)) {\r
+    Status = gBS->CreateEventEx (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    TPL_CALLBACK,\r
+                    BdsEmptyCallbackFunction,\r
+                    NULL,\r
+                    &gConnectConInEventGuid,\r
+                    &ConnectConInEvent\r
+                    );\r
+    if (EFI_ERROR(Status)) {\r
+      ConnectConInEvent = NULL;\r
+    }\r
+  }\r
+\r
   if (mBootNext != NULL) {\r
     //\r
     // Indicate we have the boot next variable, so this time\r
@@ -171,6 +208,13 @@ BdsBootDeviceSelect (
     // Check the boot option list first\r
     //\r
     if (Link == &BootLists) {\r
+      //\r
+      // When LazyConIn enabled, signal connect ConIn event before enter UI\r
+      //\r
+      if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {\r
+        gBS->SignalEvent (ConnectConInEvent);\r
+      }\r
+\r
       //\r
       // There are two ways to enter here:\r
       // 1. There is no active boot option, give user chance to\r
@@ -248,6 +292,14 @@ BdsBootDeviceSelect (
       // Boot success, then stop process the boot order, and\r
       // present the boot manager menu, front page\r
       //\r
+\r
+      //\r
+      // When LazyConIn enabled, signal connect ConIn Event before enter UI\r
+      //\r
+      if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {\r
+        gBS->SignalEvent (ConnectConInEvent);\r
+      }\r
+\r
       Timeout = 0xffff;\r
       PlatformBdsEnterFrontPage (Timeout, FALSE);\r
 \r
@@ -274,56 +326,6 @@ BdsBootDeviceSelect (
 \r
 }\r
 \r
-/**\r
-  Validate the device path instance. \r
-\r
-  Only base on the length filed in the device path node to validate the device path. \r
-\r
-  @param  DevicePath         A pointer to a device path data structure.\r
-  @param  MaxSize            Max valid device path size. If big than this size, \r
-                             return error.\r
-  \r
-  @retval TRUE               An valid device path.\r
-  @retval FALSE              An invalid device path.\r
-\r
-**/\r
-BOOLEAN\r
-IsValidDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
-  IN UINTN                     MaxSize\r
-  )\r
-{\r
-  UINTN  Size;\r
-  UINTN  NodeSize;\r
-\r
-  if (DevicePath == NULL) {\r
-    return TRUE;\r
-  }\r
-\r
-  Size = 0;\r
-\r
-  while (!IsDevicePathEnd (DevicePath)) {\r
-    NodeSize = DevicePathNodeLength (DevicePath);\r
-    if (NodeSize < END_DEVICE_PATH_LENGTH) {\r
-      return FALSE;\r
-    }\r
-\r
-    Size += NodeSize;\r
-    if (Size > MaxSize) {\r
-      return FALSE;\r
-    }\r
-\r
-    DevicePath = NextDevicePathNode (DevicePath);\r
-  }\r
-\r
-  Size += DevicePathNodeLength (DevicePath);\r
-  if (Size > MaxSize) {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
 /**\r
 \r
   Validate input console variable data. \r
@@ -347,7 +349,7 @@ BdsFormalizeConsoleVariable (
                       &gEfiGlobalVariableGuid,\r
                       &VariableSize\r
                       );\r
-  if (!IsValidDevicePath (DevicePath, VariableSize)) { \r
+  if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) { \r
     Status = gRT->SetVariable (\r
                     VariableName,\r
                     &gEfiGlobalVariableGuid,\r
@@ -455,6 +457,8 @@ BdsEntry (
   LIST_ENTRY                      BootOptionList;\r
   UINTN                           BootNextSize;\r
   CHAR16                          *FirmwareVendor;\r
+  EFI_STATUS                      Status;\r
+  UINT16                          BootTimeOut;\r
 \r
   //\r
   // Insert the performance probe\r
@@ -484,6 +488,7 @@ BdsEntry (
   //\r
   // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r
   //\r
+  gST->Hdr.CRC32 = 0;\r
   gBS->CalculateCrc32 ((VOID *)gST, sizeof(EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r
 \r
   //\r
@@ -491,6 +496,14 @@ BdsEntry (
   //\r
   BdsFormalizeEfiGlobalVariable();\r
 \r
+  //\r
+  // Report Status Code to indicate connecting drivers will happen\r
+  //\r
+  REPORT_STATUS_CODE (\r
+    EFI_PROGRESS_CODE,\r
+    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS)\r
+    );\r
+\r
   //\r
   // Do the platform init, can be customized by OEM/IBV\r
   //\r
@@ -499,6 +512,25 @@ BdsEntry (
 \r
   InitializeHwErrRecSupport();\r
 \r
+  //\r
+  // Initialize L"Timeout" EFI global variable.\r
+  //\r
+  BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);\r
+  if (BootTimeOut != 0xFFFF) {\r
+    //\r
+    // If time out value equal 0xFFFF, no need set to 0xFFFF to variable area because UEFI specification\r
+    // define same behavior between no value or 0xFFFF value for L"Timeout".\r
+    //\r
+    Status = gRT->SetVariable (\r
+                    L"Timeout",\r
+                    &gEfiGlobalVariableGuid,\r
+                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                    sizeof (UINT16),\r
+                    &BootTimeOut\r
+                    );\r
+    ASSERT_EFI_ERROR(Status);\r
+  }\r
+\r
   //\r
   // bugbug: platform specific code\r
   // Initialize the platform specific string and language\r