/** @file
Main file for connect shell Driver1 function.
Copyright (c) 2010 - 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 "UefiShellDriver1CommandsLib.h"
/**
Connect controller(s) and driver(s).
@param[in] ControllerHandle The handle to the controller. Should have driver binding on it.
@param[in] DriverHandle The handle to the driver. Should have driver binding.
@param[in] Recursive TRUE to connect recursively, FALSE otherwise.
@param[in] Output TRUE to have info on the screen, FALSE otherwise.
@param[in] AlwaysOutput Override Output for errors.
@retval EFI_SUCCESS The operation was successful.
**/
)
{
//
// If we have a single handle to connect make that a 'list'
//
if (DriverHandle == NULL) {
} else {
if (DriverHandleList == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
DriverHandleList[0] = DriverHandle;
}
//
// do we connect all controllers (with a loop) or a single one...
// This is where we call the gBS->ConnectController function.
//
if (ControllerHandle == NULL) {
for (HandleWalker = ControllerHandleList
; HandleWalker++
){
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Connect", ConvertHandleToHandleIndex(*HandleWalker), Status);
}
}
} else {
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Connect", ConvertHandleToHandleIndex(ControllerHandle), Status);
}
}
//
// Free any memory we allocated.
//
if (ControllerHandleList != NULL) {
}
if (DriverHandleList != NULL) {
}
return (Status2);
}
/**
Do a connect from an EFI variable via it's key name.
@param[in] Key The name of the EFI Variable.
@retval EFI_SUCCESS The operation was successful.
**/
)
{
Length = 0;
//
// Get the DevicePath buffer from the variable...
//
Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
if (Status == EFI_BUFFER_TOO_SMALL) {
Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
}
//
// walk the list of devices and connect them
//
for (DevPathWalker = DevPath
){
//
// get the correct handle from a given device path
//
){
}
){
}
}
}
}
return (Status);
}
/**
Convert the handle identifiers from strings and then connect them.
One of them should have driver binding and either can be NULL.
@param[in] Handle1 The first handle.
@param[in] Handle2 The second handle.
@param[in] Recursive TRUE to do connect recursively. FALSE otherwise.
@param[in] Output TRUE to have output to screen. FALSE otherwise.
@retval EFI_SUCCESS The operation was successful.
**/
)
{
//
// if only one is NULL verify it's the proper one...
//
){
//
// Figure out which one should be NULL and move the handle to the right place.
// If Handle1 is NULL then test Handle2 and vise versa.
// The one that DOES has driver binding must be Handle2
//
if (EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
// swap
} else {
// We're all good...
}
} else {
if (EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiDriverBindingProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
// We're all good...
} else {
// swap
}
}
}
return (ConnectControllers(Handle1, Handle2, Recursive, Output, (BOOLEAN)(Handle2 != NULL && Handle1 != NULL)));
}
{L"-c", TypeFlag},
{L"-r", TypeFlag},
};
/**
Function for 'connect' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
)
{
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
Status = CommandInit();
//
// parse the command line
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, ProblemParam);
} else {
}
} else {
//
// if more than 2 'value' parameters (plus the name one) or either -r or -c with any value parameters we have too many parameters
//
||((ShellCommandLineGetFlag(Package, L"-r") || ShellCommandLineGetFlag(Package, L"-c")) && ShellCommandLineGetCount(Package)>1)
){
//
// error for too many parameters
//
//
// do the conin and conout from EFI variables
// if the first fails dont 'loose' the error
//
ConnectFromDevPaths(L"ConOutDev");
} else {
}
ConnectFromDevPaths(L"ConErrDev");
} else {
}
ConnectFromDevPaths(L"ConErr");
} else {
}
ConnectFromDevPaths(L"ConIn");
} else {
}
ConnectFromDevPaths(L"ConOut");
} else {
}
}
} else {
//
// 0, 1, or 2 specific handles and possibly recursive
//
}
} else {
}
}
} else {
}
if (ShellStatus == SHELL_SUCCESS) {
} else if (Handle2 != NULL && Handle1 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
} else {
Status = ConvertAndConnectControllers(Handle1, Handle2, ShellCommandLineGetFlag(Package, L"-r"), (BOOLEAN)(Count!=0));
}
}
}
}
}
return (ShellStatus);
}