2 Library instance for ExtendedHiiLib.
4 This library instance implements the common HII routines which is
5 related to HII but reference data structures that are not defined in
6 UEFI specification, for example HII_VENDOR_DEVICE_PATH.
9 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
10 All rights reserved. This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include <Protocol/DevicePath.h>
23 #include <Library/DebugLib.h>
24 #include <Library/MemoryAllocationLib.h>
25 #include <Library/UefiBootServicesTableLib.h>
26 #include <Library/DevicePathLib.h>
27 #include <Guid\MdeModuleHii.h>
31 // Hii vendor device path template
33 GLOBAL_REMOVE_IF_UNREFERENCED CONST HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate
= {
40 (UINT8
) (sizeof (HII_VENDOR_DEVICE_PATH_NODE
)),
41 (UINT8
) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE
)) >> 8)
51 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
53 END_DEVICE_PATH_LENGTH
59 The HII driver handle passed in for HiiDatabase.NewPackageList() requires
60 that there should be DevicePath Protocol installed on it.
61 This routine create a virtual Driver Handle by installing a vendor device
62 path on it, so as to use it to invoke HiiDatabase.NewPackageList().
63 The Device Path created is a Vendor Device Path specific to Intel's implemenation
64 and it is defined as HII_VENDOR_DEVICE_PATH_NODE.
67 @param DriverHandle Handle to be returned
69 @retval EFI_SUCCESS Handle destroy success.
70 @retval EFI_OUT_OF_RESOURCES Not enough memory.
75 HiiLibCreateHiiDriverHandle (
76 OUT EFI_HANDLE
*DriverHandle
80 HII_VENDOR_DEVICE_PATH_NODE
*VendorDevicePath
;
82 VendorDevicePath
= AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH
), &mHiiVendorDevicePathTemplate
);
83 if (VendorDevicePath
== NULL
) {
84 return EFI_OUT_OF_RESOURCES
;
88 // Use memory address as unique ID to distinguish from different device paths
90 VendorDevicePath
->UniqueId
= (UINT64
) ((UINTN
) VendorDevicePath
);
93 Status
= gBS
->InstallMultipleProtocolInterfaces (
95 &gEfiDevicePathProtocolGuid
,
99 if (EFI_ERROR (Status
)) {
108 Destroy the Driver Handle created by CreateHiiDriverHandle().
110 If no Device Path protocol is installed on the DriverHandle, then ASSERT.
111 If this Device Path protocol is failed to be uninstalled, then ASSERT.
113 @param DriverHandle Handle returned by CreateHiiDriverHandle()
119 HiiLibDestroyHiiDriverHandle (
120 IN EFI_HANDLE DriverHandle
124 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
126 Status
= gBS
->HandleProtocol (
128 &gEfiDevicePathProtocolGuid
,
129 (VOID
**) &DevicePath
131 ASSERT_EFI_ERROR (Status
);
133 Status
= gBS
->UninstallProtocolInterface (
135 &gEfiDevicePathProtocolGuid
,
138 ASSERT_EFI_ERROR (Status
);
140 FreePool (DevicePath
);