/** @file\r
The platform device manager reference implementation\r
\r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
//\r
// Which form Id need to be show.\r
//\r
-EFI_FORM_ID mNextShowFormId = DEVICE_MANAGER_FORM_ID; \r
+EFI_FORM_ID mNextShowFormId = DEVICE_MANAGER_FORM_ID;\r
\r
//\r
// The Mac Address show in the NETWORK_DEVICE_LIST_FORM_ID\r
{\r
END_DEVICE_PATH_TYPE,\r
END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- { \r
+ {\r
(UINT8) (END_DEVICE_PATH_LENGTH),\r
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
}\r
{\r
END_DEVICE_PATH_TYPE,\r
END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- { \r
+ {\r
(UINT8) (END_DEVICE_PATH_LENGTH),\r
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
}\r
\r
@param Handle The HII handle.\r
@param SetupClassGuid The class guid specifies which form set will be displayed.\r
+ @param SkipCount Skip some formsets which has processed before.\r
@param FormSetTitle Formset title string.\r
@param FormSetHelp Formset help string.\r
+ @param FormSetGuid Return the formset guid for this formset.\r
\r
@retval TRUE The formset for given HII handle will be displayed.\r
@return FALSE The formset for given HII handle will not be displayed.\r
ExtractDisplayedHiiFormFromHiiHandle (\r
IN EFI_HII_HANDLE Handle,\r
IN EFI_GUID *SetupClassGuid,\r
+ IN UINTN SkipCount,\r
OUT EFI_STRING_ID *FormSetTitle,\r
- OUT EFI_STRING_ID *FormSetHelp\r
+ OUT EFI_STRING_ID *FormSetHelp,\r
+ OUT EFI_GUID **FormSetGuid\r
)\r
{\r
EFI_STATUS Status;\r
UINT8 ClassGuidNum;\r
\r
ASSERT (Handle != NULL);\r
- ASSERT (SetupClassGuid != NULL); \r
+ ASSERT (SetupClassGuid != NULL);\r
ASSERT (FormSetTitle != NULL);\r
ASSERT (FormSetHelp != NULL);\r
\r
// The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.\r
//\r
ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
- \r
+\r
HiiPackageList = AllocatePool (BufferSize);\r
ASSERT (HiiPackageList != NULL);\r
\r
Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);\r
while (Offset2 < PackageHeader.Length) {\r
OpCodeData = Package + Offset2;\r
+ Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;\r
\r
if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {\r
+ if (SkipCount != 0) {\r
+ SkipCount --;\r
+ continue;\r
+ }\r
+\r
if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {\r
//\r
// Find FormSet OpCode\r
if (CompareGuid (SetupClassGuid, ClassGuid)) {\r
CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));\r
+ *FormSetGuid = AllocateCopyPool (sizeof (EFI_GUID), &((EFI_IFR_FORM_SET *) OpCodeData)->Guid);\r
+ ASSERT (*FormSetGuid != NULL);\r
FreePool (HiiPackageList);\r
return TRUE;\r
}\r
} else {\r
CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));\r
+ *FormSetGuid = AllocateCopyPool (sizeof (EFI_GUID), &((EFI_IFR_FORM_SET *) OpCodeData)->Guid);\r
+ ASSERT (*FormSetGuid != NULL);\r
FreePool (HiiPackageList);\r
return TRUE;\r
}\r
}\r
- \r
- //\r
- // Go to next opcode\r
- //\r
- Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;\r
}\r
}\r
- \r
+\r
//\r
// Go to next package\r
//\r
/**\r
Get the mac address string from the device path.\r
if the device path has the vlan, get the vanid also.\r
- \r
- @param MacAddressNode Device path begin with mac address \r
+\r
+ @param MacAddressNode Device path begin with mac address\r
@param PBuffer Output string buffer contain mac address.\r
\r
**/\r
-BOOLEAN \r
+BOOLEAN\r
GetMacAddressString(\r
IN MAC_ADDR_DEVICE_PATH *MacAddressNode,\r
OUT CHAR16 **PBuffer\r
}\r
\r
*PBuffer = String;\r
- StrCpy(String, L"MAC:");\r
+ StrCpyS (String, BufferLen / sizeof (CHAR16), L"MAC:");\r
String += 4;\r
- \r
+\r
//\r
// Convert the MAC address into a unicode string.\r
//\r
HwAddress = &MacAddressNode->MacAddress.Addr[0];\r
for (Index = 0; Index < HwAddressSize; Index++) {\r
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);\r
+ UnicodeValueToStringS (\r
+ String,\r
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ *(HwAddress++),\r
+ 2\r
+ );\r
+ String += StrnLenS (String, (BufferLen - ((UINTN)String - (UINTN)*PBuffer)) / sizeof (CHAR16));\r
if (Index < HwAddressSize - 1) {\r
*String++ = L':';\r
}\r
}\r
- \r
+\r
//\r
// If VLAN is configured, it will need extra 5 characters like "\0005".\r
// Plus one unicode character for the null-terminator.\r
\r
if (VlanId != 0) {\r
*String++ = L'\\';\r
- String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);\r
+ UnicodeValueToStringS (\r
+ String,\r
+ BufferLen - ((UINTN)String - (UINTN)*PBuffer),\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ VlanId,\r
+ 4\r
+ );\r
+ String += StrnLenS (String, (BufferLen - ((UINTN)String - (UINTN)*PBuffer)) / sizeof (CHAR16));\r
}\r
\r
//\r
@retval EFI_SUCCESS Add the item is successful.\r
@return Other values if failed to Add the item.\r
**/\r
-BOOLEAN \r
+BOOLEAN\r
AddIdToMacDeviceList (\r
IN EFI_STRING MacAddrString\r
)\r
} else {\r
mMacDeviceList.MaxListLen += MAX_MAC_ADDRESS_NODE_LIST_LEN;\r
if (mMacDeviceList.CurListLen != 0) {\r
- TempDeviceList = (MENU_INFO_ITEM *)AllocateCopyPool (sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen, (VOID *)mMacDeviceList.NodeList);\r
+ TempDeviceList = ReallocatePool (\r
+ sizeof (MENU_INFO_ITEM) * mMacDeviceList.CurListLen,\r
+ sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen,\r
+ mMacDeviceList.NodeList\r
+ );\r
} else {\r
TempDeviceList = (MENU_INFO_ITEM *)AllocatePool (sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen);\r
}\r
- \r
+\r
if (TempDeviceList == NULL) {\r
return FALSE;\r
}\r
- TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId; \r
+ TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId;\r
TempDeviceList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) (mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);\r
- \r
- if (mMacDeviceList.CurListLen > 0) {\r
- FreePool(mMacDeviceList.NodeList);\r
- }\r
- \r
+\r
mMacDeviceList.NodeList = TempDeviceList;\r
}\r
mMacDeviceList.CurListLen ++;\r
\r
@param *Node Input device which need to be check.\r
@param *NeedAddItem Whether need to add the menu in the network device list.\r
- \r
+\r
@retval TRUE Has mac address device path.\r
- @retval FALSE NOT Has mac address device path. \r
+ @retval FALSE NOT Has mac address device path.\r
\r
**/\r
BOOLEAN\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
CHAR16 *Buffer;\r
BOOLEAN ReturnVal;\r
- \r
+\r
ASSERT (Node != NULL);\r
*NeedAddItem = FALSE;\r
ReturnVal = FALSE;\r
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&\r
(DevicePathSubType (DevicePath) == MSG_MAC_ADDR_DP)) {\r
ReturnVal = TRUE;\r
- \r
+\r
if (DEVICE_MANAGER_FORM_ID == mNextShowFormId) {\r
*NeedAddItem = TRUE;\r
break;\r
- } \r
- \r
+ }\r
+\r
if (!GetMacAddressString((MAC_ADDR_DEVICE_PATH*)DevicePath, &Buffer)) {\r
break;\r
}\r
\r
if (NETWORK_DEVICE_LIST_FORM_ID == mNextShowFormId) {\r
//\r
- // Same handle may has two network child handle, so the questionid \r
+ // Same handle may has two network child handle, so the questionid\r
// has the offset of SAME_HANDLE_KEY_OFFSET.\r
//\r
if (AddIdToMacDeviceList (Buffer)) {\r
}\r
break;\r
}\r
- } \r
+ }\r
DevicePath = NextDevicePathNode (DevicePath);\r
}\r
\r
@return FALSE Do not need to add the menu about the network.\r
\r
**/\r
-BOOLEAN \r
+BOOLEAN\r
IsNeedAddNetworkMenu (\r
IN EFI_HII_HANDLE Handle,\r
OUT UINTN *ItemCount\r
{\r
EFI_STATUS Status;\r
UINTN EntryCount;\r
- UINTN Index; \r
+ UINTN Index;\r
EFI_HANDLE DriverHandle;\r
EFI_HANDLE ControllerHandle;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
}\r
TmpDevicePath = DevicePath;\r
\r
- // \r
+ //\r
// Check whether this device path include mac address device path.\r
- // If this path has mac address path, get the value whether need \r
+ // If this path has mac address path, get the value whether need\r
// add this info to the menu and return.\r
// Else check more about the child handle devcie path.\r
//\r
}\r
\r
if (!IsDevicePathEnd (TmpDevicePath)) {\r
- return FALSE; \r
+ return FALSE;\r
}\r
\r
//\r
continue;\r
}\r
\r
- // \r
+ //\r
// Check whether this device path include mac address device path.\r
//\r
if (!IsMacAddressDevicePath(ChildDevicePath, &IsNeedAdd)) {\r
} else {\r
//\r
// If need to update other form, return whether need to add to the menu.\r
- // \r
+ //\r
goto Done;\r
}\r
}\r
\r
Done:\r
if (OpenInfoBuffer != NULL) {\r
- FreePool (OpenInfoBuffer); \r
+ FreePool (OpenInfoBuffer);\r
+ }\r
+ return IsNeedAdd;\r
+}\r
+\r
+/**\r
+ Get HiiHandle total number.\r
+\r
+ @param HiiHandles The input HiiHandle array.\r
+\r
+ @retval the Hiihandle count.\r
+\r
+**/\r
+UINTN\r
+GetHiiHandleCount (\r
+ IN EFI_HII_HANDLE *HiiHandles\r
+ )\r
+{\r
+ UINTN Index;\r
+\r
+ for (Index = 0; HiiHandles[Index] != NULL; Index++) {\r
}\r
- return IsNeedAdd; \r
+\r
+ return Index;\r
+}\r
+\r
+/**\r
+ Insert the new HiiHandle + FormsetGuid at the NewPair[InsertOffset].\r
+\r
+ @param HiiHandles The input HiiHandle array.\r
+ @param GuidLists The input form set guid lists.\r
+ @param ArrayCount The input array count, new array will be arraycount + 1 size.\r
+ @param Offset The current used HiiHandle's Offset.\r
+ @param FormSetGuid The new found formset guid.\r
+\r
+**/\r
+VOID\r
+AdjustArrayData (\r
+ IN OUT EFI_HII_HANDLE **HiiHandles,\r
+ IN OUT EFI_GUID ***GuidLists,\r
+ IN UINTN ArrayCount,\r
+ IN UINTN Offset,\r
+ IN EFI_GUID *FormSetGuid\r
+ )\r
+{\r
+ EFI_HII_HANDLE *NewHiiHandles;\r
+ EFI_GUID **NewGuidLists;\r
+\r
+ //\r
+ // +2 means include the new HiiHandle and the last empty NULL pointer.\r
+ //\r
+ NewHiiHandles = AllocateZeroPool ((ArrayCount + 2) * sizeof (EFI_HII_HANDLE));\r
+ ASSERT (NewHiiHandles != NULL);\r
+\r
+ CopyMem (NewHiiHandles, *HiiHandles, Offset * sizeof (EFI_HII_HANDLE));\r
+ NewHiiHandles[Offset] = NewHiiHandles[Offset - 1];\r
+ CopyMem (NewHiiHandles + Offset + 1, *HiiHandles + Offset, (ArrayCount - Offset) * sizeof (EFI_HII_HANDLE));\r
+\r
+ NewGuidLists = AllocateZeroPool ((ArrayCount + 2) * sizeof (EFI_GUID *));\r
+ ASSERT (NewGuidLists != NULL);\r
+\r
+ CopyMem (NewGuidLists, *GuidLists, Offset * sizeof (EFI_GUID *));\r
+ NewGuidLists[Offset] = FormSetGuid;\r
+\r
+ FreePool (*HiiHandles);\r
+ *HiiHandles = NewHiiHandles;\r
+ FreePool (*GuidLists);\r
+ *GuidLists = NewGuidLists;\r
}\r
\r
/**\r
\r
This function create the dynamic content for device manager. It includes\r
section header for all class of devices, one-of opcode to set VBIOS.\r
- \r
+\r
@retval EFI_SUCCESS Operation is successful.\r
@return Other values if failed to clean up the dynamic content from HII\r
database.\r
UINTN AddItemCount;\r
UINTN NewStringLen;\r
EFI_STRING NewStringTitle;\r
+ EFI_GUID **GuidLists;\r
+ UINTN HandleNum;\r
+ UINTN SkipCount;\r
+ EFI_GUID *FormSetGuid;\r
\r
+ GuidLists = NULL;\r
HiiHandles = NULL;\r
Status = EFI_SUCCESS;\r
gCallbackKey = 0;\r
DriverHealthHandles = NULL;\r
AddNetworkMenu = FALSE;\r
AddItemCount = 0;\r
+ SkipCount = 0;\r
+ FormSetGuid = NULL;\r
\r
//\r
// Connect all prior to entering the platform setup menu.\r
NewStringLen += (StrLen(String) + 2) * 2;\r
NewStringTitle = AllocatePool (NewStringLen);\r
UnicodeSPrint (NewStringTitle, NewStringLen, L"%s %s", String, mSelectedMacAddrString);\r
- HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NewStringTitle, NULL); \r
+ HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NewStringTitle, NULL);\r
FreePool (String);\r
FreePool (NewStringTitle);\r
}\r
HiiHandles = HiiGetHiiHandles (NULL);\r
ASSERT (HiiHandles != NULL);\r
\r
+ HandleNum = GetHiiHandleCount (HiiHandles);\r
+ GuidLists = AllocateZeroPool ((HandleNum + 1) * sizeof (EFI_GUID *));\r
+ ASSERT (GuidLists != NULL);\r
+\r
//\r
// Search for formset of each class type\r
//\r
//\r
ASSERT(Index < MAX_KEY_SECTION_LEN);\r
\r
- if (!ExtractDisplayedHiiFormFromHiiHandle (HiiHandles[Index], &gEfiHiiPlatformSetupFormsetGuid, &FormSetTitle, &FormSetHelp)) {\r
+ if (!ExtractDisplayedHiiFormFromHiiHandle (HiiHandles[Index], &gEfiHiiPlatformSetupFormsetGuid, SkipCount, &FormSetTitle, &FormSetHelp, &FormSetGuid)) {\r
+ SkipCount = 0;\r
continue;\r
}\r
\r
+ //\r
+ // One HiiHandle has more than one formset can be shown,\r
+ // Insert a new pair of HiiHandle + Guid to the HiiHandles and GuidLists list.\r
+ //\r
+ if (SkipCount > 0) {\r
+ AdjustArrayData (&HiiHandles, &GuidLists, HandleNum, Index + 1, FormSetGuid);\r
+ HandleNum ++;\r
+ Index ++;\r
+ }\r
+\r
String = HiiGetString (HiiHandles[Index], FormSetTitle, NULL);\r
if (String == NULL) {\r
String = HiiGetString (HiiHandle, STR_MISSING_STRING, NULL);\r
\r
//\r
// Network device process\r
- // \r
+ //\r
if (IsNeedAddNetworkMenu (HiiHandles[Index], &AddItemCount)) {\r
if (mNextShowFormId == DEVICE_MANAGER_FORM_ID) {\r
//\r
}\r
} else {\r
//\r
- // \r
+ //\r
// Not network device process, only need to show at device manger form.\r
//\r
if (mNextShowFormId == DEVICE_MANAGER_FORM_ID) {\r
);\r
}\r
}\r
+\r
+ //\r
+ // Try to find more formset in this HiiHandle.\r
+ //\r
+ SkipCount++;\r
+ Index--;\r
}\r
\r
Status = gBS->LocateHandleBuffer (\r
gFormBrowser2,\r
&HiiHandles[gCallbackKey - DEVICE_KEY_OFFSET],\r
1,\r
- NULL,\r
+ GuidLists[gCallbackKey - DEVICE_KEY_OFFSET],\r
0,\r
NULL,\r
&ActionRequest\r
}\r
\r
//\r
- // Driver Health item chose. \r
+ // Driver Health item chose.\r
//\r
if (gCallbackKey == DEVICE_MANAGER_KEY_DRIVER_HEALTH) {\r
CallDriverHealth ();\r
// In this case, go from the network device list to the specify device.\r
//\r
if ((gCallbackKey < MAX_KEY_SECTION_LEN + NETWORK_DEVICE_LIST_KEY_OFFSET ) && (gCallbackKey >= NETWORK_DEVICE_LIST_KEY_OFFSET)) {\r
- mNextShowFormId = NETWORK_DEVICE_FORM_ID;\r
+ mNextShowFormId = NETWORK_DEVICE_FORM_ID;\r
gCallbackKey = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
goto Done;\r
}\r
HiiFreeOpCodeHandle (EndOpCodeHandle);\r
FreePool (HiiHandles);\r
\r
+ for (Index = 0; Index < HandleNum; Index++) {\r
+ if (GuidLists[Index] != NULL) {\r
+ FreePool (GuidLists[Index]);\r
+ }\r
+ }\r
+ FreePool (GuidLists);\r
+\r
return Status;\r
}\r
\r
}\r
\r
/**\r
- Collect and display the platform's driver health relative information, allow user to do interactive \r
+ Collect and display the platform's driver health relative information, allow user to do interactive\r
operation while the platform is unhealthy.\r
\r
- This function display a form which divided into two parts. The one list all modules which has installed \r
+ This function display a form which divided into two parts. The one list all modules which has installed\r
driver health protocol. The list usually contain driver name, controller name, and it's health info.\r
While the driver name can't be retrieved, will use device path as backup. The other part of the form provide\r
a choice to the user to repair all platform.\r
VOID\r
)\r
{\r
- EFI_STATUS Status; \r
+ EFI_STATUS Status;\r
EFI_HII_HANDLE HiiHandle;\r
EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
EFI_IFR_GUID_LABEL *StartLabel;\r
LIST_ENTRY *Link;\r
EFI_DEVICE_PATH_PROTOCOL *DriverDevicePath;\r
BOOLEAN RebootRequired;\r
+ BOOLEAN IsControllerNameEmpty;\r
+ UINTN StringSize;\r
\r
Index = 0;\r
- DriverHealthInfo = NULL; \r
+ DriverHealthInfo = NULL;\r
DriverDevicePath = NULL;\r
+ IsControllerNameEmpty = FALSE;\r
InitializeListHead (&DriverHealthList);\r
\r
HiiHandle = gDeviceManagerPrivate.DriverHealthHiiHandle;\r
\r
Link = GetFirstNode (&DriverHealthList);\r
\r
- while (!IsNull (&DriverHealthList, Link)) { \r
+ while (!IsNull (&DriverHealthList, Link)) {\r
DriverHealthInfo = DEVICE_MANAGER_HEALTH_INFO_FROM_LINK (Link);\r
- \r
- //\r
- // Assume no line strings is longer than 512 bytes.\r
- //\r
- String = (EFI_STRING) AllocateZeroPool (0x200);\r
- ASSERT (String != NULL);\r
\r
Status = DriverHealthGetDriverName (DriverHealthInfo->DriverHandle, &DriverName);\r
if (EFI_ERROR (Status)) {\r
DriverDevicePath = DevicePathFromHandle (DriverHealthInfo->DriverHandle);\r
DriverName = DevicePathToStr (DriverDevicePath);\r
}\r
- //\r
- // Add the Driver name & Controller name into FormSetTitle string\r
- // \r
- StrnCat (String, DriverName, StrLen (DriverName));\r
-\r
+ StringSize = StrSize (DriverName);\r
\r
Status = DriverHealthGetControllerName (\r
- DriverHealthInfo->DriverHandle, \r
- DriverHealthInfo->ControllerHandle, \r
- DriverHealthInfo->ChildHandle, \r
+ DriverHealthInfo->DriverHandle,\r
+ DriverHealthInfo->ControllerHandle,\r
+ DriverHealthInfo->ChildHandle,\r
&ControllerName\r
);\r
\r
if (!EFI_ERROR (Status)) {\r
- //\r
- // Can not get the Controller name, just let it empty.\r
- //\r
- StrnCat (String, L" ", StrLen (L" "));\r
- StrnCat (String, ControllerName, StrLen (ControllerName)); \r
+ IsControllerNameEmpty = FALSE;\r
+ StringSize += StrLen (L" ") * sizeof(CHAR16);\r
+ StringSize += StrLen (ControllerName) * sizeof(CHAR16);\r
+ } else {\r
+ IsControllerNameEmpty = TRUE;\r
}\r
- \r
+\r
//\r
// Add the message of the Module itself provided after the string item.\r
//\r
if ((DriverHealthInfo->MessageList != NULL) && (DriverHealthInfo->MessageList->StringId != 0)) {\r
- StrnCat (String, L" ", StrLen (L" "));\r
TmpString = HiiGetString (\r
- DriverHealthInfo->MessageList->HiiHandle, \r
- DriverHealthInfo->MessageList->StringId, \r
+ DriverHealthInfo->MessageList->HiiHandle,\r
+ DriverHealthInfo->MessageList->StringId,\r
NULL\r
);\r
+ ASSERT (TmpString != NULL);\r
+\r
+ StringSize += StrLen (L" ") * sizeof(CHAR16);\r
+ StringSize += StrLen (TmpString) * sizeof(CHAR16);\r
+\r
+ String = (EFI_STRING) AllocateZeroPool (StringSize);\r
+ ASSERT (String != NULL);\r
+\r
+ StrCpyS (String, StringSize / sizeof(CHAR16), DriverName);\r
+ if (!IsControllerNameEmpty) {\r
+ StrCatS (String, StringSize / sizeof(CHAR16), L" ");\r
+ StrCatS (String, StringSize / sizeof(CHAR16), ControllerName);\r
+ }\r
+\r
+ StrCatS (String, StringSize / sizeof(CHAR16), L" ");\r
+ StrCatS (String, StringSize / sizeof(CHAR16), TmpString);\r
+\r
} else {\r
//\r
// Update the string will be displayed base on the driver's health status\r
TmpString = GetStringById (STRING_TOKEN (STR_DRIVER_HEALTH_HEALTHY));\r
break;\r
}\r
+ ASSERT (TmpString != NULL);\r
+\r
+ StringSize += StrLen (TmpString) * sizeof(CHAR16);\r
+\r
+ String = (EFI_STRING) AllocateZeroPool (StringSize);\r
+ ASSERT (String != NULL);\r
+\r
+ StrCpyS (String, StringSize / sizeof (CHAR16), DriverName);\r
+ if (!IsControllerNameEmpty) {\r
+ StrCatS (String, StringSize / sizeof (CHAR16), L" ");\r
+ StrCatS (String, StringSize / sizeof (CHAR16), ControllerName);\r
+ }\r
+\r
+ StrCatS (String, StringSize / sizeof (CHAR16), TmpString);\r
}\r
\r
- ASSERT (TmpString != NULL);\r
- StrCat (String, TmpString);\r
FreePool (TmpString);\r
\r
Token = HiiSetString (HiiHandle, 0, String, NULL);\r
Index++;\r
Link = GetNextNode (&DriverHealthList, Link);\r
}\r
- \r
+\r
//\r
// Add End Opcode for Subtitle\r
- // \r
+ //\r
HiiCreateEndOpCode (StartOpCodeHandle);\r
\r
HiiCreateSubTitleOpCode (StartOpCodeHandleRepair, STRING_TOKEN (STR_DRIVER_HEALTH_REPAIR_ALL), 0, 0, 1);\r
- TokenHelp = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DH_REPAIR_ALL_HELP)), NULL); \r
+ TokenHelp = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DH_REPAIR_ALL_HELP)), NULL);\r
\r
if (PlaformHealthStatusCheck ()) {\r
//\r
// We will have returned from processing a callback - user either hit ESC to exit, or selected\r
// a target to display.\r
// Process the diver health status states here.\r
- // \r
+ //\r
if (gCallbackKey >= DRIVER_HEALTH_KEY_OFFSET && gCallbackKey != DRIVER_HEALTH_REPAIR_ALL_KEY) {\r
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
\r
//\r
// Got the item relative node in the List\r
//\r
- if (Index == (gCallbackKey - DRIVER_HEALTH_KEY_OFFSET)) { \r
+ if (Index == (gCallbackKey - DRIVER_HEALTH_KEY_OFFSET)) {\r
DriverHealthInfo = DEVICE_MANAGER_HEALTH_INFO_FROM_LINK (Link);\r
//\r
// Process the driver's healthy status for the specify module\r
RebootRequired = FALSE;\r
ProcessSingleControllerHealth (\r
DriverHealthInfo->DriverHealth,\r
- DriverHealthInfo->ControllerHandle, \r
+ DriverHealthInfo->ControllerHandle,\r
DriverHealthInfo->ChildHandle,\r
DriverHealthInfo->HealthStatus,\r
&(DriverHealthInfo->MessageList),\r
if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
EnableResetRequired ();\r
}\r
- \r
+\r
//\r
- // Force return to the form of Driver Health in Device Manager \r
+ // Force return to the form of Driver Health in Device Manager\r
//\r
gCallbackKey = DRIVER_HEALTH_RETURN_KEY;\r
}\r
//\r
if (gCallbackKey == DRIVER_HEALTH_REPAIR_ALL_KEY) {\r
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
- \r
+\r
PlatformRepairAll (&DriverHealthList);\r
\r
gCallbackKey = DRIVER_HEALTH_RETURN_KEY;\r
}\r
- \r
+\r
//\r
// Remove driver health packagelist from HII database.\r
//\r
if (DriverHealthInfo->MessageList != NULL) {\r
FreePool(DriverHealthInfo->MessageList);\r
FreePool (DriverHealthInfo);\r
- } \r
+ }\r
}\r
\r
HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle); \r
+ HiiFreeOpCodeHandle (EndOpCodeHandle);\r
HiiFreeOpCodeHandle (StartOpCodeHandleRepair);\r
- HiiFreeOpCodeHandle (EndOpCodeHandleRepair); \r
+ HiiFreeOpCodeHandle (EndOpCodeHandleRepair);\r
\r
if (gCallbackKey == DRIVER_HEALTH_RETURN_KEY) {\r
//\r
This function called by CheckAllControllersHealthStatus () function in order to process a specify\r
contoller's health state.\r
\r
- @param DriverHealthList A Pointer to the list contain all of the platform driver health information. \r
+ @param DriverHealthList A Pointer to the list contain all of the platform driver health information.\r
@param DriverHandle The handle of driver.\r
@param ControllerHandle The class guid specifies which form set will be displayed.\r
- @param ChildHandle The handle of the child controller to retrieve the health \r
- status on. This is an optional parameter that may be NULL. \r
+ @param ChildHandle The handle of the child controller to retrieve the health\r
+ status on. This is an optional parameter that may be NULL.\r
@param DriverHealth A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r
@param HealthStatus The health status of the controller.\r
\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- DriverHealthInfo->Signature = DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE; \r
+ DriverHealthInfo->Signature = DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE;\r
DriverHealthInfo->DriverHandle = DriverHandle;\r
DriverHealthInfo->ControllerHandle = ControllerHandle;\r
DriverHealthInfo->ChildHandle = ChildHandle;\r
}\r
\r
/**\r
- Collects all the EFI Driver Health Protocols currently present in the EFI Handle Database, \r
- and queries each EFI Driver Health Protocol to determine if one or more of the controllers \r
- managed by each EFI Driver Health Protocol instance are not healthy. \r
+ Collects all the EFI Driver Health Protocols currently present in the EFI Handle Database,\r
+ and queries each EFI Driver Health Protocol to determine if one or more of the controllers\r
+ managed by each EFI Driver Health Protocol instance are not healthy.\r
\r
@param DriverHealthList A Pointer to the list contain all of the platform driver health\r
- information. \r
+ information.\r
\r
@retval EFI_NOT_FOUND No controller in the platform install Driver Health Protocol.\r
@retval EFI_SUCCESS All the controllers in the platform are healthy.\r
IN OUT LIST_ENTRY *DriverHealthList\r
)\r
{\r
- EFI_STATUS Status; \r
+ EFI_STATUS Status;\r
UINTN NumHandles;\r
EFI_HANDLE *DriverHealthHandles;\r
EFI_DRIVER_HEALTH_PROTOCOL *DriverHealth;\r
UINTN HandleCount;\r
UINTN ControllerIndex;\r
UINTN ChildIndex;\r
- \r
+\r
//\r
// Initialize local variables\r
//\r
\r
if (EFI_ERROR (Status) || DriverHealthHandles == NULL) {\r
//\r
- // If the list of Driver Health Protocol handles can not be retrieved, then \r
+ // If the list of Driver Health Protocol handles can not be retrieved, then\r
// return EFI_OUT_OF_RESOURCES\r
//\r
return EFI_OUT_OF_RESOURCES;\r
//\r
// Retrieve the Driver Health Protocol from DriverHandle\r
//\r
- Status = gBS->HandleProtocol ( \r
+ Status = gBS->HandleProtocol (\r
DriverHealthHandles[DriverHealthIndex],\r
&gEfiDriverHealthProtocolGuid,\r
(VOID **)&DriverHealth\r
}\r
\r
//\r
- // If all the controllers managed by this Driver Health Protocol are healthy, then skip to the next \r
+ // If all the controllers managed by this Driver Health Protocol are healthy, then skip to the next\r
// Driver Health Protocol handle\r
//\r
if (HealthStatus == EfiDriverHealthStatusHealthy) {\r
);\r
if (EFI_ERROR (Status) || Handles == NULL) {\r
//\r
- // If all the handles in the handle database can not be retrieved, then \r
+ // If all the handles in the handle database can not be retrieved, then\r
// return EFI_OUT_OF_RESOURCES\r
//\r
Status = EFI_OUT_OF_RESOURCES;\r
\r
\r
/**\r
- Check the healthy status of the platform, this function will return immediately while found one driver \r
+ Check the healthy status of the platform, this function will return immediately while found one driver\r
in the platform are not healthy.\r
\r
@retval FALSE at least one driver in the platform are not healthy.\r
}\r
//\r
// Assume all modules are healthy.\r
- // \r
+ //\r
AllHealthy = TRUE;\r
\r
//\r
// Found one or more Handles.\r
//\r
- if (!EFI_ERROR (Status)) { \r
+ if (!EFI_ERROR (Status)) {\r
for (Index = 0; Index < NoHandles; Index++) {\r
Status = gBS->HandleProtocol (\r
DriverHealthHandles[Index],\r
//\r
// Return immediately one driver's status not in healthy.\r
//\r
- return FALSE; \r
+ return FALSE;\r
}\r
}\r
}\r
}\r
\r
/**\r
- Processes a single controller using the EFI Driver Health Protocol associated with \r
+ Processes a single controller using the EFI Driver Health Protocol associated with\r
that controller. This algorithm continues to query the GetHealthStatus() service until\r
- one of the legal terminal states of the EFI Driver Health Protocol is reached. This may \r
+ one of the legal terminal states of the EFI Driver Health Protocol is reached. This may\r
require the processing of HII Messages, HII Form, and invocation of repair operations.\r
\r
@param DriverHealth A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r
@param ControllerHandle The class guid specifies which form set will be displayed.\r
- @param ChildHandle The handle of the child controller to retrieve the health \r
- status on. This is an optional parameter that may be NULL. \r
+ @param ChildHandle The handle of the child controller to retrieve the health\r
+ status on. This is an optional parameter that may be NULL.\r
@param HealthStatus The health status of the controller.\r
- @param MessageList An array of warning or error messages associated \r
- with the controller specified by ControllerHandle and \r
+ @param MessageList An array of warning or error messages associated\r
+ with the controller specified by ControllerHandle and\r
ChildHandle. This is an optional parameter that may be NULL.\r
- @param FormHiiHandle The HII handle for an HII form associated with the \r
+ @param FormHiiHandle The HII handle for an HII form associated with the\r
controller specified by ControllerHandle and ChildHandle.\r
@param RebootRequired Indicate whether a reboot is required to repair the controller.\r
**/\r
{\r
EFI_STATUS Status;\r
EFI_DRIVER_HEALTH_STATUS LocalHealthStatus;\r
- \r
+\r
LocalHealthStatus = HealthStatus;\r
//\r
// If the module need to be repaired or reconfiguration, will process it until\r
- // reach a terminal status. The status from EfiDriverHealthStatusRepairRequired after repair \r
+ // reach a terminal status. The status from EfiDriverHealthStatusRepairRequired after repair\r
// will be in (Health, Failed, Configuration Required).\r
//\r
while(LocalHealthStatus == EfiDriverHealthStatusConfigurationRequired ||\r
DriverHealth,\r
ControllerHandle,\r
ChildHandle,\r
- (EFI_DRIVER_HEALTH_REPAIR_PROGRESS_NOTIFY) RepairNotify\r
+ RepairNotify\r
);\r
}\r
//\r
- // Via a form of the driver need to do configuration provided to process of status in \r
+ // Via a form of the driver need to do configuration provided to process of status in\r
// EfiDriverHealthStatusConfigurationRequired. The status after configuration should be in\r
- // (Healthy, Reboot Required, Failed, Reconnect Required, Repair Required). \r
+ // (Healthy, Reboot Required, Failed, Reconnect Required, Repair Required).\r
//\r
if (LocalHealthStatus == EfiDriverHealthStatusConfigurationRequired) {\r
if (FormHiiHandle != NULL) {\r
\r
if (*MessageList != NULL) {\r
ProcessMessages (*MessageList);\r
- } \r
+ }\r
}\r
- \r
+\r
//\r
// Health status in {Healthy, Failed} may also have Messages need to process\r
//\r
if (LocalHealthStatus == EfiDriverHealthStatusRebootRequired) {\r
*RebootRequired = TRUE;\r
}\r
- \r
+\r
//\r
// Do reconnect if need.\r
//\r
\r
\r
/**\r
- Platform specific notification function for controller repair operations.\r
-\r
- If the driver for a controller support the Driver Health Protocol and the\r
- current state of the controller is EfiDriverHealthStatusRepairRequired then\r
- when the Repair() service of the Driver Health Protocol is called, this \r
- platform specific notification function can display the progress of the repair\r
- operation. Some platforms may choose to not display anything, other may choose\r
- to show the percentage complete on text consoles, and other may choose to render\r
- a progress bar on text and graphical consoles.\r
-\r
- This function displays the percentage of the repair operation that has been\r
- completed on text consoles. The percentage is Value / Limit * 100%.\r
- \r
- @param Value Value in the range 0..Limit the the repair has completed..\r
- @param Limit The maximum value of Value\r
+ Reports the progress of a repair operation.\r
+\r
+ @param[in] Value A value between 0 and Limit that identifies the current\r
+ progress of the repair operation.\r
+\r
+ @param[in] Limit The maximum value of Value for the current repair operation.\r
+ For example, a driver that wants to specify progress in\r
+ percent would use a Limit value of 100.\r
+\r
+ @retval EFI_SUCCESS The progress of a repair operation is reported successfully.\r
\r
**/\r
-VOID\r
+EFI_STATUS\r
+EFIAPI\r
RepairNotify (\r
IN UINTN Value,\r
IN UINTN Limit\r
Percent = Value * 100 / Limit;\r
Print(L"Repair Progress = %3d%%\n\r", Percent);\r
}\r
+ return EFI_SUCCESS;\r
}\r
\r
/**\r
Processes a set of messages returned by the GetHealthStatus ()\r
service of the EFI Driver Health Protocol\r
\r
- @param MessageList The MessageList point to messages need to processed. \r
+ @param MessageList The MessageList point to messages need to processed.\r
\r
**/\r
VOID\r
);\r
if (MessageString != NULL) {\r
//\r
- // User can customize the output. Just simply print out the MessageString like below. \r
+ // User can customize the output. Just simply print out the MessageString like below.\r
// Also can use the HiiHandle to display message on the front page.\r
- // \r
+ //\r
// Print(L"%s\n",MessageString);\r
// gBS->Stall (100000);\r
}\r
Repair the whole platform.\r
\r
This function is the main entry for user choose "Repair All" in the front page.\r
- It will try to do recovery job till all the driver health protocol installed modules \r
+ It will try to do recovery job till all the driver health protocol installed modules\r
reach a terminal state.\r
\r
@param DriverHealthList A Pointer to the list contain all of the platform driver health\r
PlatformRepairAll (\r
IN LIST_ENTRY *DriverHealthList\r
)\r
-{ \r
+{\r
DRIVER_HEALTH_INFO *DriverHealthInfo;\r
LIST_ENTRY *Link;\r
BOOLEAN RebootRequired;\r
//\r
ASSERT (DriverHealthInfo != NULL);\r
\r
- ProcessSingleControllerHealth ( \r
+ ProcessSingleControllerHealth (\r
DriverHealthInfo->DriverHealth,\r
DriverHealthInfo->ControllerHandle,\r
DriverHealthInfo->ChildHandle,\r
\r
/**\r
\r
- Select the best matching language according to front page policy for best user experience. \r
- \r
- This function supports both ISO 639-2 and RFC 4646 language codes, but language \r
- code types may not be mixed in a single call to this function. \r
+ Select the best matching language according to front page policy for best user experience.\r
+\r
+ This function supports both ISO 639-2 and RFC 4646 language codes, but language\r
+ code types may not be mixed in a single call to this function.\r
\r
@param SupportedLanguages A pointer to a Null-terminated ASCII string that\r
- contains a set of language codes in the format \r
+ contains a set of language codes in the format\r
specified by Iso639Language.\r
@param Iso639Language If TRUE, then all language codes are assumed to be\r
in ISO 639-2 format. If FALSE, then all language\r
codes are assumed to be in RFC 4646 language format.\r
\r
@retval NULL The best matching language could not be found in SupportedLanguages.\r
- @retval NULL There are not enough resources available to return the best matching \r
+ @retval NULL There are not enough resources available to return the best matching\r
language.\r
- @retval Other A pointer to a Null-terminated ASCII string that is the best matching \r
+ @retval Other A pointer to a Null-terminated ASCII string that is the best matching\r
language in SupportedLanguages.\r
**/\r
CHAR8 *\r
CHAR8 *LanguageVariable;\r
CHAR8 *BestLanguage;\r
\r
- LanguageVariable = GetEfiGlobalVariable (Iso639Language ? L"Lang" : L"PlatformLang");\r
+ GetEfiGlobalVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", (VOID**)&LanguageVariable, NULL);\r
\r
BestLanguage = GetBestLanguage(\r
SupportedLanguages,\r
@param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.\r
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.\r
@param ComponentName A pointer to the Component Name (2) protocol interface.\r
- @param SupportedLanguage The best suitable language that matches the SupportedLangues interface for the \r
+ @param SupportedLanguage The best suitable language that matches the SupportedLangues interface for the\r
located Component Name (2) instance.\r
\r
@retval EFI_SUCCESS The Component Name (2) protocol instance is successfully located and we find\r
EFI_COMPONENT_NAME_PROTOCOL *ComponentName;\r
\r
//\r
- // Retrieve Component Name (2) protocol instance on the driver binding handle and \r
- // find the best language this instance supports. \r
+ // Retrieve Component Name (2) protocol instance on the driver binding handle and\r
+ // find the best language this instance supports.\r
//\r
Status = GetComponentNameWorker (\r
ProtocolGuid,\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- \r
+\r
//\r
// Get the driver name from Component Name (2) protocol instance on the driver binging handle.\r
//\r
DriverName\r
);\r
FreePool (BestLanguage);\r
- \r
+\r
return Status;\r
}\r
\r
This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface\r
in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name.\r
If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward\r
- compatibility support. \r
+ compatibility support.\r
\r
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.\r
@param DriverName A pointer to the Unicode string to return. This Unicode string is the name\r
This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface\r
in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.\r
If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward\r
- compatibility support. \r
+ compatibility support.\r
\r
@param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.\r
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.\r
EFI_COMPONENT_NAME_PROTOCOL *ComponentName;\r
\r
//\r
- // Retrieve Component Name (2) protocol instance on the driver binding handle and \r
- // find the best language this instance supports. \r
+ // Retrieve Component Name (2) protocol instance on the driver binding handle and\r
+ // find the best language this instance supports.\r
//\r
Status = GetComponentNameWorker (\r
ProtocolGuid,\r
/**\r
\r
This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface\r
- in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name. \r
+ in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.\r
If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward\r
- compatibility support. \r
+ compatibility support.\r
\r
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.\r
@param ControllerHandle The handle of a controller that the driver specified by This is managing.\r