]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSample.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / HiiResourcesSampleDxe / HiiResourcesSample.c
CommitLineData
6446c987
LG
1/** @file\r
2This is an example of how a driver retrieve HII data using HII Package List\r
3Protocol, and how to publish the HII data.\r
4\r
e5eed7d3
HT
5Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
6446c987
LG
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <Uefi.h>\r
17#include <Protocol/HiiPackageList.h>\r
18#include <Library/DevicePathLib.h>\r
19#include <Library/UefiDriverEntryPoint.h>\r
20#include <Library/UefiBootServicesTableLib.h>\r
21#include <Library/UefiHiiServicesLib.h>\r
22#include <Library/HiiLib.h>\r
23\r
24#pragma pack(1)\r
25///\r
26/// HII specific Vendor Device Path definition.\r
27///\r
28typedef struct {\r
29 VENDOR_DEVICE_PATH VendorDevicePath;\r
30 EFI_DEVICE_PATH_PROTOCOL End;\r
31} HII_VENDOR_DEVICE_PATH;\r
32#pragma pack()\r
33\r
34\r
35EFI_HII_HANDLE mHiiHandle = NULL;\r
36EFI_HANDLE mDriverHandle = NULL;\r
37\r
38HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = {\r
39 {\r
40 {\r
41 HARDWARE_DEVICE_PATH,\r
42 HW_VENDOR_DP,\r
43 {\r
44 (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
45 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
46 }\r
47 },\r
48 //\r
49 // {D49D2EB0-44D5-4621-9FD6-1A92C9109B99}\r
50 //\r
51 { 0xD49D2EB0, 0x44D5, 0x4621, { 0x9F, 0xD6, 0x1A, 0x92, 0xC9, 0x10, 0x9B, 0x99 } }\r
52 },\r
53 {\r
54 END_DEVICE_PATH_TYPE,\r
55 END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
56 { \r
57 (UINT8) (END_DEVICE_PATH_LENGTH),\r
58 (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
59 }\r
60 }\r
61};\r
62\r
63/**\r
64 Main entry for this driver.\r
65 \r
66 @param[in] ImageHandle Image handle this driver.\r
67 @param[in] SystemTable Pointer to SystemTable.\r
68\r
69 @retval EFI_SUCESS This function always complete successfully.\r
70\r
71**/\r
72EFI_STATUS\r
73EFIAPI\r
74HiiResourcesSampleInit (\r
75 IN EFI_HANDLE ImageHandle,\r
76 IN EFI_SYSTEM_TABLE *SystemTable\r
77 )\r
78{\r
79 EFI_STATUS Status;\r
80 EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
81\r
82 //\r
83 // Retrieve HII package list from ImageHandle\r
84 //\r
85 Status = gBS->OpenProtocol (\r
86 ImageHandle,\r
87 &gEfiHiiPackageListProtocolGuid,\r
88 (VOID **) &PackageList,\r
89 ImageHandle,\r
90 NULL,\r
91 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
92 );\r
93 if (EFI_ERROR (Status)) {\r
94 return Status;\r
95 }\r
96\r
97 //\r
98 // Publish sample Fromset\r
99 //\r
100 Status = gBS->InstallProtocolInterface (\r
101 &mDriverHandle,\r
102 &gEfiDevicePathProtocolGuid,\r
103 EFI_NATIVE_INTERFACE,\r
104 &mHiiVendorDevicePath\r
105 );\r
106 if (EFI_ERROR (Status)) {\r
107 return Status;\r
108 }\r
109\r
110 //\r
d90434cc 111 // Publish HII package list to HII Database.\r
6446c987
LG
112 //\r
113 Status = gHiiDatabase->NewPackageList (\r
114 gHiiDatabase,\r
115 PackageList,\r
116 mDriverHandle,\r
117 &mHiiHandle\r
118 );\r
119 if (EFI_ERROR (Status)) {\r
120 return Status;\r
121 }\r
122\r
123 return EFI_SUCCESS;\r
124}\r
125\r
126/**\r
127 Unloads the application and its installed protocol.\r
128\r
129 @param[in] ImageHandle Handle that identifies the image to be unloaded.\r
130\r
131 @retval EFI_SUCCESS The image has been unloaded.\r
132**/\r
133EFI_STATUS\r
134EFIAPI\r
135HiiResourcesSampleUnload (\r
136 IN EFI_HANDLE ImageHandle\r
137 )\r
138{\r
139 if (mDriverHandle != NULL) {\r
140 gBS->UninstallProtocolInterface (\r
141 mDriverHandle,\r
142 &gEfiDevicePathProtocolGuid,\r
143 &mHiiVendorDevicePath\r
144 );\r
145 mDriverHandle = NULL;\r
146 }\r
147\r
148 if (mHiiHandle != NULL) {\r
149 HiiRemovePackages (mHiiHandle);\r
150 mHiiHandle = NULL;\r
151 }\r
152\r
153 return EFI_SUCCESS;\r
154}\r