]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / HiiDatabaseEntry.c
index 827109c4b832e7be906e724ddbf4e104d9117f48..bbf437bbb9b436428d3eb33eee0fa5ed2d45e309 100644 (file)
@@ -1,25 +1,9 @@
 /** @file\r
+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
-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
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-    HiiDatabaseEntry.c\r
-\r
-Abstract:\r
-\r
-    This file contains the entry code to the HII database, which is defined by\r
-    UEFI 2.1 specification.\r
-\r
-Revision History\r
-\r
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -30,7 +14,7 @@ Revision History
 // 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
@@ -49,11 +33,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
@@ -83,6 +75,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
@@ -102,14 +98,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
@@ -130,6 +118,33 @@ 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
+  HiiGetDatabaseInfo (&mPrivate.HiiDatabase);\r
+  HiiGetConfigRespInfo (&mPrivate.HiiDatabase);\r
+  gExportAfterReadyToBoot = TRUE;\r
+\r
+  gBS->CloseEvent (Event);\r
+}\r
+\r
 /**\r
   Initialize HII Database.\r
 \r
@@ -140,8 +155,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
@@ -153,6 +170,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
@@ -164,7 +182,8 @@ InitializeHiiDatabase (
   ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiImageProtocolGuid);\r
   ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiStringProtocolGuid);\r
   ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiConfigRoutingProtocolGuid);\r
-  \r
+  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiConfigKeywordHandlerProtocolGuid);\r
+\r
   InitializeListHead (&mPrivate.DatabaseList);\r
   InitializeListHead (&mPrivate.DatabaseNotifyList);\r
   InitializeListHead (&mPrivate.HiiHandleList);\r
@@ -178,7 +197,7 @@ InitializeHiiDatabase (
                   TPL_NOTIFY,\r
                   KeyboardLayoutChangeNullEvent,\r
                   NULL,\r
-                  &gHiiSetKbdLayoutEventGuid,\r
+                  &gEfiHiiKeyBoardLayoutGuid,\r
                   &gHiiKeyboardLayoutChanged\r
                   );\r
   if (EFI_ERROR (Status)) {\r
@@ -196,6 +215,8 @@ InitializeHiiDatabase (
                   &mPrivate.HiiDatabase,\r
                   &gEfiHiiConfigRoutingProtocolGuid,\r
                   &mPrivate.ConfigRouting,\r
+                  &gEfiConfigKeywordHandlerProtocolGuid,\r
+                  &mPrivate.ConfigKeywordHandler,\r
                   NULL\r
                   );\r
 \r
@@ -204,17 +225,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