2 The device manager reference implementation
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "DeviceManager.h"
11 DEVICE_MANAGER_CALLBACK_DATA gDeviceManagerPrivate
= {
12 DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE
,
16 DeviceManagerExtractConfig
,
17 DeviceManagerRouteConfig
,
22 #define MAX_MAC_ADDRESS_NODE_LIST_LEN 10
24 EFI_GUID mDeviceManagerGuid
= DEVICE_MANAGER_FORMSET_GUID
;
27 // Which Mac Address string is select
28 // it will decide what menu need to show in the NETWORK_DEVICE_FORM_ID form.
30 EFI_STRING mSelectedMacAddrString
;
33 // The Mac Address show in the NETWORK_DEVICE_LIST_FORM_ID
35 MAC_ADDRESS_NODE_LIST mMacDeviceList
;
37 HII_VENDOR_DEVICE_PATH mDeviceManagerHiiVendorDevicePath
= {
43 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
44 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
48 // {102579A0-3686-466e-ACD8-80C087044F4A}
50 { 0x102579a0, 0x3686, 0x466e, { 0xac, 0xd8, 0x80, 0xc0, 0x87, 0x4, 0x4f, 0x4a } }
54 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
56 (UINT8
) (END_DEVICE_PATH_LENGTH
),
57 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
63 Extract device path for given HII handle and class guid.
65 @param Handle The HII handle.
67 @retval NULL Fail to get the device path string.
68 @return PathString Get the device path string.
72 DmExtractDevicePathFromHiiHandle (
73 IN EFI_HII_HANDLE Handle
77 EFI_HANDLE DriverHandle
;
79 ASSERT (Handle
!= NULL
);
85 Status
= gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, Handle
, &DriverHandle
);
86 if (EFI_ERROR (Status
)) {
90 // Get device path string.
92 return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle
), FALSE
, FALSE
);
96 Get the mac address string from the device path.
97 if the device path has the vlan, get the vanid also.
99 @param MacAddressNode Device path begin with mac address
100 @param PBuffer Output string buffer contain mac address.
105 IN MAC_ADDR_DEVICE_PATH
*MacAddressNode
,
112 EFI_DEVICE_PATH_PROTOCOL
*Node
;
119 ASSERT(MacAddressNode
!= NULL
);
121 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
122 if (MacAddressNode
->IfType
== 0x01 || MacAddressNode
->IfType
== 0x00) {
127 // The output format is MAC:XX:XX:XX:...\XXXX
128 // The size is the Number size + ":" size + Vlan size(\XXXX) + End
130 BufferLen
= (4 + 2 * HwAddressSize
+ (HwAddressSize
- 1) + 5 + 1) * sizeof (CHAR16
);
131 String
= AllocateZeroPool (BufferLen
);
132 if (String
== NULL
) {
137 StrCpyS(String
, BufferLen
/ sizeof (CHAR16
), L
"MAC:");
141 // Convert the MAC address into a unicode string.
143 HwAddress
= &MacAddressNode
->MacAddress
.Addr
[0];
144 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
145 UnicodeValueToStringS (
147 BufferLen
- ((UINTN
)String
- (UINTN
)*PBuffer
),
148 PREFIX_ZERO
| RADIX_HEX
,
152 String
+= StrnLenS (String
, (BufferLen
- ((UINTN
)String
- (UINTN
)*PBuffer
)) / sizeof (CHAR16
));
153 if (Index
< HwAddressSize
- 1) {
159 // If VLAN is configured, it will need extra 5 characters like "\0005".
160 // Plus one unicode character for the null-terminator.
162 Node
= (EFI_DEVICE_PATH_PROTOCOL
*)MacAddressNode
;
163 while (!IsDevicePathEnd (Node
)) {
164 if (Node
->Type
== MESSAGING_DEVICE_PATH
&& Node
->SubType
== MSG_VLAN_DP
) {
165 VlanId
= ((VLAN_DEVICE_PATH
*) Node
)->VlanId
;
167 Node
= NextDevicePathNode (Node
);
172 UnicodeValueToStringS (
174 BufferLen
- ((UINTN
)String
- (UINTN
)*PBuffer
),
175 PREFIX_ZERO
| RADIX_HEX
,
179 String
+= StrnLenS (String
, (BufferLen
- ((UINTN
)String
- (UINTN
)*PBuffer
)) / sizeof (CHAR16
));
183 // Null terminate the Unicode string
191 Save question id and prompt id to the mac device list.
192 If the same mac address has saved yet, no need to add more.
194 @param MacAddrString Mac address string.
196 @retval EFI_SUCCESS Add the item is successful.
197 @return Other values if failed to Add the item.
200 AddIdToMacDeviceList (
201 IN EFI_STRING MacAddrString
204 MENU_INFO_ITEM
*TempDeviceList
;
206 EFI_STRING StoredString
;
207 EFI_STRING_ID PromptId
;
208 EFI_HII_HANDLE HiiHandle
;
210 HiiHandle
= gDeviceManagerPrivate
.HiiHandle
;
211 TempDeviceList
= NULL
;
213 for (Index
= 0; Index
< mMacDeviceList
.CurListLen
; Index
++) {
214 StoredString
= HiiGetString (HiiHandle
, mMacDeviceList
.NodeList
[Index
].PromptId
, NULL
);
215 if (StoredString
== NULL
) {
220 // Already has save the same mac address to the list.
222 if (StrCmp (MacAddrString
, StoredString
) == 0) {
227 PromptId
= HiiSetString(HiiHandle
, 0, MacAddrString
, NULL
);
229 // If not in the list, save it.
231 if (mMacDeviceList
.MaxListLen
> mMacDeviceList
.CurListLen
+ 1) {
232 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
].PromptId
= PromptId
;
233 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
].QuestionId
= (EFI_QUESTION_ID
) (mMacDeviceList
.CurListLen
+ NETWORK_DEVICE_LIST_KEY_OFFSET
);
235 mMacDeviceList
.MaxListLen
+= MAX_MAC_ADDRESS_NODE_LIST_LEN
;
236 if (mMacDeviceList
.CurListLen
!= 0) {
237 TempDeviceList
= ReallocatePool (
238 sizeof (MENU_INFO_ITEM
) * mMacDeviceList
.CurListLen
,
239 sizeof (MENU_INFO_ITEM
) * mMacDeviceList
.MaxListLen
,
240 mMacDeviceList
.NodeList
243 TempDeviceList
= (MENU_INFO_ITEM
*)AllocatePool (sizeof (MENU_INFO_ITEM
) * mMacDeviceList
.MaxListLen
);
246 if (TempDeviceList
== NULL
) {
249 TempDeviceList
[mMacDeviceList
.CurListLen
].PromptId
= PromptId
;
250 TempDeviceList
[mMacDeviceList
.CurListLen
].QuestionId
= (EFI_QUESTION_ID
) (mMacDeviceList
.CurListLen
+ NETWORK_DEVICE_LIST_KEY_OFFSET
);
252 mMacDeviceList
.NodeList
= TempDeviceList
;
254 mMacDeviceList
.CurListLen
++;
260 Check the devcie path, try to find whether it has mac address path.
262 In this function, first need to check whether this path has mac address path.
263 second, when the mac address device path has find, also need to deicide whether
264 need to add this mac address relate info to the menu.
266 @param *Node Input device which need to be check.
267 @param NextShowFormId FormId Which need to be show.
268 @param *NeedAddItem Whether need to add the menu in the network device list.
270 @retval TRUE Has mac address device path.
271 @retval FALSE NOT Has mac address device path.
275 IsMacAddressDevicePath (
277 IN EFI_FORM_ID NextShowFormId
,
278 OUT BOOLEAN
*NeedAddItem
281 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
285 ASSERT (Node
!= NULL
);
286 *NeedAddItem
= FALSE
;
290 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) Node
;
293 // find the partition device path node
295 while (!IsDevicePathEnd (DevicePath
)) {
296 if ((DevicePathType (DevicePath
) == MESSAGING_DEVICE_PATH
) &&
297 (DevicePathSubType (DevicePath
) == MSG_MAC_ADDR_DP
)) {
300 if (DEVICE_MANAGER_FORM_ID
== NextShowFormId
) {
305 if (!GetMacAddressString((MAC_ADDR_DEVICE_PATH
*)DevicePath
, &Buffer
)) {
309 if (NETWORK_DEVICE_FORM_ID
== NextShowFormId
) {
310 if (StrCmp (Buffer
, mSelectedMacAddrString
) == 0) {
316 if (NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
) {
318 // Same handle may has two network child handle, so the questionid
319 // has the offset of SAME_HANDLE_KEY_OFFSET.
321 if (AddIdToMacDeviceList (Buffer
)) {
327 DevicePath
= NextDevicePathNode (DevicePath
);
330 if (Buffer
!= NULL
) {
338 Check to see if the device path is for the network device.
340 @param Handle The HII handle which include the mac address device path.
341 @param NextShowFormId The FormId of the form which will be show next time.
342 @param ItemCount The new add Mac address item count.
344 @retval TRUE Need to add new item in the menu.
345 @return FALSE Do not need to add the menu about the network.
349 IsNeedAddNetworkMenu (
350 IN EFI_HII_HANDLE Handle
,
351 IN EFI_FORM_ID NextShowFormId
,
358 EFI_HANDLE DriverHandle
;
359 EFI_HANDLE ControllerHandle
;
360 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
361 EFI_DEVICE_PATH_PROTOCOL
*TmpDevicePath
;
362 EFI_DEVICE_PATH_PROTOCOL
*ChildDevicePath
;
363 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfoBuffer
;
367 OpenInfoBuffer
= NULL
;
368 if ((Handle
== NULL
) || (ItemCount
== NULL
)) {
373 Status
= gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, Handle
, &DriverHandle
);
374 if (EFI_ERROR (Status
)) {
378 // Get the device path by the got Driver handle .
380 Status
= gBS
->HandleProtocol (DriverHandle
, &gEfiDevicePathProtocolGuid
, (VOID
**) &DevicePath
);
381 if (EFI_ERROR (Status
)) {
384 TmpDevicePath
= DevicePath
;
387 // Check whether this device path include mac address device path.
388 // If this path has mac address path, get the value whether need
389 // add this info to the menu and return.
390 // Else check more about the child handle devcie path.
392 if (IsMacAddressDevicePath(TmpDevicePath
, NextShowFormId
,&IsNeedAdd
)) {
393 if ((NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
) && IsNeedAdd
) {
400 // Search whether this path is the controller path, not he child handle path.
401 // And the child handle has the network devcie connected.
403 TmpDevicePath
= DevicePath
;
404 Status
= gBS
->LocateDevicePath(&gEfiDevicePathProtocolGuid
, &TmpDevicePath
, &ControllerHandle
);
405 if (EFI_ERROR (Status
)) {
409 if (!IsDevicePathEnd (TmpDevicePath
)) {
414 // Retrieve the list of agents that are consuming the specific protocol
415 // on ControllerHandle.
416 // The buffer point by OpenInfoBuffer need be free at this function.
418 Status
= gBS
->OpenProtocolInformation (
420 &gEfiPciIoProtocolGuid
,
424 if (EFI_ERROR (Status
)) {
429 // Inspect if ChildHandle is one of the agents.
431 Status
= EFI_UNSUPPORTED
;
432 for (Index
= 0; Index
< EntryCount
; Index
++) {
434 // Query all the children created by the controller handle's driver
436 if ((OpenInfoBuffer
[Index
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
437 Status
= gBS
->OpenProtocol (
438 OpenInfoBuffer
[Index
].ControllerHandle
,
439 &gEfiDevicePathProtocolGuid
,
440 (VOID
**) &ChildDevicePath
,
443 EFI_OPEN_PROTOCOL_GET_PROTOCOL
445 if (EFI_ERROR (Status
)) {
450 // Check whether this device path include mac address device path.
452 if (!IsMacAddressDevicePath(ChildDevicePath
, NextShowFormId
,&IsNeedAdd
)) {
454 // If this path not has mac address path, check the other.
459 // If need to update the NETWORK_DEVICE_LIST_FORM, try to get more.
461 if ((NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
)) {
468 // If need to update other form, return whether need to add to the menu.
477 if (OpenInfoBuffer
!= NULL
) {
478 FreePool (OpenInfoBuffer
);
484 Dynamic create Hii information for Device Manager.
486 @param NextShowFormId The FormId which need to be show.
490 CreateDeviceManagerForm(
491 IN EFI_FORM_ID NextShowFormId
497 EFI_STRING_ID TokenHelp
;
498 EFI_HII_HANDLE
*HiiHandles
;
499 EFI_HII_HANDLE HiiHandle
;
500 EFI_GUID FormSetGuid
;
501 VOID
*StartOpCodeHandle
;
502 VOID
*EndOpCodeHandle
;
503 EFI_IFR_GUID_LABEL
*StartLabel
;
504 EFI_IFR_GUID_LABEL
*EndLabel
;
505 BOOLEAN AddNetworkMenu
;
508 EFI_STRING NewStringTitle
;
509 CHAR16
*DevicePathStr
;
510 EFI_STRING_ID DevicePathId
;
511 EFI_IFR_FORM_SET
*Buffer
;
523 HiiHandle
= gDeviceManagerPrivate
.HiiHandle
;
524 AddNetworkMenu
= FALSE
;
527 // If need show the Network device list form, clear the old save list first.
529 if ((NextShowFormId
== NETWORK_DEVICE_LIST_FORM_ID
) && (mMacDeviceList
.CurListLen
> 0)) {
530 mMacDeviceList
.CurListLen
= 0;
534 // Update the network device form titile.
536 if (NextShowFormId
== NETWORK_DEVICE_FORM_ID
) {
537 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE_HEAD
), NULL
);
538 if (String
== NULL
) {
541 NewStringLen
= StrLen (mSelectedMacAddrString
) * 2;
542 NewStringLen
+= (StrLen (String
) + 2) * 2;
543 NewStringTitle
= AllocatePool (NewStringLen
);
544 UnicodeSPrint (NewStringTitle
, NewStringLen
, L
"%s %s", String
, mSelectedMacAddrString
);
545 HiiSetString (HiiHandle
, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE
), NewStringTitle
, NULL
);
547 FreePool (NewStringTitle
);
551 // Allocate space for creation of UpdateData Buffer
553 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
554 ASSERT (StartOpCodeHandle
!= NULL
);
556 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
557 ASSERT (EndOpCodeHandle
!= NULL
);
560 // Create Hii Extend Label OpCode as the start opcode
562 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
563 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
565 // According to the next show Form id(mNextShowFormId) to decide which form need to update.
567 StartLabel
->Number
= (UINT16
) (LABEL_FORM_ID_OFFSET
+ NextShowFormId
);
570 // Create Hii Extend Label OpCode as the end opcode
572 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
573 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
574 EndLabel
->Number
= LABEL_END
;
577 // Get all the Hii handles
579 HiiHandles
= HiiGetHiiHandles (NULL
);
580 ASSERT (HiiHandles
!= NULL
);
583 // Search for formset of each class type
585 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
586 Status
= HiiGetFormSetFromHiiHandle(HiiHandles
[Index
], &Buffer
,&BufferSize
);
587 if (EFI_ERROR (Status
)){
590 Ptr
= (UINT8
*)Buffer
;
591 while(TempSize
< BufferSize
) {
592 TempSize
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
593 if (((EFI_IFR_OP_HEADER
*) Ptr
)->Length
<= OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)){
594 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
598 ClassGuidNum
= (UINT8
) (((EFI_IFR_FORM_SET
*)Ptr
)->Flags
& 0x3);
599 ClassGuid
= (EFI_GUID
*) (VOID
*)(Ptr
+ sizeof (EFI_IFR_FORM_SET
));
600 while (ClassGuidNum
-- > 0) {
601 if (CompareGuid (&gEfiHiiPlatformSetupFormsetGuid
, ClassGuid
)== 0) {
606 String
= HiiGetString (HiiHandles
[Index
], ((EFI_IFR_FORM_SET
*)Ptr
)->FormSetTitle
, NULL
);
607 if (String
== NULL
) {
608 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
609 ASSERT (String
!= NULL
);
611 Token
= HiiSetString (HiiHandle
, 0, String
, NULL
);
614 String
= HiiGetString (HiiHandles
[Index
], ((EFI_IFR_FORM_SET
*)Ptr
)->Help
, NULL
);
615 if (String
== NULL
) {
616 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
617 ASSERT (String
!= NULL
);
619 TokenHelp
= HiiSetString (HiiHandle
, 0, String
, NULL
);
622 FormSetGuid
= ((EFI_IFR_FORM_SET
*)Ptr
)->Guid
;
625 // Network device process
627 if (IsNeedAddNetworkMenu (HiiHandles
[Index
], NextShowFormId
,&AddItemCount
)) {
628 if (NextShowFormId
== DEVICE_MANAGER_FORM_ID
) {
630 // Only show one menu item "Network Config" in the device manger form.
632 if (!AddNetworkMenu
) {
633 AddNetworkMenu
= TRUE
;
634 HiiCreateGotoOpCode (
636 NETWORK_DEVICE_LIST_FORM_ID
,
637 STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_TITLE
),
638 STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_HELP
),
639 EFI_IFR_FLAG_CALLBACK
,
640 (EFI_QUESTION_ID
) QUESTION_NETWORK_DEVICE_ID
643 } else if (NextShowFormId
== NETWORK_DEVICE_LIST_FORM_ID
) {
645 // In network device list form, same mac address device only show one menu.
647 while (AddItemCount
> 0) {
648 HiiCreateGotoOpCode (
650 NETWORK_DEVICE_FORM_ID
,
651 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
- AddItemCount
].PromptId
,
652 STRING_TOKEN (STR_NETWORK_DEVICE_HELP
),
653 EFI_IFR_FLAG_CALLBACK
,
654 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
- AddItemCount
].QuestionId
658 } else if (NextShowFormId
== NETWORK_DEVICE_FORM_ID
) {
660 // In network device form, only the selected mac address device need to be show.
662 DevicePathStr
= DmExtractDevicePathFromHiiHandle(HiiHandles
[Index
]);
664 if (DevicePathStr
!= NULL
){
665 DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
666 FreePool(DevicePathStr
);
668 HiiCreateGotoExOpCode (
674 (EFI_QUESTION_ID
) (Index
+ DEVICE_KEY_OFFSET
),
682 // Not network device process, only need to show at device manger form.
684 if (NextShowFormId
== DEVICE_MANAGER_FORM_ID
) {
685 DevicePathStr
= DmExtractDevicePathFromHiiHandle(HiiHandles
[Index
]);
687 if (DevicePathStr
!= NULL
){
688 DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
689 FreePool(DevicePathStr
);
691 HiiCreateGotoExOpCode (
697 (EFI_QUESTION_ID
) (Index
+ DEVICE_KEY_OFFSET
),
707 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
723 HiiFreeOpCodeHandle (StartOpCodeHandle
);
724 HiiFreeOpCodeHandle (EndOpCodeHandle
);
725 FreePool (HiiHandles
);
729 This function allows a caller to extract the current configuration for one
730 or more named elements from the target driver.
733 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
734 @param Request A null-terminated Unicode string in <ConfigRequest> format.
735 @param Progress On return, points to a character in the Request string.
736 Points to the string's null terminator if request was successful.
737 Points to the most recent '&' before the first failing name/value
738 pair (or the beginning of the string if the failure is in the
739 first name/value pair) if the request was not successful.
740 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
741 has all values filled in for the names in the Request string.
742 String to be allocated by the called function.
744 @retval EFI_SUCCESS The Results is filled with the requested values.
745 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
746 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
747 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
752 DeviceManagerExtractConfig (
753 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
754 IN CONST EFI_STRING Request
,
755 OUT EFI_STRING
*Progress
,
756 OUT EFI_STRING
*Results
759 if (Progress
== NULL
|| Results
== NULL
) {
760 return EFI_INVALID_PARAMETER
;
763 return EFI_NOT_FOUND
;
767 This function processes the results of changes in configuration.
769 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
770 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
771 @param Progress A pointer to a string filled in with the offset of the most
772 recent '&' before the first failing name/value pair (or the
773 beginning of the string if the failure is in the first
774 name/value pair) or the terminating NULL if all was successful.
776 @retval EFI_SUCCESS The Results is processed successfully.
777 @retval EFI_INVALID_PARAMETER Configuration is NULL.
778 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
783 DeviceManagerRouteConfig (
784 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
785 IN CONST EFI_STRING Configuration
,
786 OUT EFI_STRING
*Progress
789 if (Configuration
== NULL
|| Progress
== NULL
) {
790 return EFI_INVALID_PARAMETER
;
793 *Progress
= Configuration
;
795 return EFI_NOT_FOUND
;
799 This function is invoked if user selected a interactive opcode from Device Manager's
800 Formset. If user set VBIOS, the new value is saved to EFI variable.
802 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
803 @param Action Specifies the type of action taken by the browser.
804 @param QuestionId A unique value which is sent to the original exporting driver
805 so that it can identify the type of data to expect.
806 @param Type The type of value for the question.
807 @param Value A pointer to the data being sent to the original exporting driver.
808 @param ActionRequest On return, points to the action requested by the callback function.
810 @retval EFI_SUCCESS The callback successfully handled the action.
811 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
816 DeviceManagerCallback (
817 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
818 IN EFI_BROWSER_ACTION Action
,
819 IN EFI_QUESTION_ID QuestionId
,
821 IN EFI_IFR_TYPE_VALUE
*Value
,
822 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
827 if (Action
!= EFI_BROWSER_ACTION_CHANGING
) {
829 // Do nothing for other UEFI Action. Only do call back when data is changed.
831 return EFI_UNSUPPORTED
;
833 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
834 return EFI_INVALID_PARAMETER
;
836 if ((QuestionId
< MAX_KEY_SECTION_LEN
+ NETWORK_DEVICE_LIST_KEY_OFFSET
) && (QuestionId
>= NETWORK_DEVICE_LIST_KEY_OFFSET
)) {
838 // If user select the mac address, need to record mac address string to support next form show.
840 for (CurIndex
= 0; CurIndex
< mMacDeviceList
.CurListLen
; CurIndex
++) {
841 if (mMacDeviceList
.NodeList
[CurIndex
].QuestionId
== QuestionId
) {
842 mSelectedMacAddrString
= HiiGetString (gDeviceManagerPrivate
.HiiHandle
, mMacDeviceList
.NodeList
[CurIndex
].PromptId
, NULL
);
845 CreateDeviceManagerForm(NETWORK_DEVICE_FORM_ID
);
846 } else if(QuestionId
== QUESTION_NETWORK_DEVICE_ID
){
847 CreateDeviceManagerForm(NETWORK_DEVICE_LIST_FORM_ID
);
854 Install Boot Manager Menu driver.
856 @param ImageHandle The image handle.
857 @param SystemTable The system table.
859 @retval EFI_SUCEESS Install Boot manager menu success.
860 @retval Other Return error status.
865 DeviceManagerUiLibConstructor (
866 IN EFI_HANDLE ImageHandle
,
867 IN EFI_SYSTEM_TABLE
*SystemTable
872 gDeviceManagerPrivate
.DriverHandle
= NULL
;
873 Status
= gBS
->InstallMultipleProtocolInterfaces (
874 &gDeviceManagerPrivate
.DriverHandle
,
875 &gEfiDevicePathProtocolGuid
,
876 &mDeviceManagerHiiVendorDevicePath
,
877 &gEfiHiiConfigAccessProtocolGuid
,
878 &gDeviceManagerPrivate
.ConfigAccess
,
881 ASSERT_EFI_ERROR (Status
);
884 // Publish our HII data.
886 gDeviceManagerPrivate
.HiiHandle
= HiiAddPackages (
888 gDeviceManagerPrivate
.DriverHandle
,
890 DeviceManagerUiLibStrings
,
893 ASSERT (gDeviceManagerPrivate
.HiiHandle
!= NULL
);
896 // Update boot manager page
898 CreateDeviceManagerForm (DEVICE_MANAGER_FORM_ID
);
904 Unloads the application and its installed protocol.
906 @param ImageHandle Handle that identifies the image to be unloaded.
907 @param SystemTable The system table.
909 @retval EFI_SUCCESS The image has been unloaded.
913 DeviceManagerUiLibDestructor(
914 IN EFI_HANDLE ImageHandle
,
915 IN EFI_SYSTEM_TABLE
*SystemTable
920 Status
= gBS
->UninstallMultipleProtocolInterfaces (
921 gDeviceManagerPrivate
.DriverHandle
,
922 &gEfiDevicePathProtocolGuid
,
923 &mDeviceManagerHiiVendorDevicePath
,
924 &gEfiHiiConfigAccessProtocolGuid
,
925 &gDeviceManagerPrivate
.ConfigAccess
,
928 ASSERT_EFI_ERROR (Status
);
930 HiiRemovePackages (gDeviceManagerPrivate
.HiiHandle
);