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_HII_HANDLE HiiDeviceManagerHandle
;
351 EFI_HANDLE DriverHandle
;
352 EFI_HANDLE ControllerHandle
;
353 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
354 EFI_DEVICE_PATH_PROTOCOL
*TmpDevicePath
;
355 EFI_DEVICE_PATH_PROTOCOL
*ChildDevicePath
;
356 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfoBuffer
;
359 HiiDeviceManagerHandle
= gDeviceManagerPrivate
.HiiHandle
;
361 OpenInfoBuffer
= NULL
;
362 if ((Handle
== NULL
) || (ItemCount
== NULL
)) {
367 Status
= gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, Handle
, &DriverHandle
);
368 if (EFI_ERROR (Status
)) {
372 // Get the device path by the got Driver handle .
374 Status
= gBS
->HandleProtocol (DriverHandle
, &gEfiDevicePathProtocolGuid
, (VOID
**) &DevicePath
);
375 if (EFI_ERROR (Status
)) {
378 TmpDevicePath
= DevicePath
;
381 // Check whether this device path include mac address device path.
382 // If this path has mac address path, get the value whether need
383 // add this info to the menu and return.
384 // Else check more about the child handle devcie path.
386 if (IsMacAddressDevicePath(TmpDevicePath
, NextShowFormId
,&IsNeedAdd
)) {
387 if ((NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
) && IsNeedAdd
) {
394 // Search whether this path is the controller path, not he child handle path.
395 // And the child handle has the network devcie connected.
397 TmpDevicePath
= DevicePath
;
398 Status
= gBS
->LocateDevicePath(&gEfiDevicePathProtocolGuid
, &TmpDevicePath
, &ControllerHandle
);
399 if (EFI_ERROR (Status
)) {
403 if (!IsDevicePathEnd (TmpDevicePath
)) {
408 // Retrieve the list of agents that are consuming the specific protocol
409 // on ControllerHandle.
410 // The buffer point by OpenInfoBuffer need be free at this function.
412 Status
= gBS
->OpenProtocolInformation (
414 &gEfiPciIoProtocolGuid
,
418 if (EFI_ERROR (Status
)) {
423 // Inspect if ChildHandle is one of the agents.
425 Status
= EFI_UNSUPPORTED
;
426 for (Index
= 0; Index
< EntryCount
; Index
++) {
428 // Query all the children created by the controller handle's driver
430 if ((OpenInfoBuffer
[Index
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
431 Status
= gBS
->OpenProtocol (
432 OpenInfoBuffer
[Index
].ControllerHandle
,
433 &gEfiDevicePathProtocolGuid
,
434 (VOID
**) &ChildDevicePath
,
437 EFI_OPEN_PROTOCOL_GET_PROTOCOL
439 if (EFI_ERROR (Status
)) {
444 // Check whether this device path include mac address device path.
446 if (!IsMacAddressDevicePath(ChildDevicePath
, NextShowFormId
,&IsNeedAdd
)) {
448 // If this path not has mac address path, check the other.
453 // If need to update the NETWORK_DEVICE_LIST_FORM, try to get more.
455 if ((NETWORK_DEVICE_LIST_FORM_ID
== NextShowFormId
)) {
462 // If need to update other form, return whether need to add to the menu.
471 if (OpenInfoBuffer
!= NULL
) {
472 FreePool (OpenInfoBuffer
);
478 Dynamic create Hii information for Device Manager.
480 @param NextShowFormId The FormId which need to be show.
484 CreateDeviceManagerForm(
485 IN EFI_FORM_ID NextShowFormId
491 EFI_STRING_ID TokenHelp
;
492 EFI_HII_HANDLE
*HiiHandles
;
493 EFI_HII_HANDLE HiiHandle
;
494 EFI_GUID FormSetGuid
;
495 VOID
*StartOpCodeHandle
;
496 VOID
*EndOpCodeHandle
;
497 EFI_IFR_GUID_LABEL
*StartLabel
;
498 EFI_IFR_GUID_LABEL
*EndLabel
;
499 BOOLEAN AddNetworkMenu
;
502 EFI_STRING NewStringTitle
;
503 CHAR16
*DevicePathStr
;
504 EFI_STRING_ID DevicePathId
;
505 EFI_IFR_FORM_SET
*Buffer
;
517 HiiHandle
= gDeviceManagerPrivate
.HiiHandle
;
518 AddNetworkMenu
= FALSE
;
521 // If need show the Network device list form, clear the old save list first.
523 if ((NextShowFormId
== NETWORK_DEVICE_LIST_FORM_ID
) && (mMacDeviceList
.CurListLen
> 0)) {
524 mMacDeviceList
.CurListLen
= 0;
528 // Update the network device form titile.
530 if (NextShowFormId
== NETWORK_DEVICE_FORM_ID
) {
531 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE
), NULL
);
532 NewStringLen
= StrLen(mSelectedMacAddrString
) * 2;
533 NewStringLen
+= (StrLen(String
) + 2) * 2;
534 NewStringTitle
= AllocatePool (NewStringLen
);
535 UnicodeSPrint (NewStringTitle
, NewStringLen
, L
"%s %s", String
, mSelectedMacAddrString
);
536 HiiSetString (HiiHandle
, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE
), NewStringTitle
, NULL
);
538 FreePool (NewStringTitle
);
542 // Allocate space for creation of UpdateData Buffer
544 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
545 ASSERT (StartOpCodeHandle
!= NULL
);
547 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
548 ASSERT (EndOpCodeHandle
!= NULL
);
551 // Create Hii Extend Label OpCode as the start opcode
553 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
554 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
556 // According to the next show Form id(mNextShowFormId) to decide which form need to update.
558 StartLabel
->Number
= (UINT16
) (LABEL_FORM_ID_OFFSET
+ NextShowFormId
);
561 // Create Hii Extend Label OpCode as the end opcode
563 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
564 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
565 EndLabel
->Number
= LABEL_END
;
568 // Get all the Hii handles
570 HiiHandles
= HiiGetHiiHandles (NULL
);
571 ASSERT (HiiHandles
!= NULL
);
574 // Search for formset of each class type
576 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
577 Status
= HiiGetFormSetFromHiiHandle(HiiHandles
[Index
], &Buffer
,&BufferSize
);
578 if (EFI_ERROR (Status
)){
581 Ptr
= (UINT8
*)Buffer
;
582 while(TempSize
< BufferSize
) {
583 TempSize
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
584 if (((EFI_IFR_OP_HEADER
*) Ptr
)->Length
<= OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)){
585 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
589 ClassGuidNum
= (UINT8
) (((EFI_IFR_FORM_SET
*)Ptr
)->Flags
& 0x3);
590 ClassGuid
= (EFI_GUID
*) (VOID
*)(Ptr
+ sizeof (EFI_IFR_FORM_SET
));
591 while (ClassGuidNum
-- > 0) {
592 if (CompareGuid (&gEfiHiiPlatformSetupFormsetGuid
, ClassGuid
)== 0) {
597 String
= HiiGetString (HiiHandles
[Index
], ((EFI_IFR_FORM_SET
*)Ptr
)->FormSetTitle
, NULL
);
598 if (String
== NULL
) {
599 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
600 ASSERT (String
!= NULL
);
602 Token
= HiiSetString (HiiHandle
, 0, String
, NULL
);
605 String
= HiiGetString (HiiHandles
[Index
], ((EFI_IFR_FORM_SET
*)Ptr
)->Help
, NULL
);
606 if (String
== NULL
) {
607 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
608 ASSERT (String
!= NULL
);
610 TokenHelp
= HiiSetString (HiiHandle
, 0, String
, NULL
);
613 FormSetGuid
= ((EFI_IFR_FORM_SET
*)Ptr
)->Guid
;
616 // Network device process
618 if (IsNeedAddNetworkMenu (HiiHandles
[Index
], NextShowFormId
,&AddItemCount
)) {
619 if (NextShowFormId
== DEVICE_MANAGER_FORM_ID
) {
621 // Only show one menu item "Network Config" in the device manger form.
623 if (!AddNetworkMenu
) {
624 AddNetworkMenu
= TRUE
;
625 HiiCreateGotoOpCode (
627 NETWORK_DEVICE_LIST_FORM_ID
,
628 STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_TITLE
),
629 STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_HELP
),
630 EFI_IFR_FLAG_CALLBACK
,
631 (EFI_QUESTION_ID
) QUESTION_NETWORK_DEVICE_ID
634 } else if (NextShowFormId
== NETWORK_DEVICE_LIST_FORM_ID
) {
636 // In network device list form, same mac address device only show one menu.
638 while (AddItemCount
> 0) {
639 HiiCreateGotoOpCode (
641 NETWORK_DEVICE_FORM_ID
,
642 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
- AddItemCount
].PromptId
,
643 STRING_TOKEN (STR_NETWORK_DEVICE_HELP
),
644 EFI_IFR_FLAG_CALLBACK
,
645 mMacDeviceList
.NodeList
[mMacDeviceList
.CurListLen
- AddItemCount
].QuestionId
649 } else if (NextShowFormId
== NETWORK_DEVICE_FORM_ID
) {
651 // In network device form, only the selected mac address device need to be show.
653 DevicePathStr
= DmExtractDevicePathFromHiiHandle(HiiHandles
[Index
]);
655 if (DevicePathStr
!= NULL
){
656 DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
657 FreePool(DevicePathStr
);
659 HiiCreateGotoExOpCode (
665 (EFI_QUESTION_ID
) (Index
+ DEVICE_KEY_OFFSET
),
673 // Not network device process, only need to show at device manger form.
675 if (NextShowFormId
== DEVICE_MANAGER_FORM_ID
) {
676 DevicePathStr
= DmExtractDevicePathFromHiiHandle(HiiHandles
[Index
]);
678 if (DevicePathStr
!= NULL
){
679 DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
680 FreePool(DevicePathStr
);
682 HiiCreateGotoExOpCode (
688 (EFI_QUESTION_ID
) (Index
+ DEVICE_KEY_OFFSET
),
698 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
714 HiiFreeOpCodeHandle (StartOpCodeHandle
);
715 HiiFreeOpCodeHandle (EndOpCodeHandle
);
716 FreePool (HiiHandles
);
720 This function allows a caller to extract the current configuration for one
721 or more named elements from the target driver.
724 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
725 @param Request A null-terminated Unicode string in <ConfigRequest> format.
726 @param Progress On return, points to a character in the Request string.
727 Points to the string's null terminator if request was successful.
728 Points to the most recent '&' before the first failing name/value
729 pair (or the beginning of the string if the failure is in the
730 first name/value pair) if the request was not successful.
731 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
732 has all values filled in for the names in the Request string.
733 String to be allocated by the called function.
735 @retval EFI_SUCCESS The Results is filled with the requested values.
736 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
737 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
738 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
743 DeviceManagerExtractConfig (
744 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
745 IN CONST EFI_STRING Request
,
746 OUT EFI_STRING
*Progress
,
747 OUT EFI_STRING
*Results
750 if (Progress
== NULL
|| Results
== NULL
) {
751 return EFI_INVALID_PARAMETER
;
754 return EFI_NOT_FOUND
;
758 This function processes the results of changes in configuration.
760 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
761 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
762 @param Progress A pointer to a string filled in with the offset of the most
763 recent '&' before the first failing name/value pair (or the
764 beginning of the string if the failure is in the first
765 name/value pair) or the terminating NULL if all was successful.
767 @retval EFI_SUCCESS The Results is processed successfully.
768 @retval EFI_INVALID_PARAMETER Configuration is NULL.
769 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
774 DeviceManagerRouteConfig (
775 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
776 IN CONST EFI_STRING Configuration
,
777 OUT EFI_STRING
*Progress
780 if (Configuration
== NULL
|| Progress
== NULL
) {
781 return EFI_INVALID_PARAMETER
;
784 *Progress
= Configuration
;
786 return EFI_NOT_FOUND
;
790 This function is invoked if user selected a interactive opcode from Device Manager's
791 Formset. If user set VBIOS, the new value is saved to EFI variable.
793 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
794 @param Action Specifies the type of action taken by the browser.
795 @param QuestionId A unique value which is sent to the original exporting driver
796 so that it can identify the type of data to expect.
797 @param Type The type of value for the question.
798 @param Value A pointer to the data being sent to the original exporting driver.
799 @param ActionRequest On return, points to the action requested by the callback function.
801 @retval EFI_SUCCESS The callback successfully handled the action.
802 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
807 DeviceManagerCallback (
808 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
809 IN EFI_BROWSER_ACTION Action
,
810 IN EFI_QUESTION_ID QuestionId
,
812 IN EFI_IFR_TYPE_VALUE
*Value
,
813 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
818 if (Action
!= EFI_BROWSER_ACTION_CHANGING
) {
820 // Do nothing for other UEFI Action. Only do call back when data is changed.
822 return EFI_UNSUPPORTED
;
824 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
825 return EFI_INVALID_PARAMETER
;
827 if ((QuestionId
< MAX_KEY_SECTION_LEN
+ NETWORK_DEVICE_LIST_KEY_OFFSET
) && (QuestionId
>= NETWORK_DEVICE_LIST_KEY_OFFSET
)) {
829 // If user select the mac address, need to record mac address string to support next form show.
831 for (CurIndex
= 0; CurIndex
< mMacDeviceList
.CurListLen
; CurIndex
++) {
832 if (mMacDeviceList
.NodeList
[CurIndex
].QuestionId
== QuestionId
) {
833 mSelectedMacAddrString
= HiiGetString (gDeviceManagerPrivate
.HiiHandle
, mMacDeviceList
.NodeList
[CurIndex
].PromptId
, NULL
);
836 CreateDeviceManagerForm(NETWORK_DEVICE_FORM_ID
);
837 } else if(QuestionId
== QUESTION_NETWORK_DEVICE_ID
){
838 CreateDeviceManagerForm(NETWORK_DEVICE_LIST_FORM_ID
);
845 Install Boot Manager Menu driver.
847 @param ImageHandle The image handle.
848 @param SystemTable The system table.
850 @retval EFI_SUCEESS Install Boot manager menu success.
851 @retval Other Return error status.
856 DeviceManagerUiLibConstructor (
857 IN EFI_HANDLE ImageHandle
,
858 IN EFI_SYSTEM_TABLE
*SystemTable
863 gDeviceManagerPrivate
.DriverHandle
= NULL
;
864 Status
= gBS
->InstallMultipleProtocolInterfaces (
865 &gDeviceManagerPrivate
.DriverHandle
,
866 &gEfiDevicePathProtocolGuid
,
867 &mDeviceManagerHiiVendorDevicePath
,
868 &gEfiHiiConfigAccessProtocolGuid
,
869 &gDeviceManagerPrivate
.ConfigAccess
,
872 ASSERT_EFI_ERROR (Status
);
875 // Publish our HII data.
877 gDeviceManagerPrivate
.HiiHandle
= HiiAddPackages (
879 gDeviceManagerPrivate
.DriverHandle
,
881 DeviceManagerUiLibStrings
,
884 ASSERT (gDeviceManagerPrivate
.HiiHandle
!= NULL
);
887 // Update boot manager page
889 CreateDeviceManagerForm (DEVICE_MANAGER_FORM_ID
);
895 Unloads the application and its installed protocol.
897 @param ImageHandle Handle that identifies the image to be unloaded.
898 @param SystemTable The system table.
900 @retval EFI_SUCCESS The image has been unloaded.
904 DeviceManagerUiLibDestructor(
905 IN EFI_HANDLE ImageHandle
,
906 IN EFI_SYSTEM_TABLE
*SystemTable
911 Status
= gBS
->UninstallMultipleProtocolInterfaces (
912 gDeviceManagerPrivate
.DriverHandle
,
913 &gEfiDevicePathProtocolGuid
,
914 &mDeviceManagerHiiVendorDevicePath
,
915 &gEfiHiiConfigAccessProtocolGuid
,
916 &gDeviceManagerPrivate
.ConfigAccess
,
919 ASSERT_EFI_ERROR (Status
);
921 HiiRemovePackages (gDeviceManagerPrivate
.HiiHandle
);