]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
MdeModulePkg HiiDataBase: Fix the potential NULL pointer reference
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / HiiDatabaseEntry.c
index 85202b2b63f962c7a5cc5cbaadf06009c13ed85e..9d09c60b23512cd4d567f55c8656603a35f0f071 100644 (file)
@@ -2,8 +2,8 @@
 This file contains the entry code to the HII database, which is defined by\r
 UEFI 2.1 specification.\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2016, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 // Global variables\r
 //\r
 EFI_EVENT gHiiKeyboardLayoutChanged;\r
-EFI_GUID gHiiSetKbdLayoutEventGuid = EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID;\r
+BOOLEAN   gExportAfterReadyToBoot = FALSE;\r
 \r
 HII_DATABASE_PRIVATE_DATA mPrivate = {\r
   HII_DATABASE_PRIVATE_DATA_SIGNATURE,\r
@@ -39,11 +39,19 @@ HII_DATABASE_PRIVATE_DATA mPrivate = {
     HiiGetFontInfo\r
   },\r
   {\r
-    NULL,\r
-    NULL,\r
-    NULL,\r
-    NULL,\r
-    NULL\r
+    HiiNewImage,\r
+    HiiGetImage,\r
+    HiiSetImage,\r
+    HiiDrawImage,\r
+    HiiDrawImageId\r
+  },\r
+  {\r
+    HiiNewImageEx,\r
+    HiiGetImageEx,\r
+    HiiSetImageEx,\r
+    HiiDrawImageEx,\r
+    HiiDrawImageIdEx,\r
+    HiiGetImageInfo\r
   },\r
   {\r
     HiiNewString,\r
@@ -73,6 +81,10 @@ HII_DATABASE_PRIVATE_DATA mPrivate = {
     HiiConfigToBlock,\r
     HiiGetAltCfg\r
   },\r
+  {\r
+    EfiConfigKeywordHandlerSetData,\r
+    EfiConfigKeywordHandlerGetData\r
+  },\r
   {\r
     (LIST_ENTRY *) NULL,\r
     (LIST_ENTRY *) NULL\r
@@ -92,14 +104,6 @@ HII_DATABASE_PRIVATE_DATA mPrivate = {
   NULL\r
 };\r
 \r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_IMAGE_PROTOCOL mImageProtocol = {\r
-  HiiNewImage,\r
-  HiiGetImage,\r
-  HiiSetImage,\r
-  HiiDrawImage,\r
-  HiiDrawImageId\r
-};\r
-\r
 /**\r
   The default event handler for gHiiKeyboardLayoutChanged\r
   event group.\r
@@ -120,6 +124,32 @@ KeyboardLayoutChangeNullEvent (
   return;\r
 }\r
 \r
+/**\r
+  On Ready To Boot Services Event notification handler.\r
+\r
+  To trigger the function that to export the Hii Configuration setting.\r
+\r
+  @param[in]  Event     Event whose notification function is being invoked\r
+  @param[in]  Context   Pointer to the notification function's context\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+OnReadyToBoot (\r
+  IN      EFI_EVENT                         Event,\r
+  IN      VOID                              *Context\r
+  )\r
+{\r
+  //\r
+  // When ready to boot, we begin to export the HiiDatabase date.\r
+  // And hook all the possible HiiDatabase change actions to export data.\r
+  //\r
+  HiiGetConfigurationSetting(&mPrivate.HiiDatabase);\r
+  gExportAfterReadyToBoot = TRUE;\r
+\r
+  gBS->CloseEvent (Event);\r
+}\r
+\r
 /**\r
   Initialize HII Database.\r
 \r
@@ -130,8 +160,10 @@ KeyboardLayoutChangeNullEvent (
   @retval EFI_SUCCESS    The Hii database is setup correctly.\r
   @return Other value if failed to create the default event for\r
           gHiiKeyboardLayoutChanged. Check gBS->CreateEventEx for\r
-          details. Or failed to insatll the protocols.\r
+          details. Or failed to install the protocols.\r
           Check gBS->InstallMultipleProtocolInterfaces for details.\r
+          Or failed to create Ready To Boot Event.\r
+          Check EfiCreateEventReadyToBootEx for details.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -143,6 +175,7 @@ InitializeHiiDatabase (
 {\r
   EFI_STATUS                             Status;\r
   EFI_HANDLE                             Handle;\r
+  EFI_EVENT                              ReadyToBootEvent;\r
 \r
   //\r
   // There will be only one HII Database in the system\r
@@ -154,6 +187,7 @@ InitializeHiiDatabase (
   ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiImageProtocolGuid);\r
   ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiStringProtocolGuid);\r
   ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiConfigRoutingProtocolGuid);\r
+  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiConfigKeywordHandlerProtocolGuid);\r
   \r
   InitializeListHead (&mPrivate.DatabaseList);\r
   InitializeListHead (&mPrivate.DatabaseNotifyList);\r
@@ -168,7 +202,7 @@ InitializeHiiDatabase (
                   TPL_NOTIFY,\r
                   KeyboardLayoutChangeNullEvent,\r
                   NULL,\r
-                  &gHiiSetKbdLayoutEventGuid,\r
+                  &gEfiHiiKeyBoardLayoutGuid,\r
                   &gHiiKeyboardLayoutChanged\r
                   );\r
   if (EFI_ERROR (Status)) {\r
@@ -186,6 +220,8 @@ InitializeHiiDatabase (
                   &mPrivate.HiiDatabase,\r
                   &gEfiHiiConfigRoutingProtocolGuid,\r
                   &mPrivate.ConfigRouting,\r
+                  &gEfiConfigKeywordHandlerProtocolGuid,\r
+                  &mPrivate.ConfigKeywordHandler,\r
                   NULL\r
                   );\r
 \r
@@ -194,17 +230,27 @@ InitializeHiiDatabase (
   }\r
 \r
   if (FeaturePcdGet (PcdSupportHiiImageProtocol)) {\r
-    CopyMem (&mPrivate.HiiImage, &mImageProtocol, sizeof (mImageProtocol));\r
-\r
     Status = gBS->InstallMultipleProtocolInterfaces (\r
                     &Handle,\r
-                    &gEfiHiiImageProtocolGuid,\r
-                    &mPrivate.HiiImage,\r
+                    &gEfiHiiImageProtocolGuid, &mPrivate.HiiImage,\r
+                    &gEfiHiiImageExProtocolGuid, &mPrivate.HiiImageEx,\r
                     NULL\r
                     );\r
 \r
   }\r
 \r
+  if (FeaturePcdGet(PcdHiiOsRuntimeSupport)) {\r
+    Status = EfiCreateEventReadyToBootEx (\r
+               TPL_CALLBACK,\r
+               OnReadyToBoot,\r
+               NULL,\r
+               &ReadyToBootEvent\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
   return Status;\r
 }\r
 \r