-/** @file\r
-Library instance for ExtendedHiiLib.\r
- \r
-This library instance implements the common HII routines which is\r
-related to HII but reference data structures that are not defined in \r
-UEFI specification, for example HII_VENDOR_DEVICE_PATH.\r
-\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\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
-#include <Uefi.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Guid/MdeModuleHii.h>\r
-\r
-\r
-//\r
-// Hii vendor device path template\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate = {\r
- {\r
- {\r
- {\r
- HARDWARE_DEVICE_PATH,\r
- HW_VENDOR_DP,\r
- {\r
- (UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),\r
- (UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
- }\r
- },\r
- EFI_IFR_TIANO_GUID\r
- },\r
- 0,\r
- 0\r
- },\r
- {\r
- END_DEVICE_PATH_TYPE,\r
- END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- { \r
- END_DEVICE_PATH_LENGTH\r
- }\r
- }\r
-};\r
-\r
-/**\r
- The HII driver handle passed in for HiiDatabase.NewPackageList() requires\r
- that there should be DevicePath Protocol installed on it.\r
- This routine create a virtual Driver Handle by installing a vendor device\r
- path on it, so as to use it to invoke HiiDatabase.NewPackageList().\r
- The Device Path created is a Vendor Device Path specific to Intel's implemenation\r
- and it is defined as HII_VENDOR_DEVICE_PATH_NODE.\r
- \r
-\r
- @param DriverHandle Handle to be returned\r
-\r
- @retval EFI_SUCCESS Handle destroy success.\r
- @retval EFI_OUT_OF_RESOURCES Not enough memory.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HiiLibCreateHiiDriverHandle (\r
- OUT EFI_HANDLE *DriverHandle\r
- )\r
-{\r
- EFI_STATUS Status;\r
- HII_VENDOR_DEVICE_PATH_NODE *VendorDevicePath;\r
-\r
- VendorDevicePath = AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);\r
- if (VendorDevicePath == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Use memory address as unique ID to distinguish from different device paths\r
- //\r
- VendorDevicePath->UniqueId = (UINT64) ((UINTN) VendorDevicePath);\r
-\r
- *DriverHandle = NULL;\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- DriverHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- VendorDevicePath,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Destroy the Driver Handle created by CreateHiiDriverHandle().\r
-\r
- If no Device Path protocol is installed on the DriverHandle, then ASSERT.\r
- If this Device Path protocol is failed to be uninstalled, then ASSERT.\r
-\r
- @param DriverHandle Handle returned by CreateHiiDriverHandle()\r
-\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-HiiLibDestroyHiiDriverHandle (\r
- IN EFI_HANDLE DriverHandle\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
-\r
- Status = gBS->HandleProtocol (\r
- DriverHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- (VOID **) &DevicePath\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- Status = gBS->UninstallProtocolInterface (\r
- DriverHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- DevicePath\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- FreePool (DevicePath);\r
-\r
-}\r
-\r
-\r
-\r