2 The device manager reference implementation
4 Copyright (c) 2004 - 2017, 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 UnicodeValueToStringS (
153 BufferLen
- ((UINTN
)String
- (UINTN
)*PBuffer
),
154 PREFIX_ZERO
| RADIX_HEX
,
158 String
+= StrnLenS (String
, (BufferLen
- ((UINTN
)String
- (UINTN
)*PBuffer
)) / sizeof (CHAR16
));
159 if (Index
< HwAddressSize
- 1) {
165 // If VLAN is configured, it will need extra 5 characters like "\0005".
166 // Plus one unicode character for the null-terminator.
168 Node
= (EFI_DEVICE_PATH_PROTOCOL
*)MacAddressNode
;
169 while (!IsDevicePathEnd (Node
)) {
170 if (Node
->Type
== MESSAGING_DEVICE_PATH
&& Node
->SubType
== MSG_VLAN_DP
) {
171 VlanId
= ((VLAN_DEVICE_PATH
*) Node
)->VlanId
;
173 Node
= NextDevicePathNode (Node
);
178 UnicodeValueToStringS (
180 BufferLen
- ((UINTN
)String
- (UINTN
)*PBuffer
),
181 PREFIX_ZERO
| RADIX_HEX
,
185 String
+= StrnLenS (String
, (BufferLen
- ((UINTN
)String
- (UINTN
)*PBuffer
)) / sizeof (CHAR16
));
189 // Null terminate the Unicode string
197 Save question id and prompt id to the mac device list.
198 If the same mac address has saved yet, no need to add more.
200 @param MacAddrString Mac address string.
202 @retval EFI_SUCCESS Add the item is successful.
203 @return Other values if failed to Add the item.
206 AddIdToMacDeviceList (
207 IN EFI_STRING MacAddrString
210 MENU_INFO_ITEM
*TempDeviceList
;
212 EFI_STRING StoredString
;
213 EFI_STRING_ID PromptId
;
214 EFI_HII_HANDLE HiiHandle
;
216 HiiHandle
= gDeviceManagerPrivate
.HiiHandle
;
217 TempDeviceList
= NULL
;
219 for (Index
= 0; Index
< mMacDeviceList
.CurListLen
; Index
++) {
220 StoredString
= HiiGetString (HiiHandle
, mMacDeviceList
.NodeList
[Index
].PromptId
, NULL
);
221 if (StoredString
== NULL
) {
226 // Already has save the same mac address to the list.
228 if (StrCmp (MacAddrString
, StoredString
) == 0) {
233 PromptId
= HiiSetString(HiiHandle
, 0, MacAddrString
, NULL
);
235 // If not in the list, save it.
237 if (mMacDeviceList
.MaxListLen
> mMacDeviceList
.CurListLen
+ 1) {
238 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
].PromptId
= PromptId
;
239 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
].QuestionId
= (EFI_QUESTION_ID
) (mMacDeviceList
.CurListLen
+ NETWORK_DEVICE_LIST_KEY_OFFSET
);
241 mMacDeviceList
.MaxListLen
+= MAX_MAC_ADDRESS_NODE_LIST_LEN
;
242 if (mMacDeviceList
.CurListLen
!= 0) {
243 TempDeviceList
= (MENU_INFO_ITEM
*)AllocateCopyPool (sizeof (MENU_INFO_ITEM
) * mMacDeviceList
.MaxListLen
, (VOID
*)mMacDeviceList
.NodeList
);
245 TempDeviceList
= (MENU_INFO_ITEM
*)AllocatePool (sizeof (MENU_INFO_ITEM
) * mMacDeviceList
.MaxListLen
);
248 if (TempDeviceList
== NULL
) {
251 TempDeviceList
[mMacDeviceList
.CurListLen
].PromptId
= PromptId
;
252 TempDeviceList
[mMacDeviceList
.CurListLen
].QuestionId
= (EFI_QUESTION_ID
) (mMacDeviceList
.CurListLen
+ NETWORK_DEVICE_LIST_KEY_OFFSET
);
254 if (mMacDeviceList
.CurListLen
> 0) {
255 FreePool(mMacDeviceList
.NodeList
);
258 mMacDeviceList
.NodeList
= TempDeviceList
;
260 mMacDeviceList
.CurListLen
++;
266 Check the devcie path, try to find whether it has mac address path.
268 In this function, first need to check whether this path has mac address path.
269 second, when the mac address device path has find, also need to deicide whether
270 need to add this mac address relate info to the menu.
272 @param *Node Input device which need to be check.
273 @param NextShowFormId FormId Which need to be show.
274 @param *NeedAddItem Whether need to add the menu in the network device list.
276 @retval TRUE Has mac address device path.
277 @retval FALSE NOT Has mac address device path.
281 IsMacAddressDevicePath (
283 IN EFI_FORM_ID NextShowFormId
,
284 OUT BOOLEAN
*NeedAddItem
287 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
291 ASSERT (Node
!= NULL
);
292 *NeedAddItem
= FALSE
;
296 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) Node
;
299 // find the partition device path node
301 while (!IsDevicePathEnd (DevicePath
)) {
302 if ((DevicePathType (DevicePath
) == MESSAGING_DEVICE_PATH
) &&
303 (DevicePathSubType (DevicePath
) == MSG_MAC_ADDR_DP
)) {
306 if (DEVICE_MANAGER_FORM_ID
== NextShowFormId
) {
311 if (!GetMacAddressString((MAC_ADDR_DEVICE_PATH
*)DevicePath
, &Buffer
)) {
315 if (NETWORK_DEVICE_FORM_ID
== NextShowFormId
) {
316 if (StrCmp (Buffer
, mSelectedMacAddrString
) == 0) {
322 if (NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
) {
324 // Same handle may has two network child handle, so the questionid
325 // has the offset of SAME_HANDLE_KEY_OFFSET.
327 if (AddIdToMacDeviceList (Buffer
)) {
333 DevicePath
= NextDevicePathNode (DevicePath
);
336 if (Buffer
!= NULL
) {
344 Check to see if the device path is for the network device.
346 @param Handle The HII handle which include the mac address device path.
347 @param NextShowFormId The FormId of the form which will be show next time.
348 @param ItemCount The new add Mac address item count.
350 @retval TRUE Need to add new item in the menu.
351 @return FALSE Do not need to add the menu about the network.
355 IsNeedAddNetworkMenu (
356 IN EFI_HII_HANDLE Handle
,
357 IN EFI_FORM_ID NextShowFormId
,
364 EFI_HANDLE DriverHandle
;
365 EFI_HANDLE ControllerHandle
;
366 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
367 EFI_DEVICE_PATH_PROTOCOL
*TmpDevicePath
;
368 EFI_DEVICE_PATH_PROTOCOL
*ChildDevicePath
;
369 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfoBuffer
;
373 OpenInfoBuffer
= NULL
;
374 if ((Handle
== NULL
) || (ItemCount
== NULL
)) {
379 Status
= gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, Handle
, &DriverHandle
);
380 if (EFI_ERROR (Status
)) {
384 // Get the device path by the got Driver handle .
386 Status
= gBS
->HandleProtocol (DriverHandle
, &gEfiDevicePathProtocolGuid
, (VOID
**) &DevicePath
);
387 if (EFI_ERROR (Status
)) {
390 TmpDevicePath
= DevicePath
;
393 // Check whether this device path include mac address device path.
394 // If this path has mac address path, get the value whether need
395 // add this info to the menu and return.
396 // Else check more about the child handle devcie path.
398 if (IsMacAddressDevicePath(TmpDevicePath
, NextShowFormId
,&IsNeedAdd
)) {
399 if ((NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
) && IsNeedAdd
) {
406 // Search whether this path is the controller path, not he child handle path.
407 // And the child handle has the network devcie connected.
409 TmpDevicePath
= DevicePath
;
410 Status
= gBS
->LocateDevicePath(&gEfiDevicePathProtocolGuid
, &TmpDevicePath
, &ControllerHandle
);
411 if (EFI_ERROR (Status
)) {
415 if (!IsDevicePathEnd (TmpDevicePath
)) {
420 // Retrieve the list of agents that are consuming the specific protocol
421 // on ControllerHandle.
422 // The buffer point by OpenInfoBuffer need be free at this function.
424 Status
= gBS
->OpenProtocolInformation (
426 &gEfiPciIoProtocolGuid
,
430 if (EFI_ERROR (Status
)) {
435 // Inspect if ChildHandle is one of the agents.
437 Status
= EFI_UNSUPPORTED
;
438 for (Index
= 0; Index
< EntryCount
; Index
++) {
440 // Query all the children created by the controller handle's driver
442 if ((OpenInfoBuffer
[Index
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
443 Status
= gBS
->OpenProtocol (
444 OpenInfoBuffer
[Index
].ControllerHandle
,
445 &gEfiDevicePathProtocolGuid
,
446 (VOID
**) &ChildDevicePath
,
449 EFI_OPEN_PROTOCOL_GET_PROTOCOL
451 if (EFI_ERROR (Status
)) {
456 // Check whether this device path include mac address device path.
458 if (!IsMacAddressDevicePath(ChildDevicePath
, NextShowFormId
,&IsNeedAdd
)) {
460 // If this path not has mac address path, check the other.
465 // If need to update the NETWORK_DEVICE_LIST_FORM, try to get more.
467 if ((NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
)) {
474 // If need to update other form, return whether need to add to the menu.
483 if (OpenInfoBuffer
!= NULL
) {
484 FreePool (OpenInfoBuffer
);
490 Dynamic create Hii information for Device Manager.
492 @param NextShowFormId The FormId which need to be show.
496 CreateDeviceManagerForm(
497 IN EFI_FORM_ID NextShowFormId
503 EFI_STRING_ID TokenHelp
;
504 EFI_HII_HANDLE
*HiiHandles
;
505 EFI_HII_HANDLE HiiHandle
;
506 EFI_GUID FormSetGuid
;
507 VOID
*StartOpCodeHandle
;
508 VOID
*EndOpCodeHandle
;
509 EFI_IFR_GUID_LABEL
*StartLabel
;
510 EFI_IFR_GUID_LABEL
*EndLabel
;
511 BOOLEAN AddNetworkMenu
;
514 EFI_STRING NewStringTitle
;
515 CHAR16
*DevicePathStr
;
516 EFI_STRING_ID DevicePathId
;
517 EFI_IFR_FORM_SET
*Buffer
;
529 HiiHandle
= gDeviceManagerPrivate
.HiiHandle
;
530 AddNetworkMenu
= FALSE
;
533 // If need show the Network device list form, clear the old save list first.
535 if ((NextShowFormId
== NETWORK_DEVICE_LIST_FORM_ID
) && (mMacDeviceList
.CurListLen
> 0)) {
536 mMacDeviceList
.CurListLen
= 0;
540 // Update the network device form titile.
542 if (NextShowFormId
== NETWORK_DEVICE_FORM_ID
) {
543 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE
), NULL
);
544 NewStringLen
= StrLen(mSelectedMacAddrString
) * 2;
545 NewStringLen
+= (StrLen(String
) + 2) * 2;
546 NewStringTitle
= AllocatePool (NewStringLen
);
547 UnicodeSPrint (NewStringTitle
, NewStringLen
, L
"%s %s", String
, mSelectedMacAddrString
);
548 HiiSetString (HiiHandle
, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE
), NewStringTitle
, NULL
);
550 FreePool (NewStringTitle
);
554 // Allocate space for creation of UpdateData Buffer
556 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
557 ASSERT (StartOpCodeHandle
!= NULL
);
559 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
560 ASSERT (EndOpCodeHandle
!= NULL
);
563 // Create Hii Extend Label OpCode as the start opcode
565 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
566 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
568 // According to the next show Form id(mNextShowFormId) to decide which form need to update.
570 StartLabel
->Number
= (UINT16
) (LABEL_FORM_ID_OFFSET
+ NextShowFormId
);
573 // Create Hii Extend Label OpCode as the end opcode
575 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
576 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
577 EndLabel
->Number
= LABEL_END
;
580 // Get all the Hii handles
582 HiiHandles
= HiiGetHiiHandles (NULL
);
583 ASSERT (HiiHandles
!= NULL
);
586 // Search for formset of each class type
588 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
589 Status
= HiiGetFormSetFromHiiHandle(HiiHandles
[Index
], &Buffer
,&BufferSize
);
590 if (EFI_ERROR (Status
)){
593 Ptr
= (UINT8
*)Buffer
;
594 while(TempSize
< BufferSize
) {
595 TempSize
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
596 if (((EFI_IFR_OP_HEADER
*) Ptr
)->Length
<= OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)){
597 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
601 ClassGuidNum
= (UINT8
) (((EFI_IFR_FORM_SET
*)Ptr
)->Flags
& 0x3);
602 ClassGuid
= (EFI_GUID
*) (VOID
*)(Ptr
+ sizeof (EFI_IFR_FORM_SET
));
603 while (ClassGuidNum
-- > 0) {
604 if (CompareGuid (&gEfiHiiPlatformSetupFormsetGuid
, ClassGuid
)== 0) {
609 String
= HiiGetString (HiiHandles
[Index
], ((EFI_IFR_FORM_SET
*)Ptr
)->FormSetTitle
, NULL
);
610 if (String
== NULL
) {
611 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
612 ASSERT (String
!= NULL
);
614 Token
= HiiSetString (HiiHandle
, 0, String
, NULL
);
617 String
= HiiGetString (HiiHandles
[Index
], ((EFI_IFR_FORM_SET
*)Ptr
)->Help
, NULL
);
618 if (String
== NULL
) {
619 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
620 ASSERT (String
!= NULL
);
622 TokenHelp
= HiiSetString (HiiHandle
, 0, String
, NULL
);
625 FormSetGuid
= ((EFI_IFR_FORM_SET
*)Ptr
)->Guid
;
628 // Network device process
630 if (IsNeedAddNetworkMenu (HiiHandles
[Index
], NextShowFormId
,&AddItemCount
)) {
631 if (NextShowFormId
== DEVICE_MANAGER_FORM_ID
) {
633 // Only show one menu item "Network Config" in the device manger form.
635 if (!AddNetworkMenu
) {
636 AddNetworkMenu
= TRUE
;
637 HiiCreateGotoOpCode (
639 NETWORK_DEVICE_LIST_FORM_ID
,
640 STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_TITLE
),
641 STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_HELP
),
642 EFI_IFR_FLAG_CALLBACK
,
643 (EFI_QUESTION_ID
) QUESTION_NETWORK_DEVICE_ID
646 } else if (NextShowFormId
== NETWORK_DEVICE_LIST_FORM_ID
) {
648 // In network device list form, same mac address device only show one menu.
650 while (AddItemCount
> 0) {
651 HiiCreateGotoOpCode (
653 NETWORK_DEVICE_FORM_ID
,
654 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
- AddItemCount
].PromptId
,
655 STRING_TOKEN (STR_NETWORK_DEVICE_HELP
),
656 EFI_IFR_FLAG_CALLBACK
,
657 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
- AddItemCount
].QuestionId
661 } else if (NextShowFormId
== NETWORK_DEVICE_FORM_ID
) {
663 // In network device form, only the selected mac address device need to be show.
665 DevicePathStr
= DmExtractDevicePathFromHiiHandle(HiiHandles
[Index
]);
667 if (DevicePathStr
!= NULL
){
668 DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
669 FreePool(DevicePathStr
);
671 HiiCreateGotoExOpCode (
677 (EFI_QUESTION_ID
) (Index
+ DEVICE_KEY_OFFSET
),
685 // Not network device process, only need to show at device manger form.
687 if (NextShowFormId
== DEVICE_MANAGER_FORM_ID
) {
688 DevicePathStr
= DmExtractDevicePathFromHiiHandle(HiiHandles
[Index
]);
690 if (DevicePathStr
!= NULL
){
691 DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
692 FreePool(DevicePathStr
);
694 HiiCreateGotoExOpCode (
700 (EFI_QUESTION_ID
) (Index
+ DEVICE_KEY_OFFSET
),
710 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
726 HiiFreeOpCodeHandle (StartOpCodeHandle
);
727 HiiFreeOpCodeHandle (EndOpCodeHandle
);
728 FreePool (HiiHandles
);
732 This function allows a caller to extract the current configuration for one
733 or more named elements from the target driver.
736 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
737 @param Request A null-terminated Unicode string in <ConfigRequest> format.
738 @param Progress On return, points to a character in the Request string.
739 Points to the string's null terminator if request was successful.
740 Points to the most recent '&' before the first failing name/value
741 pair (or the beginning of the string if the failure is in the
742 first name/value pair) if the request was not successful.
743 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
744 has all values filled in for the names in the Request string.
745 String to be allocated by the called function.
747 @retval EFI_SUCCESS The Results is filled with the requested values.
748 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
749 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
750 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
755 DeviceManagerExtractConfig (
756 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
757 IN CONST EFI_STRING Request
,
758 OUT EFI_STRING
*Progress
,
759 OUT EFI_STRING
*Results
762 if (Progress
== NULL
|| Results
== NULL
) {
763 return EFI_INVALID_PARAMETER
;
766 return EFI_NOT_FOUND
;
770 This function processes the results of changes in configuration.
772 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
773 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
774 @param Progress A pointer to a string filled in with the offset of the most
775 recent '&' before the first failing name/value pair (or the
776 beginning of the string if the failure is in the first
777 name/value pair) or the terminating NULL if all was successful.
779 @retval EFI_SUCCESS The Results is processed successfully.
780 @retval EFI_INVALID_PARAMETER Configuration is NULL.
781 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
786 DeviceManagerRouteConfig (
787 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
788 IN CONST EFI_STRING Configuration
,
789 OUT EFI_STRING
*Progress
792 if (Configuration
== NULL
|| Progress
== NULL
) {
793 return EFI_INVALID_PARAMETER
;
796 *Progress
= Configuration
;
798 return EFI_NOT_FOUND
;
802 This function is invoked if user selected a interactive opcode from Device Manager's
803 Formset. If user set VBIOS, the new value is saved to EFI variable.
805 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
806 @param Action Specifies the type of action taken by the browser.
807 @param QuestionId A unique value which is sent to the original exporting driver
808 so that it can identify the type of data to expect.
809 @param Type The type of value for the question.
810 @param Value A pointer to the data being sent to the original exporting driver.
811 @param ActionRequest On return, points to the action requested by the callback function.
813 @retval EFI_SUCCESS The callback successfully handled the action.
814 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
819 DeviceManagerCallback (
820 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
821 IN EFI_BROWSER_ACTION Action
,
822 IN EFI_QUESTION_ID QuestionId
,
824 IN EFI_IFR_TYPE_VALUE
*Value
,
825 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
830 if (Action
!= EFI_BROWSER_ACTION_CHANGING
) {
832 // Do nothing for other UEFI Action. Only do call back when data is changed.
834 return EFI_UNSUPPORTED
;
836 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
837 return EFI_INVALID_PARAMETER
;
839 if ((QuestionId
< MAX_KEY_SECTION_LEN
+ NETWORK_DEVICE_LIST_KEY_OFFSET
) && (QuestionId
>= NETWORK_DEVICE_LIST_KEY_OFFSET
)) {
841 // If user select the mac address, need to record mac address string to support next form show.
843 for (CurIndex
= 0; CurIndex
< mMacDeviceList
.CurListLen
; CurIndex
++) {
844 if (mMacDeviceList
.NodeList
[CurIndex
].QuestionId
== QuestionId
) {
845 mSelectedMacAddrString
= HiiGetString (gDeviceManagerPrivate
.HiiHandle
, mMacDeviceList
.NodeList
[CurIndex
].PromptId
, NULL
);
848 CreateDeviceManagerForm(NETWORK_DEVICE_FORM_ID
);
849 } else if(QuestionId
== QUESTION_NETWORK_DEVICE_ID
){
850 CreateDeviceManagerForm(NETWORK_DEVICE_LIST_FORM_ID
);
857 Install Boot Manager Menu driver.
859 @param ImageHandle The image handle.
860 @param SystemTable The system table.
862 @retval EFI_SUCEESS Install Boot manager menu success.
863 @retval Other Return error status.
868 DeviceManagerUiLibConstructor (
869 IN EFI_HANDLE ImageHandle
,
870 IN EFI_SYSTEM_TABLE
*SystemTable
875 gDeviceManagerPrivate
.DriverHandle
= NULL
;
876 Status
= gBS
->InstallMultipleProtocolInterfaces (
877 &gDeviceManagerPrivate
.DriverHandle
,
878 &gEfiDevicePathProtocolGuid
,
879 &mDeviceManagerHiiVendorDevicePath
,
880 &gEfiHiiConfigAccessProtocolGuid
,
881 &gDeviceManagerPrivate
.ConfigAccess
,
884 ASSERT_EFI_ERROR (Status
);
887 // Publish our HII data.
889 gDeviceManagerPrivate
.HiiHandle
= HiiAddPackages (
891 gDeviceManagerPrivate
.DriverHandle
,
893 DeviceManagerUiLibStrings
,
896 ASSERT (gDeviceManagerPrivate
.HiiHandle
!= NULL
);
899 // Update boot manager page
901 CreateDeviceManagerForm (DEVICE_MANAGER_FORM_ID
);
907 Unloads the application and its installed protocol.
909 @param ImageHandle Handle that identifies the image to be unloaded.
910 @param SystemTable The system table.
912 @retval EFI_SUCCESS The image has been unloaded.
916 DeviceManagerUiLibDestructor(
917 IN EFI_HANDLE ImageHandle
,
918 IN EFI_SYSTEM_TABLE
*SystemTable
923 Status
= gBS
->UninstallMultipleProtocolInterfaces (
924 gDeviceManagerPrivate
.DriverHandle
,
925 &gEfiDevicePathProtocolGuid
,
926 &mDeviceManagerHiiVendorDevicePath
,
927 &gEfiHiiConfigAccessProtocolGuid
,
928 &gDeviceManagerPrivate
.ConfigAccess
,
931 ASSERT_EFI_ERROR (Status
);
933 HiiRemovePackages (gDeviceManagerPrivate
.HiiHandle
);