I have a question about this.   Making the Hii Configuration data 
available to the OS at run time only exports the data from the Hii 
database.  It does not make the Hii Configuration Access protocols (or 
their callback functions) available to the OS?  So if a 3rd party OpRom 
was making using of their own Hii Configuration Access protocols and using 
callbacks to prevent specific combinations of configurations, then that 
would not be caught by an OS based setup browser?  Additionally, shouldn't 
an OS based setup browser have the problem of retrieving the current 
configuration data since it would need to use the config access protocols?

Best Regards,
Aaron



From:   "Dong, Eric" <eric.d...@intel.com>
To:     "El-Haj-Mahmoud, Samer" <samer.el-haj-mahm...@hpe.com>, "Bi, 
Dandan" <dandan...@intel.com>, "edk2-devel@lists.01.org" 
<edk2-devel@lists.01.org>, 
Cc:     "Gao, Liming" <liming....@intel.com>
Date:   12/21/2015 05:29 PM
Subject:        Re: [edk2] [patch] MdeModulePkg:Make HII configuration 
settings        available to OS runtime
Sent by:        "edk2-devel" <edk2-devel-boun...@lists.01.org>



Yes, all the Hii database data will be export. Also the ConfigResp string 
for all HII drivers. 

-----Original Message-----
From: El-Haj-Mahmoud, Samer [mailto:samer.el-haj-mahm...@hpe.com] 
Sent: Tuesday, December 22, 2015 9:25 AM
To: Dong, Eric; Bi, Dandan; edk2-devel@lists.01.org
Cc: Gao, Liming
Subject: RE: [edk2] [patch] MdeModulePkg:Make HII configuration settings 
available to OS runtime

Does this also export all string packages?

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Dong, Eric
Sent: Monday, December 21, 2015 8:22 PM
To: Bi, Dandan <dandan...@intel.com>; edk2-devel@lists.01.org
Cc: Gao, Liming <liming....@intel.com>
Subject: Re: [edk2] [patch] MdeModulePkg:Make HII configuration settings 
available to OS runtime

Reviewed-by: Eric Dong <eric.d...@intel.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Dandan Bi
Sent: Monday, December 21, 2015 4:45 PM
To: edk2-devel@lists.01.org
Cc: Dong, Eric; Gao, Liming
Subject: [edk2] [patch] MdeModulePkg:Make HII configuration settings 
available to OS runtime

This feature is aimed to allow OS make use of the HII database during 
runtime.
In this case, the contents of the HII Database is exported to a buffer.
The pointer to the buffer is placed in the EFI System Configuration Table, 
where it can be retrieved by an OS application.

Cc: Liming Gao <liming....@intel.com>
Cc: Eric Dong <eric.d...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Database.c   | 102 
++++++++++++++++++++-
 .../Universal/HiiDatabaseDxe/HiiDatabase.h         |   5 +
 .../Universal/HiiDatabaseDxe/HiiDatabaseEntry.c    |  51 +++++++++++
 3 files changed, 157 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c 
b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index ec56795..011e712 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -2773,10 +2773,96 @@ ExportPackageList (
   *UsedSize += ResultSize + sizeof (EFI_HII_PACKAGE_HEADER);
 
   return EFI_SUCCESS;
 }
 
