2010-09-14 07:18:09 +02:00
|
|
|
/** @file
|
|
|
|
Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
|
|
|
|
manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
|
|
|
|
|
2012-08-17 05:58:17 +02:00
|
|
|
Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
|
2010-09-14 07:18:09 +02:00
|
|
|
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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
|
|
|
|
#define _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
|
|
|
|
|
|
|
|
#include "Shell.h"
|
|
|
|
|
2015-11-09 03:29:31 +01:00
|
|
|
typedef enum {
|
|
|
|
Internal_Command,
|
|
|
|
Script_File_Name,
|
|
|
|
Efi_Application,
|
|
|
|
File_Sys_Change,
|
|
|
|
Unknown_Invalid
|
|
|
|
} SHELL_OPERATION_TYPES;
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
/**
|
|
|
|
creates a new EFI_SHELL_PARAMETERS_PROTOCOL instance and populates it and then
|
|
|
|
installs it on our handle and if there is an existing version of the protocol
|
|
|
|
that one is cached for removal later.
|
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] NewShellParameters on a successful return, a pointer to pointer
|
2010-09-14 07:18:09 +02:00
|
|
|
to the newly installed interface.
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] RootShellInstance on a successful return, pointer to boolean.
|
2010-09-14 07:18:09 +02:00
|
|
|
TRUE if this is the root shell instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS the operation completed successfully.
|
|
|
|
@return other the operation failed.
|
|
|
|
@sa ReinstallProtocolInterface
|
|
|
|
@sa InstallProtocolInterface
|
|
|
|
@sa ParseCommandLineToArgs
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CreatePopulateInstallShellParametersProtocol (
|
|
|
|
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL **NewShellParameters,
|
|
|
|
IN OUT BOOLEAN *RootShellInstance
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
frees all memory used by createion and installation of shell parameters protocol
|
|
|
|
and if there was an old version installed it will restore that one.
|
|
|
|
|
|
|
|
@param NewShellParameters the interface of EFI_SHELL_PARAMETERS_PROTOCOL that is
|
|
|
|
being cleaned up.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS the cleanup was successful
|
|
|
|
@return other the cleanup failed
|
|
|
|
@sa ReinstallProtocolInterface
|
|
|
|
@sa UninstallProtocolInterface
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CleanUpShellParametersProtocol (
|
|
|
|
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Funcion will replace the current Argc and Argv in the ShellParameters protocol
|
|
|
|
structure by parsing NewCommandLine. The current values are returned to the
|
|
|
|
user.
|
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] ShellParameters pointer to parameter structure to modify
|
2010-09-14 07:18:09 +02:00
|
|
|
@param[in] NewCommandLine the new command line to parse and use
|
2015-11-09 03:29:31 +01:00
|
|
|
@param[in] Type the type of operation.
|
2010-09-14 07:18:09 +02:00
|
|
|
@param[out] OldArgv pointer to old list of parameters
|
|
|
|
@param[out] OldArgc pointer to old number of items in Argv list
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS operation was sucessful, Argv and Argc are valid
|
|
|
|
@retval EFI_OUT_OF_RESOURCES a memory allocation failed.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
UpdateArgcArgv(
|
|
|
|
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
|
|
|
IN CONST CHAR16 *NewCommandLine,
|
2015-11-09 03:29:31 +01:00
|
|
|
IN SHELL_OPERATION_TYPES Type,
|
2010-09-14 07:18:09 +02:00
|
|
|
OUT CHAR16 ***OldArgv,
|
|
|
|
OUT UINTN *OldArgc
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Funcion will replace the current Argc and Argv in the ShellParameters protocol
|
|
|
|
structure with Argv and Argc. The current values are de-allocated and the
|
|
|
|
OldArgv must not be deallocated by the caller.
|
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] ShellParameters pointer to parameter structure to modify
|
|
|
|
@param[in] OldArgv pointer to old list of parameters
|
|
|
|
@param[in] OldArgc pointer to old number of items in Argv list
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
RestoreArgcArgv(
|
|
|
|
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
|
|
|
IN CHAR16 ***OldArgv,
|
|
|
|
IN UINTN *OldArgc
|
|
|
|
);
|
|
|
|
|
2010-11-16 23:31:47 +01:00
|
|
|
typedef struct {
|
|
|
|
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
|
|
|
|
EFI_HANDLE ConInHandle;
|
|
|
|
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
|
|
|
|
EFI_HANDLE ConOutHandle;
|
2012-08-17 05:58:17 +02:00
|
|
|
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;
|
|
|
|
EFI_HANDLE ErrOutHandle;
|
2010-11-16 23:31:47 +01:00
|
|
|
} SYSTEM_TABLE_INFO;
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
/**
|
|
|
|
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
|
|
|
|
structure by parsing NewCommandLine. The current values are returned to the
|
|
|
|
user.
|
|
|
|
|
2011-03-30 23:04:57 +02:00
|
|
|
This will also update the system table.
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] ShellParameters Pointer to parameter structure to modify.
|
|
|
|
@param[in] NewCommandLine The new command line to parse and use.
|
|
|
|
@param[out] OldStdIn Pointer to old StdIn.
|
|
|
|
@param[out] OldStdOut Pointer to old StdOut.
|
|
|
|
@param[out] OldStdErr Pointer to old StdErr.
|
|
|
|
@param[out] SystemTableInfo Pointer to old system table information.
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS Operation was sucessful, Argv and Argc are valid.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
UpdateStdInStdOutStdErr(
|
|
|
|
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
2011-03-30 23:04:57 +02:00
|
|
|
IN CHAR16 *NewCommandLine,
|
2010-11-16 23:31:47 +01:00
|
|
|
OUT SHELL_FILE_HANDLE *OldStdIn,
|
|
|
|
OUT SHELL_FILE_HANDLE *OldStdOut,
|
|
|
|
OUT SHELL_FILE_HANDLE *OldStdErr,
|
|
|
|
OUT SYSTEM_TABLE_INFO *SystemTableInfo
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
|
|
|
|
structure with StdIn and StdOut. The current values are de-allocated.
|
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] ShellParameters Pointer to parameter structure to modify.
|
|
|
|
@param[in] OldStdIn Pointer to old StdIn.
|
|
|
|
@param[in] OldStdOut Pointer to old StdOut.
|
|
|
|
@param[in] OldStdErr Pointer to old StdErr.
|
|
|
|
@param[in] SystemTableInfo Pointer to old system table information.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
RestoreStdInStdOutStdErr (
|
|
|
|
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
2010-11-16 23:31:47 +01:00
|
|
|
IN SHELL_FILE_HANDLE *OldStdIn,
|
|
|
|
IN SHELL_FILE_HANDLE *OldStdOut,
|
|
|
|
IN SHELL_FILE_HANDLE *OldStdErr,
|
|
|
|
IN SYSTEM_TABLE_INFO *SystemTableInfo
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
function to populate Argc and Argv.
|
|
|
|
|
|
|
|
This function parses the CommandLine and divides it into standard C style Argc/Argv
|
|
|
|
parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space
|
|
|
|
delimited and quote surrounded parameter definition.
|
|
|
|
|
2015-11-09 03:29:31 +01:00
|
|
|
@param[in] CommandLine String of command line to parse
|
|
|
|
@param[in] StripQuotation if TRUE then strip the quotation marks surrounding
|
|
|
|
the parameters.
|
|
|
|
@param[in, out] Argv pointer to array of strings; one for each parameter
|
|
|
|
@param[in, out] Argc pointer to number of strings in Argv array
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
@return EFI_SUCCESS the operation was sucessful
|
|
|
|
@return EFI_OUT_OF_RESOURCES a memory allocation failed.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ParseCommandLineToArgs(
|
|
|
|
IN CONST CHAR16 *CommandLine,
|
2015-11-09 03:29:31 +01:00
|
|
|
IN BOOLEAN StripQuotation,
|
|
|
|
IN OUT CHAR16 ***Argv,
|
|
|
|
IN OUT UINTN *Argc
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
return the next parameter from a command line string;
|
|
|
|
|
|
|
|
This function moves the next parameter from Walker into TempParameter and moves
|
|
|
|
Walker up past that parameter for recursive calling. When the final parameter
|
|
|
|
is moved *Walker will be set to NULL;
|
|
|
|
|
|
|
|
Temp Parameter must be large enough to hold the parameter before calling this
|
|
|
|
function.
|
|
|
|
|
2015-11-09 03:29:31 +01:00
|
|
|
@param[in, out] Walker pointer to string of command line. Adjusted to
|
|
|
|
reminaing command line on return
|
|
|
|
@param[in, out] TempParameter pointer to string of command line item extracted.
|
|
|
|
@param[in] Length Length of (*TempParameter) in bytes
|
|
|
|
@param[in] StripQuotation if TRUE then strip the quotation marks surrounding
|
|
|
|
the parameters.
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2015-01-27 19:56:36 +01:00
|
|
|
@return EFI_INALID_PARAMETER A required parameter was NULL or pointed to a NULL or empty string.
|
|
|
|
@return EFI_NOT_FOUND A closing " could not be found on the specified string
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2015-01-27 19:56:36 +01:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
EFIAPI
|
|
|
|
GetNextParameter(
|
2014-09-02 22:17:38 +02:00
|
|
|
IN OUT CHAR16 **Walker,
|
|
|
|
IN OUT CHAR16 **TempParameter,
|
2015-11-09 03:29:31 +01:00
|
|
|
IN CONST UINTN Length,
|
|
|
|
IN BOOLEAN StripQuotation
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
#endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
|
|
|
|
|