/** @file
Member functions of EFI_SHELL_PROTOCOL and functions for creation,
manipulation, and initialization of EFI_SHELL_PROTOCOL.
Copyright (c) 2009 - 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 "Shell.h"
#include <Library/FileHandleLib.h>
/**
Close an open file handle.
This function closes a specified file handle. All "dirty" cached file data is
flushed to the device, and the file is closed. In all cases the handle is
closed.
@param[in] FileHandle The file handle to close.
@retval EFI_SUCCESS The file handle was closed successfully.
**/
)
{
}
/**
Internal worker to determine whether there is a BlockIo somewhere
upon the device path specified.
@param[in] DevicePath The device path to test.
@retval TRUE gEfiBlockIoProtocolGuid was installed on a handle with this device path
@retval FALSE gEfiBlockIoProtocolGuid was not found.
**/
)
{
return (TRUE);
}
return (FALSE);
}
/**
Internal worker to determine whether there is a file system somewhere
upon the device path specified.
@param[in] DevicePath The device path to test.
@retval TRUE gEfiSimpleFileSystemProtocolGuid was installed on a handle with this device path
@retval FALSE gEfiSimpleFileSystemProtocolGuid was not found.
**/
)
{
return (TRUE);
}
return (FALSE);
}
/**
Internal worker debug helper function to print out maps as they are added.
@param[in] Mapping string mapping that has been added
@param[in] DevicePath pointer to device path that has been mapped.
@retval EFI_SUCCESS the operation was successful.
@return other an error ocurred
@sa LocateHandle
@sa OpenProtocol
**/
)
{
NULL,
(VOID**)&DevicePathToText);
}
if (DevicePath != NULL) {
}
}
return (Status);
}
/**
This function creates a mapping for a device path.
If both DeviecPath and Mapping are NULL, this will reset the mapping to default values.
@param DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping,
then the mapping will be deleted.
@param Mapping Points to the NULL-terminated mapping for the device path. Must end with a ':'
@retval EFI_SUCCESS Mapping created or deleted successfully.
@retval EFI_NO_MAPPING There is no handle that corresponds exactly to DevicePath. See the
boot service function LocateDevicePath().
@retval EFI_ACCESS_DENIED The mapping is a built-in alias.
@retval EFI_INVALID_PARAMETER Mapping was NULL
@retval EFI_INVALID_PARAMETER Mapping did not end with a ':'
@retval EFI_INVALID_PARAMETER DevicePath was not pointing at a device that had a SIMPLE_FILE_SYSTEM_PROTOCOL installed.
@retval EFI_NOT_FOUND There was no mapping found to delete
@retval EFI_OUT_OF_RESOURCES Memory allocation failed
**/
)
{
return (EFI_INVALID_PARAMETER);
}
return (EFI_INVALID_PARAMETER);
}
//
// Delete the mapping
//
if (DevicePath == NULL) {
return (EFI_NOT_FOUND);
}
){
return (EFI_SUCCESS);
}
} // for loop
//
// We didnt find one to delete
//
return (EFI_NOT_FOUND);
}
//
// make sure this is a valid to add device path
//
///@todo add BlockIo to this test...
return (EFI_INVALID_PARAMETER);
}
//
// First make sure there is no old mapping
//
return (Status);
}
//
// now add the new one.
//
return(Status);
}
/**
Gets the device path from the mapping.
This function gets the device path associated with a mapping.
@param Mapping A pointer to the mapping
@retval !=NULL Pointer to the device path that corresponds to the
device mapping. The returned pointer does not need
to be freed.
@retval NULL There is no device path associated with the
specified mapping.
**/
)
{
Size = 0;
}
if (MapListItem != NULL) {
return (MapListItem->DevicePath);
}
return(NULL);
}
/**
Gets the mapping(s) that most closely matches the device path.
This function gets the mapping which corresponds to the device path *DevicePath. If
there is no exact match, then the mapping which most closely matches *DevicePath
is returned, and *DevicePath is updated to point to the remaining portion of the
device path. If there is an exact match, the mapping is returned and *DevicePath
points to the end-of-device-path node.
If there are multiple map names they will be semi-colon seperated in the
NULL-terminated string.
@param DevicePath On entry, points to a device path pointer. On
exit, updates the pointer to point to the
portion of the device path after the mapping.
@retval NULL No mapping was found.
@return !=NULL Pointer to NULL-terminated mapping. The buffer
is callee allocated and should be freed by the caller.
**/
)
{
// EFI_HANDLE PathHandle;
// EFI_HANDLE MapHandle;
// EFI_STATUS Status;
// EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy;
// EFI_DEVICE_PATH_PROTOCOL *MapPathCopy;
return (NULL);
}
PathSize = 0;
){
//
// check for exact match
//
if (PathSize != 0) {
}
}
}
if (PathForReturn != NULL) {
while (!IsDevicePathEndType (*DevicePath)) {
}
}
/*
///@todo finish code for inexact matches.
if (PathForReturn == NULL) {
PathSize = 0;
DevicePathCopy = DuplicateDevicePath(*DevicePath);
ASSERT(DevicePathCopy != NULL);
Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &PathHandle);
ASSERT_EFI_ERROR(Status);
//
// check each of the device paths we have to get the root of the path for consist mappings
//
for ( Node = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
; !IsNull(&gShellMapList.Link, &Node->Link)
; Node = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &Node->Link)
){
if ((Node->Flags & SHELL_MAP_FLAGS_CONSIST) == 0) {
continue;
}
MapPathCopy = DuplicateDevicePath(Node->DevicePath);
ASSERT(MapPathCopy != NULL);
Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &MapPathCopy, &MapHandle);
if (MapHandle == PathHandle) {
*DevicePath = DevicePathCopy;
MapPathCopy = NULL;
DevicePathCopy = NULL;
PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, Node->MapName, 0);
PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, L";", 0);
break;
}
}
//
// now add on the non-consistent mappings
//
for ( Node = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
; !IsNull(&gShellMapList.Link, &Node->Link)
; Node = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &Node->Link)
){
if ((Node->Flags & SHELL_MAP_FLAGS_CONSIST) != 0) {
continue;
}
MapPathCopy = Node->DevicePath;
ASSERT(MapPathCopy != NULL);
Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &MapPathCopy, &MapHandle);
if (MapHandle == PathHandle) {
PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, Node->MapName, 0);
PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, L";", 0);
break;
}
}
}
*/
return (AddBufferToFreeList(PathForReturn));
}
/**
Converts a device path to a file system-style path.
This function converts a device path to a file system path by replacing part, or all, of
the device path with the file-system mapping. If there are more than one application
file system mappings, the one that most closely matches Path will be used.
@param Path The pointer to the device path
@retval NULL the device path could not be found.
@return all The pointer of the NULL-terminated file path. The path
is callee-allocated and should be freed by the caller.
**/
CHAR16 *
)
{
PathSize = 0;
if (DevicePathCopy == NULL) {
return (NULL);
}
///@todo BlockIo?
return (NULL);
}
//
// check each of the device paths we have to get the root of the path
//
){
///@todo BlockIo?
if (MapHandle == PathHandle) {
//
// go through all the remaining nodes in the device path
//
){
//
// all the rest should be file path nodes
//
} else {
//
// append the path part onto the filepath.
//
}
} // for loop of remaining nodes
}
if (PathForReturn != NULL) {
break;
}
} // for loop of paths to check
return(PathForReturn);
}
/**
Converts a file system style name to a device path.
This function converts a file system style name to a device path, by replacing any
mapping references to the associated device path.
@param[in] Path The pointer to the path.
@return The pointer of the file path. The file path is callee
allocated and should be freed by the caller.
@retval NULL The path could not be found.
@retval NULL There was not enough available memory.
**/
)
{
return (NULL);
}
return (NULL);
}
return (NULL);
}
if (*Path == L'\\') {
Path++;
while (PathRemoveLastItem(NewPath)) ;
}
return (DevicePathForReturn);
}
Size = 0;
//
// find the part before (but including) the : for the map name
//
return (NULL);
}
//
// look up the device path in the map
//
if (DevicePath == NULL) {
//
// Must have been a bad Mapname
//
return (NULL);
}
//
// make a copy for LocateDevicePath to modify (also save a pointer to call FreePool with)
//
if (DevicePathCopy == NULL) {
return (NULL);
}
//
// get the handle
//
///@todo BlockIo?
if (DevicePathCopyForFree != NULL) {
}
return (NULL);
}
//
// build the full device path
//
} else {
}
if (DevicePathCopyForFree != NULL) {
}
return (DevicePathForReturn);
}
/**
Gets the name of the device specified by the device handle.
This function gets the user-readable name of the device specified by the device
handle. If no user-readable name could be generated, then *BestDeviceName will be
NULL and EFI_NOT_FOUND will be returned.
If EFI_DEVICE_NAME_USE_COMPONENT_NAME is set, then the function will return the
device's name using the EFI_COMPONENT_NAME2_PROTOCOL, if present on
DeviceHandle.
If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the
device's name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle.
If both EFI_DEVICE_NAME_USE_COMPONENT_NAME and
EFI_DEVICE_NAME_USE_DEVICE_PATH are set, then
EFI_DEVICE_NAME_USE_COMPONENT_NAME will have higher priority.
@param DeviceHandle The handle of the device.
@param Flags Determines the possible sources of component names.
Valid bits are:
EFI_DEVICE_NAME_USE_COMPONENT_NAME
EFI_DEVICE_NAME_USE_DEVICE_PATH
@param Language A pointer to the language specified for the device
name, in the same format as described in the UEFI
specification, Appendix M
@param BestDeviceName On return, points to the callee-allocated NULL-
terminated name of the device. If no device name
could be found, points to NULL. The name must be
freed by the caller...
@retval EFI_SUCCESS Get the name successfully.
@retval EFI_NOT_FOUND Fail to get the device name.
@retval EFI_INVALID_PARAMETER Flags did not have a valid bit set.
@retval EFI_INVALID_PARAMETER BestDeviceName was NULL
@retval EFI_INVALID_PARAMETER DeviceHandle was NULL
**/
)
{
if (BestDeviceName == NULL ||
DeviceHandle == NULL
){
return (EFI_INVALID_PARAMETER);
}
//
// make sure one of the 2 supported bits is on
//
if (((Flags & EFI_DEVICE_NAME_USE_COMPONENT_NAME) == 0) &&
((Flags & EFI_DEVICE_NAME_USE_DEVICE_PATH) == 0)) {
return (EFI_INVALID_PARAMETER);
}
*BestDeviceName = NULL;
HandleList = NULL;
HandleCount = 0;
if ((Flags & EFI_DEVICE_NAME_USE_COMPONENT_NAME) != 0) {
NULL,
&HandleList);
//
// Go through those handles until we get one that passes for GetComponentName
//
NULL,
NULL,
}
continue;
}
return (EFI_OUT_OF_RESOURCES);
}
}
} else {
return (EFI_OUT_OF_RESOURCES);
}
}
break;
}
}
if (HandleList != NULL) {
}
//
// Now check the parent controller using this as the child.
//
if (DeviceNameToReturn == NULL){
PARSE_HANDLE_DATABASE_UEFI_DRIVERS(ParentControllerBuffer[LoopVar], &ParentDriverCount, &ParentDriverBuffer);
//
// try using that driver's component name with controller and our driver as the child.
//
NULL,
NULL,
}
continue;
}
return (EFI_OUT_OF_RESOURCES);
}
}
} else {
return (EFI_OUT_OF_RESOURCES);
}
}
Status = CompName2->GetControllerName(CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn);
break;
}
}
break;
}
}
}
//
// dont return on fail since we will try device path if that bit is on
//
if (DeviceNameToReturn != NULL){
return (EFI_SUCCESS);
}
}
if ((Flags & EFI_DEVICE_NAME_USE_DEVICE_PATH) != 0) {
NULL,
(VOID**)&DevicePathToText);
//
// we now have the device path to text protocol
//
(VOID**)&DevicePath,
NULL,
//
// use device path to text on the device path
//
return (EFI_SUCCESS);
}
}
}
//
// none of the selected bits worked.
//
return (EFI_NOT_FOUND);
}
/**
Opens the root directory of a device on a handle
This function opens the root directory of a device and returns a file handle to it.
@param DeviceHandle The handle of the device that contains the volume.
@param FileHandle On exit, points to the file handle corresponding to the root directory on the
device.
@retval EFI_SUCCESS Root opened successfully.
@retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory
could not be opened.
@retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.
@retval EFI_DEVICE_ERROR The device had an error
**/
)
{
//
// get the simple file system interface
//
(VOID**)&SimpleFileSystem,
NULL,
return (EFI_NOT_FOUND);
}
NULL,
return (EFI_NOT_FOUND);
}
//
// Open the root volume now...
//
*FileHandle = ConvertEfiFileProtocolToShellHandle(RealFileHandle, EfiShellGetMapFromDevicePath(&DevPath));
return (Status);
}
/**
Opens the root directory of a device.
This function opens the root directory of a device and returns a file handle to it.
@param DevicePath Points to the device path corresponding to the device where the
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed.
@param FileHandle On exit, points to the file handle corresponding to the root directory on the
device.
@retval EFI_SUCCESS Root opened successfully.
@retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory
could not be opened.
@retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.
@retval EFI_DEVICE_ERROR The device had an error
@retval EFI_INVALID_PARAMETER FileHandle is NULL.
**/
)
{
if (FileHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
//
// find the handle of the device with that device handle and the file system
//
///@todo BlockIo?
&Handle);
return (EFI_NOT_FOUND);
}
}
/**
Returns whether any script files are currently being processed.
@retval TRUE There is at least one script file active.
@retval FALSE No script files are active now.
**/
)
{
if (ShellCommandGetCurrentScriptFile() == NULL) {
return (FALSE);
}
return (TRUE);
}
/**
Worker function to open a file based on a device path. this will open the root
of the volume and then traverse down to the file itself.
@param DevicePath Device Path of the file.
@param FileHandle Pointer to the file upon a successful return.
@param OpenMode mode to open file in.
@param Attributes the File Attributes to use when creating a new file.
@retval EFI_SUCCESS the file is open and FileHandle is valid
@retval EFI_UNSUPPORTED the device path cotained non-path elements
@retval other an error ocurred.
**/
)
{
if (FileHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
*FileHandle = NULL;
DpCopy = DevicePath;
ShellHandle = NULL;
FilePathNode = NULL;
AlignedNode = NULL;
//
// chop off the begining part before the file system part...
//
///@todo BlockIo?
&Handle);
//
// To access as a file system, the file path should only
// contain file path components. Follow the file path nodes
// and find the target file
//
){
//
// For file system access each node should be a file path component
//
) {
break;
}
//
// Open this file path node
//
//
// if this is the last node in the DevicePath always create (if that was requested).
//
&Handle1,
);
} else {
//
// This is not the last node and we dont want to 'create' existing
// directory entries...
//
//
// open without letting it create
// prevents error on existing files/directories
//
&Handle1,
);
//
// if above failed now open and create the 'item'
// if OpenMode EFI_FILE_MODE_CREATE bit was on (but disabled above)
//
&Handle1,
);
}
}
//
// Close the last node
//
//
// If there's been an error, stop
//
break;
}
} // for loop
}
}
}
}
} else {
}
return (Status);
}
/**
Creates a file or directory by name.
This function creates an empty new file or directory with the specified attributes and
returns the new file's handle. If the file already exists and is read-only, then
EFI_INVALID_PARAMETER will be returned.
If the file already existed, it is truncated and its attributes updated. If the file is
created successfully, the FileHandle is the file's handle, else, the FileHandle is NULL.
If the file name begins with >v, then the file handle which is returned refers to the
shell environment variable with the specified name. If the shell environment variable
already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.
@param FileName Pointer to NULL-terminated file path
@param FileAttribs The new file's attrbiutes. the different attributes are
described in EFI_FILE_PROTOCOL.Open().
@param FileHandle On return, points to the created file handle or directory's handle
@retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
@retval EFI_UNSUPPORTED could not open the file path
@retval EFI_NOT_FOUND the specified file could not be found on the devide, or could not
file the file system on the device.
@retval EFI_NO_MEDIA the device has no medium.
@retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
longer supported.
@retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according
the DirName.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
@retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
when the media is write-protected.
@retval EFI_ACCESS_DENIED The service denied access to the file.
@retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
@retval EFI_VOLUME_FULL The volume is full.
**/
)
{
//
// Is this for an environment variable
// do we start with >v
//
return (EFI_INVALID_PARAMETER);
}
return (EFI_SUCCESS);
}
//
// We are opening a regular file.
//
if (DevicePath == NULL) {
return (EFI_NOT_FOUND);
}
Status = InternalOpenFileDevicePath(DevicePath, FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, FileAttribs); // 0 = no specific file attributes
return(Status);
}
/**
Opens a file or a directory by file name.
This function opens the specified file in the specified OpenMode and returns a file
handle.
If the file name begins with >v, then the file handle which is returned refers to the
shell environment variable with the specified name. If the shell environment variable
exists, is non-volatile and the OpenMode indicates EFI_FILE_MODE_WRITE, then
EFI_INVALID_PARAMETER is returned.
If the file name is >i, then the file handle which is returned refers to the standard
input. If the OpenMode indicates EFI_FILE_MODE_WRITE, then EFI_INVALID_PARAMETER
is returned.
If the file name is >o, then the file handle which is returned refers to the standard
output. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER
is returned.
If the file name is >e, then the file handle which is returned refers to the standard
error. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER
is returned.
If the file name is NUL, then the file handle that is returned refers to the standard NUL
file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is
returned.
If return EFI_SUCCESS, the FileHandle is the opened file's handle, else, the
FileHandle is NULL.
@param FileName Points to the NULL-terminated UCS-2 encoded file name.
@param FileHandle On return, points to the file handle.
@param OpenMode File open mode. Either EFI_FILE_MODE_READ or
EFI_FILE_MODE_WRITE from section 12.4 of the UEFI
Specification.
@retval EFI_SUCCESS The file was opened. FileHandle has the opened file's handle.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL.
@retval EFI_UNSUPPORTED Could not open the file path. FileHandle is NULL.
@retval EFI_NOT_FOUND The specified file could not be found on the device or the file
system could not be found on the device. FileHandle is NULL.
@retval EFI_NO_MEDIA The device has no medium. FileHandle is NULL.
@retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
longer supported. FileHandle is NULL.
@retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according
the FileName. FileHandle is NULL.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. FileHandle is NULL.
@retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
when the media is write-protected. FileHandle is NULL.
@retval EFI_ACCESS_DENIED The service denied access to the file. FileHandle is NULL.
@retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. FileHandle
is NULL.
@retval EFI_VOLUME_FULL The volume is full. FileHandle is NULL.
**/
)
{
*FileHandle = NULL;
//
// Is this for StdIn
//
//
// make sure not writing to StdIn
//
if ((OpenMode & EFI_FILE_MODE_WRITE) != 0) {
return (EFI_INVALID_PARAMETER);
}
return (EFI_SUCCESS);
}
//
// Is this for StdOut
//
//
// make sure not writing to StdIn
//
if ((OpenMode & EFI_FILE_MODE_READ) != 0) {
return (EFI_INVALID_PARAMETER);
}
return (EFI_SUCCESS);
}
//
// Is this for NUL file
//
return (EFI_SUCCESS);
}
//
// Is this for StdErr
//
//
// make sure not writing to StdIn
//
if ((OpenMode & EFI_FILE_MODE_READ) != 0) {
return (EFI_INVALID_PARAMETER);
}
return (EFI_SUCCESS);
}
//
// Is this for an environment variable
// do we start with >v
//
((OpenMode & EFI_FILE_MODE_WRITE) != 0)) {
return (EFI_INVALID_PARAMETER);
}
return (EFI_SUCCESS);
}
//
// We are opening a regular file.
//
// DEBUG_CODE(InternalShellProtocolDebugPrintMessage (NULL, DevicePath););
if (DevicePath == NULL) {
return (EFI_NOT_FOUND);
}
//
// Copy the device path, open the file, then free the memory
//
Status = InternalOpenFileDevicePath(DevicePath, FileHandle, OpenMode, 0); // 0 = no specific file attributes
return(Status);
}
/**
Deletes the file specified by the file name.
This function deletes a file.
@param FileName Points to the NULL-terminated file name.
@retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
@retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.
@sa EfiShellCreateFile
**/
)
{
//
// get a handle to the file
//
0,
&FileHandle);
return (Status);
}
//
// now delete the file
//
}
/**
Disables the page break output mode.
**/
)
{
}
/**
Enables the page break output mode.
**/
)
{
}
/**
internal worker function to load and run an image via device path.
@param ParentImageHandle A handle of the image that is executing the specified
command line.
@param DevicePath device path of the file to execute
@param CommandLine Points to the NULL-terminated UCS-2 encoded string
containing the command line. If NULL then the command-
line will be empty.
@param Environment Points to a NULL-terminated array of environment
variables with the format 'x=y', where x is the
environment variable name and y is the value. If this
is NULL, then the current shell environment is used.
@param StatusCode Points to the status code returned by the command.
@retval EFI_SUCCESS The command executed successfully. The status code
returned by the command is pointed to by StatusCode.
@retval EFI_INVALID_PARAMETER The parameters are invalid.
@retval EFI_OUT_OF_RESOURCES Out of resources.
@retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
**/
)
{
if (ParentImageHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
//
// Load the image with:
// FALSE - not from boot manager and NULL, 0 being not already in memory
//
NULL,
0,
&NewHandle);
}
return (Status);
}
(VOID**)&LoadedImage,
NULL,
if (CommandLine != NULL) {
}
//
// Save our current environment settings for later restoration if necessary
//
if (Environment != NULL) {
}
}
//
// Initialize and install a shell parameters protocol on the image.
//
Status = gBS->InstallProtocolInterface(&NewHandle, &gEfiShellParametersProtocolGuid, EFI_NATIVE_INTERFACE, &ShellParamsProtocol);
///@todo initialize and install ShellInterface protocol on the new image for compatibility if - PcdGetBool(PcdShellSupportOldProtocols)
//
// now start the image and if the caller wanted the return code pass it to them...
//
if (StatusCode != NULL) {
} else {
}
}
//
// Cleanup (and dont overwrite errors)
//
} else {
Status = gBS->UninstallProtocolInterface(NewHandle, &gEfiShellParametersProtocolGuid, &ShellParamsProtocol);
}
}
if (!IsListEmpty(&OrigEnvs)) {
} else {
}
}
return(Status);
}
/**
Execute the command line.
This function creates a nested instance of the shell and executes the specified
command (CommandLine) with the specified environment (Environment). Upon return,
the status code returned by the specified command is placed in StatusCode.
If Environment is NULL, then the current environment is used and all changes made
by the commands executed will be reflected in the current environment. If the
Environment is non-NULL, then the changes made will be discarded.
The CommandLine is executed from the current working directory on the current
device.
@param ParentImageHandle A handle of the image that is executing the specified
command line.
@param CommandLine Points to the NULL-terminated UCS-2 encoded string
containing the command line. If NULL then the command-
line will be empty.
@param Environment Points to a NULL-terminated array of environment
variables with the format 'x=y', where x is the
environment variable name and y is the value. If this
is NULL, then the current shell environment is used.
@param StatusCode Points to the status code returned by the command.
@retval EFI_SUCCESS The command executed successfully. The status code
returned by the command is pointed to by StatusCode.
@retval EFI_INVALID_PARAMETER The parameters are invalid.
@retval EFI_OUT_OF_RESOURCES Out of resources.
@retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
@retval EFI_UNSUPPORTED The support level required for this function is not present.
@sa InternalShellExecuteDevicePath
**/
)
{
return (EFI_UNSUPPORTED);
}
Size = 0;
Temp,
//
// de-allocate and return
//
return(Status);
}
/**
Utility cleanup function for EFI_SHELL_FILE_INFO objects.
1) frees all pointers (non-NULL)
2) Closes the SHELL_FILE_HANDLE
@param FileListNode pointer to the list node to free
**/
)
{
}
}
}
}
}
/**
Frees the file list.
This function cleans up the file list and any related data structures. It has no
impact on the files themselves.
@param FileList The file list to free. Type EFI_SHELL_FILE_INFO is
defined in OpenFileList()
@retval EFI_SUCCESS Free the file list successfully.
@retval EFI_INVALID_PARAMETER FileList was NULL or *FileList was NULL;
**/
)
{
return (EFI_INVALID_PARAMETER);
}
){
}
return(EFI_SUCCESS);
}
/**
Deletes the duplicate file names files in the given file list.
This function deletes the reduplicate files in the given file list.
@param FileList A pointer to the first entry in the file list.
@retval EFI_SUCCESS Always success.
@retval EFI_INVALID_PARAMETER FileList was NULL or *FileList was NULL;
**/
)
{
return (EFI_INVALID_PARAMETER);
}
; ShellFileListItem = (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileList)->Link, &ShellFileListItem->Link)
){
for ( ShellFileListItem2 = (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileList)->Link, &ShellFileListItem->Link)
; ShellFileListItem2 = (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileList)->Link, &ShellFileListItem2->Link)
){
if (gUnicodeCollation->StriColl(
){
}
}
}
return (EFI_SUCCESS);
}
/**
Allocates and duplicates a EFI_SHELL_FILE_INFO node.
@param[in] Node The node to copy from.
@param[in] Save TRUE to set Node->Handle to NULL, FALSE otherwise.
@retval NULL a memory allocation error ocurred
@return != NULL a pointer to the new node
**/
)
{
return (NULL);
}
){
return(NULL);
}
if (!Save) {
}
return(NewNode);
}
/**
Allocates and populates a EFI_SHELL_FILE_INFO structure. if any memory operation
failed it will return NULL.
@param[in] BasePath the Path to prepend onto filename for FullPath
@param[in] Status Status member initial value.
@param[in] FullName FullName member initial value.
@param[in] FileName FileName member initial value.
@param[in] Handle Handle member initial value.
@param[in] Info Info struct to copy.
@retval NULL An error ocurred.
@return a pointer to the newly allocated structure.
**/
)
{
TempString = NULL;
Size = 0;
if (ShellFileListItem == NULL) {
return (NULL);
}
return (NULL);
}
} else {
}
return (NULL);
}
} else {
}
Size = 0;
TempString = NULL;
if (TempString == NULL) {
return (NULL);
}
}
if (TempString == NULL) {
return (NULL);
}
}
return (ShellFileListItem);
}
/**
Find all files in a specified directory.
@param FileDirHandle Handle of the directory to search.
@param FileList On return, points to the list of files in the directory
or NULL if there are no files in the directory.
@retval EFI_SUCCESS File information was returned successfully.
@retval EFI_VOLUME_CORRUPTED The file system structures have been corrupted.
@retval EFI_DEVICE_ERROR The device reported an error.
@retval EFI_NO_MEDIA The device media is not present.
@retval EFI_INVALID_PARAMETER The FileDirHandle was not a directory.
@return An error from FileHandleGetFileName().
**/
)
{
return (Status);
}
TempString = NULL;
Size = 0;
if (TempString == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
}
if (TempString == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
}
){
TempString = NULL;
Size = 0;
//
// allocate a new EFI_SHELL_FILE_INFO and populate it...
//
EFI_SUCCESS, // success since we didnt fail to open it...
NULL, // no handle since not open
FileInfo);
if (ShellFileList == NULL) {
}
}
} else {
}
return(Status);
}
/**
Updates a file name to be preceeded by the mapped drive name
@param[in] BasePath the Mapped drive name to prepend
@param[in, out] Path pointer to pointer to the file name to update.
@retval EFI_SUCCESS
@retval EFI_OUT_OF_RESOURCES
**/
)
{
Path2Size = 0;
//
// convert a local path to an absolute path
//
return (EFI_OUT_OF_RESOURCES);
}
return (EFI_OUT_OF_RESOURCES);
}
}
return (EFI_SUCCESS);
}
/**
If FileHandle is a directory then the function reads from FileHandle and reads in
each of the FileInfo structures. If one of them matches the Pattern's first
"level" then it opens that handle and calls itself on that handle.
If FileHandle is a file and matches all of the remaining Pattern (which would be
on its last node), then add a EFI_SHELL_FILE_INFO object for this file to fileList.
Upon a EFI_SUCCESS return fromt he function any the caller is responsible to call
FreeFileList with FileList.
@param[in] FilePattern The FilePattern to check against.
@param[in] UnicodeCollation The pointer to EFI_UNICODE_COLLATION_PROTOCOL structure
@param[in] FileHandle The FileHandle to start with
@param[in, out] FileList pointer to pointer to list of found files.
@param[in] ParentNode The node for the parent. Same file as identified by HANDLE.
@param[in] MapName The file system name this file is on.
@retval EFI_SUCCESS all files were found and the FileList contains a list.
@retval EFI_NOT_FOUND no files were found
@retval EFI_OUT_OF_RESOURCES a memory allocation failed
**/
)
{
if ( FilePattern == NULL
|| UnicodeCollation == NULL
){
return (EFI_INVALID_PARAMETER);
}
if (*FilePattern == L'\\') {
FilePattern++;
}
for( NextFilePatternStart = FilePattern
; NextFilePatternStart++);
if (CurrentFilePattern[0] == CHAR_NULL
&&NextFilePatternStart[0] == CHAR_NULL
){
//
// Add the current parameter FileHandle to the list, then end...
//
if (ParentNode == NULL) {
} else {
if (NewShellNode == NULL) {
} else {
}
//
// Add to the returning to use list
//
}
}
} else {
} else {
}
){
if (UnicodeCollation->MetaiMatch(UnicodeCollation, (CHAR16*)ShellInfoNode->FileName, CurrentFilePattern)){
if (NewFullName == NULL) {
} else {
}
}
if (Directory && !EFI_ERROR(Status) && ShellInfoNode->FullName != NULL && ShellInfoNode->FileName != NULL){
//
// should be a directory
//
//
// don't open the . and .. directories
//
){
//
//
//
break;
}
//
// Open the directory since we need that handle in the next recursion.
//
ShellInfoNode->Status = EfiShellOpenFileByName (ShellInfoNode->FullName, &ShellInfoNode->Handle, EFI_FILE_MODE_READ);
//
// recurse with the next part of the pattern
//
Status = ShellSearchHandle(NextFilePatternStart, UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);
}
//
// should be a file
//
//
// copy the information we need into a new Node
//
if (NewShellNode == NULL) {
}
}
//
// Add to the returning to use list
//
}
}
break;
}
}
} else {
}
}
}
return (Status);
}
/**
Find files that match a specified pattern.
This function searches for all files and directories that match the specified
FilePattern. The FilePattern can contain wild-card characters. The resulting file
information is placed in the file list FileList.
Wildcards are processed
according to the rules specified in UEFI Shell 2.0 spec section 3.7.1.
The files in the file list are not opened. The OpenMode field is set to 0 and the FileInfo
field is set to NULL.
if *FileList is not NULL then it must be a pre-existing and properly initialized list.
@param FilePattern Points to a NULL-terminated shell file path, including wildcards.
@param FileList On return, points to the start of a file list containing the names
of all matching files or else points to NULL if no matching files
were found. only on a EFI_SUCCESS return will; this be non-NULL.
@retval EFI_SUCCESS Files found. FileList is a valid list.
@retval EFI_NOT_FOUND No files found.
@retval EFI_NO_MEDIA The device has no media
@retval EFI_DEVICE_ERROR The device reported an error
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
**/
)
{
if ( FilePattern == NULL
){
return (EFI_INVALID_PARAMETER);
}
if (PatternCopy == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
Count += 2;
} else {
if (RootDevicePath == NULL) {
} else {
for ( PatternCurrentLocation = PatternCopy
; *PatternCurrentLocation != ':'
; PatternCurrentLocation++);
Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, RootFileHandle, FileList, NULL, MapName);
}
}
}
return(Status);
}
/**
Opens the files that match the path specified.
This function opens all of the files specified by Path. Wildcards are processed
according to the rules specified in UEFI Shell 2.0 spec section 3.7.1. Each
matching file has an EFI_SHELL_FILE_INFO structure created in a linked list.
@param Path A pointer to the path string.
@param OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or
EFI_FILE_MODE_WRITE.
@param FileList Points to the start of a list of files opened.
@retval EFI_SUCCESS Create the file list successfully.
@return Others Can't create the file list.
**/
)
{
Path2Size = 0;
return (EFI_INVALID_PARAMETER);
}
Path+=2;
}
//
// convert a local path to an absolute path
//
if (*Path == L'\\') {
Path++;
while (PathRemoveLastItem(Path2)) ;
}
} else {
}
//
// do the search
//
return (Status);
}
//
// We had no errors so open all the files (that are not already opened...)
//
; ShellFileListItem = (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileList)->Link, &ShellFileListItem->Link)
){
ShellFileListItem->Status = EfiShellOpenFileByName (ShellFileListItem->FullName, &ShellFileListItem->Handle, OpenMode);
}
}
if (!Found) {
return (EFI_NOT_FOUND);
}
return(EFI_SUCCESS);
}
/**
This function updated with errata.
Gets either a single or list of environment variables.
If name is not NULL then this function returns the current value of the specified
environment variable.
If Name is NULL, then a list of all environment variable names is returned. Each is a
NULL terminated string with a double NULL terminating the list.
@param Name A pointer to the environment variable name. If
Name is NULL, then the function will return all
of the defined shell environment variables. In
the case where multiple environment variables are
being returned, each variable will be terminated by
a NULL, and the list will be terminated by a double
NULL.
@return !=NULL A pointer to the returned string.
The returned pointer does not need to be freed by the caller.
@retval NULL The environment variable doesn't exist or there are
no environment variables.
**/
)
{
Size = 0;
//
// Get all our environment variables
//
return (NULL);
}
//
// Build the semi-colon delimited list. (2 passes)
//
){
}
if (!IsListEmpty (&List)) {
}
return (NULL);
}
){
}
//
// Free the list...
//
if (!IsListEmpty (&List)) {
}
} else {
//
// We are doing a specific environment variable
//
//
// get the size we need for this EnvVariable
//
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate the space and recall the get function
//
}
//
// we didnt get it (might not exist)
// free the memory if we allocated any and return NULL
//
}
return (NULL);
}
}
//
// return the buffer
//
return (AddBufferToFreeList(Buffer));
}
/**
Internal variable setting function. Allows for setting of the read only variables.
@param Name Points to the NULL-terminated environment variable name.
@param Value Points to the NULL-terminated environment variable value. If the value is an
empty string then the environment variable is deleted.
@param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
@retval EFI_SUCCESS The environment variable was successfully updated.
**/
)
{
return (SHELL_DELETE_ENVIRONMENT_VARIABLE(Name));
} else {
if (Volatile) {
} else {
}
}
}
/**
Sets the environment variable.
This function changes the current value of the specified environment variable. If the
environment variable exists and the Value is an empty string, then the environment
variable is deleted. If the environment variable exists and the Value is not an empty
string, then the value of the environment variable is changed. If the environment
variable does not exist and the Value is an empty string, there is no action. If the
environment variable does not exist and the Value is a non-empty string, then the
environment variable is created and assigned the specified value.
For a description of volatile and non-volatile environment variables, see UEFI Shell
2.0 specification section 3.6.1.
@param Name Points to the NULL-terminated environment variable name.
@param Value Points to the NULL-terminated environment variable value. If the value is an
empty string then the environment variable is deleted.
@param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
@retval EFI_SUCCESS The environment variable was successfully updated.
**/
)
{
return (EFI_INVALID_PARAMETER);
}
//
// Make sure we dont 'set' a predefined read only variable
//
if (gUnicodeCollation->StriColl(
L"cwd") == 0
L"Lasterror") == 0
L"profiles") == 0
L"uefishellsupport") == 0
L"uefishellversion") == 0
L"uefiversion") == 0
){
return (EFI_INVALID_PARAMETER);
}
}
/**
Returns the current directory on the specified device.
If FileSystemMapping is NULL, it returns the current working directory. If the
FileSystemMapping is not NULL, it returns the current directory associated with the
FileSystemMapping. In both cases, the returned name includes the file system
mapping (i.e. fs0:\current-dir).
@param FileSystemMapping A pointer to the file system mapping. If NULL,
then the current working directory is returned.
@retval !=NULL The current directory.
@retval NULL Current directory does not exist.
**/
)
{
//
// if parameter is NULL, use current
//
if (FileSystemMapping == NULL) {
return (EfiShellGetEnv(L"cwd"));
} else {
Size = 0;
PathToReturn = NULL;
if (MapListItem != NULL) {
}
}
return (AddBufferToFreeList(PathToReturn));
} else {
return (NULL);
}
}
/**
Changes the current directory on the specified device.
If the FileSystem is NULL, and the directory Dir does not contain a file system's
mapped name, this function changes the current working directory.
If the FileSystem is NULL and the directory Dir contains a mapped name, then the
current file system and the current directory on that file system are changed.
If FileSystem is NULL, and Dir is not NULL, then this changes the current working file
system.
If FileSystem is not NULL and Dir is not NULL, then this function changes the current
directory on the specified file system.
If the current working directory or the current working file system is changed then the
%cwd% environment variable will be updated
@param FileSystem A pointer to the file system's mapped name. If NULL, then the current working
directory is changed.
@param Dir Points to the NULL-terminated directory on the device specified by FileSystem.
@retval EFI_SUCCESS The operation was sucessful
@retval EFI_NOT_FOUND The file system could not be found
**/
)
{
Size = 0;
MapListItem = NULL;
TempString = NULL;
return (EFI_INVALID_PARAMETER);
}
return (EFI_NOT_FOUND);
}
if (FileSystem == NULL) {
//
// determine the file system mapping to use
//
MapName = StrnCatGrow(&MapName, NULL, DirectoryName, (StrStr(DirectoryName, L":")-DirectoryName+1));
}
//
// find the file system mapping's entry in the list
// or use current
//
//
// make that the current file system mapping
//
if (MapListItem != NULL) {
}
} else {
}
if (MapListItem == NULL) {
return (EFI_NOT_FOUND);
}
//
// now update the MapListItem's current directory
//
if (MapListItem->CurrentDirectoryPath != NULL && DirectoryName[StrLen(DirectoryName) - 1] != L':') {
}
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName+StrLen(MapName), 0);
}
} else {
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
}
if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
}
} else {
//
// cant have a mapping in the directory...
//
return (EFI_INVALID_PARAMETER);
}
//
// FileSystem != NULL
//
if (MapListItem == NULL) {
return (EFI_INVALID_PARAMETER);
}
// gShellCurDir = MapListItem;
if (DirectoryName != NULL) {
//
// change current dir on that file system
//
}
// ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
// MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, FileSystem, 0);
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
}
}
}
//
// if updated the current directory then update the environment variable
//
if (MapListItem == gShellCurDir) {
Size = 0;
return (Status);
}
return(EFI_SUCCESS);
}
/**
Return help information about a specific command.
This function returns the help information for the specified command. The help text
can be internal to the shell or can be from a UEFI Shell manual page.
If Sections is specified, then each section name listed will be compared in a casesensitive
manner, to the section names described in Appendix B. If the section exists,
it will be appended to the returned help text. If the section does not exist, no
information will be returned. If Sections is NULL, then all help text information
available will be returned.
@param Command Points to the NULL-terminated UEFI Shell command name.
@param Sections Points to the NULL-terminated comma-delimited
section names to return. If NULL, then all
sections will be returned.
@param HelpText On return, points to a callee-allocated buffer
containing all specified help text.
@retval EFI_SUCCESS The help text was returned.
@retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the
returned help text.
@retval EFI_INVALID_PARAMETER HelpText is NULL
@retval EFI_NOT_FOUND There is no help text available for Command.
**/
)
{
if (ManFileName != NULL) {
} else {
}
}
/**
Gets the enable status of the page break output mode.
User can use this function to determine current page break mode.
@retval TRUE The page break output mode is enabled.
@retval FALSE The page break output mode is disabled.
**/
)
{
return(ShellInfoObject.PageBreakEnabled);
}
/**
Judges whether the active shell is the root shell.
This function makes the user to know that whether the active Shell is the root shell.
@retval TRUE The active Shell is the root Shell.
@retval FALSE The active Shell is NOT the root Shell.
**/
)
{
return(ShellInfoObject.RootShellInstance);
}
/**
function to return a semi-colon delimeted list of all alias' in the current shell
up to caller to free the memory.
@retval NULL No alias' were found
@retval NULL An error ocurred getting alias'
@return !NULL a list of all alias'
**/
CHAR16 *
)
{
Status = gRT->QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, &MaxStorSize, &RemStorSize, &MaxVarSize);
RetSize = 0;
if (VariableName == NULL) {
return (NULL);
}
VariableName[0] = CHAR_NULL;
while (TRUE) {
if (Status == EFI_NOT_FOUND){
break;
}
break;
}
} // compare guid
} // while
return (RetVal);
}
/**
This function returns the command associated with a alias or a list of all
alias'.
@param[in] Alias Points to the NULL-terminated shell alias.
If this parameter is NULL, then all
aliases will be returned in ReturnedData.
@param[out] Volatile upon return of a single command if TRUE indicates
this is stored in a volatile fashion. FALSE otherwise.
@return If Alias is not NULL, it will return a pointer to
the NULL-terminated command for that alias.
If Alias is NULL, ReturnedData points to a ';'
delimited list of alias (e.g.
ReturnedData = "dir;del;copy;mfp") that is NULL-terminated.
@retval NULL an error ocurred
@retval NULL Alias was not a valid Alias
**/
)
{
}
RetSize = 0;
if (Status == EFI_BUFFER_TOO_SMALL) {
}
}
return (NULL);
}
} else {
}
return (AddBufferToFreeList(RetVal));
}
return (AddBufferToFreeList(InternalEfiShellGetListAlias()));
}
/**
Changes a shell command alias.
This function creates an alias for a shell command or if Alias is NULL it will delete an existing alias.
this function does not check for built in alias'.
@param[in] Command Points to the NULL-terminated shell command or existing alias.
@param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and
Command refers to an alias, that alias will be deleted.
@param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the
Alias being set will be stored in a non-volatile fashion.
@retval EFI_SUCCESS Alias created or deleted successfully.
@retval EFI_NOT_FOUND the Alias intended to be deleted was not found
**/
)
{
//
// We must be trying to remove one if Alias is NULL
//
//
// remove an alias (but passed in COMMAND parameter)
//
} else {
//
// Add and replace are the same
//
// We dont check the error return on purpose since the variable may not exist.
return (gRT->SetVariable((CHAR16*)Alias, &gShellAliasGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOLATILE), StrSize(Command), (VOID*)Command));
}
}
/**
Changes a shell command alias.
This function creates an alias for a shell command or if Alias is NULL it will delete an existing alias.
@param[in] Command Points to the NULL-terminated shell command or existing alias.
@param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and
Command refers to an alias, that alias will be deleted.
@param[in] Replace If TRUE and the alias already exists, then the existing alias will be replaced. If
FALSE and the alias already exists, then the existing alias is unchanged and
EFI_ACCESS_DENIED is returned.
@param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the
Alias being set will be stored in a non-volatile fashion.
@retval EFI_SUCCESS Alias created or deleted successfully.
@retval EFI_NOT_FOUND the Alias intended to be deleted was not found
@retval EFI_ACCESS_DENIED The alias is a built-in alias or already existed and Replace was set to
FALSE.
**/
)
{
//
// cant set over a built in alias
//
return (EFI_ACCESS_DENIED);
}
return (EFI_INVALID_PARAMETER);
}
return (EFI_ACCESS_DENIED);
}
}
// Pure FILE_HANDLE operations are passed to FileHandleLib
// these functions are indicated by the *
NULL,
};
/**
Function to create and install on the current handle.
Will overwrite any existing ShellProtocols in the system to be sure that
the current shell is in control.
This must be removed via calling CleanUpShellProtocol().
@param[in, out] NewShell The pointer to the pointer to the structure
to install.
@retval EFI_SUCCESS The operation was successful.
@return An error from LocateHandle, CreateEvent, or other core function.
**/
)
{
return (EFI_INVALID_PARAMETER);
}
BufferSize = 0;
//
// Initialize EfiShellProtocol object...
//
0,
NULL,
NULL,
return (Status);
}
//
// Get the size of the buffer we need.
//
NULL,
Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate and recall with buffer of correct size
//
return (EFI_OUT_OF_RESOURCES);
}
NULL,
Buffer);
return (Status);
}
//
// now overwrite each of them, but save the info to restore when we end.
//
NULL,
);
//
// reinstall over the old one...
//
(VOID*)(&mShellProtocol));
//
// we reinstalled sucessfully. log this so we can reverse it later.
//
//
// add to the list for subsequent...
//
}
}
}
} else if (Status == EFI_NOT_FOUND) {
//
// no one else published yet. just publish it ourselves.
//
(VOID*)(&mShellProtocol));
}
///@todo support ShellEnvironment2
///@todo do we need to support ShellEnvironment (not ShellEnvironment2) also?
}
*NewShell = &mShellProtocol;
}
return (Status);
}
/**
Opposite of CreatePopulateInstallShellProtocol.
Free all memory and restore the system to the state it was in before calling
CreatePopulateInstallShellProtocol.
@param[in, out] NewShell The pointer to the new shell protocol structure.
@retval EFI_SUCCESS The operation was successful.
**/
)
{
//
// if we need to restore old protocols...
//
){
}
} else {
//
// no need to restore
//
NewShell);
}
NULL,
}
return (Status);
}
/**
Notification function for keystrokes.
@param[in] KeyData The key that was pressed.
@retval EFI_SUCCESS The operation was successful.
**/
)
{
// ShellPrintEx(-1,-1,L" <Notify> ");
(KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))
){
return (EFI_UNSUPPORTED);
}
(KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))
){
}
return (EFI_SUCCESS);
}
/**
Function to start monitoring for CTRL-C using SimpleTextInputEx. This
feature's enabled state was not known when the shell initially launched.
@retval EFI_SUCCESS The feature is enabled.
@retval EFI_OUT_OF_RESOURCES There is not enough mnemory available.
**/
)
{
NULL,
-1,
-1,
NULL,
return (EFI_SUCCESS);
}
return (EFI_UNSUPPORTED);
}
&KeyData,
&KeyData,
}
&KeyData,
}
&KeyData,
}
return (Status);
}