+/**
+This is an internal function,mainly use to get and update configuration 
settings information.
+
+@param  This            A pointer to the EFI_HII_DATABASE_PROTOCOL 
instance.
+@param  NewPackage      Indaicate whether add the packages in the package 
list to the database.
+
+@retval EFI_SUCCESS     Get the information successfully.
+
+**/
+EFI_STATUS
+HiiGetConfigurationSetting(
+  IN CONST EFI_HII_DATABASE_PROTOCOL        *This,
+  IN BOOLEAN                                NewPackage
+  )
+{
+  EFI_STATUS                          Status;
+  HII_DATABASE_PRIVATE_DATA           *Private;
+  EFI_HII_PACKAGE_LIST_HEADER         *DatabaseInfo;
+  EFI_STRING                          ConfigAltResp;
+  UINTN                               DatabaseInfoSize;
+  UINTN                               ConfigLen;
+ 
+  DatabaseInfo         = NULL;
+  ConfigAltResp        = NULL;
+  DatabaseInfoSize     = 0;
+  ConfigLen            = 0;
+
+  Private = HII_DATABASE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+
+  //
+  // Get the length of the buffer that is required for the exported data.
+  //
+
+  Status = HiiExportPackageLists(This, NULL, &DatabaseInfoSize, 
+ DatabaseInfo);  if (Status == EFI_BUFFER_TOO_SMALL) {
+    if (gRTDatabaseInfoBuffer == NULL){
+      gRTDatabaseInfoBuffer = AllocateRuntimePool (DatabaseInfoSize);
+    } else if (DatabaseInfoSize != gDatabaseInfoSize ) {
+      if (NewPackage){
+        gBS->InstallConfigurationTable (&gEfiHiiDatabaseProtocolGuid, 
NULL);
+      }
+      gRTDatabaseInfoBuffer = 
ReallocateRuntimePool(gDatabaseInfoSize,DatabaseInfoSize,gRTDatabaseInfoBuffer);
+    }
+    ASSERT (gRTDatabaseInfoBuffer != NULL);
+
+    gDatabaseInfoSize = DatabaseInfoSize;
+
+    //
+    //install it to configuration table.
+    //
+    if (NewPackage){
+      gBS->InstallConfigurationTable (&gEfiHiiDatabaseProtocolGuid, 
gRTDatabaseInfoBuffer);
+    }
+  }
+
+  //
+  // Get ConfigResp string
+  //
+  Status =
+ HiiConfigRoutingExportConfig(&Private->ConfigRouting,&ConfigAltResp);
+  if (!EFI_ERROR (Status)){
+    ConfigLen = StrLen(ConfigAltResp);
+    if (gRTConfigRespBuffer == NULL){
+      gRTConfigRespBuffer = AllocateRuntimePool ((ConfigLen + 1) * sizeof 
(CHAR16));
+    } else if (ConfigLen != gConfigLen ){
+      if (NewPackage){
+        gBS->InstallConfigurationTable 
(&gEfiHiiConfigRoutingProtocolGuid, NULL);
+      }
+      gRTConfigRespBuffer = ReallocateRuntimePool((gConfigLen + 1) * 
sizeof (CHAR16),(ConfigLen + 1) * sizeof (CHAR16),gRTConfigRespBuffer);
+    }
+    ASSERT (gRTConfigRespBuffer != NULL);
+
+    gConfigLen = ConfigLen;
+ 
+    //
+    //install it to configuration table.
+    //
+    if (NewPackage){
+      gBS->InstallConfigurationTable (&gEfiHiiConfigRoutingProtocolGuid, 
gRTConfigRespBuffer);
+    }
+
+    FreePool(ConfigAltResp);
+  }
+
+  return EFI_SUCCESS;
+
+}
 
 /**
   This function adds the packages in the package list to the database and 
returns a handle. If there is a
   EFI_DEVICE_PATH_PROTOCOL associated with the DriverHandle, then this 
function will
   create a package of type EFI_PACKAGE_TYPE_DEVICE_PATH and add it to the 
package list.
@@ -2865,10 +2951,18 @@ HiiNewPackageList (
     Status = AddDevicePathPackage (Private, 
EFI_HII_DATABASE_NOTIFY_NEW_PACK, DevicePath, DatabaseRecord);
     ASSERT_EFI_ERROR (Status);
   }
 
   *Handle = DatabaseRecord->Handle;
+
+  //
+  // Get the configuration setting info.
+  // And install it to configuration table.
+  //
+
+  HiiGetConfigurationSetting(This,TRUE);
+
   return EFI_SUCCESS;
 }
 
 
 /**
@@ -3077,11 +3171,17 @@ HiiUpdatePackageList (
       }
 
       //
       // Add all of the packages within the new package list
       //
-      return AddPackages (Private, EFI_HII_DATABASE_NOTIFY_ADD_PACK, 
PackageList, Node);
+      Status = AddPackages (Private, EFI_HII_DATABASE_NOTIFY_ADD_PACK, 
PackageList, Node);
+      //
+      // Update the the configuration setting info
+      //
+      HiiGetConfigurationSetting(This,FALSE);
+
+      return Status;
     }
   }
 
   return EFI_NOT_FOUND;
 }
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h 
b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
index bb0090a..1be508b 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
@@ -2017,6 +2017,11 @@ GetSupportedLanguages (
 
 //
 // Global variables
 //
 extern EFI_EVENT gHiiKeyboardLayoutChanged;
+extern EFI_HII_PACKAGE_LIST_HEADER *gRTDatabaseInfoBuffer; extern 
+EFI_STRING gRTConfigRespBuffer; extern UINTN gDatabaseInfoSize; extern 
+UINTN gConfigLen;
+
 #endif
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c 
b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
index 6448c97..c35655c 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
@@ -18,10 +18,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED.
 
 //
 // Global variables
 //
 EFI_EVENT gHiiKeyboardLayoutChanged;
+EFI_EVENT mExitBootServicesEvent = (EFI_EVENT)NULL;
+
+EFI_HII_PACKAGE_LIST_HEADER    *gRTDatabaseInfoBuffer = NULL;
+EFI_STRING                     gRTConfigRespBuffer    = NULL;
+UINTN                          gDatabaseInfoSize = 0;
+UINTN                          gConfigLen = 0;
 
 HII_DATABASE_PRIVATE_DATA mPrivate = {
   HII_DATABASE_PRIVATE_DATA_SIGNATURE,
   {
     (LIST_ENTRY *) NULL,
@@ -122,10 +128,43 @@ KeyboardLayoutChangeNullEvent (  {
   return;
 }
 
 /**
+  Callback function for ExitBootServices.
+
+  @param  Event                 Event whose notification function is 
being invoked.
+  @param  Context               The pointer to the notification 
function's context,
+                                which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+ExitBootServicesCallback (
+  IN EFI_EVENT                Event,
+  IN VOID                     *Context
+  )
+{
+  EFI_STATUS                          Status;
+
+  //
+  //export the contents of the HII Database and the current 
+ configuration into  runtime buffer  //  Status = 
+ HiiExportPackageLists(&mPrivate.HiiDatabase, NULL, &gDatabaseInfoSize, 
+ gRTDatabaseInfoBuffer);  ASSERT_EFI_ERROR (Status);
+
+  Status =
+ HiiConfigRoutingExportConfig(&mPrivate.ConfigRouting,&gRTConfigRespBuf
+ fer);
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // Install the package list and configuration date to configuration 
table.
+  //
+  gBS->InstallConfigurationTable (&gEfiHiiDatabaseProtocolGuid, 
+gRTDatabaseInfoBuffer);
+  gBS->InstallConfigurationTable (&gEfiHiiConfigRoutingProtocolGuid,
+gRTConfigRespBuffer); }
+
+/**
   Initialize HII Database.
 
 
   @param ImageHandle     The image handle.
   @param SystemTable     The system table.
@@ -177,10 +216,22 @@ InitializeHiiDatabase (
                   );
   if (EFI_ERROR (Status)) {
     return Status;
   }
 
+  //
+  // Create a event with EVT_SIGNAL_EXIT_BOOT_SERVICES type.
+  //
+  Status = gBS->CreateEvent (
+                  EVT_SIGNAL_EXIT_BOOT_SERVICES,
+                  TPL_CALLBACK,
+                  ExitBootServicesCallback,
+                  NULL,
+                  &mExitBootServicesEvent
+                  );
+  ASSERT_EFI_ERROR (Status);
+
   Handle = NULL;
   Status = gBS->InstallMultipleProtocolInterfaces (
                   &Handle,
                   &gEfiHiiFontProtocolGuid,
                   &mPrivate.HiiFont,
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to