Add an example HII driver to show how to generate HII resource section
authorlgao4 <lgao4@de2fecce-e211-0410-80a6-f3fac2684e05>
Mon, 19 Oct 2009 10:07:34 +0000 (10:07 +0000)
committerlgao4 <lgao4@de2fecce-e211-0410-80a6-f3fac2684e05>
Mon, 19 Oct 2009 10:07:34 +0000 (10:07 +0000)
git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@9344 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSample.c [new file with mode: 0644]
edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSampleDxe.inf [new file with mode: 0644]
edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/Sample.vfr [new file with mode: 0644]
edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/SampleStrings.uni [new file with mode: 0644]

diff --git a/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSample.c b/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSample.c
new file mode 100644 (file)
index 0000000..c3c5725
--- /dev/null
@@ -0,0 +1,156 @@
+/** @file\r
+This is an example of how a driver retrieve HII data using HII Package List\r
+Protocol, and how to publish the HII data.\r
+\r
+Copyright (c) 2009, 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
+**/\r
+\r
+#include <Uefi.h>\r
+#include <Protocol/HiiPackageList.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiHiiServicesLib.h>\r
+#include <Library/HiiLib.h>\r
+\r
+#pragma pack(1)\r
+///\r
+/// HII specific Vendor Device Path definition.\r
+///\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH             VendorDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL       End;\r
+} HII_VENDOR_DEVICE_PATH;\r
+#pragma pack()\r
+\r
+\r
+EFI_HII_HANDLE  mHiiHandle = NULL;\r
+EFI_HANDLE      mDriverHandle = NULL;\r
+\r
+HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePath = {\r
+  {\r
+    {\r
+      HARDWARE_DEVICE_PATH,\r
+      HW_VENDOR_DP,\r
+      {\r
+        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
+        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
+      }\r
+    },\r
+    //\r
+    // {D49D2EB0-44D5-4621-9FD6-1A92C9109B99}\r
+    //\r
+    { 0xD49D2EB0, 0x44D5, 0x4621, { 0x9F, 0xD6, 0x1A, 0x92, 0xC9, 0x10, 0x9B, 0x99 } }\r
+  },\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+    { \r
+      (UINT8) (END_DEVICE_PATH_LENGTH),\r
+      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
+    }\r
+  }\r
+};\r
+\r
+/**\r
+  Main entry for this driver.\r
+  \r
+  @param[in] ImageHandle     Image handle this driver.\r
+  @param[in] SystemTable     Pointer to SystemTable.\r
+\r
+  @retval EFI_SUCESS     This function always complete successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiResourcesSampleInit (\r
+  IN EFI_HANDLE                   ImageHandle,\r
+  IN EFI_SYSTEM_TABLE             *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_HII_PACKAGE_LIST_HEADER     *PackageList;\r
+\r
+  //\r
+  // Retrieve HII package list from ImageHandle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ImageHandle,\r
+                  &gEfiHiiPackageListProtocolGuid,\r
+                  (VOID **) &PackageList,\r
+                  ImageHandle,\r
+                  NULL,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Publish sample Fromset\r
+  //\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &mDriverHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &mHiiVendorDevicePath\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Publish HII package list to HII Database. Here we use ImageHandle as\r
+  // the "Driver Handle" for HiiDatabase->NewPackageList(), since there will\r
+  // be EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL installed on the ImageHandle.\r
+  //\r
+  Status = gHiiDatabase->NewPackageList (\r
+                          gHiiDatabase,\r
+                          PackageList,\r
+                          mDriverHandle,\r
+                          &mHiiHandle\r
+                          );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Unloads the application and its installed protocol.\r
+\r
+  @param[in]  ImageHandle       Handle that identifies the image to be unloaded.\r
+\r
+  @retval EFI_SUCCESS           The image has been unloaded.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiResourcesSampleUnload (\r
+  IN EFI_HANDLE  ImageHandle\r
+  )\r
+{\r
+  if (mDriverHandle != NULL) {\r
+    gBS->UninstallProtocolInterface (\r
+            mDriverHandle,\r
+            &gEfiDevicePathProtocolGuid,\r
+            &mHiiVendorDevicePath\r
+           );\r
+    mDriverHandle = NULL;\r
+  }\r
+\r
+  if (mHiiHandle != NULL) {\r
+    HiiRemovePackages (mHiiHandle);\r
+    mHiiHandle = NULL;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSampleDxe.inf b/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSampleDxe.inf
new file mode 100644 (file)
index 0000000..82e2412
--- /dev/null
@@ -0,0 +1,53 @@
+#/** @file\r
+# This is an example of how a driver retrieve HII data using HII Package List\r
+# Protocol, and how to publish the HII data.\r
+#\r
+#  Copyright (c) 2009, Intel Corporation. All rights reserved.\r
+#\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
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = HiiResourcesSample\r
+  FILE_GUID                      = D49D2EB0-44D5-4621-9FD6-1A92C9109B99\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = HiiResourcesSampleInit\r
+  UNLOAD_IMAGE                   = HiiResourcesSampleUnload\r
+#\r
+#  This flag specifies whether HII resource section is generated into PE image.\r
+#\r
+  UEFI_HII_RESOURCE_SECTION      = TRUE\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  HiiResourcesSample.c\r
+  SampleStrings.uni\r
+  Sample.vfr\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  UefiDriverEntryPoint\r
+  UefiHiiServicesLib\r
+  HiiLib\r
+\r
+[Protocols]\r
+  gEfiHiiPackageListProtocolGuid    ## CONSUMES\r
diff --git a/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/Sample.vfr b/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/Sample.vfr
new file mode 100644 (file)
index 0000000..ad0ecad
--- /dev/null
@@ -0,0 +1,46 @@
+// *++\r
+//\r
+// Copyright (c) 2009, 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
+//   Sample.vfr\r
+//\r
+// Abstract:\r
+//\r
+//   Sample Form.\r
+//\r
+// Revision History:\r
+//\r
+// --*/\r
+\r
+#define SAMPLE_GUID    { 0x4f4ef7f0, 0xaa29, 0x4ce9, 0xba, 0x41, 0x64, 0x3e, 0x1, 0x23, 0xa9, 0x9f }\r
+\r
+\r
+formset\r
+  guid     = SAMPLE_GUID,\r
+  title    = STRING_TOKEN(STR_SAMPLE_FORM_SET_TITLE),\r
+  help     = STRING_TOKEN(STR_SAMPLE_FORM_SET_HELP),\r
+\r
+  form formid = 1,\r
+       title  = STRING_TOKEN(STR_SAMPLE_FORM1_TITLE);\r
+\r
+       text\r
+      help   = STRING_TOKEN(STR_SAMPLE_VERSION_HELP),\r
+      text   = STRING_TOKEN(STR_SAMPLE_VERSION_TEXT),\r
+           text   = STRING_TOKEN(STR_SAMPLE_EMPTY);\r
+\r
+    subtitle text = STRING_TOKEN(STR_SAMPLE_EMPTY);\r
+\r
+    subtitle text = STRING_TOKEN(STR_SAMPLE_ESC);\r
+\r
+  endform;\r
+\r
+endformset;\r
diff --git a/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/SampleStrings.uni b/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/SampleStrings.uni
new file mode 100644 (file)
index 0000000..5b3f1d9
Binary files /dev/null and b/edk2/MdeModulePkg/Universal/HiiResourcesSampleDxe/SampleStrings.uni differ