]>
Commit | Line | Data |
---|---|---|
9226efe5 | 1 | /** @file\r |
f875a4f1 | 2 | Library instance for ExtendedHiiLib.\r |
3 | \r | |
4 | This library instance implements the common HII routines which is\r | |
5 | related to HII but reference data structures that are not defined in \r | |
6 | UEFI specification, for example HII_VENDOR_DEVICE_PATH.\r | |
7 | \r | |
9226efe5 | 8 | \r |
8dbae30d | 9 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r |
10 | All rights reserved. This program and the accompanying materials\r | |
11 | are licensed and made available under the terms and conditions of the BSD License\r | |
12 | which accompanies this distribution. The full text of the license may be found at\r | |
13 | http://opensource.org/licenses/bsd-license.php\r | |
9226efe5 | 14 | \r |
8dbae30d | 15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
9226efe5 | 17 | \r |
18 | **/\r | |
19 | \r | |
20 | \r | |
60c93673 | 21 | #include <Uefi.h>\r |
9226efe5 | 22 | #include <Protocol/DevicePath.h>\r |
9226efe5 | 23 | #include <Library/DebugLib.h>\r |
24 | #include <Library/MemoryAllocationLib.h>\r | |
25 | #include <Library/UefiBootServicesTableLib.h>\r | |
1232b214 | 26 | #include <Library/DevicePathLib.h>\r |
5c526736 | 27 | #include <Guid\MdeModuleHii.h>\r |
9226efe5 | 28 | \r |
29 | \r | |
30 | //\r | |
31 | // Hii vendor device path template\r | |
32 | //\r | |
329d3f3d | 33 | GLOBAL_REMOVE_IF_UNREFERENCED CONST HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate = {\r |
9226efe5 | 34 | {\r |
35 | {\r | |
36 | {\r | |
37 | HARDWARE_DEVICE_PATH,\r | |
38 | HW_VENDOR_DP,\r | |
39 | {\r | |
40 | (UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),\r | |
41 | (UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)\r | |
42 | }\r | |
43 | },\r | |
44 | EFI_IFR_TIANO_GUID\r | |
45 | },\r | |
c7493fe5 | 46 | 0,\r |
9226efe5 | 47 | 0\r |
48 | },\r | |
49 | {\r | |
50 | END_DEVICE_PATH_TYPE,\r | |
51 | END_ENTIRE_DEVICE_PATH_SUBTYPE,\r | |
52 | { \r | |
53 | END_DEVICE_PATH_LENGTH\r | |
54 | }\r | |
55 | }\r | |
56 | };\r | |
57 | \r | |
6ca46b63 | 58 | /**\r |
59 | The HII driver handle passed in for HiiDatabase.NewPackageList() requires\r | |
60 | that there should be DevicePath Protocol installed on it.\r | |
61 | This routine create a virtual Driver Handle by installing a vendor device\r | |
62 | path on it, so as to use it to invoke HiiDatabase.NewPackageList().\r | |
63 | The Device Path created is a Vendor Device Path specific to Intel's implemenation\r | |
64 | and it is defined as HII_VENDOR_DEVICE_PATH_NODE.\r | |
65 | \r | |
9226efe5 | 66 | \r |
6ca46b63 | 67 | @param DriverHandle Handle to be returned\r |
68 | \r | |
69 | @retval EFI_SUCCESS Handle destroy success.\r | |
70 | @retval EFI_OUT_OF_RESOURCES Not enough memory.\r | |
71 | \r | |
72 | **/\r | |
9226efe5 | 73 | EFI_STATUS\r |
74 | EFIAPI\r | |
75 | HiiLibCreateHiiDriverHandle (\r | |
76 | OUT EFI_HANDLE *DriverHandle\r | |
77 | )\r | |
78 | {\r | |
79 | EFI_STATUS Status;\r | |
80 | HII_VENDOR_DEVICE_PATH_NODE *VendorDevicePath;\r | |
9226efe5 | 81 | \r |
82 | VendorDevicePath = AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);\r | |
83 | if (VendorDevicePath == NULL) {\r | |
84 | return EFI_OUT_OF_RESOURCES;\r | |
85 | }\r | |
86 | \r | |
c7493fe5 | 87 | //\r |
88 | // Use memory address as unique ID to distinguish from different device paths\r | |
89 | //\r | |
90 | VendorDevicePath->UniqueId = (UINT64) ((UINTN) VendorDevicePath);\r | |
9226efe5 | 91 | \r |
92 | *DriverHandle = NULL;\r | |
c7493fe5 | 93 | Status = gBS->InstallMultipleProtocolInterfaces (\r |
9226efe5 | 94 | DriverHandle,\r |
95 | &gEfiDevicePathProtocolGuid,\r | |
c7493fe5 | 96 | VendorDevicePath,\r |
97 | NULL\r | |
9226efe5 | 98 | );\r |
99 | if (EFI_ERROR (Status)) {\r | |
100 | return Status;\r | |
101 | }\r | |
102 | \r | |
103 | return EFI_SUCCESS;\r | |
104 | }\r | |
105 | \r | |
106 | \r | |
6ca46b63 | 107 | /**\r |
108 | Destroy the Driver Handle created by CreateHiiDriverHandle().\r | |
109 | \r | |
110 | If no Device Path protocol is installed on the DriverHandle, then ASSERT.\r | |
111 | If this Device Path protocol is failed to be uninstalled, then ASSERT.\r | |
112 | \r | |
113 | @param DriverHandle Handle returned by CreateHiiDriverHandle()\r | |
114 | \r | |
115 | \r | |
116 | **/\r | |
9226efe5 | 117 | VOID\r |
118 | EFIAPI\r | |
119 | HiiLibDestroyHiiDriverHandle (\r | |
120 | IN EFI_HANDLE DriverHandle\r | |
121 | )\r | |
122 | {\r | |
123 | EFI_STATUS Status;\r | |
124 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
125 | \r | |
126 | Status = gBS->HandleProtocol (\r | |
127 | DriverHandle,\r | |
128 | &gEfiDevicePathProtocolGuid,\r | |
129 | (VOID **) &DevicePath\r | |
130 | );\r | |
131 | ASSERT_EFI_ERROR (Status);\r | |
132 | \r | |
133 | Status = gBS->UninstallProtocolInterface (\r | |
134 | DriverHandle,\r | |
135 | &gEfiDevicePathProtocolGuid,\r | |
136 | DevicePath\r | |
137 | );\r | |
138 | ASSERT_EFI_ERROR (Status);\r | |
139 | \r | |
140 | FreePool (DevicePath);\r | |
141 | \r | |
142 | }\r | |
143 | \r | |
144 | \r | |
145 | \r |