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