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