mirror of https://github.com/acidanthera/audk.git
Handle multi instances device path while connecting console devices.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben carsey <Jaben.carsey@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15537 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
67c49e4e28
commit
36d6448c1e
|
@ -34,19 +34,28 @@ ShellConnectDevicePath (
|
||||||
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
|
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_HANDLE Handle;
|
EFI_HANDLE Handle;
|
||||||
|
EFI_HANDLE PreviousHandle;
|
||||||
|
|
||||||
if (DevicePathToConnect == NULL) {
|
if (DevicePathToConnect == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
do{
|
PreviousHandle = NULL;
|
||||||
|
do{
|
||||||
RemainingDevicePath = DevicePathToConnect;
|
RemainingDevicePath = DevicePathToConnect;
|
||||||
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
|
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
|
||||||
|
|
||||||
if (!EFI_ERROR (Status) && (Handle != NULL)) {
|
if (!EFI_ERROR (Status) && (Handle != NULL)) {
|
||||||
Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
|
if (PreviousHandle == Handle) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
} else {
|
||||||
|
PreviousHandle = Handle;
|
||||||
|
Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
|
|
||||||
|
} while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath) );
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -188,11 +197,13 @@ ConnectFromDevPaths (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevPathWalker;
|
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevPath;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *Next;
|
||||||
UINTN Length;
|
UINTN Length;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINTN HandleArrayCount;
|
UINTN HandleArrayCount;
|
||||||
|
UINTN Size;
|
||||||
EFI_HANDLE *HandleArray;
|
EFI_HANDLE *HandleArray;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
BOOLEAN AtLeastOneConnected;
|
BOOLEAN AtLeastOneConnected;
|
||||||
|
@ -202,7 +213,7 @@ ConnectFromDevPaths (
|
||||||
DevPath = NULL;
|
DevPath = NULL;
|
||||||
Length = 0;
|
Length = 0;
|
||||||
AtLeastOneConnected = FALSE;
|
AtLeastOneConnected = FALSE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the DevicePath buffer from the variable...
|
// Get the DevicePath buffer from the variable...
|
||||||
//
|
//
|
||||||
|
@ -213,31 +224,51 @@ ConnectFromDevPaths (
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
|
Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
if (DevPath != NULL) {
|
||||||
|
FreePool (DevPath);
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
} else if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
|
|
||||||
|
CopyOfDevPath = DevPath;
|
||||||
//
|
//
|
||||||
// walk the list of devices and connect them
|
// walk the list of devices and connect them
|
||||||
//
|
//
|
||||||
for (DevPathWalker = DevPath
|
do {
|
||||||
; DevPathWalker < (DevPath + Length) && EFI_ERROR(Status) && DevPath != NULL
|
//
|
||||||
; DevPathWalker += GetDevicePathSize(DevPathWalker)
|
// Check every instance of the console variable
|
||||||
){
|
//
|
||||||
|
Instance = GetNextDevicePathInstance (&CopyOfDevPath, &Size);
|
||||||
|
if (Instance == NULL) {
|
||||||
|
if (DevPath != NULL) {
|
||||||
|
FreePool (DevPath);
|
||||||
|
}
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Next = Instance;
|
||||||
|
while (!IsDevicePathEndType (Next)) {
|
||||||
|
Next = NextDevicePathNode (Next);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDevicePathEndNode (Next);
|
||||||
//
|
//
|
||||||
// connect short form device path
|
// connect short form device path
|
||||||
//
|
//
|
||||||
if ((DevicePathType (DevPathWalker) == MESSAGING_DEVICE_PATH) &&
|
if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
|
||||||
((DevicePathSubType (DevPathWalker) == MSG_USB_CLASS_DP)
|
((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
|
||||||
|| (DevicePathSubType (DevPathWalker) == MSG_USB_WWID_DP)
|
|| (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
|
||||||
)) {
|
)) {
|
||||||
Instance = DuplicateDevicePath (DevPathWalker);
|
|
||||||
if (Instance == NULL) {
|
|
||||||
FreePool(DevPath);
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = ShellConnectPciRootBridge ();
|
Status = ShellConnectPciRootBridge ();
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
|
FreePool(Instance);
|
||||||
FreePool(DevPath);
|
FreePool(DevPath);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -281,26 +312,18 @@ ConnectFromDevPaths (
|
||||||
if (HandleArray != NULL) {
|
if (HandleArray != NULL) {
|
||||||
FreePool (HandleArray);
|
FreePool (HandleArray);
|
||||||
}
|
}
|
||||||
FreePool (Instance);
|
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// connect the entire device path
|
// connect the entire device path
|
||||||
//
|
//
|
||||||
Instance = DuplicateDevicePath (DevPathWalker);
|
|
||||||
if (Instance == NULL) {
|
|
||||||
FreePool(DevPath);
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = ShellConnectDevicePath (Instance);
|
Status = ShellConnectDevicePath (Instance);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
AtLeastOneConnected = TRUE;
|
AtLeastOneConnected = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool (Instance);
|
|
||||||
}
|
}
|
||||||
|
FreePool (Instance);
|
||||||
|
|
||||||
}
|
} while (CopyOfDevPath != NULL);
|
||||||
|
|
||||||
if (DevPath != NULL) {
|
if (DevPath != NULL) {
|
||||||
FreePool(DevPath);
|
FreePool(DevPath);
|
||||||
|
@ -399,7 +422,6 @@ ShellCommandRunConnect (
|
||||||
UINT64 Intermediate;
|
UINT64 Intermediate;
|
||||||
|
|
||||||
ShellStatus = SHELL_SUCCESS;
|
ShellStatus = SHELL_SUCCESS;
|
||||||
|
|
||||||
//
|
//
|
||||||
// initialize the shell lib (we must be in non-auto-init...)
|
// initialize the shell lib (we must be in non-auto-init...)
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue