14CHAR16 *mBmHealthStatusText[] = {
17 L
"Configuration Required",
19 L
"Reconnect Required",
46 CHAR16 *ControllerName;
47 CHAR8 *LanguageVariable;
49 BOOLEAN Iso639Language;
52 ControllerName =
NULL;
57 Iso639Language =
FALSE;
58 Status =
gBS->HandleProtocol (
60 &gEfiComponentName2ProtocolGuid,
61 (VOID **)&ComponentName
63 if (EFI_ERROR (Status)) {
64 Status =
gBS->HandleProtocol (
66 &gEfiComponentNameProtocolGuid,
67 (VOID **)&ComponentName
69 if (!EFI_ERROR (Status)) {
70 Iso639Language =
TRUE;
74 if (!EFI_ERROR (Status)) {
79 (LanguageVariable !=
NULL) ? LanguageVariable :
"",
80 Iso639Language ?
"eng" :
"en-US",
83 if (LanguageVariable !=
NULL) {
87 Status = ComponentName->GetControllerName (
96 if (!EFI_ERROR (Status)) {
119 CHAR16 *ControllerName;
121 if ((DriverHealthInfo->MessageList ==
NULL) ||
122 (DriverHealthInfo->MessageList[0].HiiHandle ==
NULL))
128 DriverHealthInfo->DriverHealthHandle,
129 DriverHealthInfo->ControllerHandle,
130 DriverHealthInfo->ChildHandle
133 DEBUG ((DEBUG_INFO,
"Controller: %s\n", ControllerName));
134 Print (L
"Controller: %s\n", ControllerName);
135 for (Index = 0; DriverHealthInfo->MessageList[Index].HiiHandle !=
NULL; Index++) {
137 DriverHealthInfo->MessageList[Index].HiiHandle,
138 DriverHealthInfo->MessageList[Index].StringId,
141 if (String !=
NULL) {
142 Print (L
" %s\n", String);
143 DEBUG ((DEBUG_INFO,
" %s\n", String));
148 if (ControllerName !=
NULL) {
171 DEBUG ((DEBUG_INFO,
"[BDS]RepairNotify: %d/%d\n", Value, Limit));
172 Print (L
"[BDS]RepairNotify: %d/%d\n", Value, Limit);
206 ASSERT (DriverHealthHandle !=
NULL);
210 Status =
gBS->HandleProtocol (
212 &gEfiDriverHealthProtocolGuid,
213 (VOID **)&DriverHealth
217 if (ControllerHandle ==
NULL) {
221 Status = DriverHealth->GetHealthStatus (DriverHealth,
NULL,
NULL, &HealthStatus,
NULL,
NULL);
222 if (!EFI_ERROR (Status) && (HealthStatus == EfiDriverHealthStatusHealthy)) {
228 ASSERT (*DriverHealthInfo !=
NULL);
230 (*DriverHealthInfo)[*Count].DriverHealthHandle = DriverHealthHandle;
231 (*DriverHealthInfo)[*Count].DriverHealth = DriverHealth;
232 (*DriverHealthInfo)[*Count].HealthStatus = HealthStatus;
236 Status = EFI_ABORTED;
243 FormHiiHandle =
NULL;
248 Status = DriverHealth->GetHealthStatus (DriverHealth, ControllerHandle, ChildHandle, &HealthStatus, &MessageList, &FormHiiHandle);
249 if (!EFI_ERROR (Status)) {
255 ASSERT (*DriverHealthInfo !=
NULL);
256 (*DriverHealthInfo)[*Count].DriverHealth = DriverHealth;
257 (*DriverHealthInfo)[*Count].DriverHealthHandle = DriverHealthHandle;
258 (*DriverHealthInfo)[*Count].ControllerHandle = ControllerHandle;
259 (*DriverHealthInfo)[*Count].ChildHandle = ChildHandle;
260 (*DriverHealthInfo)[*Count].HiiHandle = FormHiiHandle;
261 (*DriverHealthInfo)[*Count].MessageList = MessageList;
262 (*DriverHealthInfo)[*Count].HealthStatus = HealthStatus;
295 UINTN DriverHealthIndex;
298 UINTN ControllerIndex;
306 DriverHealthInfo =
NULL;
308 DriverHealthHandles =
NULL;
312 Status =
gBS->LocateHandleBuffer (
314 &gEfiDriverHealthProtocolGuid,
320 if ((Status == EFI_NOT_FOUND) || (NumHandles == 0)) {
328 ASSERT (DriverHealthHandles !=
NULL);
334 for (DriverHealthIndex = 0; DriverHealthIndex < NumHandles; DriverHealthIndex++) {
339 if (EFI_ERROR (Status)) {
347 if (Handles ==
NULL) {
351 Status =
gBS->LocateHandleBuffer (
364 for (ControllerIndex = 0; ControllerIndex < HandleCount; ControllerIndex++) {
366 if (EFI_ERROR (Status)) {
373 for (ChildIndex = 0; ChildIndex < HandleCount; ChildIndex++) {
375 if (EFI_ERROR (Status)) {
384 if (Handles !=
NULL) {
388 if (DriverHealthHandles !=
NULL) {
392 return DriverHealthInfo;
413 for (Index = 0; Index < Count; Index++) {
414 if (DriverHealthInfo[Index].MessageList !=
NULL) {
415 FreePool (DriverHealthInfo[Index].MessageList);
419 return gBS->FreePool (DriverHealthInfo);
430 UINTN ReconnectRepairCount
438 BOOLEAN RepairRequired;
439 BOOLEAN ConfigurationRequired;
440 BOOLEAN ReconnectRequired;
441 BOOLEAN RebootRequired;
444 UINT32 MaxRepairCount;
454 Status =
gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid,
NULL, (VOID **)&FormBrowser2);
457 MaxRepairCount =
PcdGet32 (PcdMaxRepairCount);
461 RepairRequired =
FALSE;
462 ConfigurationRequired =
FALSE;
468 for (Index = 0; Index < Count; Index++) {
469 if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusConfigurationRequired) {
470 ConfigurationRequired =
TRUE;
473 if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusRepairRequired) {
474 RepairRequired =
TRUE;
478 Status = DriverHealthInfo[Index].DriverHealth->Repair (
479 DriverHealthInfo[Index].DriverHealth,
480 DriverHealthInfo[Index].ControllerHandle,
481 DriverHealthInfo[Index].ChildHandle,
484 if (!EFI_ERROR (Status) && !ConfigurationRequired) {
485 Status = DriverHealthInfo[Index].DriverHealth->GetHealthStatus (
486 DriverHealthInfo[Index].DriverHealth,
487 DriverHealthInfo[Index].ControllerHandle,
488 DriverHealthInfo[Index].ChildHandle,
493 if (!EFI_ERROR (Status) && (HealthStatus == EfiDriverHealthStatusConfigurationRequired)) {
494 ConfigurationRequired =
TRUE;
500 if (ConfigurationRequired) {
502 if (HiiHandles !=
NULL) {
503 for (Index = 0; HiiHandles[Index] !=
NULL; Index++) {
504 Status = FormBrowser2->SendForm (
508 PcdGetPtr (PcdDriverHealthConfigureForm),
513 if (!EFI_ERROR (Status)) {
524 }
while ((RepairRequired || ConfigurationRequired) && ((MaxRepairCount == 0) || (RepairCount < MaxRepairCount)));
526 RebootRequired =
FALSE;
527 ReconnectRequired =
FALSE;
529 for (Index = 0; Index < Count; Index++) {
532 if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusReconnectRequired) {
533 Status =
gBS->DisconnectController (DriverHealthInfo[Index].ControllerHandle,
NULL,
NULL);
534 if (EFI_ERROR (Status)) {
538 RebootRequired =
TRUE;
540 gBS->ConnectController (DriverHealthInfo[Index].ControllerHandle,
NULL,
NULL,
TRUE);
541 ReconnectRequired =
TRUE;
545 if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusRebootRequired) {
546 RebootRequired =
TRUE;
553 CHAR16 *ControllerName;
556 for (Index = 0; Index < Count; Index++) {
558 DriverHealthInfo[Index].DriverHealthHandle,
559 DriverHealthInfo[Index].ControllerHandle,
560 DriverHealthInfo[Index].ChildHandle
567 mBmHealthStatusText[DriverHealthInfo[Index].HealthStatus]
569 if (ControllerName !=
NULL) {
577 if (ReconnectRequired) {
578 if (ReconnectRepairCount < MAX_RECONNECT_REPAIR) {
583 "[%a:%d] Repair failed after %d retries.\n",
591 if (RebootRequired) {
592 DEBUG ((DEBUG_INFO,
"[BDS] One of the Driver Health instances requires rebooting.\n"));
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
BOOLEAN EFIAPI IsZeroGuid(IN CONST GUID *Guid)
CHAR16 * BmGetControllerName(IN EFI_HANDLE DriverHealthHandle, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle)
VOID BmDisplayMessages(IN EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo)
EFI_STATUS EFIAPI EfiBootManagerFreeDriverHealthInfo(EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo, UINTN Count)
EFI_STATUS EFIAPI BmRepairNotify(IN UINTN Value, IN UINTN Limit)
VOID BmRepairAllControllers(UINTN ReconnectRepairCount)
EFI_STATUS BmGetSingleControllerHealthStatus(IN OUT EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO **DriverHealthInfo, IN OUT UINTN *Count, IN EFI_HANDLE DriverHealthHandle, IN EFI_HANDLE ControllerHandle OPTIONAL, IN EFI_HANDLE ChildHandle OPTIONAL)
EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *EFIAPI EfiBootManagerGetDriverHealthInfo(UINTN *Count)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_HII_HANDLE *EFIAPI HiiGetHiiHandles(IN CONST EFI_GUID *PackageListGuid OPTIONAL)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
EFI_RUNTIME_SERVICES * gRT
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define PcdGet32(TokenName)
#define PcdGetPtr(TokenName)
EFI_STATUS EFIAPI GetEfiGlobalVariable2(IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
CHAR8 *EFIAPI GetBestLanguage(IN CONST CHAR8 *SupportedLanguages, IN UINTN Iso639Language,...)
CHAR8 * SupportedLanguages