/** @file
The platform device manager reference implementation
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "DeviceManager.h"
NULL,
NULL,
NULL,
NULL,
{
},
{
}
};
//
// Which Mac Address string is select
// it will decide what menu need to show in the NETWORK_DEVICE_FORM_ID form.
//
//
// Which form Id need to be show.
//
//
// The Mac Address show in the NETWORK_DEVICE_LIST_FORM_ID
//
};
{
{
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
}
},
},
{
{
}
}
};
{
{
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
}
},
},
{
{
}
}
};
/**
This function is invoked if user selected a interactive opcode from Device Manager's
Formset. The decision by user is saved to gCallbackKey for later processing. If
user set VBIOS, the new value is saved to EFI variable.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser.
@param QuestionId A unique value which is sent to the original exporting driver
so that it can identify the type of data to expect.
@param Type The type of value for the question.
@param Value A pointer to the data being sent to the original exporting driver.
@param ActionRequest On return, points to the action requested by the callback function.
@retval EFI_SUCCESS The callback successfully handled the action.
@retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
**/
)
{
if (Action != EFI_BROWSER_ACTION_CHANGING) {
//
// All other action return unsupported.
//
return EFI_UNSUPPORTED;
}
return EFI_INVALID_PARAMETER;
}
if ((QuestionId < MAX_KEY_SECTION_LEN + NETWORK_DEVICE_LIST_KEY_OFFSET) && (QuestionId >= NETWORK_DEVICE_LIST_KEY_OFFSET)) {
//
// If user select the mac address, need to record mac address string to support next form show.
//
mSelectedMacAddrString = HiiGetString (gDeviceManagerPrivate.HiiHandle, mMacDeviceList.NodeList[CurIndex].PromptId, NULL);
}
}
}
return EFI_SUCCESS;
}
/**
This function registers HII packages to HII database.
@retval EFI_SUCCESS HII packages for the Device Manager were registered successfully.
@retval EFI_OUT_OF_RESOURCES HII packages for the Device Manager failed to be registered.
**/
)
{
//
// Install Device Path Protocol and Config Access protocol to driver handle
//
);
);
mMacDeviceList.CurListLen = 0;
mMacDeviceList.MaxListLen = 0;
return Status;
}
/**
Extract the displayed formset for given HII handle and class guid.
@param Handle The HII handle.
@param SetupClassGuid The class guid specifies which form set will be displayed.
@param FormSetTitle Formset title string.
@param FormSetHelp Formset help string.
@retval TRUE The formset for given HII handle will be displayed.
@return FALSE The formset for given HII handle will not be displayed.
**/
)
{
*FormSetTitle = 0;
*FormSetHelp = 0;
ClassGuidNum = 0;
//
// Get HII PackageList
//
BufferSize = 0;
//
// Handle is a invalid handle. Check if Handle is corrupted.
//
//
// The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
//
return FALSE;
}
//
// Get Form package from this HII package List
//
Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
Offset2 = 0;
while (Offset < PackageListLength) {
//
// Search FormSet Opcode in this Form Package
//
Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
//
// Find FormSet OpCode
//
while (ClassGuidNum-- > 0) {
return TRUE;
}
ClassGuid ++;
}
} else {
return TRUE;
}
}
//
// Go to next opcode
//
}
}
//
// Go to next package
//
}
return FALSE;
}
/**
Get the mac address string from the device path.
if the device path has the vlan, get the vanid also.
@param MacAddressNode Device path begin with mac address
@param PBuffer Output string buffer contain mac address.
**/
)
{
VlanId = 0;
HwAddressSize = sizeof (EFI_MAC_ADDRESS);
HwAddressSize = 6;
}
//
// The output format is MAC:XX:XX:XX:...\XXXX
// The size is the Number size + ":" size + Vlan size(\XXXX) + End
//
return FALSE;
}
String += 4;
//
// Convert the MAC address into a unicode string.
//
*String++ = L':';
}
}
//
// If VLAN is configured, it will need extra 5 characters like "\0005".
// Plus one unicode character for the null-terminator.
//
while (!IsDevicePathEnd (Node)) {
}
}
if (VlanId != 0) {
*String++ = L'\\';
}
//
// Null terminate the Unicode string
//
*String = L'\0';
return TRUE;
}
/**
Save question id and prompt id to the mac device list.
If the same mac address has saved yet, no need to add more.
@param MacAddrString Mac address string.
@retval EFI_SUCCESS Add the item is successful.
@return Other values if failed to Add the item.
**/
)
{
if (StoredString == NULL) {
return FALSE;
}
//
// Already has save the same mac address to the list.
//
return FALSE;
}
}
//
// If not in the list, save it.
//
mMacDeviceList.NodeList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) (mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);
} else {
if (mMacDeviceList.CurListLen != 0) {
TempDeviceList = (MENU_INFO_ITEM *)AllocateCopyPool (sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen, (VOID *)mMacDeviceList.NodeList);
} else {
TempDeviceList = (MENU_INFO_ITEM *)AllocatePool (sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen);
}
if (TempDeviceList == NULL) {
return FALSE;
}
TempDeviceList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) (mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);
if (mMacDeviceList.CurListLen > 0) {
}
}
return TRUE;
}
/**
Check the devcie path, try to find whether it has mac address path.
In this function, first need to check whether this path has mac address path.
second, when the mac address device path has find, also need to deicide whether
need to add this mac address relate info to the menu.
@param *Node Input device which need to be check.
@param *NeedAddItem Whether need to add the menu in the network device list.
@retval TRUE Has mac address device path.
@retval FALSE NOT Has mac address device path.
**/
)
{
*NeedAddItem = FALSE;
//
// find the partition device path node
//
while (!IsDevicePathEnd (DevicePath)) {
if (DEVICE_MANAGER_FORM_ID == mNextShowFormId) {
*NeedAddItem = TRUE;
break;
}
break;
}
if (NETWORK_DEVICE_FORM_ID == mNextShowFormId) {
*NeedAddItem = TRUE;
}
break;
}
if (NETWORK_DEVICE_LIST_FORM_ID == mNextShowFormId) {
//
// Same handle may has two network child handle, so the questionid
// has the offset of SAME_HANDLE_KEY_OFFSET.
//
if (AddIdToMacDeviceList (Buffer)) {
*NeedAddItem = TRUE;
}
break;
}
}
}
}
return ReturnVal;
}
/**
Check to see if the device path is for the network device.
@param Handle The HII handle which include the mac address device path.
@param ItemCount The new add Mac address item count.
@retval TRUE Need to add new item in the menu.
@return FALSE Do not need to add the menu about the network.
**/
)
{
return FALSE;
}
*ItemCount = 0;
return FALSE;
}
//
// Get the device path by the got Driver handle .
//
return FALSE;
}
//
// Check whether this device path include mac address device path.
// If this path has mac address path, get the value whether need
// add this info to the menu and return.
// Else check more about the child handle devcie path.
//
(*ItemCount) = 1;
}
return IsNeedAdd;
}
//
// Search whether this path is the controller path, not he child handle path.
// And the child handle has the network devcie connected.
//
return FALSE;
}
if (!IsDevicePathEnd (TmpDevicePath)) {
return FALSE;
}
//
// Retrieve the list of agents that are consuming the specific protocol
// on ControllerHandle.
// The buffer point by OpenInfoBuffer need be free at this function.
//
);
return FALSE;
}
//
// Inspect if ChildHandle is one of the agents.
//
//
// Query all the children created by the controller handle's driver
//
(VOID **) &ChildDevicePath,
NULL,
NULL,
);
continue;
}
//
// Check whether this device path include mac address device path.
//
//
// If this path not has mac address path, check the other.
//
continue;
} else {
//
// If need to update the NETWORK_DEVICE_LIST_FORM, try to get more.
//
if ((NETWORK_DEVICE_LIST_FORM_ID == mNextShowFormId)) {
if (IsNeedAdd) {
(*ItemCount) += 1;
}
continue;
} else {
//
// If need to update other form, return whether need to add to the menu.
//
goto Done;
}
}
}
}
Done:
if (OpenInfoBuffer != NULL) {
}
return IsNeedAdd;
}
/**
Call the browser and display the device manager to allow user
to configure the platform.
This function create the dynamic content for device manager. It includes
section header for all class of devices, one-of opcode to set VBIOS.
@retval EFI_SUCCESS Operation is successful.
@return Other values if failed to clean up the dynamic content from HII
database.
**/
)
{
HiiHandles = NULL;
gCallbackKey = 0;
NumHandles = 0;
AddItemCount = 0;
//
// Connect all prior to entering the platform setup menu.
//
if (!gConnectAllHappened) {
}
//
// Publish our HII data.
//
);
return EFI_OUT_OF_RESOURCES;
}
}
//
// If need show the Network device list form, clear the old save list first.
//
mMacDeviceList.CurListLen = 0;
}
//
// Update the network device form titile.
//
if (mNextShowFormId == NETWORK_DEVICE_FORM_ID) {
}
//
// Allocate space for creation of UpdateData Buffer
//
//
// Create Hii Extend Label OpCode as the start opcode
//
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
//
// According to the next show Form id(mNextShowFormId) to decide which form need to update.
//
//
// Create Hii Extend Label OpCode as the end opcode
//
EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
//
// Get all the Hii handles
//
//
// Search for formset of each class type
//
//
// The QuestionId in the form which will call the driver form has this asssumption.
// QuestionId = Handle Index + NETWORK_DEVICE_LIST_KEY_OFFSET;
// Different QuestionId at least has the section of NETWORK_DEVICE_LIST_KEY_OFFSET.
//
if (!ExtractDisplayedHiiFormFromHiiHandle (HiiHandles[Index], &gEfiHiiPlatformSetupFormsetGuid, &FormSetTitle, &FormSetHelp)) {
continue;
}
}
}
//
// Network device process
//
if (mNextShowFormId == DEVICE_MANAGER_FORM_ID) {
//
// Only show one menu item "Network Config" in the device manger form.
//
if (!AddNetworkMenu) {
);
}
} else if (mNextShowFormId == NETWORK_DEVICE_LIST_FORM_ID) {
//
// In network device list form, same mac address device only show one menu.
//
while (AddItemCount > 0) {
);
AddItemCount -= 1;
}
} else if (mNextShowFormId == NETWORK_DEVICE_FORM_ID) {
//
// In network device form, only the selected mac address device need to be show.
//
);
}
} else {
//
//
// Not network device process, only need to show at device manger form.
//
if (mNextShowFormId == DEVICE_MANAGER_FORM_ID) {
);
}
}
}
NULL,
);
//
// If there are no drivers installed driver health protocol, do not create driver health entry in UI
//
if (NumHandles != 0) {
//
// If driver health protocol is installed, create Driver Health subtitle and entry
//
DEVICE_MANAGER_KEY_DRIVER_HEALTH // Question ID
);
//
// Check All Driver health status
//
if (!PlaformHealthStatusCheck ()) {
//
// At least one driver in the platform are not in healthy status
//
HiiSetString (HiiHandle, STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY), GetStringById (STRING_TOKEN (STR_DRIVER_NOT_HEALTH)), NULL);
} else {
//
// For the string of STR_DRIVER_HEALTH_ALL_HEALTHY previously has been updated and we need to update it while re-entry.
//
HiiSetString (HiiHandle, STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY), GetStringById (STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY)), NULL);
}
}
);
1,
NULL,
);
}
//
// We will have returned from processing a callback, selected
// a target to display
//
if ((gCallbackKey >= DEVICE_KEY_OFFSET)) {
1,
NULL,
0,
NULL,
);
}
//
// Force return to Device Manager
//
goto Done;
}
//
// Driver Health item chose.
//
if (gCallbackKey == DEVICE_MANAGER_KEY_DRIVER_HEALTH) {
CallDriverHealth ();
//
// Force return to Device Manager
//
goto Done;
}
//
// Enter from device manager and into the network device list.
//
if (gCallbackKey == QUESTION_NETWORK_DEVICE_ID) {
goto Done;
}
//
// In this case, go from the network device list to the specify device.
//
if ((gCallbackKey < MAX_KEY_SECTION_LEN + NETWORK_DEVICE_LIST_KEY_OFFSET ) && (gCallbackKey >= NETWORK_DEVICE_LIST_KEY_OFFSET)) {
goto Done;
}
//
// Select the ESC, the gCallbackKey == 0.
//
} else {
}
Done:
//
// Remove our packagelist from HII database.
//
return Status;
}
/**
This function is invoked if user selected a interactive opcode from Driver Health's
Formset. The decision by user is saved to gCallbackKey for later processing.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser.
@param QuestionId A unique value which is sent to the original exporting driver
so that it can identify the type of data to expect.
@param Type The type of value for the question.
@param Value A pointer to the data being sent to the original exporting driver.
@param ActionRequest On return, points to the action requested by the callback function.
@retval EFI_SUCCESS The callback successfully handled the action.
@retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
**/
)
{
if (Action == EFI_BROWSER_ACTION_CHANGED) {
return EFI_INVALID_PARAMETER;
}
//
// Request to exit SendForm(), so as to switch to selected form
//
return EFI_SUCCESS;
}
//
// All other action return unsupported.
//
return EFI_UNSUPPORTED;
}
/**
Collect and display the platform's driver health relative information, allow user to do interactive
operation while the platform is unhealthy.
This function display a form which divided into two parts. The one list all modules which has installed
driver health protocol. The list usually contain driver name, controller name, and it's health info.
While the driver name can't be retrieved, will use device path as backup. The other part of the form provide
a choice to the user to repair all platform.
**/
)
{
Index = 0;
//
// Publish Driver Health HII data.
//
);
return;
}
}
//
// Allocate space for creation of UpdateData Buffer
//
//
// Create Hii Extend Label OpCode as the start opcode
//
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
//
// Create Hii Extend Label OpCode as the start opcode
//
StartLabelRepair = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandleRepair, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
//
// Create Hii Extend Label OpCode as the end opcode
//
EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
//
// Create Hii Extend Label OpCode as the end opcode
//
EndLabelRepair = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandleRepair, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
//
// Assume no line strings is longer than 512 bytes.
//
//
// Can not get the Driver name, so use the Device path
//
}
//
// Add the Driver name & Controller name into FormSetTitle string
//
);
//
// Can not get the Controller name, just let it empty.
//
}
//
// Add the message of the Module itself provided after the string item.
//
);
} else {
//
// Update the string will be displayed base on the driver's health status
//
switch(DriverHealthInfo->HealthStatus) {
break;
break;
break;
break;
break;
default:
break;
}
}
TokenHelp = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DH_REPAIR_SINGLE_HELP)), NULL);
0
);
Index++;
}
//
// Add End Opcode for Subtitle
//
HiiCreateSubTitleOpCode (StartOpCodeHandleRepair, STRING_TOKEN (STR_DRIVER_HEALTH_REPAIR_ALL), 0, 0, 1);
TokenHelp = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DH_REPAIR_ALL_HELP)), NULL);
if (PlaformHealthStatusCheck ()) {
//
// No action need to do for the platform
//
Token = HiiSetString (HiiHandle, 0, GetStringById( STRING_TOKEN (STR_DRIVER_HEALTH_ALL_HEALTHY)), NULL);
0,
0
);
} else {
//
// Create ActionOpCode only while the platform need to do health related operation.
//
0
);
}
Status = HiiUpdateForm (
);
Status = HiiUpdateForm (
);
1,
NULL,
);
}
//
// We will have returned from processing a callback - user either hit ESC to exit, or selected
// a target to display.
// Process the diver health status states here.
//
Index = 0;
//
// Got the item relative node in the List
//
//
// Process the driver's healthy status for the specify module
//
);
if (RebootRequired) {
}
break;
}
Index++;
}
}
//
// Force return to the form of Driver Health in Device Manager
//
}
//
// Repair the whole platform
//
if (gCallbackKey == DRIVER_HEALTH_REPAIR_ALL_KEY) {
}
//
// Remove driver health packagelist from HII database.
//
//
// Free driver health info list
//
while (!IsListEmpty (&DriverHealthList)) {
}
}
if (gCallbackKey == DRIVER_HEALTH_RETURN_KEY) {
//
// Force return to Driver Health Form
//
CallDriverHealth ();
}
}
/**
Check the Driver Health status of a single controller and try to process it if not healthy.
This function called by CheckAllControllersHealthStatus () function in order to process a specify
contoller's health state.
@param DriverHealthList A Pointer to the list contain all of the platform driver health information.
@param DriverHandle The handle of driver.
@param ControllerHandle The class guid specifies which form set will be displayed.
@param ChildHandle The handle of the child controller to retrieve the health
status on. This is an optional parameter that may be NULL.
@param DriverHealth A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
@param HealthStatus The health status of the controller.
@retval EFI_INVALID_PARAMETER HealthStatus or DriverHealth is NULL.
@retval HealthStatus The Health status of specify controller.
@retval EFI_OUT_OF_RESOURCES The list of Driver Health Protocol handles can not be retrieved.
@retval EFI_NOT_FOUND No controller in the platform install Driver Health Protocol.
@retval EFI_SUCCESS The Health related operation has been taken successfully.
**/
)
{
if (HealthStatus == NULL) {
//
// If HealthStatus is NULL, then return EFI_INVALID_PARAMETER
//
return EFI_INVALID_PARAMETER;
}
//
// Assume the HealthStatus is healthy
//
if (DriverHealth == NULL) {
//
// If DriverHealth is NULL, then return EFI_INVALID_PARAMETER
//
return EFI_INVALID_PARAMETER;
}
if (ControllerHandle == NULL) {
//
// If ControllerHandle is NULL, the return the cumulative health status of the driver
//
if (*HealthStatus == EfiDriverHealthStatusHealthy) {
//
// Add the driver health related information into the list
//
if (DriverHealthInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
}
return Status;
}
MessageList = NULL;
//
// Collect the health status with the optional HII message list
//
Status = DriverHealth->GetHealthStatus (DriverHealth, ControllerHandle, ChildHandle, HealthStatus, &MessageList, &FormHiiHandle);
//
// If the health status could not be retrieved, then return immediately
//
return Status;
}
//
// Add the driver health related information into the list
//
if (DriverHealthInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
/**
Collects all the EFI Driver Health Protocols currently present in the EFI Handle Database,
and queries each EFI Driver Health Protocol to determine if one or more of the controllers
managed by each EFI Driver Health Protocol instance are not healthy.
@param DriverHealthList A Pointer to the list contain all of the platform driver health
information.
@retval EFI_NOT_FOUND No controller in the platform install Driver Health Protocol.
@retval EFI_SUCCESS All the controllers in the platform are healthy.
@retval EFI_OUT_OF_RESOURCES The list of Driver Health Protocol handles can not be retrieved.
**/
)
{
//
// Initialize local variables
//
NumHandles = 0;
HandleCount = 0;
NULL,
);
//
// If there are no Driver Health Protocols handles, then return EFI_NOT_FOUND
//
return EFI_NOT_FOUND;
}
//
// If the list of Driver Health Protocol handles can not be retrieved, then
// return EFI_OUT_OF_RESOURCES
//
return EFI_OUT_OF_RESOURCES;
}
//
// Check the health status of all controllers in the platform
// Start by looping through all the Driver Health Protocol handles in the handle database
//
//
// Skip NULL Driver Health Protocol handles
//
continue;
}
//
// Retrieve the Driver Health Protocol from DriverHandle
//
(VOID **)&DriverHealth
);
//
// If the Driver Health Protocol can not be retrieved, then skip to the next
// Driver Health Protocol handle
//
continue;
}
//
// Check the health of all the controllers managed by a Driver Health Protocol handle
//
Status = GetSingleControllerHealthStatus (DriverHealthList, DriverHealthHandles[DriverHealthIndex], NULL, NULL, DriverHealth, &HealthStatus);
//
// If Status is an error code, then the health information could not be retrieved, so assume healthy
// and skip to the next Driver Health Protocol handle
//
continue;
}
//
// If all the controllers managed by this Driver Health Protocol are healthy, then skip to the next
// Driver Health Protocol handle
//
if (HealthStatus == EfiDriverHealthStatusHealthy) {
continue;
}
//
// See if the list of all handles in the handle database has been retrieved
//
//
//
// Retrieve the list of all handles from the handle database
//
NULL,
NULL,
);
//
// If all the handles in the handle database can not be retrieved, then
// return EFI_OUT_OF_RESOURCES
//
goto Done;
}
}
//
// Loop through all the controller handles in the handle database
//
//
// Skip NULL controller handles
//
continue;
}
Status = GetSingleControllerHealthStatus (DriverHealthList, DriverHealthHandles[DriverHealthIndex], Handles[ControllerIndex], NULL, DriverHealth, &HealthStatus);
//
// If Status is an error code, then the health information could not be retrieved, so assume healthy
//
}
//
// If CheckHealthSingleController() returned an error on a terminal state, then do not check the health of child controllers
//
continue;
}
//
// Loop through all the child handles in the handle database
//
//
// Skip NULL child handles
//
continue;
}
Status = GetSingleControllerHealthStatus (DriverHealthList, DriverHealthHandles[DriverHealthIndex], Handles[ControllerIndex], Handles[ChildIndex], DriverHealth, &HealthStatus);
//
// If Status is an error code, then the health information could not be retrieved, so assume healthy
//
}
//
// If CheckHealthSingleController() returned an error on a terminal state, then skip to the next child
//
continue;
}
}
}
}
Done:
}
if (DriverHealthHandles != NULL) {
}
return Status;
}
/**
Check the healthy status of the platform, this function will return immediately while found one driver
in the platform are not healthy.
@retval FALSE at least one driver in the platform are not healthy.
@retval TRUE No controller install Driver Health Protocol,
or all controllers in the platform are in healthy status.
**/
)
{
//
// Initialize local variables
//
DriverHealth = NULL;
NULL,
);
//
// There are no handles match the search for Driver Health Protocol has been installed.
//
if (Status == EFI_NOT_FOUND) {
return TRUE;
}
//
// Assume all modules are healthy.
//
AllHealthy = TRUE;
//
// Found one or more Handles.
//
(VOID **) &DriverHealth
);
NULL,
NULL,
NULL,
);
}
//
// Get the healthy status of the module
//
if (HealthStatus != EfiDriverHealthStatusHealthy) {
//
// Return immediately one driver's status not in healthy.
//
return FALSE;
}
}
}
}
return AllHealthy;
}
/**
Processes a single controller using the EFI Driver Health Protocol associated with
that controller. This algorithm continues to query the GetHealthStatus() service until
one of the legal terminal states of the EFI Driver Health Protocol is reached. This may
require the processing of HII Messages, HII Form, and invocation of repair operations.
@param DriverHealth A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
@param ControllerHandle The class guid specifies which form set will be displayed.
@param ChildHandle The handle of the child controller to retrieve the health
status on. This is an optional parameter that may be NULL.
@param HealthStatus The health status of the controller.
@param MessageList An array of warning or error messages associated
with the controller specified by ControllerHandle and
ChildHandle. This is an optional parameter that may be NULL.
@param FormHiiHandle The HII handle for an HII form associated with the
controller specified by ControllerHandle and ChildHandle.
@param RebootRequired Indicate whether a reboot is required to repair the controller.
**/
)
{
//
// If the module need to be repaired or reconfiguration, will process it until
// reach a terminal status. The status from EfiDriverHealthStatusRepairRequired after repair
// will be in (Health, Failed, Configuration Required).
//
);
}
//
// Via a form of the driver need to do configuration provided to process of status in
// EfiDriverHealthStatusConfigurationRequired. The status after configuration should be in
// (Healthy, Reboot Required, Failed, Reconnect Required, Repair Required).
//
if (FormHiiHandle != NULL) {
1,
0,
NULL,
);
} else {
//
// Exit the loop in case no FormHiiHandle is supplied to prevent dead-loop
//
break;
}
}
NULL,
);
if (*MessageList != NULL) {
}
}
//
// Health status in {Healthy, Failed} may also have Messages need to process
//
if (LocalHealthStatus == EfiDriverHealthStatusHealthy || LocalHealthStatus == EfiDriverHealthStatusFailed) {
if (*MessageList != NULL) {
}
}
//
// Check for RebootRequired or ReconnectRequired
//
*RebootRequired = TRUE;
}
//
// Do reconnect if need.
//
//
// Disconnect failed. Need to promote reconnect to a reboot.
//
*RebootRequired = TRUE;
} else {
}
}
}
/**
Platform specific notification function for controller repair operations.
If the driver for a controller support the Driver Health Protocol and the
current state of the controller is EfiDriverHealthStatusRepairRequired then
when the Repair() service of the Driver Health Protocol is called, this
platform specific notification function can display the progress of the repair
operation. Some platforms may choose to not display anything, other may choose
to show the percentage complete on text consoles, and other may choose to render
a progress bar on text and graphical consoles.
This function displays the percentage of the repair operation that has been
completed on text consoles. The percentage is Value / Limit * 100%.
@param Value Value in the range 0..Limit the the repair has completed..
@param Limit The maximum value of Value
**/
)
{
if (Limit == 0) {
Print(L"Repair Progress Undefined\n\r");
} else {
}
}
/**
Processes a set of messages returned by the GetHealthStatus ()
service of the EFI Driver Health Protocol
@param MessageList The MessageList point to messages need to processed.
**/
)
{
for (MessageIndex = 0;
MessageIndex++) {
);
if (MessageString != NULL) {
//
// User can customize the output. Just simply print out the MessageString like below.
// Also can use the HiiHandle to display message on the front page.
//
// Print(L"%s\n",MessageString);
// gBS->Stall (100000);
}
}
}
/**
Repair the whole platform.
This function is the main entry for user choose "Repair All" in the front page.
It will try to do recovery job till all the driver health protocol installed modules
reach a terminal state.
@param DriverHealthList A Pointer to the list contain all of the platform driver health
information.
**/
)
{
) {
//
// Do driver health status operation by each link node
//
);
}
if (RebootRequired) {
}
}
/**
Select the best matching language according to front page policy for best user experience.
This function supports both ISO 639-2 and RFC 4646 language codes, but language
code types may not be mixed in a single call to this function.
@param SupportedLanguages A pointer to a Null-terminated ASCII string that
contains a set of language codes in the format
specified by Iso639Language.
@param Iso639Language If TRUE, then all language codes are assumed to be
in ISO 639-2 format. If FALSE, then all language
codes are assumed to be in RFC 4646 language format.
@retval NULL The best matching language could not be found in SupportedLanguages.
@retval NULL There are not enough resources available to return the best matching
language.
@retval Other A pointer to a Null-terminated ASCII string that is the best matching
language in SupportedLanguages.
**/
CHAR8 *
)
{
);
if (LanguageVariable != NULL) {
}
return BestLanguage;
}
/**
This is an internal worker function to get the Component Name (2) protocol interface
and the language it supports.
@param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
@param ComponentName A pointer to the Component Name (2) protocol interface.
@param SupportedLanguage The best suitable language that matches the SupportedLangues interface for the
located Component Name (2) instance.
@retval EFI_SUCCESS The Component Name (2) protocol instance is successfully located and we find
the best matching language it support.
@retval EFI_UNSUPPORTED The input Language is not supported by the Component Name (2) protocol.
@retval Other Some error occurs when locating Component Name (2) protocol instance or finding
the supported language.
**/
)
{
//
// Locate Component Name (2) protocol on the driver binging handle.
//
(VOID **) ComponentName,
NULL,
NULL,
);
return Status;
}
//
// Apply shell policy to select the best language.
//
);
if (*SupportedLanguage == NULL) {
}
return Status;
}
/**
This is an internal worker function to get driver name from Component Name (2) protocol interface.
@param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
@param DriverName A pointer to the Unicode string to return. This Unicode string is the name
of the driver specified by This.
@retval EFI_SUCCESS The driver name is successfully retrieved from Component Name (2) protocol
interface.
@retval Other The driver name cannot be retrieved from Component Name (2) protocol
interface.
**/
)
{
//
// Retrieve Component Name (2) protocol instance on the driver binding handle and
// find the best language this instance supports.
//
);
return Status;
}
//
// Get the driver name from Component Name (2) protocol instance on the driver binging handle.
//
);
return Status;
}
/**
This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface
in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name.
If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward
compatibility support.
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
@param DriverName A pointer to the Unicode string to return. This Unicode string is the name
of the driver specified by This.
@retval EFI_SUCCESS The driver name is successfully retrieved from Component Name (2) protocol
interface.
@retval Other The driver name cannot be retrieved from Component Name (2) protocol
interface.
**/
)
{
//
// Get driver name from UEFI 2.0 Component Name 2 protocol interface.
//
//
// If it fails to get the driver name from Component Name protocol interface, we should fall back on
// EFI 1.1 Component Name protocol interface.
//
}
return Status;
}
/**
This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface
in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.
If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward
compatibility support.
@param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
@param ControllerHandle The handle of a controller that the driver specified by This is managing.
This handle specifies the controller whose name is to be returned.
@param ChildHandle The handle of the child controller to retrieve the name of. This is an
optional parameter that may be NULL. It will be NULL for device drivers.
It will also be NULL for bus drivers that attempt to retrieve the name
of the bus controller. It will not be NULL for a bus driver that attempts
to retrieve the name of a child controller.
@param ControllerName A pointer to the Unicode string to return. This Unicode string
is the name of the controller specified by ControllerHandle and ChildHandle.
@retval EFI_SUCCESS The controller name is successfully retrieved from Component Name (2) protocol
interface.
@retval Other The controller name cannot be retrieved from Component Name (2) protocol.
**/
)
{
//
// Retrieve Component Name (2) protocol instance on the driver binding handle and
// find the best language this instance supports.
//
);
return Status;
}
//
// Get the controller name from Component Name (2) protocol instance on the driver binging handle.
//
);
return Status;
}
/**
This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface
in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.
If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward
compatibility support.
@param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
@param ControllerHandle The handle of a controller that the driver specified by This is managing.
This handle specifies the controller whose name is to be returned.
@param ChildHandle The handle of the child controller to retrieve the name of. This is an
optional parameter that may be NULL. It will be NULL for device drivers.
It will also be NULL for bus drivers that attempt to retrieve the name
of the bus controller. It will not be NULL for a bus driver that attempts
to retrieve the name of a child controller.
@param ControllerName A pointer to the Unicode string to return. This Unicode string
is the name of the controller specified by ControllerHandle and ChildHandle.
@retval EFI_SUCCESS The controller name is successfully retrieved from Component Name (2) protocol
interface.
@retval Other The controller name cannot be retrieved from Component Name (2) protocol.
**/
)
{
//
// Get controller name from UEFI 2.0 Component Name 2 protocol interface.
//
);
//
// If it fails to get the controller name from Component Name protocol interface, we should fall back on
// EFI 1.1 Component Name protocol interface.
//
);
}
return Status;
}