TianoCore EDK2 master
Loading...
Searching...
No Matches
BootDiscoveryPolicyUiLib.c
Go to the documentation of this file.
1
15#include <Library/BaseLib.h>
17#include <Library/DebugLib.h>
18#include <Library/HiiLib.h>
19#include <Library/UefiLib.h>
22
26typedef struct {
27 VENDOR_DEVICE_PATH VendorDevicePath;
30
31extern UINT8 BootDiscoveryPolicyUiLibVfrBin[];
32
33EFI_HII_HANDLE mBPHiiHandle = NULL;
34EFI_HANDLE mBPDriverHandle = NULL;
35
36STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = {
37 {
38 {
41 {
42 (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
43 (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
44 }
45 },
46 BOOT_DISCOVERY_POLICY_MGR_FORMSET_GUID
47 },
48 {
49 END_DEVICE_PATH_TYPE,
50 END_ENTIRE_DEVICE_PATH_SUBTYPE,
51 {
52 (UINT8)(END_DEVICE_PATH_LENGTH),
53 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
54 }
55 }
56};
57
70EFIAPI
72 IN EFI_HANDLE ImageHandle,
73 IN EFI_SYSTEM_TABLE *SystemTable
74 )
75{
76 EFI_STATUS Status;
77 UINTN Size;
78 UINT32 BootDiscoveryPolicy;
79
80 Size = sizeof (UINT32);
81 Status = gRT->GetVariable (
82 BOOT_DISCOVERY_POLICY_VAR,
83 &gBootDiscoveryPolicyMgrFormsetGuid,
84 NULL,
85 &Size,
86 &BootDiscoveryPolicy
87 );
88 if (EFI_ERROR (Status)) {
89 Status = PcdSet32S (PcdBootDiscoveryPolicy, PcdGet32 (PcdBootDiscoveryPolicy));
90 ASSERT_EFI_ERROR (Status);
91 }
92
93 Status = gBS->InstallMultipleProtocolInterfaces (
94 &mBPDriverHandle,
95 &gEfiDevicePathProtocolGuid,
96 &mVendorDevicePath,
97 NULL
98 );
99 if (EFI_ERROR (Status)) {
100 return Status;
101 }
102
103 //
104 // Publish our HII data
105 //
106 mBPHiiHandle = HiiAddPackages (
107 &gBootDiscoveryPolicyMgrFormsetGuid,
108 mBPDriverHandle,
109 BootDiscoveryPolicyUiLibVfrBin,
110 BootDiscoveryPolicyUiLibStrings,
111 NULL
112 );
113 if (mBPHiiHandle == NULL) {
114 gBS->UninstallMultipleProtocolInterfaces (
115 mBPDriverHandle,
116 &gEfiDevicePathProtocolGuid,
117 &mVendorDevicePath,
118 NULL
119 );
120
121 return EFI_OUT_OF_RESOURCES;
122 }
123
124 return EFI_SUCCESS;
125}
126
138EFIAPI
140 IN EFI_HANDLE ImageHandle,
141 IN EFI_SYSTEM_TABLE *SystemTable
142 )
143{
144 if (mBPDriverHandle != NULL) {
145 gBS->UninstallProtocolInterface (
146 mBPDriverHandle,
147 &gEfiDevicePathProtocolGuid,
148 &mVendorDevicePath
149 );
150 mBPDriverHandle = NULL;
151 }
152
153 if (mBPHiiHandle != NULL) {
154 HiiRemovePackages (mBPHiiHandle);
155 mBPHiiHandle = NULL;
156 }
157
158 return EFI_SUCCESS;
159}
UINT64 UINTN
EFI_STATUS EFIAPI BootDiscoveryPolicyUiLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI BootDiscoveryPolicyUiLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
Definition: HiiLib.c:141
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLib.c:253
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
#define PcdSet32S(TokenName, Value)
Definition: PcdLib.h:497
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
VOID * EFI_HII_HANDLE