]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileManager.c
SecurityPkg/UserProfileManagerDxe: Update RouteConfig function
[mirror_edk2.git] / SecurityPkg / UserIdentification / UserProfileManagerDxe / UserProfileManager.c
1 /** @file
2 This driver is a configuration tool for adding, deleting or modifying user
3 profiles, including gathering the necessary information to ascertain their
4 identity in the future, updating user access policy and identification
5 policy, etc.
6
7 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
8 (C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>
9 This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18
19 #include "UserProfileManager.h"
20
21 EFI_USER_MANAGER_PROTOCOL *mUserManager = NULL;
22 CREDENTIAL_PROVIDER_INFO *mProviderInfo = NULL;
23 UINT8 mProviderChoice;
24 UINT8 mConncetLogical;
25 USER_INFO_ACCESS mAccessInfo;
26 USER_INFO mUserInfo;
27 USER_PROFILE_MANAGER_CALLBACK_INFO *mCallbackInfo;
28 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = {
29 {
30 {
31 HARDWARE_DEVICE_PATH,
32 HW_VENDOR_DP,
33 {
34 (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
35 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
36 }
37 },
38 USER_PROFILE_MANAGER_GUID
39 },
40 {
41 END_DEVICE_PATH_TYPE,
42 END_ENTIRE_DEVICE_PATH_SUBTYPE,
43 {
44 (UINT8) (END_DEVICE_PATH_LENGTH),
45 (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
46 }
47 }
48 };
49
50
51 /**
52 Get string by string id from HII Interface.
53
54
55 @param[in] Id String ID to get the string from.
56
57 @retval CHAR16 * String from ID.
58 @retval NULL If error occurs.
59
60 **/
61 CHAR16 *
62 GetStringById (
63 IN EFI_STRING_ID Id
64 )
65 {
66 //
67 // Get the current string for the current Language.
68 //
69 return HiiGetString (mCallbackInfo->HiiHandle, Id, NULL);
70 }
71
72
73 /**
74 This function gets all the credential providers in the system and saved them
75 to mProviderInfo.
76
77 @retval EFI_SUCESS Init credential provider database successfully.
78 @retval Others Fail to init credential provider database.
79
80 **/
81 EFI_STATUS
82 InitProviderInfo (
83 VOID
84 )
85 {
86 EFI_STATUS Status;
87 UINTN HandleCount;
88 EFI_HANDLE *HandleBuf;
89 UINTN Index;
90
91 //
92 // Try to find all the user credential provider driver.
93 //
94 HandleCount = 0;
95 HandleBuf = NULL;
96 Status = gBS->LocateHandleBuffer (
97 ByProtocol,
98 &gEfiUserCredential2ProtocolGuid,
99 NULL,
100 &HandleCount,
101 &HandleBuf
102 );
103 if (EFI_ERROR (Status)) {
104 return Status;
105 }
106
107 //
108 // Get provider infomation.
109 //
110 if (mProviderInfo != NULL) {
111 FreePool (mProviderInfo);
112 }
113 mProviderInfo = AllocateZeroPool (
114 sizeof (CREDENTIAL_PROVIDER_INFO) -
115 sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *) +
116 HandleCount * sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *)
117 );
118 if (mProviderInfo == NULL) {
119 FreePool (HandleBuf);
120 return EFI_OUT_OF_RESOURCES;
121 }
122
123 mProviderInfo->Count = HandleCount;
124 for (Index = 0; Index < HandleCount; Index++) {
125 Status = gBS->HandleProtocol (
126 HandleBuf[Index],
127 &gEfiUserCredential2ProtocolGuid,
128 (VOID **) &mProviderInfo->Provider[Index]
129 );
130 if (EFI_ERROR (Status)) {
131 FreePool (HandleBuf);
132 FreePool (mProviderInfo);
133 mProviderInfo = NULL;
134 return Status;
135 }
136 }
137
138 FreePool (HandleBuf);
139 return EFI_SUCCESS;
140 }
141
142
143 /**
144 This function processes changes in user profile configuration.
145
146 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
147 @param Action Specifies the type of action taken by the browser.
148 @param QuestionId A unique value which is sent to the original
149 exporting driver so that it can identify the type
150 of data to expect.
151 @param Type The type of value for the question.
152 @param Value A pointer to the data being sent to the original
153 exporting driver.
154 @param ActionRequest On return, points to the action requested by the
155 callback function.
156
157 @retval EFI_SUCCESS The callback successfully handled the action.
158 @retval Others Fail to handle the action.
159
160 **/
161 EFI_STATUS
162 EFIAPI
163 UserProfileManagerCallback (
164 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
165 IN EFI_BROWSER_ACTION Action,
166 IN EFI_QUESTION_ID QuestionId,
167 IN UINT8 Type,
168 IN EFI_IFR_TYPE_VALUE *Value,
169 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
170 )
171 {
172 EFI_STATUS Status;
173 EFI_INPUT_KEY Key;
174 UINT32 CurrentAccessRight;
175 CHAR16 *QuestionStr;
176 CHAR16 *PromptStr;
177 VOID *StartOpCodeHandle;
178 VOID *EndOpCodeHandle;
179 EFI_IFR_GUID_LABEL *StartLabel;
180 EFI_IFR_GUID_LABEL *EndLabel;
181 EFI_USER_PROFILE_HANDLE CurrentUser;
182
183 Status = EFI_SUCCESS;
184
185 switch (Action) {
186 case EFI_BROWSER_ACTION_FORM_OPEN:
187 {
188 //
189 // Update user manage Form when user manage Form is opened.
190 // This will be done only in FORM_OPEN CallBack of question with QUESTIONID_USER_MANAGE from user manage Form.
191 //
192 if (QuestionId != QUESTIONID_USER_MANAGE) {
193 return EFI_SUCCESS;
194 }
195
196 //
197 // Get current user
198 //
199 CurrentUser = NULL;
200 mUserManager->Current (mUserManager, &CurrentUser);
201 if (CurrentUser == NULL) {
202 DEBUG ((DEBUG_ERROR, "Error: current user does not exist!\n"));
203 return EFI_NOT_READY;
204 }
205
206 //
207 // Get current user's right information.
208 //
209 Status = GetAccessRight (&CurrentAccessRight);
210 if (EFI_ERROR (Status)) {
211 CurrentAccessRight = EFI_USER_INFO_ACCESS_ENROLL_SELF;
212 }
213
214 //
215 // Init credential provider information.
216 //
217 Status = InitProviderInfo ();
218 if (EFI_ERROR (Status)) {
219 return Status;
220 }
221
222 //
223 // Initialize the container for dynamic opcodes.
224 //
225 StartOpCodeHandle = HiiAllocateOpCodeHandle ();
226 ASSERT (StartOpCodeHandle != NULL);
227
228 EndOpCodeHandle = HiiAllocateOpCodeHandle ();
229 ASSERT (EndOpCodeHandle != NULL);
230
231 //
232 // Create Hii Extend Label OpCode.
233 //
234 StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
235 StartOpCodeHandle,
236 &gEfiIfrTianoGuid,
237 NULL,
238 sizeof (EFI_IFR_GUID_LABEL)
239 );
240 StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
241 StartLabel->Number = LABEL_USER_MANAGE_FUNC;
242
243 EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
244 EndOpCodeHandle,
245 &gEfiIfrTianoGuid,
246 NULL,
247 sizeof (EFI_IFR_GUID_LABEL)
248 );
249 EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
250 EndLabel->Number = LABEL_END;
251
252 //
253 // Add user profile option.
254 //
255 if ((CurrentAccessRight == EFI_USER_INFO_ACCESS_MANAGE) ||
256 (CurrentAccessRight == EFI_USER_INFO_ACCESS_ENROLL_OTHERS)
257 ) {
258 HiiCreateActionOpCode (
259 StartOpCodeHandle, // Container for dynamic created opcodes
260 KEY_ADD_USER, // Question ID
261 STRING_TOKEN (STR_ADD_USER_TITLE), // Prompt text
262 STRING_TOKEN (STR_ADD_USER_HELP), // Help text
263 EFI_IFR_FLAG_CALLBACK, // Question flag
264 0 // Action String ID
265 );
266 }
267
268 //
269 // Add modify user profile option.
270 //
271 HiiCreateGotoOpCode (
272 StartOpCodeHandle, // Container for dynamic created opcodes
273 FORMID_MODIFY_USER, // Target Form ID
274 STRING_TOKEN (STR_MODIFY_USER_TITLE), // Prompt text
275 STRING_TOKEN (STR_MODIFY_USER_HELP), // Help text
276 EFI_IFR_FLAG_CALLBACK, // Question flag
277 KEY_MODIFY_USER // Question ID
278 );
279
280 //
281 // Add delete user profile option
282 //
283 if (CurrentAccessRight == EFI_USER_INFO_ACCESS_MANAGE) {
284 HiiCreateGotoOpCode (
285 StartOpCodeHandle, // Container for dynamic created opcodes
286 FORMID_DEL_USER, // Target Form ID
287 STRING_TOKEN (STR_DELETE_USER_TITLE), // Prompt text
288 STRING_TOKEN (STR_DELETE_USER_HELP), // Help text
289 EFI_IFR_FLAG_CALLBACK, // Question flag
290 KEY_DEL_USER // Question ID
291 );
292 }
293
294 HiiUpdateForm (
295 mCallbackInfo->HiiHandle, // HII handle
296 &gUserProfileManagerGuid, // Formset GUID
297 FORMID_USER_MANAGE, // Form ID
298 StartOpCodeHandle, // Label for where to insert opcodes
299 EndOpCodeHandle // Replace data
300 );
301
302 HiiFreeOpCodeHandle (StartOpCodeHandle);
303 HiiFreeOpCodeHandle (EndOpCodeHandle);
304
305 return EFI_SUCCESS;
306 }
307 break;
308
309 case EFI_BROWSER_ACTION_FORM_CLOSE:
310 Status = EFI_SUCCESS;
311 break;
312
313 case EFI_BROWSER_ACTION_CHANGED:
314 {
315 //
316 // Handle the request from form.
317 //
318 if ((Value == NULL) || (ActionRequest == NULL)) {
319 return EFI_INVALID_PARAMETER;
320 }
321
322 //
323 // Judge first 2 bits.
324 //
325 switch (QuestionId & KEY_FIRST_FORM_MASK) {
326 //
327 // Add user profile operation.
328 //
329 case KEY_ADD_USER:
330 CallAddUser ();
331 break;
332
333 //
334 // Delete user profile operation.
335 //
336 case KEY_DEL_USER:
337 //
338 // Judge next 2 bits.
339 //
340 switch (QuestionId & KEY_SECOND_FORM_MASK) {
341 //
342 // Delete specified user profile.
343 //
344 case KEY_SELECT_USER:
345 DeleteUser ((UINT8) QuestionId);
346 //
347 // Update select user form after delete a user.
348 //
349 SelectUserToDelete ();
350 break;
351
352 default:
353 break;
354 }
355 break;
356
357 //
358 // Modify user profile operation.
359 //
360 case KEY_MODIFY_USER:
361 //
362 // Judge next 2 bits.
363 //
364 switch (QuestionId & KEY_SECOND_FORM_MASK) {
365 //
366 // Enter user profile information form.
367 //
368 case KEY_SELECT_USER:
369 //
370 // Judge next 3 bits.
371 //
372 switch (QuestionId & KEY_MODIFY_INFO_MASK) {
373 //
374 // Modify user name.
375 //
376 case KEY_MODIFY_NAME:
377 ModifyUserName ();
378 //
379 // Update username in parent form.
380 //
381 SelectUserToModify ();
382 break;
383
384 //
385 // Modify identity policy.
386 //
387 case KEY_MODIFY_IP:
388 //
389 // Judge next 3 bits
390 //
391 switch (QuestionId & KEY_MODIFY_IP_MASK) {
392 //
393 // Change credential provider option.
394 //
395 case KEY_MODIFY_PROV:
396 mProviderChoice = Value->u8;
397 break;
398
399 //
400 // Change logical connector.
401 //
402 case KEY_MODIFY_CONN:
403 mConncetLogical = Value->u8;
404 break;
405
406 //
407 // Save option.
408 //
409 case KEY_ADD_IP_OP:
410 AddIdentityPolicyItem ();
411 break;
412
413 //
414 // Return to user profile information form.
415 //
416 case KEY_IP_RETURN_UIF:
417 SaveIdentityPolicy ();
418 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
419 break;
420
421 default:
422 break;
423 }
424 break;
425
426 //
427 // Modify access policy.
428 //
429 case KEY_MODIFY_AP:
430 //
431 // Judge next 3 bits.
432 //
433 switch (QuestionId & KEY_MODIFY_AP_MASK) {
434 //
435 // Change access right choice.
436 //
437 case KEY_MODIFY_RIGHT:
438 mAccessInfo.AccessRight = Value->u8;
439 break;
440
441 //
442 // Change setup choice.
443 //
444 case KEY_MODIFY_SETUP:
445 mAccessInfo.AccessSetup= Value->u8;
446 break;
447
448 //
449 // Change boot order choice.
450 //
451 case KEY_MODIFY_BOOT:
452 mAccessInfo.AccessBootOrder = Value->u32;
453 break;
454
455 //
456 // Return to user profile information form.
457 //
458 case KEY_AP_RETURN_UIF:
459 SaveAccessPolicy ();
460 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
461 break;
462
463 default:
464 break;
465 }
466 break;
467
468 default:
469 break;
470 }
471 break;
472
473 //
474 // Access policy device path modified.
475 //
476 case KEY_MODIFY_AP_DP:
477 //
478 // Judge next 2 bits.
479 //
480 switch (QuestionId & KEY_MODIFY_DP_MASK) {
481 //
482 // Load permit device path modified.
483 //
484 case KEY_LOAD_PERMIT_MODIFY:
485 QuestionStr = GetStringById (STRING_TOKEN (STR_MOVE_TO_FORBID_LIST));
486 PromptStr = GetStringById (STRING_TOKEN (STR_PRESS_KEY_CONTINUE));
487 CreatePopUp (
488 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
489 &Key,
490 QuestionStr,
491 L"",
492 PromptStr,
493 NULL
494 );
495 FreePool (QuestionStr);
496 FreePool (PromptStr);
497 if (Key.UnicodeChar != CHAR_CARRIAGE_RETURN) {
498 break;
499 }
500
501 AddToForbidLoad ((UINT16)(QuestionId & (KEY_MODIFY_DP_MASK - 1)));
502 DisplayLoadPermit ();
503 break;
504
505 //
506 // Load forbid device path modified.
507 //
508 case KEY_LOAD_FORBID_MODIFY:
509 QuestionStr = GetStringById (STRING_TOKEN (STR_MOVE_TO_PERMIT_LIST));
510 PromptStr = GetStringById (STRING_TOKEN (STR_PRESS_KEY_CONTINUE));
511 CreatePopUp (
512 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
513 &Key,
514 QuestionStr,
515 L"",
516 PromptStr,
517 NULL
518 );
519 FreePool (QuestionStr);
520 FreePool (PromptStr);
521 if (Key.UnicodeChar != CHAR_CARRIAGE_RETURN) {
522 break;
523 }
524
525 DeleteFromForbidLoad ((UINT16)(QuestionId & (KEY_MODIFY_DP_MASK - 1)));
526 DisplayLoadForbid ();
527 break;
528
529 //
530 // Connect permit device path modified.
531 //
532 case KEY_CONNECT_PERMIT_MODIFY:
533 break;
534
535 //
536 // Connect forbid device path modified.
537 //
538 case KEY_CONNECT_FORBID_MODIFY:
539 break;
540
541 default:
542 break;
543 }
544 break;
545
546 default:
547 break;
548 }
549 break;
550
551 default:
552 break;
553 }
554 }
555 break;
556
557
558 case EFI_BROWSER_ACTION_CHANGING:
559 {
560 //
561 // Handle the request from form.
562 //
563 if (Value == NULL) {
564 return EFI_INVALID_PARAMETER;
565 }
566
567 //
568 // Judge first 2 bits.
569 //
570 switch (QuestionId & KEY_FIRST_FORM_MASK) {
571 //
572 // Delete user profile operation.
573 //
574 case KEY_DEL_USER:
575 //
576 // Judge next 2 bits.
577 //
578 switch (QuestionId & KEY_SECOND_FORM_MASK) {
579 //
580 // Enter delete user profile form.
581 //
582 case KEY_ENTER_NEXT_FORM:
583 SelectUserToDelete ();
584 break;
585
586 default:
587 break;
588 }
589 break;
590
591 //
592 // Modify user profile operation.
593 //
594 case KEY_MODIFY_USER:
595 //
596 // Judge next 2 bits.
597 //
598 switch (QuestionId & KEY_SECOND_FORM_MASK) {
599 //
600 // Enter modify user profile form.
601 //
602 case KEY_ENTER_NEXT_FORM:
603 SelectUserToModify ();
604 break;
605
606 //
607 // Enter user profile information form.
608 //
609 case KEY_SELECT_USER:
610 //
611 // Judge next 3 bits.
612 //
613 switch (QuestionId & KEY_MODIFY_INFO_MASK) {
614 //
615 // Display user information form.
616 //
617 case KEY_ENTER_NEXT_FORM:
618 ModifyUserInfo ((UINT8) QuestionId);
619 break;
620
621 //
622 // Modify identity policy.
623 //
624 case KEY_MODIFY_IP:
625 //
626 // Judge next 3 bits
627 //
628 switch (QuestionId & KEY_MODIFY_IP_MASK) {
629 //
630 // Display identity policy modify form.
631 //
632 case KEY_ENTER_NEXT_FORM:
633 ModifyIdentityPolicy ();
634 break;
635
636 default:
637 break;
638 }
639 break;
640
641 //
642 // Modify access policy.
643 //
644 case KEY_MODIFY_AP:
645 //
646 // Judge next 3 bits.
647 //
648 switch (QuestionId & KEY_MODIFY_AP_MASK) {
649 //
650 // Display access policy modify form.
651 //
652 case KEY_ENTER_NEXT_FORM:
653 ModidyAccessPolicy ();
654 break;
655 //
656 // Load device path form.
657 //
658 case KEY_MODIFY_LOAD:
659 //
660 // Judge next 2 bits.
661 //
662 switch (QuestionId & KEY_DISPLAY_DP_MASK) {
663 //
664 // Permit load device path.
665 //
666 case KEY_PERMIT_MODIFY:
667 DisplayLoadPermit ();
668 break;
669
670 //
671 // Forbid load device path.
672 //
673 case KEY_FORBID_MODIFY:
674 DisplayLoadForbid ();
675 break;
676
677 default:
678 break;
679 }
680 break;
681
682 //
683 // Connect device path form.
684 //
685 case KEY_MODIFY_CONNECT:
686 //
687 // Judge next 2 bits.
688 //
689 switch (QuestionId & KEY_DISPLAY_DP_MASK) {
690 //
691 // Permit connect device path.
692 //
693 case KEY_PERMIT_MODIFY:
694 DisplayConnectPermit ();
695 break;
696
697 //
698 // Forbid connect device path.
699 //
700 case KEY_FORBID_MODIFY:
701 DisplayConnectForbid ();
702 break;
703
704 default:
705 break;
706 }
707 break;
708
709 default:
710 break;
711 }
712 break;
713
714 default:
715 break;
716 }
717 break;
718
719 default:
720 break;
721 }
722 break;
723
724 default:
725 break;
726 }
727 }
728 break;
729
730 default:
731 //
732 // All other action return unsupported.
733 //
734 Status = EFI_UNSUPPORTED;
735 break;
736 }
737
738
739 return Status;
740 }
741
742
743 /**
744 This function allows a caller to extract the current configuration for one
745 or more named elements from the target driver.
746
747
748 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
749 @param Request A null-terminated Unicode string in <ConfigRequest> format.
750 @param Progress On return, points to a character in the Request string.
751 Points to the string's null terminator if request was successful.
752 Points to the most recent '&' before the first failing name/value
753 pair (or the beginning of the string if the failure is in the
754 first name/value pair) if the request was not successful.
755 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
756 has all values filled in for the names in the Request string.
757 String to be allocated by the called function.
758
759 @retval EFI_SUCCESS The Results is filled with the requested values.
760 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
761 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
762 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
763
764 **/
765 EFI_STATUS
766 EFIAPI
767 FakeExtractConfig (
768 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
769 IN CONST EFI_STRING Request,
770 OUT EFI_STRING *Progress,
771 OUT EFI_STRING *Results
772 )
773 {
774 if (Progress == NULL || Results == NULL) {
775 return EFI_INVALID_PARAMETER;
776 }
777 *Progress = Request;
778 return EFI_NOT_FOUND;
779 }
780
781 /**
782 This function processes the results of changes in configuration.
783
784
785 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
786 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
787 @param Progress A pointer to a string filled in with the offset of the most
788 recent '&' before the first failing name/value pair (or the
789 beginning of the string if the failure is in the first
790 name/value pair) or the terminating NULL if all was successful.
791
792 @retval EFI_SUCCESS The Results is processed successfully.
793 @retval EFI_INVALID_PARAMETER Configuration is NULL.
794 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
795
796 **/
797 EFI_STATUS
798 EFIAPI
799 FakeRouteConfig (
800 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
801 IN CONST EFI_STRING Configuration,
802 OUT EFI_STRING *Progress
803 )
804 {
805 if (Configuration == NULL || Progress == NULL) {
806 return EFI_INVALID_PARAMETER;
807 }
808
809 *Progress = Configuration;
810
811 return EFI_NOT_FOUND;
812 }
813
814
815 /**
816 Main entry for this driver.
817
818 @param ImageHandle Image handle this driver.
819 @param SystemTable Pointer to SystemTable.
820
821 @retval EFI_SUCESS This function always complete successfully.
822
823 **/
824 EFI_STATUS
825 EFIAPI
826 UserProfileManagerInit (
827 IN EFI_HANDLE ImageHandle,
828 IN EFI_SYSTEM_TABLE *SystemTable
829 )
830 {
831 EFI_STATUS Status;
832 USER_PROFILE_MANAGER_CALLBACK_INFO *CallbackInfo;
833
834 Status = gBS->LocateProtocol (
835 &gEfiUserManagerProtocolGuid,
836 NULL,
837 (VOID **) &mUserManager
838 );
839 if (EFI_ERROR (Status)) {
840 return EFI_SUCCESS;
841 }
842
843 //
844 // Initialize driver private data.
845 //
846 ZeroMem (&mUserInfo, sizeof (mUserInfo));
847 ZeroMem (&mAccessInfo, sizeof (mAccessInfo));
848
849 CallbackInfo = AllocateZeroPool (sizeof (USER_PROFILE_MANAGER_CALLBACK_INFO));
850 ASSERT (CallbackInfo != NULL);
851
852 CallbackInfo->Signature = USER_PROFILE_MANAGER_SIGNATURE;
853 CallbackInfo->ConfigAccess.ExtractConfig = FakeExtractConfig;
854 CallbackInfo->ConfigAccess.RouteConfig = FakeRouteConfig;
855 CallbackInfo->ConfigAccess.Callback = UserProfileManagerCallback;
856 CallbackInfo->DriverHandle = NULL;
857
858 //
859 // Install Device Path Protocol and Config Access protocol to driver handle.
860 //
861 Status = gBS->InstallMultipleProtocolInterfaces (
862 &CallbackInfo->DriverHandle,
863 &gEfiDevicePathProtocolGuid,
864 &mHiiVendorDevicePath,
865 &gEfiHiiConfigAccessProtocolGuid,
866 &CallbackInfo->ConfigAccess,
867 NULL
868 );
869 ASSERT_EFI_ERROR (Status);
870
871 //
872 // Publish HII data.
873 //
874 CallbackInfo->HiiHandle = HiiAddPackages (
875 &gUserProfileManagerGuid,
876 CallbackInfo->DriverHandle,
877 UserProfileManagerStrings,
878 UserProfileManagerVfrBin,
879 NULL
880 );
881 ASSERT (CallbackInfo->HiiHandle != NULL);
882 mCallbackInfo = CallbackInfo;
883
884 return Status;
885 }
886
887