Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> 1) ShellPkg/Library/UefiHandleParsingLib a. UefiHandleParsingLib.c – ConvertHandleToHandleIndex() and ConvertHandleIndexToHandle() i. Update to work correctly when handles are destroyed due to driver disconnect operations. Same handle index is never reused. b. UefiHandleParsingLib.c – ParseHandleDatabaseByRelationshipWithType() and ParseHandleDatabaseForChildControllers() i. Expand to handle Service Binding Protocol usage such as Network stack. 2) ShellPkg/Library/UefiShellDriver1CommandsLib a. DevTree.c – Fix bug where the same handle is shown more than once. b. Dh.c – Fix use of GetDriverName() and GetDriverImageName(). The status returned must always be evaluated. c. Disconnect.c – Remove requirement that a handle being disconnected must support Device Path Protocol. This prevents driver model handles without device paths from being disconnected (i.e. Network Stack) d. OpenInfo.c – Fix bug when showing open info about a ControllerHandle that has been destroyed due to a disconnect or an unload operation. e. UefiShellDriver1CommandsLib.uni – Fix “drivers” command formatting when handle indexes have more than 2 characters. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13786 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -948,7 +948,11 @@ ConvertHandleToHandleIndex(
|
|||||||
IN CONST EFI_HANDLE TheHandle
|
IN CONST EFI_HANDLE TheHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HANDLE_LIST *ListWalker;
|
EFI_STATUS Status;
|
||||||
|
EFI_GUID **ProtocolBuffer;
|
||||||
|
UINTN ProtocolCount;
|
||||||
|
HANDLE_LIST *ListWalker;
|
||||||
|
|
||||||
if (TheHandle == NULL) {
|
if (TheHandle == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -960,9 +964,34 @@ ConvertHandleToHandleIndex(
|
|||||||
; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
|
; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
|
||||||
){
|
){
|
||||||
if (ListWalker->TheHandle == TheHandle) {
|
if (ListWalker->TheHandle == TheHandle) {
|
||||||
|
//
|
||||||
|
// Verify that TheHandle is still present in the Handle Database
|
||||||
|
//
|
||||||
|
Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// TheHandle is not present in the Handle Database, so delete from the handle list
|
||||||
|
//
|
||||||
|
RemoveEntryList (&ListWalker->Link);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
FreePool (ProtocolBuffer);
|
||||||
return (ListWalker->TheIndex);
|
return (ListWalker->TheIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Verify that TheHandle is valid handle
|
||||||
|
//
|
||||||
|
Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// TheHandle is not valid, so do not add to handle list
|
||||||
|
//
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
FreePool (ProtocolBuffer);
|
||||||
|
|
||||||
ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
|
ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
|
||||||
ASSERT(ListWalker != NULL);
|
ASSERT(ListWalker != NULL);
|
||||||
ListWalker->TheHandle = TheHandle;
|
ListWalker->TheHandle = TheHandle;
|
||||||
@ -988,23 +1017,36 @@ ConvertHandleIndexToHandle(
|
|||||||
IN CONST UINTN TheIndex
|
IN CONST UINTN TheIndex
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_GUID **ProtocolBuffer;
|
||||||
|
UINTN ProtocolCount;
|
||||||
HANDLE_LIST *ListWalker;
|
HANDLE_LIST *ListWalker;
|
||||||
|
|
||||||
InternalShellInitHandleList();
|
InternalShellInitHandleList();
|
||||||
|
|
||||||
if (TheIndex >= mHandleList.NextIndex) {
|
if (TheIndex >= mHandleList.NextIndex) {
|
||||||
return (NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)
|
for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)
|
||||||
; !IsNull(&mHandleList.List.Link,&ListWalker->Link)
|
; !IsNull(&mHandleList.List.Link,&ListWalker->Link)
|
||||||
; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
|
; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
|
||||||
){
|
){
|
||||||
if (ListWalker->TheIndex == TheIndex) {
|
if (ListWalker->TheIndex == TheIndex && ListWalker->TheHandle != NULL) {
|
||||||
|
//
|
||||||
|
// Verify that LinkWalker->TheHandle is valid handle
|
||||||
|
//
|
||||||
|
Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// TheHandle is not valid, so do not add to handle list
|
||||||
|
//
|
||||||
|
ListWalker->TheHandle = NULL;
|
||||||
|
}
|
||||||
return (ListWalker->TheHandle);
|
return (ListWalker->TheHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1052,6 +1094,7 @@ ParseHandleDatabaseByRelationshipWithType (
|
|||||||
UINTN OpenInfoCount;
|
UINTN OpenInfoCount;
|
||||||
UINTN OpenInfoIndex;
|
UINTN OpenInfoIndex;
|
||||||
UINTN ChildIndex;
|
UINTN ChildIndex;
|
||||||
|
INTN DriverBindingHandleIndex;
|
||||||
|
|
||||||
ASSERT(HandleCount != NULL);
|
ASSERT(HandleCount != NULL);
|
||||||
ASSERT(HandleBuffer != NULL);
|
ASSERT(HandleBuffer != NULL);
|
||||||
@ -1079,6 +1122,13 @@ ParseHandleDatabaseByRelationshipWithType (
|
|||||||
*HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));
|
*HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));
|
||||||
ASSERT(*HandleType != NULL);
|
ASSERT(*HandleType != NULL);
|
||||||
|
|
||||||
|
DriverBindingHandleIndex = -1;
|
||||||
|
for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
|
||||||
|
if (DriverBindingHandle != NULL && (*HandleBuffer)[HandleIndex] == DriverBindingHandle) {
|
||||||
|
DriverBindingHandleIndex = (INTN)HandleIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
|
for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
|
||||||
//
|
//
|
||||||
// Retrieve the list of all the protocols on each handle
|
// Retrieve the list of all the protocols on each handle
|
||||||
@ -1088,102 +1138,150 @@ ParseHandleDatabaseByRelationshipWithType (
|
|||||||
&ProtocolGuidArray,
|
&ProtocolGuidArray,
|
||||||
&ArrayCount
|
&ArrayCount
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
|
for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the bit describing what this handle has
|
// Set the bit describing what this handle has
|
||||||
//
|
//
|
||||||
if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid) ) {
|
if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid) ) {
|
||||||
(*HandleType)[HandleIndex] |= HR_IMAGE_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_IMAGE_HANDLE;
|
||||||
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid) ) {
|
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid) ) {
|
||||||
(*HandleType)[HandleIndex] |= HR_DRIVER_BINDING_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_DRIVER_BINDING_HANDLE;
|
||||||
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) {
|
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) {
|
||||||
(*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE;
|
||||||
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) {
|
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) {
|
||||||
(*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE;
|
||||||
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) ) {
|
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) ) {
|
||||||
(*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE;
|
||||||
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) ) {
|
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) ) {
|
||||||
(*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE;
|
||||||
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid) ) {
|
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid) ) {
|
||||||
(*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE;
|
||||||
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) {
|
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) {
|
||||||
(*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE;
|
||||||
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid) ) {
|
} else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid) ) {
|
||||||
(*HandleType)[HandleIndex] |= HR_DEVICE_HANDLE;
|
(*HandleType)[HandleIndex] |= HR_DEVICE_HANDLE;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_CODE_BEGIN();
|
DEBUG_CODE_BEGIN();
|
||||||
ASSERT((*HandleType)[HandleIndex] == (*HandleType)[HandleIndex]);
|
ASSERT((*HandleType)[HandleIndex] == (*HandleType)[HandleIndex]);
|
||||||
DEBUG_CODE_END();
|
DEBUG_CODE_END();
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Retrieve the list of agents that have opened each protocol
|
// Retrieve the list of agents that have opened each protocol
|
||||||
//
|
//
|
||||||
Status = gBS->OpenProtocolInformation (
|
Status = gBS->OpenProtocolInformation (
|
||||||
(*HandleBuffer)[HandleIndex],
|
(*HandleBuffer)[HandleIndex],
|
||||||
ProtocolGuidArray[ProtocolIndex],
|
ProtocolGuidArray[ProtocolIndex],
|
||||||
&OpenInfo,
|
&OpenInfo,
|
||||||
&OpenInfoCount
|
&OpenInfoCount
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
|
continue;
|
||||||
if (DriverBindingHandle != NULL && OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
|
}
|
||||||
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) {
|
|
||||||
(*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
|
if (ControllerHandle == NULL) {
|
||||||
|
//
|
||||||
|
// ControllerHandle == NULL and DriverBindingHandle != NULL.
|
||||||
|
// Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
|
||||||
|
//
|
||||||
|
for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
|
||||||
|
(*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
|
||||||
|
if (DriverBindingHandleIndex != -1) {
|
||||||
|
(*HandleType)[DriverBindingHandleIndex] |= HR_DEVICE_DRIVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
||||||
|
(*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
|
||||||
|
if (DriverBindingHandleIndex != -1) {
|
||||||
|
(*HandleType)[DriverBindingHandleIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER);
|
||||||
|
}
|
||||||
|
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
|
||||||
|
(*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
|
||||||
}
|
}
|
||||||
if (ControllerHandle != NULL && (*HandleBuffer)[HandleIndex] == ControllerHandle) {
|
}
|
||||||
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {
|
}
|
||||||
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
|
}
|
||||||
if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].ControllerHandle) {
|
}
|
||||||
(*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
|
if (DriverBindingHandle == NULL && ControllerHandle != NULL) {
|
||||||
}
|
if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {
|
||||||
}
|
(*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
|
||||||
|
for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
|
||||||
|
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
|
||||||
|
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
|
||||||
|
(*HandleType)[ChildIndex] |= HR_DEVICE_DRIVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DriverBindingHandle == NULL && OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
|
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
||||||
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) {
|
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
|
||||||
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
|
if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
|
||||||
if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) {
|
(*HandleType)[ChildIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER);
|
||||||
(*HandleType)[ChildIndex] |= HR_DEVICE_DRIVER;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
|
||||||
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {
|
(*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
|
||||||
(*HandleType)[HandleIndex] |= HR_PARENT_HANDLE;
|
|
||||||
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
|
|
||||||
if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) {
|
|
||||||
(*HandleType)[ChildIndex] |= HR_BUS_DRIVER;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
FreePool (OpenInfo);
|
for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
|
||||||
|
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
|
||||||
|
(*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_PARENT_HANDLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (DriverBindingHandle != NULL && ControllerHandle != NULL) {
|
||||||
|
if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {
|
||||||
|
(*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
|
||||||
|
for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
|
||||||
|
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
|
||||||
|
if (DriverBindingHandleIndex != -1) {
|
||||||
|
(*HandleType)[DriverBindingHandleIndex] |= HR_DEVICE_DRIVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
|
||||||
|
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
|
||||||
|
(*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FreePool (ProtocolGuidArray);
|
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
|
||||||
|
(*HandleType)[ChildIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
|
||||||
|
if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
||||||
|
if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
|
||||||
|
(*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_PARENT_HANDLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FreePool (OpenInfo);
|
||||||
}
|
}
|
||||||
|
FreePool (ProtocolGuidArray);
|
||||||
}
|
}
|
||||||
|
return EFI_SUCCESS;
|
||||||
if (EFI_ERROR(Status)) {
|
|
||||||
if (*HandleType != NULL) {
|
|
||||||
FreePool (*HandleType);
|
|
||||||
}
|
|
||||||
if (*HandleBuffer != NULL) {
|
|
||||||
FreePool (*HandleBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
*HandleCount = 0;
|
|
||||||
*HandleBuffer = NULL;
|
|
||||||
*HandleType = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1338,14 +1436,13 @@ ParseHandleDatabaseForChildControllers(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
// UINTN HandleIndex;
|
UINTN HandleIndex;
|
||||||
UINTN DriverBindingHandleCount;
|
UINTN DriverBindingHandleCount;
|
||||||
EFI_HANDLE *DriverBindingHandleBuffer;
|
EFI_HANDLE *DriverBindingHandleBuffer;
|
||||||
UINTN DriverBindingHandleIndex;
|
UINTN DriverBindingHandleIndex;
|
||||||
UINTN ChildControllerHandleCount;
|
UINTN ChildControllerHandleCount;
|
||||||
EFI_HANDLE *ChildControllerHandleBuffer;
|
EFI_HANDLE *ChildControllerHandleBuffer;
|
||||||
UINTN ChildControllerHandleIndex;
|
UINTN ChildControllerHandleIndex;
|
||||||
// BOOLEAN Found;
|
|
||||||
EFI_HANDLE *HandleBufferForReturn;
|
EFI_HANDLE *HandleBufferForReturn;
|
||||||
|
|
||||||
if (MatchingHandleCount == NULL) {
|
if (MatchingHandleCount == NULL) {
|
||||||
@ -1365,7 +1462,7 @@ ParseHandleDatabaseForChildControllers(
|
|||||||
//
|
//
|
||||||
// Get a buffer big enough for all the controllers.
|
// Get a buffer big enough for all the controllers.
|
||||||
//
|
//
|
||||||
HandleBufferForReturn = GetHandleListByProtocol(&gEfiDevicePathProtocolGuid);
|
HandleBufferForReturn = GetHandleListByProtocol(NULL);
|
||||||
if (HandleBufferForReturn == NULL) {
|
if (HandleBufferForReturn == NULL) {
|
||||||
FreePool (DriverBindingHandleBuffer);
|
FreePool (DriverBindingHandleBuffer);
|
||||||
return (EFI_NOT_FOUND);
|
return (EFI_NOT_FOUND);
|
||||||
@ -1386,18 +1483,14 @@ ParseHandleDatabaseForChildControllers(
|
|||||||
ChildControllerHandleIndex < ChildControllerHandleCount;
|
ChildControllerHandleIndex < ChildControllerHandleCount;
|
||||||
ChildControllerHandleIndex++
|
ChildControllerHandleIndex++
|
||||||
) {
|
) {
|
||||||
// Found = FALSE;
|
for (HandleIndex = 0; HandleIndex < *MatchingHandleCount; HandleIndex++) {
|
||||||
HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];
|
if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {
|
||||||
// for (HandleIndex = 0; HandleBufferForReturn[HandleIndex] != NULL; HandleIndex++) {
|
break;
|
||||||
// if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {
|
}
|
||||||
// Found = TRUE;
|
}
|
||||||
// break;
|
if (HandleIndex >= *MatchingHandleCount) {
|
||||||
// }
|
HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (Found) {
|
|
||||||
// HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool (ChildControllerHandleBuffer);
|
FreePool (ChildControllerHandleBuffer);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Main file for DevTree shell Driver1 function.
|
Main file for DevTree shell Driver1 function.
|
||||||
|
|
||||||
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -84,23 +84,6 @@ DoDevTreeForHandle(
|
|||||||
return SHELL_SUCCESS;
|
return SHELL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// If we are at the begining then we want root handles they have no parents and do have device path.
|
|
||||||
//
|
|
||||||
if (IndentCharCount == 0) {
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
TheHandle,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return SHELL_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
|
FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
|
||||||
|
|
||||||
ASSERT(HiiString != NULL);
|
ASSERT(HiiString != NULL);
|
||||||
@ -169,6 +152,8 @@ ShellCommandRunDevTree (
|
|||||||
EFI_HANDLE TheHandle;
|
EFI_HANDLE TheHandle;
|
||||||
BOOLEAN FlagD;
|
BOOLEAN FlagD;
|
||||||
UINT64 Intermediate;
|
UINT64 Intermediate;
|
||||||
|
UINTN ParentControllerHandleCount;
|
||||||
|
EFI_HANDLE *ParentControllerHandleBuffer;
|
||||||
|
|
||||||
ShellStatus = SHELL_SUCCESS;
|
ShellStatus = SHELL_SUCCESS;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
@ -226,6 +211,39 @@ ShellCommandRunDevTree (
|
|||||||
if (TheHandle == NULL){
|
if (TheHandle == NULL){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Skip handles that do not have device path protocol
|
||||||
|
//
|
||||||
|
Status = gBS->OpenProtocol (
|
||||||
|
TheHandle,
|
||||||
|
&gEfiDevicePathProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Skip handles that do have parents
|
||||||
|
//
|
||||||
|
ParentControllerHandleBuffer = NULL;
|
||||||
|
Status = PARSE_HANDLE_DATABASE_PARENTS (
|
||||||
|
TheHandle,
|
||||||
|
&ParentControllerHandleCount,
|
||||||
|
&ParentControllerHandleBuffer
|
||||||
|
);
|
||||||
|
SHELL_FREE_NON_NULL (ParentControllerHandleBuffer);
|
||||||
|
if (ParentControllerHandleCount > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Start a devtree from TheHandle that has a device path and no parents
|
||||||
|
//
|
||||||
ShellStatus = DoDevTreeForHandle(TheHandle, Language, FlagD, 0, HiiString);
|
ShellStatus = DoDevTreeForHandle(TheHandle, Language, FlagD, 0, HiiString);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Main file for Dh shell Driver1 function.
|
Main file for Dh shell Driver1 function.
|
||||||
|
|
||||||
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -394,11 +394,14 @@ DisplayDriverModelHandle (
|
|||||||
Language,
|
Language,
|
||||||
&DriverName
|
&DriverName
|
||||||
);
|
);
|
||||||
if (DriverName == NULL) {
|
if (EFI_ERROR (Status)) {
|
||||||
Status = GetDriverImageName (
|
Status = GetDriverImageName (
|
||||||
DriverBindingHandleBuffer[Index],
|
DriverBindingHandleBuffer[Index],
|
||||||
&DriverName
|
&DriverName
|
||||||
);
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DriverName = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Image) {
|
if (Image) {
|
||||||
@ -537,6 +540,9 @@ DisplayDriverModelHandle (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status = GetDriverName (Handle, Language, &DriverName);
|
Status = GetDriverName (Handle, Language, &DriverName);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DriverName = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ShellPrintHiiEx(
|
ShellPrintHiiEx(
|
||||||
-1,
|
-1,
|
||||||
@ -548,11 +554,13 @@ DisplayDriverModelHandle (
|
|||||||
DriverName!=NULL?DriverName:L"<Unknown>"
|
DriverName!=NULL?DriverName:L"<Unknown>"
|
||||||
);
|
);
|
||||||
SHELL_FREE_NON_NULL(DriverName);
|
SHELL_FREE_NON_NULL(DriverName);
|
||||||
DriverName = NULL;
|
|
||||||
Status = GetDriverImageName (
|
Status = GetDriverImageName (
|
||||||
Handle,
|
Handle,
|
||||||
&DriverName
|
&DriverName
|
||||||
);
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DriverName = NULL;
|
||||||
|
}
|
||||||
ShellPrintHiiEx(
|
ShellPrintHiiEx(
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Main file for Disconnect shell Driver1 function.
|
Main file for Disconnect shell Driver1 function.
|
||||||
|
|
||||||
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -163,10 +163,6 @@ ShellCommandRunDisconnect (
|
|||||||
} else if (Param3 != NULL && Handle3 == NULL) {
|
} else if (Param3 != NULL && Handle3 == NULL) {
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param3);
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param3);
|
||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
} else if (EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiDevicePathProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
|
|
||||||
ASSERT(Param1 != NULL);
|
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param1), L"controller handle");
|
|
||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
||||||
} else if (Handle2 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
|
} else if (Handle2 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
|
||||||
ASSERT(Param2 != NULL);
|
ASSERT(Param2 != NULL);
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param2), L"driver handle");
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param2), L"driver handle");
|
||||||
|
@ -48,6 +48,7 @@ TraverseHandleDatabase (
|
|||||||
CHAR16 *TempString;
|
CHAR16 *TempString;
|
||||||
UINTN HandleIndex;
|
UINTN HandleIndex;
|
||||||
CONST CHAR16 *Name;
|
CONST CHAR16 *Name;
|
||||||
|
UINTN ControllerIndex;
|
||||||
|
|
||||||
if (TheHandle == NULL) {
|
if (TheHandle == NULL) {
|
||||||
return (EFI_INVALID_PARAMETER);
|
return (EFI_INVALID_PARAMETER);
|
||||||
@ -98,9 +99,10 @@ TraverseHandleDatabase (
|
|||||||
OpenTypeString = StringDriverEx; break;
|
OpenTypeString = StringDriverEx; break;
|
||||||
default: OpenTypeString = StringUnknown; break;
|
default: OpenTypeString = StringUnknown; break;
|
||||||
}
|
}
|
||||||
HandleIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].AgentHandle);
|
HandleIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].AgentHandle);
|
||||||
Name = GetStringNameFromHandle(OpenInfo[OpenInfoIndex].AgentHandle, NULL);
|
Name = GetStringNameFromHandle(OpenInfo[OpenInfoIndex].AgentHandle, NULL);
|
||||||
if (OpenInfo[OpenInfoIndex].ControllerHandle!=NULL) {
|
ControllerIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].ControllerHandle);
|
||||||
|
if (ControllerIndex != 0) {
|
||||||
ShellPrintHiiEx(
|
ShellPrintHiiEx(
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
@ -108,7 +110,7 @@ TraverseHandleDatabase (
|
|||||||
STRING_TOKEN(STR_OPENINFO_LINE),
|
STRING_TOKEN(STR_OPENINFO_LINE),
|
||||||
gShellDriver1HiiHandle,
|
gShellDriver1HiiHandle,
|
||||||
HandleIndex,
|
HandleIndex,
|
||||||
ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].ControllerHandle),
|
ControllerIndex,
|
||||||
OpenInfo[OpenInfoIndex].OpenCount,
|
OpenInfo[OpenInfoIndex].OpenCount,
|
||||||
OpenTypeString,
|
OpenTypeString,
|
||||||
Name
|
Name
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user