2 The device manager reference implementation
4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "DeviceManager.h"
17 DEVICE_MANAGER_CALLBACK_DATA gDeviceManagerPrivate
= {
18 DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE
,
22 DeviceManagerExtractConfig
,
23 DeviceManagerRouteConfig
,
28 #define MAX_MAC_ADDRESS_NODE_LIST_LEN 10
30 EFI_GUID mDeviceManagerGuid
= DEVICE_MANAGER_FORMSET_GUID
;
33 // Which Mac Address string is select
34 // it will decide what menu need to show in the NETWORK_DEVICE_FORM_ID form.
36 EFI_STRING mSelectedMacAddrString
;
39 // The Mac Address show in the NETWORK_DEVICE_LIST_FORM_ID
41 MAC_ADDRESS_NODE_LIST mMacDeviceList
;
43 HII_VENDOR_DEVICE_PATH mDeviceManagerHiiVendorDevicePath
= {
49 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
50 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
54 // {102579A0-3686-466e-ACD8-80C087044F4A}
56 { 0x102579a0, 0x3686, 0x466e, { 0xac, 0xd8, 0x80, 0xc0, 0x87, 0x4, 0x4f, 0x4a } }
60 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
62 (UINT8
) (END_DEVICE_PATH_LENGTH
),
63 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
69 Extract device path for given HII handle and class guid.
71 @param Handle The HII handle.
73 @retval NULL Fail to get the device path string.
74 @return PathString Get the device path string.
78 DmExtractDevicePathFromHiiHandle (
79 IN EFI_HII_HANDLE Handle
83 EFI_HANDLE DriverHandle
;
85 ASSERT (Handle
!= NULL
);
91 Status
= gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, Handle
, &DriverHandle
);
92 if (EFI_ERROR (Status
)) {
96 // Get device path string.
98 return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle
), FALSE
, FALSE
);
102 Get the mac address string from the device path.
103 if the device path has the vlan, get the vanid also.
105 @param MacAddressNode Device path begin with mac address
106 @param PBuffer Output string buffer contain mac address.
111 IN MAC_ADDR_DEVICE_PATH
*MacAddressNode
,
118 EFI_DEVICE_PATH_PROTOCOL
*Node
;
125 ASSERT(MacAddressNode
!= NULL
);
127 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
128 if (MacAddressNode
->IfType
== 0x01 || MacAddressNode
->IfType
== 0x00) {
133 // The output format is MAC:XX:XX:XX:...\XXXX
134 // The size is the Number size + ":" size + Vlan size(\XXXX) + End
136 BufferLen
= (4 + 2 * HwAddressSize
+ (HwAddressSize
- 1) + 5 + 1) * sizeof (CHAR16
);
137 String
= AllocateZeroPool (BufferLen
);
138 if (String
== NULL
) {
143 StrCpyS(String
, BufferLen
/ sizeof (CHAR16
), L
"MAC:");
147 // Convert the MAC address into a unicode string.
149 HwAddress
= &MacAddressNode
->MacAddress
.Addr
[0];
150 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
151 String
+= UnicodeValueToString (String
, PREFIX_ZERO
| RADIX_HEX
, *(HwAddress
++), 2);
152 if (Index
< HwAddressSize
- 1) {
158 // If VLAN is configured, it will need extra 5 characters like "\0005".
159 // Plus one unicode character for the null-terminator.
161 Node
= (EFI_DEVICE_PATH_PROTOCOL
*)MacAddressNode
;
162 while (!IsDevicePathEnd (Node
)) {
163 if (Node
->Type
== MESSAGING_DEVICE_PATH
&& Node
->SubType
== MSG_VLAN_DP
) {
164 VlanId
= ((VLAN_DEVICE_PATH
*) Node
)->VlanId
;
166 Node
= NextDevicePathNode (Node
);
171 String
+= UnicodeValueToString (String
, PREFIX_ZERO
| RADIX_HEX
, VlanId
, 4);
175 // Null terminate the Unicode string
183 Save question id and prompt id to the mac device list.
184 If the same mac address has saved yet, no need to add more.
186 @param MacAddrString Mac address string.
188 @retval EFI_SUCCESS Add the item is successful.
189 @return Other values if failed to Add the item.
192 AddIdToMacDeviceList (
193 IN EFI_STRING MacAddrString
196 MENU_INFO_ITEM
*TempDeviceList
;
198 EFI_STRING StoredString
;
199 EFI_STRING_ID PromptId
;
200 EFI_HII_HANDLE HiiHandle
;
202 HiiHandle
= gDeviceManagerPrivate
.HiiHandle
;
203 TempDeviceList
= NULL
;
205 for (Index
= 0; Index
< mMacDeviceList
.CurListLen
; Index
++) {
206 StoredString
= HiiGetString (HiiHandle
, mMacDeviceList
.NodeList
[Index
].PromptId
, NULL
);
207 if (StoredString
== NULL
) {
212 // Already has save the same mac address to the list.
214 if (StrCmp (MacAddrString
, StoredString
) == 0) {
219 PromptId
= HiiSetString(HiiHandle
, 0, MacAddrString
, NULL
);
221 // If not in the list, save it.
223 if (mMacDeviceList
.MaxListLen
> mMacDeviceList
.CurListLen
+ 1) {
224 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
].PromptId
= PromptId
;
225 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
].QuestionId
= (EFI_QUESTION_ID
) (mMacDeviceList
.CurListLen
+ NETWORK_DEVICE_LIST_KEY_OFFSET
);
227 mMacDeviceList
.MaxListLen
+= MAX_MAC_ADDRESS_NODE_LIST_LEN
;
228 if (mMacDeviceList
.CurListLen
!= 0) {
229 TempDeviceList
= (MENU_INFO_ITEM
*)AllocateCopyPool (sizeof (MENU_INFO_ITEM
) * mMacDeviceList
.MaxListLen
, (VOID
*)mMacDeviceList
.NodeList
);
231 TempDeviceList
= (MENU_INFO_ITEM
*)AllocatePool (sizeof (MENU_INFO_ITEM
) * mMacDeviceList
.MaxListLen
);
234 if (TempDeviceList
== NULL
) {
237 TempDeviceList
[mMacDeviceList
.CurListLen
].PromptId
= PromptId
;
238 TempDeviceList
[mMacDeviceList
.CurListLen
].QuestionId
= (EFI_QUESTION_ID
) (mMacDeviceList
.CurListLen
+ NETWORK_DEVICE_LIST_KEY_OFFSET
);
240 if (mMacDeviceList
.CurListLen
> 0) {
241 FreePool(mMacDeviceList
.NodeList
);
244 mMacDeviceList
.NodeList
= TempDeviceList
;
246 mMacDeviceList
.CurListLen
++;
252 Check the devcie path, try to find whether it has mac address path.
254 In this function, first need to check whether this path has mac address path.
255 second, when the mac address device path has find, also need to deicide whether
256 need to add this mac address relate info to the menu.
258 @param *Node Input device which need to be check.
259 @param NextShowFormId FormId Which need to be show.
260 @param *NeedAddItem Whether need to add the menu in the network device list.
262 @retval TRUE Has mac address device path.
263 @retval FALSE NOT Has mac address device path.
267 IsMacAddressDevicePath (
269 IN EFI_FORM_ID NextShowFormId
,
270 OUT BOOLEAN
*NeedAddItem
273 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
277 ASSERT (Node
!= NULL
);
278 *NeedAddItem
= FALSE
;
282 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) Node
;
285 // find the partition device path node
287 while (!IsDevicePathEnd (DevicePath
)) {
288 if ((DevicePathType (DevicePath
) == MESSAGING_DEVICE_PATH
) &&
289 (DevicePathSubType (DevicePath
) == MSG_MAC_ADDR_DP
)) {
292 if (DEVICE_MANAGER_FORM_ID
== NextShowFormId
) {
297 if (!GetMacAddressString((MAC_ADDR_DEVICE_PATH
*)DevicePath
, &Buffer
)) {
301 if (NETWORK_DEVICE_FORM_ID
== NextShowFormId
) {
302 if (StrCmp (Buffer
, mSelectedMacAddrString
) == 0) {
308 if (NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
) {
310 // Same handle may has two network child handle, so the questionid
311 // has the offset of SAME_HANDLE_KEY_OFFSET.
313 if (AddIdToMacDeviceList (Buffer
)) {
319 DevicePath
= NextDevicePathNode (DevicePath
);
322 if (Buffer
!= NULL
) {
330 Check to see if the device path is for the network device.
332 @param Handle The HII handle which include the mac address device path.
333 @param NextShowFormId The FormId of the form which will be show next time.
334 @param ItemCount The new add Mac address item count.
336 @retval TRUE Need to add new item in the menu.
337 @return FALSE Do not need to add the menu about the network.
341 IsNeedAddNetworkMenu (
342 IN EFI_HII_HANDLE Handle
,
343 IN EFI_FORM_ID NextShowFormId
,
350 EFI_HANDLE DriverHandle
;
351 EFI_HANDLE ControllerHandle
;
352 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
353 EFI_DEVICE_PATH_PROTOCOL
*TmpDevicePath
;
354 EFI_DEVICE_PATH_PROTOCOL
*ChildDevicePath
;
355 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfoBuffer
;
359 OpenInfoBuffer
= NULL
;
360 if ((Handle
== NULL
) || (ItemCount
== NULL
)) {
365 Status
= gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, Handle
, &DriverHandle
);
366 if (EFI_ERROR (Status
)) {
370 // Get the device path by the got Driver handle .
372 Status
= gBS
->HandleProtocol (DriverHandle
, &gEfiDevicePathProtocolGuid
, (VOID
**) &DevicePath
);
373 if (EFI_ERROR (Status
)) {
376 TmpDevicePath
= DevicePath
;
379 // Check whether this device path include mac address device path.
380 // If this path has mac address path, get the value whether need
381 // add this info to the menu and return.
382 // Else check more about the child handle devcie path.
384 if (IsMacAddressDevicePath(TmpDevicePath
, NextShowFormId
,&IsNeedAdd
)) {
385 if ((NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
) && IsNeedAdd
) {
392 // Search whether this path is the controller path, not he child handle path.
393 // And the child handle has the network devcie connected.
395 TmpDevicePath
= DevicePath
;
396 Status
= gBS
->LocateDevicePath(&gEfiDevicePathProtocolGuid
, &TmpDevicePath
, &ControllerHandle
);
397 if (EFI_ERROR (Status
)) {
401 if (!IsDevicePathEnd (TmpDevicePath
)) {
406 // Retrieve the list of agents that are consuming the specific protocol
407 // on ControllerHandle.
408 // The buffer point by OpenInfoBuffer need be free at this function.
410 Status
= gBS
->OpenProtocolInformation (
412 &gEfiPciIoProtocolGuid
,
416 if (EFI_ERROR (Status
)) {
421 // Inspect if ChildHandle is one of the agents.
423 Status
= EFI_UNSUPPORTED
;
424 for (Index
= 0; Index
< EntryCount
; Index
++) {
426 // Query all the children created by the controller handle's driver
428 if ((OpenInfoBuffer
[Index
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
429 Status
= gBS
->OpenProtocol (
430 OpenInfoBuffer
[Index
].ControllerHandle
,
431 &gEfiDevicePathProtocolGuid
,
432 (VOID
**) &ChildDevicePath
,
435 EFI_OPEN_PROTOCOL_GET_PROTOCOL
437 if (EFI_ERROR (Status
)) {
442 // Check whether this device path include mac address device path.
444 if (!IsMacAddressDevicePath(ChildDevicePath
, NextShowFormId
,&IsNeedAdd
)) {
446 // If this path not has mac address path, check the other.
451 // If need to update the NETWORK_DEVICE_LIST_FORM, try to get more.
453 if ((NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
)) {
460 // If need to update other form, return whether need to add to the menu.
469 if (OpenInfoBuffer
!= NULL
) {
470 FreePool (OpenInfoBuffer
);
476 Dynamic create Hii information for Device Manager.
478 @param NextShowFormId The FormId which need to be show.
482 CreateDeviceManagerForm(
483 IN EFI_FORM_ID NextShowFormId
489 EFI_STRING_ID TokenHelp
;
490 EFI_HII_HANDLE
*HiiHandles
;
491 EFI_HII_HANDLE HiiHandle
;
492 EFI_GUID FormSetGuid
;
493 VOID
*StartOpCodeHandle
;
494 VOID
*EndOpCodeHandle
;
495 EFI_IFR_GUID_LABEL
*StartLabel
;
496 EFI_IFR_GUID_LABEL
*EndLabel
;
497 BOOLEAN AddNetworkMenu
;
500 EFI_STRING NewStringTitle
;
501 CHAR16
*DevicePathStr
;
502 EFI_STRING_ID DevicePathId
;
503 EFI_IFR_FORM_SET
*Buffer
;
515 HiiHandle
= gDeviceManagerPrivate
.HiiHandle
;
516 AddNetworkMenu
= FALSE
;
519 // If need show the Network device list form, clear the old save list first.
521 if ((NextShowFormId
== NETWORK_DEVICE_LIST_FORM_ID
) && (mMacDeviceList
.CurListLen
> 0)) {
522 mMacDeviceList
.CurListLen
= 0;
526 // Update the network device form titile.
528 if (NextShowFormId
== NETWORK_DEVICE_FORM_ID
) {
529 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE
), NULL
);
530 NewStringLen
= StrLen(mSelectedMacAddrString
) * 2;
531 NewStringLen
+= (StrLen(String
) + 2) * 2;
532 NewStringTitle
= AllocatePool (NewStringLen
);
533 UnicodeSPrint (NewStringTitle
, NewStringLen
, L
"%s %s", String
, mSelectedMacAddrString
);
534 HiiSetString (HiiHandle
, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE
), NewStringTitle
, NULL
);
536 FreePool (NewStringTitle
);
540 // Allocate space for creation of UpdateData Buffer
542 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
543 ASSERT (StartOpCodeHandle
!= NULL
);
545 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
546 ASSERT (EndOpCodeHandle
!= NULL
);
549 // Create Hii Extend Label OpCode as the start opcode
551 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
552 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
554 // According to the next show Form id(mNextShowFormId) to decide which form need to update.
556 StartLabel
->Number
= (UINT16
) (LABEL_FORM_ID_OFFSET
+ NextShowFormId
);
559 // Create Hii Extend Label OpCode as the end opcode
561 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
562 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
563 EndLabel
->Number
= LABEL_END
;
566 // Get all the Hii handles
568 HiiHandles
= HiiGetHiiHandles (NULL
);
569 ASSERT (HiiHandles
!= NULL
);
572 // Search for formset of each class type
574 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
575 Status
= HiiGetFormSetFromHiiHandle(HiiHandles
[Index
], &Buffer
,&BufferSize
);
576 if (EFI_ERROR (Status
)){
579 Ptr
= (UINT8
*)Buffer
;
580 while(TempSize
< BufferSize
) {
581 TempSize
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
582 if (((EFI_IFR_OP_HEADER
*) Ptr
)->Length
<= OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)){
583 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
587 ClassGuidNum
= (UINT8
) (((EFI_IFR_FORM_SET
*)Ptr
)->Flags
& 0x3);
588 ClassGuid
= (EFI_GUID
*) (VOID
*)(Ptr
+ sizeof (EFI_IFR_FORM_SET
));
589 while (ClassGuidNum
-- > 0) {
590 if (CompareGuid (&gEfiHiiPlatformSetupFormsetGuid
, ClassGuid
)== 0) {
595 String
= HiiGetString (HiiHandles
[Index
], ((EFI_IFR_FORM_SET
*)Ptr
)->FormSetTitle
, NULL
);
596 if (String
== NULL
) {
597 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
598 ASSERT (String
!= NULL
);
600 Token
= HiiSetString (HiiHandle
, 0, String
, NULL
);
603 String
= HiiGetString (HiiHandles
[Index
], ((EFI_IFR_FORM_SET
*)Ptr
)->Help
, NULL
);
604 if (String
== NULL
) {
605 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
606 ASSERT (String
!= NULL
);
608 TokenHelp
= HiiSetString (HiiHandle
, 0, String
, NULL
);
611 FormSetGuid
= ((EFI_IFR_FORM_SET
*)Ptr
)->Guid
;
614 // Network device process
616 if (IsNeedAddNetworkMenu (HiiHandles
[Index
], NextShowFormId
,&AddItemCount
)) {
617 if (NextShowFormId
== DEVICE_MANAGER_FORM_ID
) {
619 // Only show one menu item "Network Config" in the device manger form.
621 if (!AddNetworkMenu
) {
622 AddNetworkMenu
= TRUE
;
623 HiiCreateGotoOpCode (
625 NETWORK_DEVICE_LIST_FORM_ID
,
626 STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_TITLE
),
627 STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_HELP
),
628 EFI_IFR_FLAG_CALLBACK
,
629 (EFI_QUESTION_ID
) QUESTION_NETWORK_DEVICE_ID
632 } else if (NextShowFormId
== NETWORK_DEVICE_LIST_FORM_ID
) {
634 // In network device list form, same mac address device only show one menu.
636 while (AddItemCount
> 0) {
637 HiiCreateGotoOpCode (
639 NETWORK_DEVICE_FORM_ID
,
640 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
- AddItemCount
].PromptId
,
641 STRING_TOKEN (STR_NETWORK_DEVICE_HELP
),
642 EFI_IFR_FLAG_CALLBACK
,
643 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
- AddItemCount
].QuestionId
647 } else if (NextShowFormId
== NETWORK_DEVICE_FORM_ID
) {
649 // In network device form, only the selected mac address device need to be show.
651 DevicePathStr
= DmExtractDevicePathFromHiiHandle(HiiHandles
[Index
]);
653 if (DevicePathStr
!= NULL
){
654 DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
655 FreePool(DevicePathStr
);
657 HiiCreateGotoExOpCode (
663 (EFI_QUESTION_ID
) (Index
+ DEVICE_KEY_OFFSET
),
671 // Not network device process, only need to show at device manger form.
673 if (NextShowFormId
== DEVICE_MANAGER_FORM_ID
) {
674 DevicePathStr
= DmExtractDevicePathFromHiiHandle(HiiHandles
[Index
]);
676 if (DevicePathStr
!= NULL
){
677 DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
678 FreePool(DevicePathStr
);
680 HiiCreateGotoExOpCode (
686 (EFI_QUESTION_ID
) (Index
+ DEVICE_KEY_OFFSET
),
696 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
712 HiiFreeOpCodeHandle (StartOpCodeHandle
);
713 HiiFreeOpCodeHandle (EndOpCodeHandle
);
714 FreePool (HiiHandles
);
718 This function allows a caller to extract the current configuration for one
719 or more named elements from the target driver.
722 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
723 @param Request A null-terminated Unicode string in <ConfigRequest> format.
724 @param Progress On return, points to a character in the Request string.
725 Points to the string's null terminator if request was successful.
726 Points to the most recent '&' before the first failing name/value
727 pair (or the beginning of the string if the failure is in the
728 first name/value pair) if the request was not successful.
729 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
730 has all values filled in for the names in the Request string.
731 String to be allocated by the called function.
733 @retval EFI_SUCCESS The Results is filled with the requested values.
734 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
735 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
736 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
741 DeviceManagerExtractConfig (
742 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
743 IN CONST EFI_STRING Request
,
744 OUT EFI_STRING
*Progress
,
745 OUT EFI_STRING
*Results
748 if (Progress
== NULL
|| Results
== NULL
) {
749 return EFI_INVALID_PARAMETER
;
752 return EFI_NOT_FOUND
;
756 This function processes the results of changes in configuration.
758 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
759 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
760 @param Progress A pointer to a string filled in with the offset of the most
761 recent '&' before the first failing name/value pair (or the
762 beginning of the string if the failure is in the first
763 name/value pair) or the terminating NULL if all was successful.
765 @retval EFI_SUCCESS The Results is processed successfully.
766 @retval EFI_INVALID_PARAMETER Configuration is NULL.
767 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
772 DeviceManagerRouteConfig (
773 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
774 IN CONST EFI_STRING Configuration
,
775 OUT EFI_STRING
*Progress
778 if (Configuration
== NULL
|| Progress
== NULL
) {
779 return EFI_INVALID_PARAMETER
;
782 *Progress
= Configuration
;
784 return EFI_NOT_FOUND
;
788 This function is invoked if user selected a interactive opcode from Device Manager's
789 Formset. If user set VBIOS, the new value is saved to EFI variable.
791 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
792 @param Action Specifies the type of action taken by the browser.
793 @param QuestionId A unique value which is sent to the original exporting driver
794 so that it can identify the type of data to expect.
795 @param Type The type of value for the question.
796 @param Value A pointer to the data being sent to the original exporting driver.
797 @param ActionRequest On return, points to the action requested by the callback function.
799 @retval EFI_SUCCESS The callback successfully handled the action.
800 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
805 DeviceManagerCallback (
806 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
807 IN EFI_BROWSER_ACTION Action
,
808 IN EFI_QUESTION_ID QuestionId
,
810 IN EFI_IFR_TYPE_VALUE
*Value
,
811 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
816 if (Action
!= EFI_BROWSER_ACTION_CHANGING
) {
818 // Do nothing for other UEFI Action. Only do call back when data is changed.
820 return EFI_UNSUPPORTED
;
822 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
823 return EFI_INVALID_PARAMETER
;
825 if ((QuestionId
< MAX_KEY_SECTION_LEN
+ NETWORK_DEVICE_LIST_KEY_OFFSET
) && (QuestionId
>= NETWORK_DEVICE_LIST_KEY_OFFSET
)) {
827 // If user select the mac address, need to record mac address string to support next form show.
829 for (CurIndex
= 0; CurIndex
< mMacDeviceList
.CurListLen
; CurIndex
++) {
830 if (mMacDeviceList
.NodeList
[CurIndex
].QuestionId
== QuestionId
) {
831 mSelectedMacAddrString
= HiiGetString (gDeviceManagerPrivate
.HiiHandle
, mMacDeviceList
.NodeList
[CurIndex
].PromptId
, NULL
);
834 CreateDeviceManagerForm(NETWORK_DEVICE_FORM_ID
);
835 } else if(QuestionId
== QUESTION_NETWORK_DEVICE_ID
){
836 CreateDeviceManagerForm(NETWORK_DEVICE_LIST_FORM_ID
);
843 Install Boot Manager Menu driver.
845 @param ImageHandle The image handle.
846 @param SystemTable The system table.
848 @retval EFI_SUCEESS Install Boot manager menu success.
849 @retval Other Return error status.
854 DeviceManagerUiLibConstructor (
855 IN EFI_HANDLE ImageHandle
,
856 IN EFI_SYSTEM_TABLE
*SystemTable
861 gDeviceManagerPrivate
.DriverHandle
= NULL
;
862 Status
= gBS
->InstallMultipleProtocolInterfaces (
863 &gDeviceManagerPrivate
.DriverHandle
,
864 &gEfiDevicePathProtocolGuid
,
865 &mDeviceManagerHiiVendorDevicePath
,
866 &gEfiHiiConfigAccessProtocolGuid
,
867 &gDeviceManagerPrivate
.ConfigAccess
,
870 ASSERT_EFI_ERROR (Status
);
873 // Publish our HII data.
875 gDeviceManagerPrivate
.HiiHandle
= HiiAddPackages (
877 gDeviceManagerPrivate
.DriverHandle
,
879 DeviceManagerUiLibStrings
,
882 ASSERT (gDeviceManagerPrivate
.HiiHandle
!= NULL
);
885 // Update boot manager page
887 CreateDeviceManagerForm (DEVICE_MANAGER_FORM_ID
);
893 Unloads the application and its installed protocol.
895 @param ImageHandle Handle that identifies the image to be unloaded.
896 @param SystemTable The system table.
898 @retval EFI_SUCCESS The image has been unloaded.
902 DeviceManagerUiLibDestructor(
903 IN EFI_HANDLE ImageHandle
,
904 IN EFI_SYSTEM_TABLE
*SystemTable
909 Status
= gBS
->UninstallMultipleProtocolInterfaces (
910 gDeviceManagerPrivate
.DriverHandle
,
911 &gEfiDevicePathProtocolGuid
,
912 &mDeviceManagerHiiVendorDevicePath
,
913 &gEfiHiiConfigAccessProtocolGuid
,
914 &gDeviceManagerPrivate
.ConfigAccess
,
917 ASSERT_EFI_ERROR (Status
);
919 HiiRemovePackages (gDeviceManagerPrivate
.HiiHandle
);