]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: PlatformDxe: add an empty HII form
authorLaszlo Ersek <lersek@redhat.com>
Sat, 22 Mar 2014 07:13:18 +0000 (07:13 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 22 Mar 2014 07:13:18 +0000 (07:13 +0000)
... which opens from the Device Manager window.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15367 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/PlatformDxe/Platform.c
OvmfPkg/PlatformDxe/Platform.h [new file with mode: 0644]
OvmfPkg/PlatformDxe/Platform.inf
OvmfPkg/PlatformDxe/Platform.uni [new file with mode: 0644]
OvmfPkg/PlatformDxe/PlatformForms.vfr [new file with mode: 0644]

index a6172a8018761f9a8c97e73eadff9b110a50782a..16066a0f0e238b161d6bbe8a27b049c1c284b57b 100644 (file)
 **/\r
 \r
 #include <Library/DebugLib.h>\r
 **/\r
 \r
 #include <Library/DebugLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/HiiLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/HiiConfigAccess.h>\r
 \r
 #include "PlatformConfig.h"\r
 \r
 \r
 #include "PlatformConfig.h"\r
 \r
+//\r
+// The HiiAddPackages() library function requires that any controller (or\r
+// image) handle, to be associated with the HII packages under installation, be\r
+// "decorated" with a device path. The tradition seems to be a vendor device\r
+// path.\r
+//\r
+// We'd like to associate our HII packages with the driver's image handle. The\r
+// first idea is to use the driver image's device path. Unfortunately, loaded\r
+// images only come with an EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL (not the\r
+// usual EFI_DEVICE_PATH_PROTOCOL), ie. a different GUID. In addition, even the\r
+// EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL interface may be NULL, if the image\r
+// has been loaded from an "unnamed" memory source buffer.\r
+//\r
+// Hence let's just stick with the tradition -- use a dedicated vendor device\r
+// path, with the driver's FILE_GUID.\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH       VendorDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL End;\r
+} PKG_DEVICE_PATH;\r
+#pragma pack()\r
+\r
+STATIC PKG_DEVICE_PATH mPkgDevicePath = {\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
+    EFI_CALLER_ID_GUID\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
+// The configuration interface between the HII engine (form display etc) and\r
+// this driver.\r
+//\r
+STATIC EFI_HII_CONFIG_ACCESS_PROTOCOL mConfigAccess;\r
+\r
+//\r
+// The handle representing our list of packages after installation.\r
+//\r
+STATIC EFI_HII_HANDLE mInstalledPackages;\r
+\r
+//\r
+// The arrays below constitute our HII package list. They are auto-generated by\r
+// the VFR compiler and linked into the driver image during the build.\r
+//\r
+// - The strings package receives its C identifier from the driver's BASE_NAME,\r
+//   plus "Strings".\r
+//\r
+// - The forms package receives its C identifier from the VFR file's basename,\r
+//   plus "Bin".\r
+//\r
+//\r
+extern UINT8 PlatformDxeStrings[];\r
+extern UINT8 PlatformFormsBin[];\r
+\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+ExtractConfig (\r
+  IN CONST  EFI_HII_CONFIG_ACCESS_PROTOCOL  *This,\r
+  IN CONST  EFI_STRING                      Request,\r
+  OUT       EFI_STRING                      *Progress,\r
+  OUT       EFI_STRING                      *Results\r
+)\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+RouteConfig (\r
+  IN CONST  EFI_HII_CONFIG_ACCESS_PROTOCOL  *This,\r
+  IN CONST  EFI_STRING                      Configuration,\r
+  OUT       EFI_STRING                      *Progress\r
+)\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+Callback (\r
+  IN     CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN     EFI_BROWSER_ACTION                     Action,\r
+  IN     EFI_QUESTION_ID                        QuestionId,\r
+  IN     UINT8                                  Type,\r
+  IN OUT EFI_IFR_TYPE_VALUE                     *Value,\r
+  OUT    EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
 /**\r
   Load and execute the platform configuration.\r
 \r
 /**\r
   Load and execute the platform configuration.\r
 \r
@@ -64,6 +182,8 @@ ExecutePlatformConfig (
   @param[in] SystemTable  Pointer to SystemTable.\r
 \r
   @retval EFI_SUCESS            Driver has loaded successfully.\r
   @param[in] SystemTable  Pointer to SystemTable.\r
 \r
   @retval EFI_SUCESS            Driver has loaded successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to install HII packages.\r
+  @return                       Error codes from lower level functions.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -73,8 +193,48 @@ PlatformInit (
   IN  EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
   IN  EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
+  EFI_STATUS Status;\r
+\r
   ExecutePlatformConfig ();\r
   ExecutePlatformConfig ();\r
+\r
+  mConfigAccess.ExtractConfig = &ExtractConfig;\r
+  mConfigAccess.RouteConfig   = &RouteConfig;\r
+  mConfigAccess.Callback      = &Callback;\r
+\r
+  //\r
+  // Declare ourselves suitable for HII communication.\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle,\r
+                  &gEfiDevicePathProtocolGuid,      &mPkgDevicePath,\r
+                  &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess,\r
+                  NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Publish the HII package list to HII Database.\r
+  //\r
+  mInstalledPackages = HiiAddPackages (\r
+                         &gEfiCallerIdGuid,  // PackageListGuid\r
+                         ImageHandle,        // associated DeviceHandle\r
+                         PlatformDxeStrings, // 1st package\r
+                         PlatformFormsBin,   // 2nd package\r
+                         NULL                // terminator\r
+                         );\r
+  if (mInstalledPackages == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto UninstallProtocols;\r
+  }\r
+\r
   return EFI_SUCCESS;\r
   return EFI_SUCCESS;\r
+\r
+UninstallProtocols:\r
+  gBS->UninstallMultipleProtocolInterfaces (ImageHandle,\r
+         &gEfiDevicePathProtocolGuid,      &mPkgDevicePath,\r
+         &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess,\r
+         NULL);\r
+  return Status;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -90,5 +250,10 @@ PlatformUnload (
   IN  EFI_HANDLE  ImageHandle\r
   )\r
 {\r
   IN  EFI_HANDLE  ImageHandle\r
   )\r
 {\r
+  HiiRemovePackages (mInstalledPackages);\r
+  gBS->UninstallMultipleProtocolInterfaces (ImageHandle,\r
+         &gEfiDevicePathProtocolGuid,      &mPkgDevicePath,\r
+         &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess,\r
+         NULL);\r
   return EFI_SUCCESS;\r
 }\r
   return EFI_SUCCESS;\r
 }\r
diff --git a/OvmfPkg/PlatformDxe/Platform.h b/OvmfPkg/PlatformDxe/Platform.h
new file mode 100644 (file)
index 0000000..1ee580e
--- /dev/null
@@ -0,0 +1,24 @@
+/** @file\r
+  This driver effectuates OVMF's platform configuration settings and exposes\r
+  them via HII.\r
+\r
+  Copyright (C) 2014, Red Hat, Inc.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  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, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef _PLATFORM_H_\r
+#define _PLATFORM_H_\r
+\r
+//\r
+// Macro and type definitions that connect the form with the HII driver code.\r
+//\r
+#define FORMID_MAIN_FORM       1\r
+\r
+#endif // _PLATFORM_H_\r
index 315f55949d4a4f33e82d2cb6799d21e14608e143..e3701d41724856028393cb822751d060743dd2d5 100644 (file)
@@ -26,7 +26,9 @@
 \r
 [Sources]\r
   Platform.c\r
 \r
 [Sources]\r
   Platform.c\r
+  Platform.uni\r
   PlatformConfig.c\r
   PlatformConfig.c\r
+  PlatformForms.vfr\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
@@ -36,6 +38,8 @@
 [LibraryClasses]\r
   BaseMemoryLib\r
   DebugLib\r
 [LibraryClasses]\r
   BaseMemoryLib\r
   DebugLib\r
+  DevicePathLib\r
+  HiiLib\r
   MemoryAllocationLib\r
   UefiBootServicesTableLib\r
   UefiLib\r
   MemoryAllocationLib\r
   UefiBootServicesTableLib\r
   UefiLib\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution\r
 \r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution\r
 \r
+[Protocols]\r
+  gEfiDevicePathProtocolGuid      ## PRODUCES\r
+  gEfiHiiConfigAccessProtocolGuid ## PRODUCES\r
+\r
 [Guids]\r
   gOvmfPlatformConfigGuid\r
 \r
 [Depex]\r
 [Guids]\r
   gOvmfPlatformConfigGuid\r
 \r
 [Depex]\r
+  gEfiHiiDatabaseProtocolGuid       AND\r
   gEfiVariableArchProtocolGuid      AND\r
   gEfiVariableWriteArchProtocolGuid\r
   gEfiVariableArchProtocolGuid      AND\r
   gEfiVariableWriteArchProtocolGuid\r
diff --git a/OvmfPkg/PlatformDxe/Platform.uni b/OvmfPkg/PlatformDxe/Platform.uni
new file mode 100644 (file)
index 0000000..9d41e44
Binary files /dev/null and b/OvmfPkg/PlatformDxe/Platform.uni differ
diff --git a/OvmfPkg/PlatformDxe/PlatformForms.vfr b/OvmfPkg/PlatformDxe/PlatformForms.vfr
new file mode 100644 (file)
index 0000000..e9ae0de
--- /dev/null
@@ -0,0 +1,38 @@
+// *++\r
+//\r
+// Copyright (C) 2014, Red Hat, Inc.\r
+// Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+//\r
+// This program and the accompanying materials are licensed and made available\r
+// under the terms and conditions of the BSD License which accompanies this\r
+// 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\r
+// IMPLIED.\r
+//\r
+// Module Name:\r
+//\r
+//   PlatformForms.vfr\r
+//\r
+// Abstract:\r
+//\r
+//   Form definitions for exposing some of OVMF's platform knobs via HII.\r
+//\r
+// --*/\r
+\r
+#include <Guid/OvmfPlatformConfig.h>\r
+#include "Platform.h"\r
+\r
+formset\r
+  guid  = OVMF_PLATFORM_CONFIG_GUID,\r
+  title = STRING_TOKEN(STR_FORMSET_TITLE),\r
+  help  = STRING_TOKEN(STR_FORMSET_HELP),\r
+\r
+  form\r
+    formid = FORMID_MAIN_FORM,\r
+    title  = STRING_TOKEN(STR_MAIN_FORM_TITLE);\r
+  endform;\r
+\r
+endformset;\r