]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.c
modify coding style to pass ecc tool
[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
16#include <PiDxe.h>\r
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
24#include <MdeModuleHii.h>\r
25\r
26\r
27//\r
28// Hii vendor device path template\r
29//\r
30HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate = {\r
31 {\r
32 {\r
33 {\r
34 HARDWARE_DEVICE_PATH,\r
35 HW_VENDOR_DP,\r
36 {\r
37 (UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),\r
38 (UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
39 }\r
40 },\r
41 EFI_IFR_TIANO_GUID\r
42 },\r
43 0\r
44 },\r
45 {\r
46 END_DEVICE_PATH_TYPE,\r
47 END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
48 { \r
49 END_DEVICE_PATH_LENGTH\r
50 }\r
51 }\r
52};\r
53\r
6ca46b63 54/**\r
55 The HII driver handle passed in for HiiDatabase.NewPackageList() requires\r
56 that there should be DevicePath Protocol installed on it.\r
57 This routine create a virtual Driver Handle by installing a vendor device\r
58 path on it, so as to use it to invoke HiiDatabase.NewPackageList().\r
59 The Device Path created is a Vendor Device Path specific to Intel's implemenation\r
60 and it is defined as HII_VENDOR_DEVICE_PATH_NODE.\r
61 \r
9226efe5 62\r
6ca46b63 63 @param DriverHandle Handle to be returned\r
64\r
65 @retval EFI_SUCCESS Handle destroy success.\r
66 @retval EFI_OUT_OF_RESOURCES Not enough memory.\r
67\r
68**/\r
9226efe5 69EFI_STATUS\r
70EFIAPI\r
71HiiLibCreateHiiDriverHandle (\r
72 OUT EFI_HANDLE *DriverHandle\r
73 )\r
74{\r
75 EFI_STATUS Status;\r
76 HII_VENDOR_DEVICE_PATH_NODE *VendorDevicePath;\r
77 UINT64 MonotonicCount;\r
78\r
79 VendorDevicePath = AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);\r
80 if (VendorDevicePath == NULL) {\r
81 return EFI_OUT_OF_RESOURCES;\r
82 }\r
83\r
84 gBS->GetNextMonotonicCount (&MonotonicCount);\r
85 VendorDevicePath->MonotonicCount = (UINT32) MonotonicCount;\r
86\r
87 *DriverHandle = NULL;\r
88 Status = gBS->InstallProtocolInterface (\r
89 DriverHandle,\r
90 &gEfiDevicePathProtocolGuid,\r
91 EFI_NATIVE_INTERFACE,\r
92 VendorDevicePath\r
93 );\r
94 if (EFI_ERROR (Status)) {\r
95 return Status;\r
96 }\r
97\r
98 return EFI_SUCCESS;\r
99}\r
100\r
101\r
6ca46b63 102/**\r
103 Destroy the Driver Handle created by CreateHiiDriverHandle().\r
104\r
105 If no Device Path protocol is installed on the DriverHandle, then ASSERT.\r
106 If this Device Path protocol is failed to be uninstalled, then ASSERT.\r
107\r
108 @param DriverHandle Handle returned by CreateHiiDriverHandle()\r
109\r
110\r
111**/\r
9226efe5 112VOID\r
113EFIAPI\r
114HiiLibDestroyHiiDriverHandle (\r
115 IN EFI_HANDLE DriverHandle\r
116 )\r
117{\r
118 EFI_STATUS Status;\r
119 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
120\r
121 Status = gBS->HandleProtocol (\r
122 DriverHandle,\r
123 &gEfiDevicePathProtocolGuid,\r
124 (VOID **) &DevicePath\r
125 );\r
126 ASSERT_EFI_ERROR (Status);\r
127\r
128 Status = gBS->UninstallProtocolInterface (\r
129 DriverHandle,\r
130 &gEfiDevicePathProtocolGuid,\r
131 DevicePath\r
132 );\r
133 ASSERT_EFI_ERROR (Status);\r
134\r
135 FreePool (DevicePath);\r
136\r
137}\r
138\r
139\r
140\r