]>
Commit | Line | Data |
---|---|---|
93e3992d | 1 | /** @file\r |
53cf48e0 | 2 | This is an example of how a driver might export data to the HII protocol to be\r |
3 | later utilized by the Setup Protocol\r | |
4 | \r | |
8d00a0f1 | 5 | Copyright (c) 2004 - 2008, Intel Corporation\r |
93e3992d | 6 | All rights reserved. This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
93e3992d | 14 | **/\r |
15 | \r | |
16 | \r | |
17 | #include "DriverSample.h"\r | |
18 | \r | |
7e3bcccb | 19 | #define DISPLAY_ONLY_MY_ITEM 0x0002\r |
93e3992d | 20 | \r |
21 | EFI_GUID mFormSetGuid = FORMSET_GUID;\r | |
22 | EFI_GUID mInventoryGuid = INVENTORY_GUID;\r | |
23 | \r | |
24 | CHAR16 VariableName[] = L"MyIfrNVData";\r | |
25 | \r | |
2f3065c0 LG |
26 | EFI_HANDLE DriverHandle[2] = {NULL, NULL};\r |
27 | DRIVER_SAMPLE_PRIVATE_DATA *PrivateData = NULL;\r | |
28 | \r | |
29 | HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0 = {\r | |
f6f910dd | 30 | {\r |
31 | {\r | |
32 | HARDWARE_DEVICE_PATH,\r | |
33 | HW_VENDOR_DP,\r | |
34 | {\r | |
35 | (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r | |
36 | (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r | |
37 | }\r | |
38 | },\r | |
39 | //\r | |
40 | // {C153B68D-EBFC-488e-B110-662867745B87}\r | |
41 | //\r | |
42 | { 0xc153b68d, 0xebfc, 0x488e, { 0xb1, 0x10, 0x66, 0x28, 0x67, 0x74, 0x5b, 0x87 } }\r | |
43 | },\r | |
44 | {\r | |
45 | END_DEVICE_PATH_TYPE,\r | |
46 | END_ENTIRE_DEVICE_PATH_SUBTYPE,\r | |
47 | { \r | |
48 | (UINT8) (END_DEVICE_PATH_LENGTH),\r | |
49 | (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r | |
50 | }\r | |
51 | }\r | |
52 | };\r | |
53 | \r | |
2f3065c0 | 54 | HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath1 = {\r |
f6f910dd | 55 | {\r |
56 | {\r | |
57 | HARDWARE_DEVICE_PATH,\r | |
58 | HW_VENDOR_DP,\r | |
59 | {\r | |
60 | (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r | |
61 | (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r | |
62 | }\r | |
63 | },\r | |
64 | //\r | |
65 | // {06F37F07-0C48-40e9-8436-0A08A0BB76B0}\r | |
66 | //\r | |
67 | { 0x6f37f07, 0xc48, 0x40e9, { 0x84, 0x36, 0xa, 0x8, 0xa0, 0xbb, 0x76, 0xb0 } }\r | |
68 | },\r | |
69 | {\r | |
70 | END_DEVICE_PATH_TYPE,\r | |
71 | END_ENTIRE_DEVICE_PATH_SUBTYPE,\r | |
72 | { \r | |
73 | (UINT8) (END_DEVICE_PATH_LENGTH),\r | |
74 | (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r | |
75 | }\r | |
76 | }\r | |
77 | };\r | |
78 | \r | |
7064c0a5 | 79 | /**\r |
80 | Encode the password using a simple algorithm.\r | |
81 | \r | |
82 | @param Password The string to be encoded.\r | |
83 | @param MaxSize The size of the string.\r | |
84 | \r | |
85 | **/\r | |
93e3992d | 86 | VOID\r |
87 | EncodePassword (\r | |
88 | IN CHAR16 *Password,\r | |
5a829f56 | 89 | IN UINTN MaxSize\r |
93e3992d | 90 | )\r |
91 | {\r | |
92 | UINTN Index;\r | |
93 | UINTN Loop;\r | |
94 | CHAR16 *Buffer;\r | |
95 | CHAR16 *Key;\r | |
96 | \r | |
97 | Key = L"MAR10648567";\r | |
98 | Buffer = AllocateZeroPool (MaxSize);\r | |
99 | ASSERT (Buffer != NULL);\r | |
100 | \r | |
101 | for (Index = 0; Key[Index] != 0; Index++) {\r | |
102 | for (Loop = 0; Loop < (UINT8) (MaxSize / 2); Loop++) {\r | |
103 | Buffer[Loop] = (CHAR16) (Password[Loop] ^ Key[Index]);\r | |
104 | }\r | |
105 | }\r | |
106 | \r | |
107 | CopyMem (Password, Buffer, MaxSize);\r | |
108 | \r | |
53cf48e0 | 109 | FreePool (Buffer);\r |
93e3992d | 110 | return ;\r |
111 | }\r | |
112 | \r | |
7064c0a5 | 113 | /**\r |
114 | Validate the user's password.\r | |
115 | \r | |
116 | @param PrivateData This driver's private context data.\r | |
117 | @param StringId The user's input.\r | |
118 | \r | |
119 | @retval EFI_SUCCESS The user's input matches the password.\r | |
120 | @retval EFI_NOT_READY The user's input does not match the password.\r | |
121 | **/\r | |
93e3992d | 122 | EFI_STATUS\r |
123 | ValidatePassword (\r | |
7064c0a5 | 124 | IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData,\r |
125 | IN EFI_STRING_ID StringId\r | |
93e3992d | 126 | )\r |
127 | {\r | |
128 | EFI_STATUS Status;\r | |
129 | UINTN Index;\r | |
130 | UINTN BufferSize;\r | |
131 | CHAR16 *Password;\r | |
132 | CHAR16 *EncodedPassword;\r | |
133 | BOOLEAN OldPassword;\r | |
134 | \r | |
135 | //\r | |
136 | // Get encoded password first\r | |
137 | //\r | |
138 | BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r | |
139 | Status = gRT->GetVariable (\r | |
140 | VariableName,\r | |
141 | &mFormSetGuid,\r | |
142 | NULL,\r | |
143 | &BufferSize,\r | |
144 | &PrivateData->Configuration\r | |
145 | );\r | |
146 | if (EFI_ERROR (Status)) {\r | |
147 | //\r | |
148 | // Old password not exist, prompt for new password\r | |
149 | //\r | |
150 | return EFI_SUCCESS;\r | |
151 | }\r | |
152 | \r | |
153 | OldPassword = FALSE;\r | |
154 | //\r | |
155 | // Check whether we have any old password set\r | |
156 | //\r | |
157 | for (Index = 0; Index < 20; Index++) {\r | |
158 | if (PrivateData->Configuration.WhatIsThePassword2[Index] != 0) {\r | |
159 | OldPassword = TRUE;\r | |
160 | break;\r | |
161 | }\r | |
162 | }\r | |
163 | if (!OldPassword) {\r | |
164 | //\r | |
165 | // Old password not exist, return EFI_SUCCESS to prompt for new password\r | |
166 | //\r | |
167 | return EFI_SUCCESS;\r | |
168 | }\r | |
169 | \r | |
170 | //\r | |
171 | // Get user input password\r | |
172 | //\r | |
cb7d01c0 | 173 | Password = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL);\r |
174 | if (Password == NULL) {\r | |
175 | return EFI_NOT_READY;\r | |
176 | }\r | |
177 | if (StrLen (Password) > 20) {\r | |
53cf48e0 | 178 | FreePool (Password);\r |
cb7d01c0 | 179 | return EFI_NOT_READY;\r |
93e3992d | 180 | }\r |
181 | \r | |
182 | //\r | |
183 | // Validate old password\r | |
184 | //\r | |
cb7d01c0 | 185 | EncodedPassword = AllocateZeroPool (21 * sizeof (CHAR16));\r |
93e3992d | 186 | ASSERT (EncodedPassword != NULL);\r |
cb7d01c0 | 187 | StrnCpy (EncodedPassword, Password, 21);\r |
93e3992d | 188 | EncodePassword (EncodedPassword, 20 * sizeof (CHAR16));\r |
189 | if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, 20 * sizeof (CHAR16)) != 0) {\r | |
190 | //\r | |
191 | // Old password mismatch, return EFI_NOT_READY to prompt for error message\r | |
192 | //\r | |
193 | Status = EFI_NOT_READY;\r | |
194 | } else {\r | |
195 | Status = EFI_SUCCESS;\r | |
196 | }\r | |
197 | \r | |
53cf48e0 | 198 | FreePool (Password);\r |
199 | FreePool (EncodedPassword);\r | |
93e3992d | 200 | \r |
201 | return Status;\r | |
202 | }\r | |
203 | \r | |
7064c0a5 | 204 | /**\r |
205 | Encode the password using a simple algorithm.\r | |
206 | \r | |
207 | @param PrivateData This driver's private context data.\r | |
208 | @param StringId The password from User.\r | |
209 | \r | |
210 | @retval EFI_SUCESS The operation is successful.\r | |
211 | @return Other value if gRT->SetVariable () fails.\r | |
212 | \r | |
213 | **/\r | |
93e3992d | 214 | EFI_STATUS\r |
215 | SetPassword (\r | |
7064c0a5 | 216 | IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData,\r |
217 | IN EFI_STRING_ID StringId\r | |
93e3992d | 218 | )\r |
219 | {\r | |
220 | EFI_STATUS Status;\r | |
93e3992d | 221 | CHAR16 *Password;\r |
cb7d01c0 | 222 | CHAR16 *TempPassword;\r |
5a829f56 | 223 | UINTN PasswordSize;\r |
93e3992d | 224 | DRIVER_SAMPLE_CONFIGURATION *Configuration;\r |
7e3bcccb | 225 | UINTN BufferSize;\r |
93e3992d | 226 | \r |
227 | //\r | |
228 | // Get Buffer Storage data from EFI variable\r | |
229 | //\r | |
230 | BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r | |
231 | Status = gRT->GetVariable (\r | |
232 | VariableName,\r | |
233 | &mFormSetGuid,\r | |
234 | NULL,\r | |
235 | &BufferSize,\r | |
236 | &PrivateData->Configuration\r | |
237 | );\r | |
238 | if (EFI_ERROR (Status)) {\r | |
239 | return Status;\r | |
240 | }\r | |
241 | \r | |
242 | //\r | |
243 | // Get user input password\r | |
244 | //\r | |
245 | Password = &PrivateData->Configuration.WhatIsThePassword2[0];\r | |
cb7d01c0 | 246 | PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2); \r |
5a829f56 | 247 | ZeroMem (Password, PasswordSize);\r |
cb7d01c0 | 248 | \r |
249 | TempPassword = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL);\r | |
250 | if (TempPassword == NULL) {\r | |
251 | return EFI_NOT_READY;\r | |
252 | }\r | |
253 | if (StrLen (TempPassword) > PasswordSize / sizeof (CHAR16)) {\r | |
254 | FreePool (TempPassword);\r | |
255 | return EFI_NOT_READY;\r | |
93e3992d | 256 | }\r |
cb7d01c0 | 257 | StrnCpy (Password, TempPassword, PasswordSize / sizeof (CHAR16));\r |
258 | FreePool (TempPassword);\r | |
93e3992d | 259 | \r |
260 | //\r | |
261 | // Retrive uncommitted data from Browser\r | |
262 | //\r | |
1d451ff9 LG |
263 | Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_CONFIGURATION));\r |
264 | ASSERT (Configuration != NULL);\r | |
265 | if (HiiGetBrowserData (&mFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION), (UINT8 *) Configuration)) {\r | |
93e3992d | 266 | //\r |
267 | // Update password's clear text in the screen\r | |
268 | //\r | |
5a829f56 | 269 | CopyMem (Configuration->PasswordClearText, Password, PasswordSize);\r |
93e3992d | 270 | \r |
271 | //\r | |
272 | // Update uncommitted data of Browser\r | |
273 | //\r | |
7e3bcccb LG |
274 | HiiSetBrowserData (\r |
275 | &mFormSetGuid,\r | |
276 | VariableName,\r | |
277 | sizeof (DRIVER_SAMPLE_CONFIGURATION),\r | |
278 | (UINT8 *) Configuration,\r | |
279 | NULL\r | |
280 | );\r | |
93e3992d | 281 | }\r |
7e3bcccb | 282 | \r |
1d451ff9 LG |
283 | //\r |
284 | // Free Configuration Buffer\r | |
285 | //\r | |
286 | FreePool (Configuration);\r | |
287 | \r | |
93e3992d | 288 | \r |
289 | //\r | |
290 | // Set password\r | |
291 | //\r | |
5a829f56 | 292 | EncodePassword (Password, PasswordSize);\r |
93e3992d | 293 | Status = gRT->SetVariable(\r |
294 | VariableName,\r | |
295 | &mFormSetGuid,\r | |
296 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
297 | sizeof (DRIVER_SAMPLE_CONFIGURATION),\r | |
298 | &PrivateData->Configuration\r | |
299 | );\r | |
300 | return Status;\r | |
301 | }\r | |
302 | \r | |
303 | \r | |
304 | /**\r | |
305 | This function allows a caller to extract the current configuration for one\r | |
306 | or more named elements from the target driver.\r | |
307 | \r | |
308 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
309 | @param Request A null-terminated Unicode string in\r | |
310 | <ConfigRequest> format.\r | |
311 | @param Progress On return, points to a character in the Request\r | |
312 | string. Points to the string's null terminator if\r | |
313 | request was successful. Points to the most recent\r | |
314 | '&' before the first failing name/value pair (or\r | |
315 | the beginning of the string if the failure is in\r | |
316 | the first name/value pair) if the request was not\r | |
317 | successful.\r | |
318 | @param Results A null-terminated Unicode string in\r | |
319 | <ConfigAltResp> format which has all values filled\r | |
320 | in for the names in the Request string. String to\r | |
321 | be allocated by the called function.\r | |
322 | \r | |
323 | @retval EFI_SUCCESS The Results is filled with the requested values.\r | |
324 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r | |
325 | @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.\r | |
326 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
327 | driver.\r | |
328 | \r | |
329 | **/\r | |
330 | EFI_STATUS\r | |
331 | EFIAPI\r | |
332 | ExtractConfig (\r | |
333 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
334 | IN CONST EFI_STRING Request,\r | |
335 | OUT EFI_STRING *Progress,\r | |
336 | OUT EFI_STRING *Results\r | |
337 | )\r | |
338 | {\r | |
339 | EFI_STATUS Status;\r | |
340 | UINTN BufferSize;\r | |
341 | DRIVER_SAMPLE_PRIVATE_DATA *PrivateData;\r | |
342 | EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r | |
343 | \r | |
344 | PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);\r | |
345 | HiiConfigRouting = PrivateData->HiiConfigRouting;\r | |
346 | \r | |
8d00a0f1 | 347 | //\r |
93e3992d | 348 | //\r |
349 | // Get Buffer Storage data from EFI variable\r | |
350 | //\r | |
351 | BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r | |
352 | Status = gRT->GetVariable (\r | |
353 | VariableName,\r | |
354 | &mFormSetGuid,\r | |
355 | NULL,\r | |
356 | &BufferSize,\r | |
357 | &PrivateData->Configuration\r | |
358 | );\r | |
359 | if (EFI_ERROR (Status)) {\r | |
360 | return Status;\r | |
361 | }\r | |
362 | \r | |
8d00a0f1 | 363 | if (Request == NULL) {\r |
364 | //\r | |
365 | // Request is set to NULL, return all configurable elements together with ALTCFG\r | |
366 | //\r | |
7e3bcccb LG |
367 | *Results = HiiConstructConfigAltResp (\r |
368 | &mFormSetGuid,\r | |
369 | VariableName,\r | |
370 | PrivateData->DriverHandle[0],\r | |
371 | &PrivateData->Configuration,\r | |
372 | BufferSize,\r | |
373 | VfrMyIfrNVDataBlockName,\r | |
374 | STRING_TOKEN (STR_STANDARD_DEFAULT_PROMPT),\r | |
375 | VfrMyIfrNVDataDefault0000,\r | |
376 | STRING_TOKEN (STR_MANUFACTURE_DEFAULT_PROMPT),\r | |
377 | VfrMyIfrNVDataDefault0001,\r | |
378 | 0,\r | |
379 | NULL\r | |
8d00a0f1 | 380 | );\r |
7e3bcccb LG |
381 | \r |
382 | //\r | |
383 | // No matched storage is found.\r | |
384 | //\r | |
385 | if (*Results == NULL) {\r | |
386 | return EFI_NOT_FOUND;\r | |
387 | }\r | |
8d00a0f1 | 388 | \r |
7e3bcccb | 389 | return EFI_SUCCESS;\r |
8d00a0f1 | 390 | }\r |
391 | \r | |
392 | //\r | |
393 | // Check routing data in <ConfigHdr>.\r | |
394 | // Note: if only one Storage is used, then this checking could be skipped.\r | |
395 | //\r | |
7e3bcccb | 396 | if (!HiiIsConfigHdrMatch (Request, &mFormSetGuid, VariableName)) {\r |
8d00a0f1 | 397 | *Progress = Request;\r |
398 | return EFI_NOT_FOUND;\r | |
399 | }\r | |
400 | \r | |
93e3992d | 401 | //\r |
402 | // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r | |
403 | //\r | |
404 | Status = HiiConfigRouting->BlockToConfig (\r | |
405 | HiiConfigRouting,\r | |
406 | Request,\r | |
407 | (UINT8 *) &PrivateData->Configuration,\r | |
408 | BufferSize,\r | |
409 | Results,\r | |
410 | Progress\r | |
411 | );\r | |
412 | return Status;\r | |
413 | }\r | |
414 | \r | |
415 | \r | |
416 | /**\r | |
417 | This function processes the results of changes in configuration.\r | |
418 | \r | |
419 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
420 | @param Configuration A null-terminated Unicode string in <ConfigResp>\r | |
421 | format.\r | |
422 | @param Progress A pointer to a string filled in with the offset of\r | |
423 | the most recent '&' before the first failing\r | |
424 | name/value pair (or the beginning of the string if\r | |
425 | the failure is in the first name/value pair) or\r | |
426 | the terminating NULL if all was successful.\r | |
427 | \r | |
428 | @retval EFI_SUCCESS The Results is processed successfully.\r | |
429 | @retval EFI_INVALID_PARAMETER Configuration is NULL.\r | |
430 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
431 | driver.\r | |
432 | \r | |
433 | **/\r | |
434 | EFI_STATUS\r | |
435 | EFIAPI\r | |
436 | RouteConfig (\r | |
437 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
438 | IN CONST EFI_STRING Configuration,\r | |
439 | OUT EFI_STRING *Progress\r | |
440 | )\r | |
441 | {\r | |
442 | EFI_STATUS Status;\r | |
443 | UINTN BufferSize;\r | |
444 | DRIVER_SAMPLE_PRIVATE_DATA *PrivateData;\r | |
445 | EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r | |
446 | \r | |
8d00a0f1 | 447 | if (Configuration == NULL) {\r |
448 | return EFI_INVALID_PARAMETER;\r | |
449 | }\r | |
450 | \r | |
93e3992d | 451 | PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);\r |
452 | HiiConfigRouting = PrivateData->HiiConfigRouting;\r | |
453 | \r | |
8d00a0f1 | 454 | // Check routing data in <ConfigHdr>.\r |
455 | // Note: if only one Storage is used, then this checking could be skipped.\r | |
456 | //\r | |
7e3bcccb | 457 | if (!HiiIsConfigHdrMatch (Configuration, &mFormSetGuid, VariableName)) {\r |
8d00a0f1 | 458 | *Progress = Configuration;\r |
459 | return EFI_NOT_FOUND;\r | |
460 | }\r | |
461 | \r | |
93e3992d | 462 | //\r |
463 | // Get Buffer Storage data from EFI variable\r | |
464 | //\r | |
465 | BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r | |
466 | Status = gRT->GetVariable (\r | |
467 | VariableName,\r | |
468 | &mFormSetGuid,\r | |
469 | NULL,\r | |
470 | &BufferSize,\r | |
471 | &PrivateData->Configuration\r | |
472 | );\r | |
473 | if (EFI_ERROR (Status)) {\r | |
474 | return Status;\r | |
475 | }\r | |
476 | \r | |
477 | //\r | |
478 | // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()\r | |
479 | //\r | |
480 | BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r | |
481 | Status = HiiConfigRouting->ConfigToBlock (\r | |
482 | HiiConfigRouting,\r | |
483 | Configuration,\r | |
484 | (UINT8 *) &PrivateData->Configuration,\r | |
485 | &BufferSize,\r | |
486 | Progress\r | |
487 | );\r | |
488 | if (EFI_ERROR (Status)) {\r | |
489 | return Status;\r | |
490 | }\r | |
491 | \r | |
492 | //\r | |
493 | // Store Buffer Storage back to EFI variable\r | |
494 | //\r | |
495 | Status = gRT->SetVariable(\r | |
496 | VariableName,\r | |
497 | &mFormSetGuid,\r | |
498 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
499 | sizeof (DRIVER_SAMPLE_CONFIGURATION),\r | |
500 | &PrivateData->Configuration\r | |
501 | );\r | |
502 | \r | |
503 | return Status;\r | |
504 | }\r | |
505 | \r | |
506 | \r | |
507 | /**\r | |
508 | This function processes the results of changes in configuration.\r | |
509 | \r | |
510 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
511 | @param Action Specifies the type of action taken by the browser.\r | |
512 | @param QuestionId A unique value which is sent to the original\r | |
513 | exporting driver so that it can identify the type\r | |
514 | of data to expect.\r | |
515 | @param Type The type of value for the question.\r | |
516 | @param Value A pointer to the data being sent to the original\r | |
517 | exporting driver.\r | |
518 | @param ActionRequest On return, points to the action requested by the\r | |
519 | callback function.\r | |
520 | \r | |
521 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
522 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r | |
523 | variable and its data.\r | |
524 | @retval EFI_DEVICE_ERROR The variable could not be saved.\r | |
525 | @retval EFI_UNSUPPORTED The specified Action is not supported by the\r | |
526 | callback.\r | |
527 | \r | |
528 | **/\r | |
529 | EFI_STATUS\r | |
530 | EFIAPI\r | |
531 | DriverCallback (\r | |
532 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
533 | IN EFI_BROWSER_ACTION Action,\r | |
534 | IN EFI_QUESTION_ID QuestionId,\r | |
535 | IN UINT8 Type,\r | |
536 | IN EFI_IFR_TYPE_VALUE *Value,\r | |
537 | OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r | |
538 | )\r | |
539 | {\r | |
540 | DRIVER_SAMPLE_PRIVATE_DATA *PrivateData;\r | |
541 | EFI_STATUS Status;\r | |
8d00a0f1 | 542 | UINT8 MyVar;\r |
7e3bcccb LG |
543 | VOID *StartOpCodeHandle;\r |
544 | VOID *OptionsOpCodeHandle;\r | |
545 | EFI_IFR_GUID_LABEL *StartLabel;\r | |
546 | VOID *EndOpCodeHandle;\r | |
547 | EFI_IFR_GUID_LABEL *EndLabel;\r | |
93e3992d | 548 | \r |
549 | if ((Value == NULL) || (ActionRequest == NULL)) {\r | |
550 | return EFI_INVALID_PARAMETER;\r | |
551 | }\r | |
552 | \r | |
553 | Status = EFI_SUCCESS;\r | |
554 | PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);\r | |
555 | \r | |
556 | switch (QuestionId) {\r | |
557 | case 0x1234:\r | |
558 | //\r | |
8d00a0f1 | 559 | // Initialize the container for dynamic opcodes\r |
93e3992d | 560 | //\r |
7e3bcccb LG |
561 | StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r |
562 | ASSERT (StartOpCodeHandle != NULL);\r | |
563 | \r | |
564 | EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r | |
565 | ASSERT (EndOpCodeHandle != NULL);\r | |
566 | \r | |
567 | //\r | |
568 | // Create Hii Extend Label OpCode as the start opcode\r | |
569 | //\r | |
570 | StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r | |
571 | StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r | |
572 | StartLabel->Number = LABEL_UPDATE1;\r | |
573 | \r | |
574 | //\r | |
575 | // Create Hii Extend Label OpCode as the end opcode\r | |
576 | //\r | |
577 | EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r | |
578 | EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r | |
579 | EndLabel->Number = LABEL_END;\r | |
580 | \r | |
581 | HiiCreateActionOpCode (\r | |
582 | StartOpCodeHandle, // Container for dynamic created opcodes\r | |
583 | 0x1237, // Question ID\r | |
584 | STRING_TOKEN(STR_EXIT_TEXT), // Prompt text\r | |
585 | STRING_TOKEN(STR_EXIT_TEXT), // Help text\r | |
586 | EFI_IFR_FLAG_CALLBACK, // Question flag\r | |
587 | 0 // Action String ID\r | |
588 | );\r | |
589 | \r | |
590 | //\r | |
591 | // Create Option OpCode\r | |
592 | //\r | |
593 | OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r | |
594 | ASSERT (OptionsOpCodeHandle != NULL);\r | |
595 | \r | |
596 | HiiCreateOneOfOptionOpCode (\r | |
597 | OptionsOpCodeHandle,\r | |
598 | STRING_TOKEN (STR_BOOT_OPTION1),\r | |
599 | 0,\r | |
600 | EFI_IFR_NUMERIC_SIZE_1,\r | |
601 | 1\r | |
602 | );\r | |
603 | \r | |
604 | HiiCreateOneOfOptionOpCode (\r | |
605 | OptionsOpCodeHandle,\r | |
606 | STRING_TOKEN (STR_BOOT_OPTION2),\r | |
607 | 0,\r | |
608 | EFI_IFR_NUMERIC_SIZE_1,\r | |
609 | 2\r | |
610 | );\r | |
611 | \r | |
612 | //\r | |
613 | // Prepare initial value for the dynamic created oneof Question\r | |
614 | //\r | |
615 | PrivateData->Configuration.DynamicOneof = 2;\r | |
616 | Status = gRT->SetVariable(\r | |
617 | VariableName,\r | |
618 | &mFormSetGuid,\r | |
619 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
620 | sizeof (DRIVER_SAMPLE_CONFIGURATION),\r | |
621 | &PrivateData->Configuration\r | |
622 | );\r | |
623 | \r | |
624 | HiiCreateOneOfOpCode (\r | |
625 | StartOpCodeHandle, // Container for dynamic created opcodes\r | |
626 | 0x8001, // Question ID (or call it "key")\r | |
627 | CONFIGURATION_VARSTORE_ID, // VarStore ID\r | |
628 | (UINT16) DYNAMIC_ONE_OF_VAR_OFFSET, // Offset in Buffer Storage\r | |
629 | STRING_TOKEN (STR_ONE_OF_PROMPT), // Question prompt text\r | |
630 | STRING_TOKEN (STR_ONE_OF_HELP), // Question help text\r | |
631 | EFI_IFR_FLAG_CALLBACK, // Question flag\r | |
632 | EFI_IFR_NUMERIC_SIZE_1, // Data type of Question Value\r | |
633 | OptionsOpCodeHandle, // Option Opcode list\r | |
634 | NULL // Default Opcode is NULl\r | |
635 | );\r | |
636 | \r | |
637 | HiiCreateOrderedListOpCode (\r | |
638 | StartOpCodeHandle, // Container for dynamic created opcodes\r | |
639 | 0x8002, // Question ID\r | |
640 | CONFIGURATION_VARSTORE_ID, // VarStore ID\r | |
641 | (UINT16) DYNAMIC_ORDERED_LIST_VAR_OFFSET, // Offset in Buffer Storage\r | |
642 | STRING_TOKEN (STR_BOOT_OPTIONS), // Question prompt text\r | |
643 | STRING_TOKEN (STR_BOOT_OPTIONS), // Question help text\r | |
644 | EFI_IFR_FLAG_RESET_REQUIRED, // Question flag\r | |
645 | 0, // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET\r | |
646 | EFI_IFR_NUMERIC_SIZE_1, // Data type of Question value\r | |
647 | 5, // Maximum container\r | |
648 | OptionsOpCodeHandle, // Option Opcode list\r | |
649 | NULL // Default Opcode is NULl\r | |
650 | );\r | |
651 | \r | |
652 | HiiCreateGotoOpCode (\r | |
653 | StartOpCodeHandle, // Container for dynamic created opcodes\r | |
654 | 1, // Target Form ID\r | |
655 | STRING_TOKEN (STR_GOTO_FORM1), // Prompt text\r | |
656 | STRING_TOKEN (STR_GOTO_HELP), // Help text\r | |
657 | 0, // Question flag\r | |
658 | 0x8003 // Question ID\r | |
659 | );\r | |
660 | \r | |
661 | HiiUpdateForm (\r | |
662 | PrivateData->HiiHandle[0], // HII handle\r | |
663 | &mFormSetGuid, // Formset GUID\r | |
664 | 0x1234, // Form ID\r | |
665 | StartOpCodeHandle, // Label for where to insert opcodes\r | |
666 | EndOpCodeHandle // Replace data\r | |
667 | );\r | |
668 | \r | |
669 | HiiFreeOpCodeHandle (StartOpCodeHandle);\r | |
670 | HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r | |
671 | break;\r | |
8d00a0f1 | 672 | \r |
7e3bcccb LG |
673 | case 0x5678:\r |
674 | //\r | |
675 | // We will reach here once the Question is refreshed\r | |
676 | //\r | |
677 | \r | |
678 | //\r | |
679 | // Initialize the container for dynamic opcodes\r | |
680 | //\r | |
681 | StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r | |
682 | ASSERT (StartOpCodeHandle != NULL);\r | |
683 | \r | |
684 | //\r | |
685 | // Create Hii Extend Label OpCode as the start opcode\r | |
686 | //\r | |
687 | StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r | |
688 | StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r | |
689 | StartLabel->Number = LABEL_UPDATE2;\r | |
690 | \r | |
691 | HiiCreateActionOpCode (\r | |
692 | StartOpCodeHandle, // Container for dynamic created opcodes\r | |
693 | 0x1237, // Question ID\r | |
694 | STRING_TOKEN(STR_EXIT_TEXT), // Prompt text\r | |
695 | STRING_TOKEN(STR_EXIT_TEXT), // Help text\r | |
696 | EFI_IFR_FLAG_CALLBACK, // Question flag\r | |
697 | 0 // Action String ID\r | |
698 | );\r | |
8d00a0f1 | 699 | \r |
7e3bcccb LG |
700 | HiiUpdateForm (\r |
701 | PrivateData->HiiHandle[0], // HII handle\r | |
702 | &mFormSetGuid, // Formset GUID\r | |
703 | 0x3, // Form ID\r | |
704 | StartOpCodeHandle, // Label for where to insert opcodes\r | |
705 | NULL // Insert data\r | |
706 | );\r | |
707 | \r | |
708 | HiiFreeOpCodeHandle (StartOpCodeHandle); \r | |
709 | \r | |
710 | //\r | |
711 | // Refresh the Question value\r | |
712 | //\r | |
713 | PrivateData->Configuration.DynamicRefresh++;\r | |
714 | Status = gRT->SetVariable(\r | |
715 | VariableName,\r | |
716 | &mFormSetGuid,\r | |
717 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
718 | sizeof (DRIVER_SAMPLE_CONFIGURATION),\r | |
719 | &PrivateData->Configuration\r | |
720 | );\r | |
721 | \r | |
722 | //\r | |
723 | // Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause\r | |
724 | // the first statement in Form 3 be suppressed\r | |
725 | //\r | |
726 | MyVar = 111;\r | |
727 | Status = gRT->SetVariable(\r | |
728 | L"MyVar",\r | |
729 | &mFormSetGuid,\r | |
730 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
731 | 1,\r | |
732 | &MyVar\r | |
733 | );\r | |
93e3992d | 734 | break;\r |
735 | \r | |
736 | case 0x1237:\r | |
737 | //\r | |
738 | // User press "Exit now", request Browser to exit\r | |
739 | //\r | |
740 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r | |
741 | break;\r | |
742 | \r | |
743 | case 0x1238:\r | |
744 | //\r | |
745 | // User press "Save now", request Browser to save the uncommitted data.\r | |
746 | //\r | |
747 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r | |
748 | break;\r | |
749 | \r | |
750 | case 0x2000:\r | |
751 | //\r | |
752 | // When try to set a new password, user will be chanlleged with old password.\r | |
753 | // The Callback is responsible for validating old password input by user,\r | |
754 | // If Callback return EFI_SUCCESS, it indicates validation pass.\r | |
755 | //\r | |
756 | switch (PrivateData->PasswordState) {\r | |
757 | case BROWSER_STATE_VALIDATE_PASSWORD:\r | |
758 | Status = ValidatePassword (PrivateData, Value->string);\r | |
759 | if (Status == EFI_SUCCESS) {\r | |
760 | PrivateData->PasswordState = BROWSER_STATE_SET_PASSWORD;\r | |
761 | }\r | |
762 | break;\r | |
763 | \r | |
764 | case BROWSER_STATE_SET_PASSWORD:\r | |
765 | Status = SetPassword (PrivateData, Value->string);\r | |
766 | PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD;\r | |
767 | break;\r | |
768 | \r | |
769 | default:\r | |
770 | break;\r | |
771 | }\r | |
772 | \r | |
773 | break;\r | |
774 | \r | |
775 | default:\r | |
776 | break;\r | |
777 | }\r | |
778 | \r | |
779 | return Status;\r | |
780 | }\r | |
781 | \r | |
7064c0a5 | 782 | /**\r |
783 | Main entry for this driver.\r | |
784 | \r | |
785 | @param ImageHandle Image handle this driver.\r | |
786 | @param SystemTable Pointer to SystemTable.\r | |
787 | \r | |
788 | @retval EFI_SUCESS This function always complete successfully.\r | |
789 | \r | |
790 | **/\r | |
93e3992d | 791 | EFI_STATUS\r |
792 | EFIAPI\r | |
793 | DriverSampleInit (\r | |
794 | IN EFI_HANDLE ImageHandle,\r | |
795 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
796 | )\r | |
797 | {\r | |
798 | EFI_STATUS Status;\r | |
93e3992d | 799 | EFI_HII_HANDLE HiiHandle[2];\r |
93e3992d | 800 | EFI_SCREEN_DESCRIPTOR Screen;\r |
801 | EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r | |
802 | EFI_HII_STRING_PROTOCOL *HiiString;\r | |
803 | EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;\r | |
804 | EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r | |
805 | CHAR16 *NewString;\r | |
806 | UINTN BufferSize;\r | |
807 | DRIVER_SAMPLE_CONFIGURATION *Configuration;\r | |
808 | BOOLEAN ExtractIfrDefault;\r | |
809 | \r | |
810 | //\r | |
811 | // Initialize the library and our protocol.\r | |
812 | //\r | |
93e3992d | 813 | \r |
814 | //\r | |
815 | // Initialize screen dimensions for SendForm().\r | |
816 | // Remove 3 characters from top and bottom\r | |
817 | //\r | |
818 | ZeroMem (&Screen, sizeof (EFI_SCREEN_DESCRIPTOR));\r | |
819 | gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &Screen.RightColumn, &Screen.BottomRow);\r | |
820 | \r | |
821 | Screen.TopRow = 3;\r | |
822 | Screen.BottomRow = Screen.BottomRow - 3;\r | |
823 | \r | |
824 | //\r | |
825 | // Initialize driver private data\r | |
826 | //\r | |
827 | PrivateData = AllocatePool (sizeof (DRIVER_SAMPLE_PRIVATE_DATA));\r | |
828 | if (PrivateData == NULL) {\r | |
829 | return EFI_OUT_OF_RESOURCES;\r | |
830 | }\r | |
831 | \r | |
832 | PrivateData->Signature = DRIVER_SAMPLE_PRIVATE_SIGNATURE;\r | |
833 | \r | |
834 | PrivateData->ConfigAccess.ExtractConfig = ExtractConfig;\r | |
835 | PrivateData->ConfigAccess.RouteConfig = RouteConfig;\r | |
836 | PrivateData->ConfigAccess.Callback = DriverCallback;\r | |
837 | PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD;\r | |
838 | \r | |
839 | //\r | |
840 | // Locate Hii Database protocol\r | |
841 | //\r | |
842 | Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &HiiDatabase);\r | |
843 | if (EFI_ERROR (Status)) {\r | |
844 | return Status;\r | |
845 | }\r | |
846 | PrivateData->HiiDatabase = HiiDatabase;\r | |
847 | \r | |
848 | //\r | |
849 | // Locate HiiString protocol\r | |
850 | //\r | |
851 | Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString);\r | |
852 | if (EFI_ERROR (Status)) {\r | |
853 | return Status;\r | |
854 | }\r | |
855 | PrivateData->HiiString = HiiString;\r | |
856 | \r | |
857 | //\r | |
858 | // Locate Formbrowser2 protocol\r | |
859 | //\r | |
860 | Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);\r | |
861 | if (EFI_ERROR (Status)) {\r | |
862 | return Status;\r | |
863 | }\r | |
864 | PrivateData->FormBrowser2 = FormBrowser2;\r | |
865 | \r | |
866 | //\r | |
867 | // Locate ConfigRouting protocol\r | |
868 | //\r | |
869 | Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting);\r | |
870 | if (EFI_ERROR (Status)) {\r | |
871 | return Status;\r | |
872 | }\r | |
873 | PrivateData->HiiConfigRouting = HiiConfigRouting;\r | |
874 | \r | |
f6f910dd | 875 | Status = gBS->InstallMultipleProtocolInterfaces (\r |
93e3992d | 876 | &DriverHandle[0],\r |
f6f910dd | 877 | &gEfiDevicePathProtocolGuid,\r |
2f3065c0 | 878 | &mHiiVendorDevicePath0,\r |
93e3992d | 879 | &gEfiHiiConfigAccessProtocolGuid,\r |
f6f910dd | 880 | &PrivateData->ConfigAccess,\r |
881 | NULL\r | |
93e3992d | 882 | );\r |
883 | ASSERT_EFI_ERROR (Status);\r | |
884 | \r | |
f6f910dd | 885 | PrivateData->DriverHandle[0] = DriverHandle[0];\r |
886 | \r | |
93e3992d | 887 | //\r |
888 | // Publish our HII data\r | |
889 | //\r | |
cb7d01c0 | 890 | HiiHandle[0] = HiiAddPackages (\r |
891 | &mFormSetGuid,\r | |
892 | DriverHandle[0],\r | |
893 | DriverSampleStrings,\r | |
894 | VfrBin,\r | |
895 | NULL\r | |
896 | );\r | |
897 | if (HiiHandle[0] == NULL) {\r | |
93e3992d | 898 | return EFI_OUT_OF_RESOURCES;\r |
899 | }\r | |
900 | \r | |
93e3992d | 901 | PrivateData->HiiHandle[0] = HiiHandle[0];\r |
902 | \r | |
903 | //\r | |
904 | // Publish another Fromset\r | |
905 | //\r | |
f6f910dd | 906 | Status = gBS->InstallMultipleProtocolInterfaces (\r |
907 | &DriverHandle[1],\r | |
908 | &gEfiDevicePathProtocolGuid,\r | |
2f3065c0 | 909 | &mHiiVendorDevicePath1,\r |
f6f910dd | 910 | NULL\r |
911 | );\r | |
912 | ASSERT_EFI_ERROR (Status);\r | |
913 | \r | |
93e3992d | 914 | PrivateData->DriverHandle[1] = DriverHandle[1];\r |
915 | \r | |
cb7d01c0 | 916 | HiiHandle[1] = HiiAddPackages (\r |
917 | &mInventoryGuid,\r | |
918 | DriverHandle[1],\r | |
919 | DriverSampleStrings,\r | |
920 | InventoryBin,\r | |
921 | NULL\r | |
922 | );\r | |
923 | if (HiiHandle[1] == NULL) {\r | |
93e3992d | 924 | return EFI_OUT_OF_RESOURCES;\r |
925 | }\r | |
926 | \r | |
93e3992d | 927 | PrivateData->HiiHandle[1] = HiiHandle[1];\r |
928 | \r | |
929 | //\r | |
930 | // Very simple example of how one would update a string that is already\r | |
931 | // in the HII database\r | |
932 | //\r | |
933 | NewString = L"700 Mhz";\r | |
934 | \r | |
cb7d01c0 | 935 | if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_CPU_STRING2), NewString, NULL) == 0) {\r |
936 | return EFI_OUT_OF_RESOURCES;\r | |
93e3992d | 937 | }\r |
938 | \r | |
939 | //\r | |
940 | // Initialize configuration data\r | |
941 | //\r | |
942 | Configuration = &PrivateData->Configuration;\r | |
943 | ZeroMem (Configuration, sizeof (DRIVER_SAMPLE_CONFIGURATION));\r | |
944 | \r | |
945 | //\r | |
946 | // Try to read NV config EFI variable first\r | |
947 | //\r | |
948 | ExtractIfrDefault = TRUE;\r | |
949 | BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r | |
950 | Status = gRT->GetVariable (VariableName, &mFormSetGuid, NULL, &BufferSize, Configuration);\r | |
951 | if (!EFI_ERROR (Status) && (BufferSize == sizeof (DRIVER_SAMPLE_CONFIGURATION))) {\r | |
952 | ExtractIfrDefault = FALSE;\r | |
953 | }\r | |
954 | \r | |
955 | if (ExtractIfrDefault) {\r | |
956 | //\r | |
957 | // EFI variable for NV config doesn't exit, we should build this variable\r | |
958 | // based on default values stored in IFR\r | |
959 | //\r | |
960 | BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r | |
3c7449e4 | 961 | Status = HiiIfrLibExtractDefault (Configuration, &BufferSize, 1, VfrMyIfrNVDataDefault0000);\r |
93e3992d | 962 | \r |
963 | if (!EFI_ERROR (Status)) {\r | |
964 | gRT->SetVariable(\r | |
965 | VariableName,\r | |
966 | &mFormSetGuid,\r | |
967 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
968 | sizeof (DRIVER_SAMPLE_CONFIGURATION),\r | |
969 | Configuration\r | |
970 | );\r | |
971 | }\r | |
972 | }\r | |
973 | \r | |
974 | //\r | |
7e3bcccb LG |
975 | // Default this driver is built into Flash device image, \r |
976 | // the following code doesn't run.\r | |
93e3992d | 977 | //\r |
7e3bcccb | 978 | \r |
2f3065c0 | 979 | //\r |
7e3bcccb LG |
980 | // Example of how to display only the item we sent to HII\r |
981 | // When this driver is not built into Flash device image, \r | |
982 | // it need to call SendForm to show front page by itself.\r | |
2f3065c0 | 983 | //\r |
7e3bcccb LG |
984 | if (DISPLAY_ONLY_MY_ITEM <= 1) {\r |
985 | //\r | |
986 | // Have the browser pull out our copy of the data, and only display our data\r | |
987 | //\r | |
988 | Status = FormBrowser2->SendForm (\r | |
989 | FormBrowser2,\r | |
990 | &(HiiHandle[DISPLAY_ONLY_MY_ITEM]),\r | |
991 | 1,\r | |
992 | NULL,\r | |
993 | 0,\r | |
994 | NULL,\r | |
995 | NULL\r | |
996 | );\r | |
7e3bcccb | 997 | \r |
14d59fa1 | 998 | HiiRemovePackages (HiiHandle[0]);\r |
7e3bcccb | 999 | \r |
14d59fa1 | 1000 | HiiRemovePackages (HiiHandle[1]);\r |
2f3065c0 LG |
1001 | }\r |
1002 | \r | |
14d59fa1 | 1003 | return Status;\r |
2f3065c0 LG |
1004 | }\r |
1005 | \r | |
1006 | /**\r | |
1007 | Unloads the application and its installed protocol.\r | |
1008 | \r | |
1009 | @param[in] ImageHandle Handle that identifies the image to be unloaded.\r | |
1010 | \r | |
1011 | @retval EFI_SUCCESS The image has been unloaded.\r | |
1012 | **/\r | |
1013 | EFI_STATUS\r | |
1014 | EFIAPI\r | |
1015 | DriverSampleUnload (\r | |
1016 | IN EFI_HANDLE ImageHandle\r | |
1017 | )\r | |
1018 | {\r | |
1019 | if (DriverHandle[0] != NULL) {\r | |
1020 | gBS->UninstallMultipleProtocolInterfaces (\r | |
1021 | DriverHandle[0],\r | |
1022 | &gEfiDevicePathProtocolGuid,\r | |
1023 | &mHiiVendorDevicePath0,\r | |
1024 | &gEfiHiiConfigAccessProtocolGuid,\r | |
1025 | &PrivateData->ConfigAccess,\r | |
1026 | NULL\r | |
1027 | );\r | |
1028 | }\r | |
1029 | \r | |
1030 | if (DriverHandle[1] != NULL) {\r | |
1031 | gBS->UninstallMultipleProtocolInterfaces (\r | |
1032 | DriverHandle[1],\r | |
1033 | &gEfiDevicePathProtocolGuid,\r | |
1034 | &mHiiVendorDevicePath1,\r | |
1035 | NULL\r | |
1036 | );\r | |
1037 | }\r | |
1038 | \r | |
14d59fa1 LG |
1039 | if (PrivateData->HiiHandle[0] != NULL) {\r |
1040 | HiiRemovePackages (PrivateData->HiiHandle[0]);\r | |
1041 | }\r | |
1042 | \r | |
1043 | if (PrivateData->HiiHandle[1] != NULL) {\r | |
1044 | HiiRemovePackages (PrivateData->HiiHandle[1]);\r | |
1045 | }\r | |
1046 | \r | |
2f3065c0 LG |
1047 | if (PrivateData != NULL) {\r |
1048 | FreePool (PrivateData);\r | |
93e3992d | 1049 | }\r |
1050 | \r | |
1051 | return EFI_SUCCESS;\r | |
1052 | }\r |