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 <MdeModuleHii.h>
28 // Hii vendor device path template
30 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate
= {
37 (UINT8
) (sizeof (HII_VENDOR_DEVICE_PATH_NODE
)),
38 (UINT8
) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE
)) >> 8)
47 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
49 END_DEVICE_PATH_LENGTH
55 The HII driver handle passed in for HiiDatabase.NewPackageList() requires
56 that there should be DevicePath Protocol installed on it.
57 This routine create a virtual Driver Handle by installing a vendor device
58 path on it, so as to use it to invoke HiiDatabase.NewPackageList().
59 The Device Path created is a Vendor Device Path specific to Intel's implemenation
60 and it is defined as HII_VENDOR_DEVICE_PATH_NODE.
63 @param DriverHandle Handle to be returned
65 @retval EFI_SUCCESS Handle destroy success.
66 @retval EFI_OUT_OF_RESOURCES Not enough memory.
71 HiiLibCreateHiiDriverHandle (
72 OUT EFI_HANDLE
*DriverHandle
76 HII_VENDOR_DEVICE_PATH_NODE
*VendorDevicePath
;
77 UINT64 MonotonicCount
;
79 VendorDevicePath
= AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH
), &mHiiVendorDevicePathTemplate
);
80 if (VendorDevicePath
== NULL
) {
81 return EFI_OUT_OF_RESOURCES
;
84 gBS
->GetNextMonotonicCount (&MonotonicCount
);
85 VendorDevicePath
->MonotonicCount
= (UINT32
) MonotonicCount
;
88 Status
= gBS
->InstallProtocolInterface (
90 &gEfiDevicePathProtocolGuid
,
94 if (EFI_ERROR (Status
)) {
103 Destroy the Driver Handle created by CreateHiiDriverHandle().
105 If no Device Path protocol is installed on the DriverHandle, then ASSERT.
106 If this Device Path protocol is failed to be uninstalled, then ASSERT.
108 @param DriverHandle Handle returned by CreateHiiDriverHandle()
114 HiiLibDestroyHiiDriverHandle (
115 IN EFI_HANDLE DriverHandle
119 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
121 Status
= gBS
->HandleProtocol (
123 &gEfiDevicePathProtocolGuid
,
124 (VOID
**) &DevicePath
126 ASSERT_EFI_ERROR (Status
);
128 Status
= gBS
->UninstallProtocolInterface (
130 &gEfiDevicePathProtocolGuid
,
133 ASSERT_EFI_ERROR (Status
);
135 FreePool (DevicePath
);