2 HII Library implementation that uses DXE protocols and services.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Protocol/DevicePath.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/MemoryAllocationLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/DevicePathLib.h>
25 #include <MdeModuleHii.h>
29 // Hii vendor device path template
31 GLOBAL_REMOVE_IF_UNREFERENCED CONST HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate
= {
38 (UINT8
) (sizeof (HII_VENDOR_DEVICE_PATH_NODE
)),
39 (UINT8
) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE
)) >> 8)
49 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
51 END_DEVICE_PATH_LENGTH
57 The HII driver handle passed in for HiiDatabase.NewPackageList() requires
58 that there should be DevicePath Protocol installed on it.
59 This routine create a virtual Driver Handle by installing a vendor device
60 path on it, so as to use it to invoke HiiDatabase.NewPackageList().
61 The Device Path created is a Vendor Device Path specific to Intel's implemenation
62 and it is defined as HII_VENDOR_DEVICE_PATH_NODE.
65 @param DriverHandle Handle to be returned
67 @retval EFI_SUCCESS Handle destroy success.
68 @retval EFI_OUT_OF_RESOURCES Not enough memory.
73 HiiLibCreateHiiDriverHandle (
74 OUT EFI_HANDLE
*DriverHandle
78 HII_VENDOR_DEVICE_PATH_NODE
*VendorDevicePath
;
80 VendorDevicePath
= AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH
), &mHiiVendorDevicePathTemplate
);
81 if (VendorDevicePath
== NULL
) {
82 return EFI_OUT_OF_RESOURCES
;
86 // Use memory address as unique ID to distinguish from different device paths
88 VendorDevicePath
->UniqueId
= (UINT64
) ((UINTN
) VendorDevicePath
);
91 Status
= gBS
->InstallMultipleProtocolInterfaces (
93 &gEfiDevicePathProtocolGuid
,
97 if (EFI_ERROR (Status
)) {
106 Destroy the Driver Handle created by CreateHiiDriverHandle().
108 If no Device Path protocol is installed on the DriverHandle, then ASSERT.
109 If this Device Path protocol is failed to be uninstalled, then ASSERT.
111 @param DriverHandle Handle returned by CreateHiiDriverHandle()
117 HiiLibDestroyHiiDriverHandle (
118 IN EFI_HANDLE DriverHandle
122 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
124 Status
= gBS
->HandleProtocol (
126 &gEfiDevicePathProtocolGuid
,
127 (VOID
**) &DevicePath
129 ASSERT_EFI_ERROR (Status
);
131 Status
= gBS
->UninstallProtocolInterface (
133 &gEfiDevicePathProtocolGuid
,
136 ASSERT_EFI_ERROR (Status
);
138 FreePool (DevicePath
);