TianoCore EDK2 master
Loading...
Searching...
No Matches
HiiResourcesSample.c
Go to the documentation of this file.
1
10#include <Uefi.h>
17#include <Library/HiiLib.h>
18
19#pragma pack(1)
23typedef struct {
24 VENDOR_DEVICE_PATH VendorDevicePath;
27#pragma pack()
28
29EFI_HII_HANDLE mHiiHandle = NULL;
30EFI_HANDLE mDriverHandle = NULL;
31
32HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = {
33 {
34 {
37 {
38 (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
39 (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
40 }
41 },
42 HII_RESOURCE_SAMPLE_FORM_SET_GUID
43 },
44 {
45 END_DEVICE_PATH_TYPE,
46 END_ENTIRE_DEVICE_PATH_SUBTYPE,
47 {
48 (UINT8)(END_DEVICE_PATH_LENGTH),
49 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
50 }
51 }
52};
53
64EFIAPI
66 IN EFI_HANDLE ImageHandle,
67 IN EFI_SYSTEM_TABLE *SystemTable
68 )
69{
70 EFI_STATUS Status;
71 EFI_HII_PACKAGE_LIST_HEADER *PackageList;
72
73 //
74 // Retrieve HII package list from ImageHandle
75 //
76 Status = gBS->OpenProtocol (
77 ImageHandle,
78 &gEfiHiiPackageListProtocolGuid,
79 (VOID **)&PackageList,
80 ImageHandle,
81 NULL,
82 EFI_OPEN_PROTOCOL_GET_PROTOCOL
83 );
84 if (EFI_ERROR (Status)) {
85 return Status;
86 }
87
88 //
89 // Publish sample Fromset
90 //
91 Status = gBS->InstallProtocolInterface (
92 &mDriverHandle,
93 &gEfiDevicePathProtocolGuid,
95 &mHiiVendorDevicePath
96 );
97 if (EFI_ERROR (Status)) {
98 return Status;
99 }
100
101 //
102 // Publish HII package list to HII Database.
103 //
104 Status = gHiiDatabase->NewPackageList (
106 PackageList,
107 mDriverHandle,
108 &mHiiHandle
109 );
110 if (EFI_ERROR (Status)) {
111 return Status;
112 }
113
114 return EFI_SUCCESS;
115}
116
125EFIAPI
127 IN EFI_HANDLE ImageHandle
128 )
129{
130 if (mDriverHandle != NULL) {
131 gBS->UninstallProtocolInterface (
132 mDriverHandle,
133 &gEfiDevicePathProtocolGuid,
134 &mHiiVendorDevicePath
135 );
136 mDriverHandle = NULL;
137 }
138
139 if (mHiiHandle != NULL) {
140 HiiRemovePackages (mHiiHandle);
141 mHiiHandle = NULL;
142 }
143
144 return EFI_SUCCESS;
145}
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLib.c:253
EFI_STATUS EFIAPI HiiResourcesSampleInit(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI HiiResourcesSampleUnload(IN EFI_HANDLE ImageHandle)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_HII_DATABASE_PROTOCOL * gHiiDatabase
VOID * EFI_HII_HANDLE
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193