mirror of https://github.com/acidanthera/audk.git
console logger - support disabling the console out.
console wrapper - comment fixes. file handle wrappers - allow for creation of layers of file interfaces to automatically convert ASCII to UCS-2. shell - add CTRL-S support and change how searching for startup.nsh. shellenvvar - zero the memory allocations. shall man parser - input verification on the help text. shellparameters protocol - input redirection verification enhanced, leave ^ behind when not used. shell protocol - remove ASSERTs, fixed GetDeviceName, allow mapping of BlockIO devices, and enhanced key monitoring for CTRL-S (now CTRL-S and CTRL-C). git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11440 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
dc56f067d2
commit
733f138d84
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Provides interface to shell console logger.
|
Provides interface to shell console logger.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -39,40 +39,40 @@ ConsoleLoggerInstall(
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
ASSERT(ConsoleInfo != NULL);
|
ASSERT(ConsoleInfo != NULL);
|
||||||
|
|
||||||
(*ConsoleInfo) = AllocatePool(sizeof(CONSOLE_LOGGER_PRIVATE_DATA));
|
(*ConsoleInfo) = AllocateZeroPool(sizeof(CONSOLE_LOGGER_PRIVATE_DATA));
|
||||||
if ((*ConsoleInfo) == NULL) {
|
if ((*ConsoleInfo) == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*ConsoleInfo)->Signature = CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE;
|
(*ConsoleInfo)->Signature = CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE;
|
||||||
(*ConsoleInfo)->OldConOut = NULL;
|
(*ConsoleInfo)->OldConOut = gST->ConOut;
|
||||||
(*ConsoleInfo)->OldConHandle = NULL;
|
(*ConsoleInfo)->OldConHandle = gST->ConsoleOutHandle;
|
||||||
(*ConsoleInfo)->Buffer = NULL;
|
(*ConsoleInfo)->Buffer = NULL;
|
||||||
(*ConsoleInfo)->BufferSize = 0;
|
(*ConsoleInfo)->BufferSize = 0;
|
||||||
(*ConsoleInfo)->OriginalStartRow = 0;
|
(*ConsoleInfo)->OriginalStartRow = 0;
|
||||||
(*ConsoleInfo)->CurrentStartRow = 0;
|
(*ConsoleInfo)->CurrentStartRow = 0;
|
||||||
(*ConsoleInfo)->RowsPerScreen = 0;
|
(*ConsoleInfo)->RowsPerScreen = 0;
|
||||||
(*ConsoleInfo)->ColsPerScreen = 0;
|
(*ConsoleInfo)->ColsPerScreen = 0;
|
||||||
(*ConsoleInfo)->Attributes = NULL;
|
(*ConsoleInfo)->Attributes = NULL;
|
||||||
(*ConsoleInfo)->AttribSize = 0;
|
(*ConsoleInfo)->AttribSize = 0;
|
||||||
(*ConsoleInfo)->ScreenCount = ScreensToSave;
|
(*ConsoleInfo)->ScreenCount = ScreensToSave;
|
||||||
(*ConsoleInfo)->HistoryMode.MaxMode = 1;
|
(*ConsoleInfo)->HistoryMode.MaxMode = 1;
|
||||||
(*ConsoleInfo)->HistoryMode.Mode = 0;
|
(*ConsoleInfo)->HistoryMode.Mode = 0;
|
||||||
(*ConsoleInfo)->HistoryMode.Attribute = 0;
|
(*ConsoleInfo)->HistoryMode.Attribute = 0;
|
||||||
(*ConsoleInfo)->HistoryMode.CursorColumn = 0;
|
(*ConsoleInfo)->HistoryMode.CursorColumn = 0;
|
||||||
(*ConsoleInfo)->HistoryMode.CursorRow = 0;
|
(*ConsoleInfo)->HistoryMode.CursorRow = 0;
|
||||||
(*ConsoleInfo)->HistoryMode.CursorVisible = FALSE;
|
(*ConsoleInfo)->HistoryMode.CursorVisible = FALSE;
|
||||||
(*ConsoleInfo)->OurConOut.Reset = ConsoleLoggerReset;
|
(*ConsoleInfo)->OurConOut.Reset = ConsoleLoggerReset;
|
||||||
(*ConsoleInfo)->OurConOut.OutputString = ConsoleLoggerOutputString;
|
(*ConsoleInfo)->OurConOut.OutputString = ConsoleLoggerOutputString;
|
||||||
(*ConsoleInfo)->OurConOut.TestString = ConsoleLoggerTestString;
|
(*ConsoleInfo)->OurConOut.TestString = ConsoleLoggerTestString;
|
||||||
(*ConsoleInfo)->OurConOut.QueryMode = ConsoleLoggerQueryMode;
|
(*ConsoleInfo)->OurConOut.QueryMode = ConsoleLoggerQueryMode;
|
||||||
(*ConsoleInfo)->OurConOut.SetMode = ConsoleLoggerSetMode;
|
(*ConsoleInfo)->OurConOut.SetMode = ConsoleLoggerSetMode;
|
||||||
(*ConsoleInfo)->OurConOut.SetAttribute = ConsoleLoggerSetAttribute;
|
(*ConsoleInfo)->OurConOut.SetAttribute = ConsoleLoggerSetAttribute;
|
||||||
(*ConsoleInfo)->OurConOut.ClearScreen = ConsoleLoggerClearScreen;
|
(*ConsoleInfo)->OurConOut.ClearScreen = ConsoleLoggerClearScreen;
|
||||||
(*ConsoleInfo)->OurConOut.SetCursorPosition = ConsoleLoggerSetCursorPosition;
|
(*ConsoleInfo)->OurConOut.SetCursorPosition = ConsoleLoggerSetCursorPosition;
|
||||||
(*ConsoleInfo)->OurConOut.EnableCursor = ConsoleLoggerEnableCursor;
|
(*ConsoleInfo)->OurConOut.EnableCursor = ConsoleLoggerEnableCursor;
|
||||||
(*ConsoleInfo)->OurConOut.Mode = NULL;
|
(*ConsoleInfo)->OurConOut.Mode = gST->ConOut->Mode;
|
||||||
(*ConsoleInfo)->Enabled = TRUE;
|
(*ConsoleInfo)->Enabled = TRUE;
|
||||||
|
|
||||||
Status = ConsoleLoggerResetBuffers(*ConsoleInfo);
|
Status = ConsoleLoggerResetBuffers(*ConsoleInfo);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
|
@ -90,11 +90,8 @@ ConsoleLoggerInstall(
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*ConsoleInfo)->OldConOut = gST->ConOut;
|
|
||||||
(*ConsoleInfo)->OldConHandle = gST->ConsoleOutHandle;
|
|
||||||
|
|
||||||
gST->ConsoleOutHandle = gImageHandle;
|
gST->ConsoleOutHandle = gImageHandle;
|
||||||
gST->ConOut = &(*ConsoleInfo)->OurConOut;
|
gST->ConOut = &(*ConsoleInfo)->OurConOut;
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +100,7 @@ ConsoleLoggerInstall(
|
||||||
Return the system to the state it was before InstallConsoleLogger
|
Return the system to the state it was before InstallConsoleLogger
|
||||||
was installed.
|
was installed.
|
||||||
|
|
||||||
@param[in,out] ConsoleInfo The object from the install function.
|
@param[in] ConsoleInfo The object from the install function.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The operation was successful
|
@retval EFI_SUCCESS The operation was successful
|
||||||
@return other The operation failed. This was from UninstallProtocolInterface.
|
@return other The operation failed. This was from UninstallProtocolInterface.
|
||||||
|
@ -631,7 +628,10 @@ ConsoleLoggerDoPageBreak(
|
||||||
}
|
}
|
||||||
if (*Resp == ShellPromptResponseContinue) {
|
if (*Resp == ShellPromptResponseContinue) {
|
||||||
FreePool(Resp);
|
FreePool(Resp);
|
||||||
ShellInfoObject.ConsoleInfo->RowCounter = 0;
|
ShellInfoObject.ConsoleInfo->RowCounter = 0;
|
||||||
|
// ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorRow = 0;
|
||||||
|
// ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
|
||||||
|
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
} else if (*Resp == ShellPromptResponseQuit) {
|
} else if (*Resp == ShellPromptResponseQuit) {
|
||||||
FreePool(Resp);
|
FreePool(Resp);
|
||||||
|
@ -660,16 +660,23 @@ ConsoleLoggerDoPageBreak(
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ConsoleLoggerPrintWithPageBreak(
|
ConsoleLoggerPrintWithPageBreak(
|
||||||
IN CHAR16 *String,
|
IN CONST CHAR16 *String,
|
||||||
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
|
IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CONST CHAR16 *Walker;
|
CONST CHAR16 *Walker;
|
||||||
CONST CHAR16 *LineStart;
|
CONST CHAR16 *LineStart;
|
||||||
|
CHAR16 *StringCopy;
|
||||||
CHAR16 TempChar;
|
CHAR16 TempChar;
|
||||||
|
|
||||||
for ( Walker = String
|
StringCopy = NULL;
|
||||||
, LineStart = String
|
StringCopy = StrnCatGrow(&StringCopy, NULL, String, 0);
|
||||||
|
if (StringCopy == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Walker = StringCopy
|
||||||
|
, LineStart = StringCopy
|
||||||
; Walker != NULL && *Walker != CHAR_NULL
|
; Walker != NULL && *Walker != CHAR_NULL
|
||||||
; Walker++
|
; Walker++
|
||||||
){
|
){
|
||||||
|
@ -766,6 +773,7 @@ ConsoleLoggerPrintWithPageBreak(
|
||||||
//
|
//
|
||||||
// We got an error which means 'break' and halt the printing
|
// We got an error which means 'break' and halt the printing
|
||||||
//
|
//
|
||||||
|
SHELL_FREE_NON_NULL(StringCopy);
|
||||||
return (EFI_DEVICE_ERROR);
|
return (EFI_DEVICE_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -775,6 +783,7 @@ ConsoleLoggerPrintWithPageBreak(
|
||||||
ConsoleLoggerOutputStringSplit (LineStart, ConsoleInfo);
|
ConsoleLoggerOutputStringSplit (LineStart, ConsoleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHELL_FREE_NON_NULL(StringCopy);
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,6 +812,9 @@ ConsoleLoggerOutputString (
|
||||||
{
|
{
|
||||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
|
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
|
||||||
|
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
|
||||||
|
return (EFI_UNSUPPORTED);
|
||||||
|
}
|
||||||
ASSERT(ShellInfoObject.ConsoleInfo == ConsoleInfo);
|
ASSERT(ShellInfoObject.ConsoleInfo == ConsoleInfo);
|
||||||
if (!ShellInfoObject.ConsoleInfo->Enabled) {
|
if (!ShellInfoObject.ConsoleInfo->Enabled) {
|
||||||
return (EFI_DEVICE_ERROR);
|
return (EFI_DEVICE_ERROR);
|
||||||
|
@ -893,8 +905,8 @@ ConsoleLoggerQueryMode (
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ConsoleLoggerSetMode (
|
ConsoleLoggerSetMode (
|
||||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||||
IN UINTN ModeNumber
|
IN UINTN ModeNumber
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
@ -911,6 +923,7 @@ ConsoleLoggerSetMode (
|
||||||
// Check that the buffers are still correct for logging
|
// Check that the buffers are still correct for logging
|
||||||
//
|
//
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
|
ConsoleInfo->OurConOut.Mode = gST->ConOut->Mode;
|
||||||
ConsoleLoggerResetBuffers(ConsoleInfo);
|
ConsoleLoggerResetBuffers(ConsoleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,9 +994,12 @@ ConsoleLoggerClearScreen (
|
||||||
INT32 *Attributes;
|
INT32 *Attributes;
|
||||||
UINTN Row;
|
UINTN Row;
|
||||||
UINTN Column;
|
UINTN Column;
|
||||||
|
|
||||||
|
|
||||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||||
|
|
||||||
|
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
|
||||||
|
return (EFI_UNSUPPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
|
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1044,8 +1060,12 @@ ConsoleLoggerSetCursorPosition (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
|
||||||
|
|
||||||
|
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
|
||||||
|
return (EFI_UNSUPPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
|
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
|
||||||
//
|
//
|
||||||
// Forward the request to the original ConOut
|
// Forward the request to the original ConOut
|
||||||
|
@ -1154,8 +1174,6 @@ ConsoleLoggerResetBuffers(
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleInfo->OurConOut.Mode = gST->ConOut->Mode;
|
|
||||||
ConsoleInfo->OldConOut = gST->ConOut;
|
|
||||||
CopyMem (&ConsoleInfo->HistoryMode, ConsoleInfo->OldConOut->Mode, sizeof (EFI_SIMPLE_TEXT_OUTPUT_MODE));
|
CopyMem (&ConsoleInfo->HistoryMode, ConsoleInfo->OldConOut->Mode, sizeof (EFI_SIMPLE_TEXT_OUTPUT_MODE));
|
||||||
|
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Function definitions for shell simple text in and out on top of file handles.
|
Function definitions for shell simple text in and out on top of file handles.
|
||||||
|
|
||||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2011, 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
|
||||||
|
@ -82,15 +82,15 @@ FileBasedSimpleTextInReset(
|
||||||
ReadKeyStroke function for the fake simple text input.
|
ReadKeyStroke function for the fake simple text input.
|
||||||
|
|
||||||
@param[in] This A pointer to the SimpleTextIn structure.
|
@param[in] This A pointer to the SimpleTextIn structure.
|
||||||
@param[out] Key A pointer to the Key structure to fill.
|
@param[in,out] Key A pointer to the Key structure to fill.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The read was successful.
|
@retval EFI_SUCCESS The read was successful.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
FileBasedSimpleTextInReadKeyStroke(
|
FileBasedSimpleTextInReadKeyStroke(
|
||||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||||
IN EFI_INPUT_KEY *Key
|
IN OUT EFI_INPUT_KEY *Key
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
|
@ -454,14 +454,14 @@ CreateSimpleTextOutOnFile(
|
||||||
Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
|
Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
|
||||||
SHELL_FILE_HANDLE to support redirecting output from a file.
|
SHELL_FILE_HANDLE to support redirecting output from a file.
|
||||||
|
|
||||||
@param[in] SimpleTextOut The pointer to the SimpleTextOUT to close.
|
@param[in] SimpleTextOut The pointer to the SimpleTextOUT to close.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The object was closed.
|
@retval EFI_SUCCESS The object was closed.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CloseSimpleTextOutOnFile(
|
CloseSimpleTextOutOnFile(
|
||||||
OUT EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
|
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Function definitions for shell simple text in and out on top of file handles.
|
Function definitions for shell simple text in and out on top of file handles.
|
||||||
|
|
||||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2011, 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
|
||||||
|
@ -67,14 +67,14 @@ CreateSimpleTextOutOnFile(
|
||||||
Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
|
Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
|
||||||
SHELL_FILE_HANDLE to support redirecting output from a file.
|
SHELL_FILE_HANDLE to support redirecting output from a file.
|
||||||
|
|
||||||
@param[in] SimpleTextOut The pointer to the SimpleTextOUT to close.
|
@param[in] SimpleTextOut The pointer to the SimpleTextOUT to close.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The object was closed.
|
@retval EFI_SUCCESS The object was closed.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CloseSimpleTextOutOnFile(
|
CloseSimpleTextOutOnFile(
|
||||||
OUT EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
|
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif //_SHELL_CONSOLE_WRAPPERS_HEADER_
|
#endif //_SHELL_CONSOLE_WRAPPERS_HEADER_
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
EFI_FILE_PROTOCOL wrappers for other items (Like Environment Variables,
|
EFI_FILE_PROTOCOL wrappers for other items (Like Environment Variables,
|
||||||
StdIn, StdOut, StdErr, etc...).
|
StdIn, StdOut, StdErr, etc...).
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -166,18 +166,18 @@ FileInterfaceStdOutWrite(
|
||||||
/**
|
/**
|
||||||
File style interface for StdIn (Write).
|
File style interface for StdIn (Write).
|
||||||
|
|
||||||
@param[in] This Ignored.
|
@param[in] This Ignored.
|
||||||
@param[in] BufferSize Ignored.
|
@param[in,out] BufferSize Ignored.
|
||||||
@param[in] Buffer Ignored.
|
@param[in] Buffer Ignored.
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED
|
@retval EFI_UNSUPPORTED
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
FileInterfaceStdInWrite(
|
FileInterfaceStdInWrite(
|
||||||
IN EFI_FILE_PROTOCOL *This,
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
IN OUT UINTN *BufferSize,
|
IN OUT UINTN *BufferSize,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (EFI_UNSUPPORTED);
|
return (EFI_UNSUPPORTED);
|
||||||
|
@ -232,7 +232,7 @@ FileInterfaceStdOutRead(
|
||||||
@param[in,out] BufferSize Ignored.
|
@param[in,out] BufferSize Ignored.
|
||||||
@param[out] Buffer Ignored.
|
@param[out] Buffer Ignored.
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED
|
@retval EFI_UNSUPPORTED Always.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
|
@ -250,16 +250,16 @@ FileInterfaceStdErrRead(
|
||||||
|
|
||||||
@param[in] This Ignored.
|
@param[in] This Ignored.
|
||||||
@param[in,out] BufferSize Ignored.
|
@param[in,out] BufferSize Ignored.
|
||||||
@param[in] Buffer Ignored.
|
@param[out] Buffer Ignored.
|
||||||
|
|
||||||
@retval EFI_SUCCESS
|
@retval EFI_SUCCESS Always.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
FileInterfaceNulRead(
|
FileInterfaceNulRead(
|
||||||
IN EFI_FILE_PROTOCOL *This,
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
IN OUT UINTN *BufferSize,
|
IN OUT UINTN *BufferSize,
|
||||||
OUT VOID *Buffer
|
OUT VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
|
@ -1352,7 +1352,7 @@ FileInterfaceMemWrite(
|
||||||
//
|
//
|
||||||
// Ascii
|
// Ascii
|
||||||
//
|
//
|
||||||
AsciiBuffer = AllocatePool(*BufferSize);
|
AsciiBuffer = AllocateZeroPool(*BufferSize);
|
||||||
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
|
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
|
||||||
if ((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize)) {
|
if ((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize)) {
|
||||||
((EFI_FILE_PROTOCOL_MEM*)This)->Buffer = ReallocatePool((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize), (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize) + AsciiStrSize(AsciiBuffer) + 10, ((EFI_FILE_PROTOCOL_MEM*)This)->Buffer);
|
((EFI_FILE_PROTOCOL_MEM*)This)->Buffer = ReallocatePool((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize), (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize) + AsciiStrSize(AsciiBuffer) + 10, ((EFI_FILE_PROTOCOL_MEM*)This)->Buffer);
|
||||||
|
@ -1474,6 +1474,224 @@ typedef struct {
|
||||||
EFI_FILE_PROTOCOL *Orig;
|
EFI_FILE_PROTOCOL *Orig;
|
||||||
} EFI_FILE_PROTOCOL_FILE;
|
} EFI_FILE_PROTOCOL_FILE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set a files current position
|
||||||
|
|
||||||
|
@param This Protocol instance pointer.
|
||||||
|
@param Position Byte position from the start of the file.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Data was written.
|
||||||
|
@retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FileInterfaceFileSetPosition(
|
||||||
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
|
IN UINT64 Position
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->SetPosition(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get a file's current position
|
||||||
|
|
||||||
|
@param This Protocol instance pointer.
|
||||||
|
@param Position Byte position from the start of the file.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Data was written.
|
||||||
|
@retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open..
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FileInterfaceFileGetPosition(
|
||||||
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
|
OUT UINT64 *Position
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->GetPosition(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get information about a file.
|
||||||
|
|
||||||
|
@param This Protocol instance pointer.
|
||||||
|
@param InformationType Type of information to return in Buffer.
|
||||||
|
@param BufferSize On input size of buffer, on output amount of data in buffer.
|
||||||
|
@param Buffer The buffer to return data.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Data was returned.
|
||||||
|
@retval EFI_UNSUPPORT InformationType is not supported.
|
||||||
|
@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.
|
||||||
|
@retval EFI_WRITE_PROTECTED The device is write protected.
|
||||||
|
@retval EFI_ACCESS_DENIED The file was open for read only.
|
||||||
|
@retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in BufferSize.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FileInterfaceFileGetInfo(
|
||||||
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
|
IN EFI_GUID *InformationType,
|
||||||
|
IN OUT UINTN *BufferSize,
|
||||||
|
OUT VOID *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->GetInfo(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, InformationType, BufferSize, Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set information about a file
|
||||||
|
|
||||||
|
@param File Protocol instance pointer.
|
||||||
|
@param InformationType Type of information in Buffer.
|
||||||
|
@param BufferSize Size of buffer.
|
||||||
|
@param Buffer The data to write.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Data was returned.
|
||||||
|
@retval EFI_UNSUPPORT InformationType is not supported.
|
||||||
|
@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.
|
||||||
|
@retval EFI_WRITE_PROTECTED The device is write protected.
|
||||||
|
@retval EFI_ACCESS_DENIED The file was open for read only.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FileInterfaceFileSetInfo(
|
||||||
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
|
IN EFI_GUID *InformationType,
|
||||||
|
IN UINTN BufferSize,
|
||||||
|
IN VOID *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->SetInfo(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, InformationType, BufferSize, Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Flush data back for the file handle.
|
||||||
|
|
||||||
|
@param This Protocol instance pointer.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Data was written.
|
||||||
|
@retval EFI_UNSUPPORT Writes to Open directory are not supported.
|
||||||
|
@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.
|
||||||
|
@retval EFI_WRITE_PROTECTED The device is write protected.
|
||||||
|
@retval EFI_ACCESS_DENIED The file was open for read only.
|
||||||
|
@retval EFI_VOLUME_FULL The volume is full.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FileInterfaceFileFlush(
|
||||||
|
IN EFI_FILE_PROTOCOL *This
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Flush(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Read data from the file.
|
||||||
|
|
||||||
|
@param This Protocol instance pointer.
|
||||||
|
@param BufferSize On input size of buffer, on output amount of data in buffer.
|
||||||
|
@param Buffer The buffer in which data is read.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Data was read.
|
||||||
|
@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.
|
||||||
|
@retval EFI_BUFFER_TO_SMALL BufferSize is too small. BufferSize contains required size.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FileInterfaceFileRead(
|
||||||
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
|
IN OUT UINTN *BufferSize,
|
||||||
|
OUT VOID *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CHAR8 *AsciiBuffer;
|
||||||
|
UINTN Size;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
if (((EFI_FILE_PROTOCOL_FILE*)This)->Unicode) {
|
||||||
|
//
|
||||||
|
// Unicode
|
||||||
|
//
|
||||||
|
return (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Read(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, BufferSize, Buffer));
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Ascii
|
||||||
|
//
|
||||||
|
AsciiBuffer = AllocateZeroPool((Size = *BufferSize));
|
||||||
|
Status = (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Read(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, &Size, AsciiBuffer));
|
||||||
|
UnicodeSPrint(Buffer, *BufferSize, L"%a", AsciiBuffer);
|
||||||
|
FreePool(AsciiBuffer);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Opens a new file relative to the source file's location.
|
||||||
|
|
||||||
|
@param[in] This The protocol instance pointer.
|
||||||
|
@param[out] NewHandle Returns File Handle for FileName.
|
||||||
|
@param[in] FileName Null terminated string. "\", ".", and ".." are supported.
|
||||||
|
@param[in] OpenMode Open mode for file.
|
||||||
|
@param[in] Attributes Only used for EFI_FILE_MODE_CREATE.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The device was opened.
|
||||||
|
@retval EFI_NOT_FOUND The specified file could not be found on the device.
|
||||||
|
@retval EFI_NO_MEDIA The device has no media.
|
||||||
|
@retval EFI_MEDIA_CHANGED The media has changed.
|
||||||
|
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||||
|
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||||
|
@retval EFI_ACCESS_DENIED The service denied access to the file.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
|
||||||
|
@retval EFI_VOLUME_FULL The volume is full.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FileInterfaceFileOpen (
|
||||||
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
|
OUT EFI_FILE_PROTOCOL **NewHandle,
|
||||||
|
IN CHAR16 *FileName,
|
||||||
|
IN UINT64 OpenMode,
|
||||||
|
IN UINT64 Attributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Open(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, NewHandle, FileName, OpenMode, Attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Close and delete the file handle.
|
||||||
|
|
||||||
|
@param This Protocol instance pointer.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The device was opened.
|
||||||
|
@retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FileInterfaceFileDelete(
|
||||||
|
IN EFI_FILE_PROTOCOL *This
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
Status = ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Delete(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);
|
||||||
|
FreePool(This);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
File style interface for File (Close).
|
File style interface for File (Close).
|
||||||
|
|
||||||
|
@ -1487,9 +1705,10 @@ FileInterfaceFileClose(
|
||||||
IN EFI_FILE_PROTOCOL *This
|
IN EFI_FILE_PROTOCOL *This
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Close(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);
|
EFI_STATUS Status;
|
||||||
|
Status = ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Close(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);
|
||||||
FreePool(This);
|
FreePool(This);
|
||||||
return (EFI_SUCCESS);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1498,18 +1717,18 @@ FileInterfaceFileClose(
|
||||||
If the file was opened with ASCII mode the data will be processed through
|
If the file was opened with ASCII mode the data will be processed through
|
||||||
AsciiSPrint before writing.
|
AsciiSPrint before writing.
|
||||||
|
|
||||||
@param[in] This The pointer to the EFI_FILE_PROTOCOL object.
|
@param[in] This The pointer to the EFI_FILE_PROTOCOL object.
|
||||||
@param[in] BufferSize Size in bytes of Buffer.
|
@param[in,out] BufferSize Size in bytes of Buffer.
|
||||||
@param[in] Buffer The pointer to the buffer to write.
|
@param[in] Buffer The pointer to the buffer to write.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The data was written.
|
@retval EFI_SUCCESS The data was written.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
FileInterfaceFileWrite(
|
FileInterfaceFileWrite(
|
||||||
IN EFI_FILE_PROTOCOL *This,
|
IN EFI_FILE_PROTOCOL *This,
|
||||||
IN OUT UINTN *BufferSize,
|
IN OUT UINTN *BufferSize,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CHAR8 *AsciiBuffer;
|
CHAR8 *AsciiBuffer;
|
||||||
|
@ -1524,7 +1743,7 @@ FileInterfaceFileWrite(
|
||||||
//
|
//
|
||||||
// Ascii
|
// Ascii
|
||||||
//
|
//
|
||||||
AsciiBuffer = AllocatePool(*BufferSize);
|
AsciiBuffer = AllocateZeroPool(*BufferSize);
|
||||||
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
|
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
|
||||||
Size = AsciiStrSize(AsciiBuffer) - 1; // (we dont need the null terminator)
|
Size = AsciiStrSize(AsciiBuffer) - 1; // (we dont need the null terminator)
|
||||||
Status = (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Write(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, &Size, AsciiBuffer));
|
Status = (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Write(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, &Size, AsciiBuffer));
|
||||||
|
@ -1552,15 +1771,23 @@ CreateFileInterfaceFile(
|
||||||
{
|
{
|
||||||
EFI_FILE_PROTOCOL_FILE *NewOne;
|
EFI_FILE_PROTOCOL_FILE *NewOne;
|
||||||
|
|
||||||
NewOne = AllocatePool(sizeof(EFI_FILE_PROTOCOL_FILE));
|
NewOne = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_FILE));
|
||||||
if (NewOne == NULL) {
|
if (NewOne == NULL) {
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
CopyMem(NewOne, Template, sizeof(EFI_FILE_PROTOCOL_FILE));
|
CopyMem(NewOne, Template, sizeof(EFI_FILE_PROTOCOL_FILE));
|
||||||
NewOne->Orig = (EFI_FILE_PROTOCOL *)Template;
|
NewOne->Orig = (EFI_FILE_PROTOCOL *)Template;
|
||||||
NewOne->Unicode = Unicode;
|
NewOne->Unicode = Unicode;
|
||||||
NewOne->Close = FileInterfaceFileClose;
|
NewOne->Open = FileInterfaceFileOpen;
|
||||||
NewOne->Write = FileInterfaceFileWrite;
|
NewOne->Close = FileInterfaceFileClose;
|
||||||
|
NewOne->Delete = FileInterfaceFileDelete;
|
||||||
|
NewOne->Read = FileInterfaceFileRead;
|
||||||
|
NewOne->Write = FileInterfaceFileWrite;
|
||||||
|
NewOne->GetPosition = FileInterfaceFileGetPosition;
|
||||||
|
NewOne->SetPosition = FileInterfaceFileSetPosition;
|
||||||
|
NewOne->GetInfo = FileInterfaceFileGetInfo;
|
||||||
|
NewOne->SetInfo = FileInterfaceFileSetInfo;
|
||||||
|
NewOne->Flush = FileInterfaceFileFlush;
|
||||||
|
|
||||||
return ((EFI_FILE_PROTOCOL *)NewOne);
|
return ((EFI_FILE_PROTOCOL *)NewOne);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
This is THE shell (application)
|
This is THE shell (application)
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -62,6 +62,82 @@ STATIC CONST CHAR16 mScriptExtension[] = L".NSH";
|
||||||
STATIC CONST CHAR16 mExecutableExtensions[] = L".NSH;.EFI";
|
STATIC CONST CHAR16 mExecutableExtensions[] = L".NSH;.EFI";
|
||||||
STATIC CONST CHAR16 mStartupScript[] = L"startup.nsh";
|
STATIC CONST CHAR16 mStartupScript[] = L"startup.nsh";
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function to start monitoring for CTRL-S 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.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
InternalEfiShellStartCtrlSMonitor(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
|
||||||
|
EFI_KEY_DATA KeyData;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = gBS->OpenProtocol(
|
||||||
|
gST->ConsoleInHandle,
|
||||||
|
&gEfiSimpleTextInputExProtocolGuid,
|
||||||
|
(VOID**)&SimpleEx,
|
||||||
|
gImageHandle,
|
||||||
|
NULL,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
ShellPrintHiiEx(
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
NULL,
|
||||||
|
STRING_TOKEN (STR_SHELL_NO_IN_EX),
|
||||||
|
ShellInfoObject.HiiHandle);
|
||||||
|
return (EFI_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyData.KeyState.KeyToggleState = 0;
|
||||||
|
KeyData.Key.ScanCode = 0;
|
||||||
|
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
|
||||||
|
KeyData.Key.UnicodeChar = L's';
|
||||||
|
|
||||||
|
Status = SimpleEx->RegisterKeyNotify(
|
||||||
|
SimpleEx,
|
||||||
|
&KeyData,
|
||||||
|
NotificationFunction,
|
||||||
|
&ShellInfoObject.CtrlSNotifyHandle1);
|
||||||
|
|
||||||
|
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
|
||||||
|
if (!EFI_ERROR(Status)) {
|
||||||
|
Status = SimpleEx->RegisterKeyNotify(
|
||||||
|
SimpleEx,
|
||||||
|
&KeyData,
|
||||||
|
NotificationFunction,
|
||||||
|
&ShellInfoObject.CtrlSNotifyHandle2);
|
||||||
|
}
|
||||||
|
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
|
||||||
|
KeyData.Key.UnicodeChar = 19;
|
||||||
|
|
||||||
|
if (!EFI_ERROR(Status)) {
|
||||||
|
Status = SimpleEx->RegisterKeyNotify(
|
||||||
|
SimpleEx,
|
||||||
|
&KeyData,
|
||||||
|
NotificationFunction,
|
||||||
|
&ShellInfoObject.CtrlSNotifyHandle2);
|
||||||
|
}
|
||||||
|
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
|
||||||
|
if (!EFI_ERROR(Status)) {
|
||||||
|
Status = SimpleEx->RegisterKeyNotify(
|
||||||
|
SimpleEx,
|
||||||
|
&KeyData,
|
||||||
|
NotificationFunction,
|
||||||
|
&ShellInfoObject.CtrlSNotifyHandle2);
|
||||||
|
}
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The entry point for the application.
|
The entry point for the application.
|
||||||
|
|
||||||
|
@ -278,6 +354,13 @@ UefiMain (
|
||||||
Status = InernalEfiShellStartMonitor();
|
Status = InernalEfiShellStartMonitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!EFI_ERROR(Status) && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
|
||||||
|
//
|
||||||
|
// Set up the event for CTRL-S monitoring...
|
||||||
|
//
|
||||||
|
Status = InternalEfiShellStartCtrlSMonitor();
|
||||||
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && PcdGet8(PcdShellSupportLevel) >= 1) {
|
if (!EFI_ERROR(Status) && PcdGet8(PcdShellSupportLevel) >= 1) {
|
||||||
//
|
//
|
||||||
// process the startup script or launch the called app.
|
// process the startup script or launch the called app.
|
||||||
|
@ -577,6 +660,7 @@ ProcessCommandLine(
|
||||||
UINTN Count;
|
UINTN Count;
|
||||||
UINTN LoopVar;
|
UINTN LoopVar;
|
||||||
CHAR16 *ProblemParam;
|
CHAR16 *ProblemParam;
|
||||||
|
UINT64 Intermediate;
|
||||||
|
|
||||||
Package = NULL;
|
Package = NULL;
|
||||||
ProblemParam = NULL;
|
ProblemParam = NULL;
|
||||||
|
@ -587,7 +671,7 @@ ProcessCommandLine(
|
||||||
Size = 0;
|
Size = 0;
|
||||||
TempConst = ShellCommandLineGetRawValue(Package, Count++);
|
TempConst = ShellCommandLineGetRawValue(Package, Count++);
|
||||||
if (TempConst != NULL && StrLen(TempConst)) {
|
if (TempConst != NULL && StrLen(TempConst)) {
|
||||||
ShellInfoObject.ShellInitSettings.FileName = AllocatePool(StrSize(TempConst));
|
ShellInfoObject.ShellInitSettings.FileName = AllocateZeroPool(StrSize(TempConst));
|
||||||
if (ShellInfoObject.ShellInitSettings.FileName == NULL) {
|
if (ShellInfoObject.ShellInitSettings.FileName == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
@ -641,17 +725,19 @@ ProcessCommandLine(
|
||||||
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = ShellCommandLineGetFlag(Package, L"-noversion");
|
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = ShellCommandLineGetFlag(Package, L"-noversion");
|
||||||
ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = ShellCommandLineGetFlag(Package, L"-delay");
|
ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = ShellCommandLineGetFlag(Package, L"-delay");
|
||||||
|
|
||||||
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay) {
|
ShellInfoObject.ShellInitSettings.Delay = 5;
|
||||||
TempConst = ShellCommandLineGetValue(Package, L"-delay");
|
|
||||||
if (TempConst != NULL) {
|
|
||||||
ShellInfoObject.ShellInitSettings.Delay = StrDecimalToUintn (TempConst);
|
|
||||||
} else {
|
|
||||||
ShellInfoObject.ShellInitSettings.Delay = 5;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ShellInfoObject.ShellInitSettings.Delay = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoInterrupt) {
|
||||||
|
ShellInfoObject.ShellInitSettings.Delay = 0;
|
||||||
|
} else if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay) {
|
||||||
|
TempConst = ShellCommandLineGetValue(Package, L"-delay");
|
||||||
|
if (*TempConst == L':') {
|
||||||
|
TempConst++;
|
||||||
|
}
|
||||||
|
if (TempConst != NULL && !EFI_ERROR(ShellConvertStringToUint64(TempConst, &Intermediate, FALSE, FALSE))) {
|
||||||
|
ShellInfoObject.ShellInitSettings.Delay = (UINTN)Intermediate;
|
||||||
|
}
|
||||||
|
}
|
||||||
ShellCommandLineFreeVarList(Package);
|
ShellCommandLineFreeVarList(Package);
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
|
@ -681,7 +767,9 @@ DoStartupScript(
|
||||||
EFI_DEVICE_PATH_PROTOCOL *NewPath;
|
EFI_DEVICE_PATH_PROTOCOL *NewPath;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *NamePath;
|
EFI_DEVICE_PATH_PROTOCOL *NamePath;
|
||||||
CHAR16 *FileStringPath;
|
CHAR16 *FileStringPath;
|
||||||
|
CHAR16 *TempSpot;
|
||||||
UINTN NewSize;
|
UINTN NewSize;
|
||||||
|
CONST CHAR16 *MapName;
|
||||||
|
|
||||||
Key.UnicodeChar = CHAR_NULL;
|
Key.UnicodeChar = CHAR_NULL;
|
||||||
Key.ScanCode = 0;
|
Key.ScanCode = 0;
|
||||||
|
@ -723,13 +811,15 @@ DoStartupScript(
|
||||||
//
|
//
|
||||||
// print out our warning and see if they press a key
|
// print out our warning and see if they press a key
|
||||||
//
|
//
|
||||||
for ( Status = EFI_UNSUPPORTED, Delay = (ShellInfoObject.ShellInitSettings.Delay * 10)
|
for ( Status = EFI_UNSUPPORTED, Delay = ShellInfoObject.ShellInitSettings.Delay * 10
|
||||||
; Delay > 0 && EFI_ERROR(Status)
|
; Delay != 0 && EFI_ERROR(Status)
|
||||||
; Delay--
|
; Delay--
|
||||||
){
|
){
|
||||||
ShellPrintHiiEx(0, gST->ConOut->Mode->CursorRow, NULL, STRING_TOKEN (STR_SHELL_STARTUP_QUESTION), ShellInfoObject.HiiHandle, Delay/10);
|
ShellPrintHiiEx(0, gST->ConOut->Mode->CursorRow, NULL, STRING_TOKEN (STR_SHELL_STARTUP_QUESTION), ShellInfoObject.HiiHandle, Delay/10);
|
||||||
gBS->Stall (100000);
|
gBS->Stall (100000);
|
||||||
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
|
||||||
|
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_CRLF), ShellInfoObject.HiiHandle);
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_CRLF), ShellInfoObject.HiiHandle);
|
||||||
|
|
||||||
|
@ -740,25 +830,39 @@ DoStartupScript(
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NamePath = FileDevicePath (NULL, mStartupScript);
|
|
||||||
//
|
//
|
||||||
// Try the first location
|
// Try the first location (must be file system)
|
||||||
//
|
//
|
||||||
NewPath = AppendDevicePathNode (ImagePath, NamePath);
|
MapName = ShellInfoObject.NewEfiShellProtocol->GetMapFromDevicePath(&ImagePath);
|
||||||
Status = InternalOpenFileDevicePath(NewPath, &FileHandle, EFI_FILE_MODE_READ, 0);
|
if (MapName != NULL) {
|
||||||
if (EFI_ERROR(Status)) {
|
FileStringPath = NULL;
|
||||||
//
|
NewSize = 0;
|
||||||
// Try the second location
|
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, MapName, 0);
|
||||||
//
|
TempSpot = StrStr(FileStringPath, L";");
|
||||||
FreePool(NewPath);
|
if (TempSpot != NULL) {
|
||||||
NewPath = AppendDevicePathNode (FilePath , NamePath);
|
*TempSpot = CHAR_NULL;
|
||||||
Status = InternalOpenFileDevicePath(NewPath, &FileHandle, EFI_FILE_MODE_READ, 0);
|
}
|
||||||
|
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, ((FILEPATH_DEVICE_PATH*)FilePath)->PathName, 0);
|
||||||
|
ChopLastSlash(FileStringPath);
|
||||||
|
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, mStartupScript, 0);
|
||||||
|
Status = ShellInfoObject.NewEfiShellProtocol->OpenFileByName(FileStringPath, &FileHandle, EFI_FILE_MODE_READ);
|
||||||
|
FreePool(FileStringPath);
|
||||||
}
|
}
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
NamePath = FileDevicePath (NULL, mStartupScript);
|
||||||
|
NewPath = AppendDevicePathNode (ImagePath, NamePath);
|
||||||
|
FreePool(NamePath);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try the location
|
||||||
|
//
|
||||||
|
Status = InternalOpenFileDevicePath(NewPath, &FileHandle, EFI_FILE_MODE_READ, 0);
|
||||||
|
FreePool(NewPath);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// If we got a file, run it
|
// If we got a file, run it
|
||||||
//
|
//
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status) && FileHandle != NULL) {
|
||||||
Status = RunScriptFileHandle (FileHandle, mStartupScript);
|
Status = RunScriptFileHandle (FileHandle, mStartupScript);
|
||||||
ShellInfoObject.NewEfiShellProtocol->CloseFile(FileHandle);
|
ShellInfoObject.NewEfiShellProtocol->CloseFile(FileHandle);
|
||||||
} else {
|
} else {
|
||||||
|
@ -775,8 +879,6 @@ DoStartupScript(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool(NamePath);
|
|
||||||
FreePool(NewPath);
|
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
@ -920,7 +1022,7 @@ ShellConvertAlias(
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
FreePool(*CommandString);
|
FreePool(*CommandString);
|
||||||
*CommandString = AllocatePool(StrSize(NewString));
|
*CommandString = AllocateZeroPool(StrSize(NewString));
|
||||||
if (*CommandString == NULL) {
|
if (*CommandString == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1287,7 @@ RunCommand(
|
||||||
UINTN PostAliasSize;
|
UINTN PostAliasSize;
|
||||||
CHAR16 *PostVariableCmdLine;
|
CHAR16 *PostVariableCmdLine;
|
||||||
CHAR16 *CommandWithPath;
|
CHAR16 *CommandWithPath;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
CONST EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
||||||
CONST CHAR16 *TempLocation;
|
CONST CHAR16 *TempLocation;
|
||||||
CONST CHAR16 *TempLocation2;
|
CONST CHAR16 *TempLocation2;
|
||||||
SHELL_FILE_HANDLE OriginalStdIn;
|
SHELL_FILE_HANDLE OriginalStdIn;
|
||||||
|
@ -1319,7 +1421,11 @@ RunCommand(
|
||||||
|
|
||||||
Status = UpdateStdInStdOutStdErr(ShellInfoObject.NewShellParametersProtocol, PostVariableCmdLine, &OriginalStdIn, &OriginalStdOut, &OriginalStdErr, &OriginalSystemTableInfo);
|
Status = UpdateStdInStdOutStdErr(ShellInfoObject.NewShellParametersProtocol, PostVariableCmdLine, &OriginalStdIn, &OriginalStdOut, &OriginalStdErr, &OriginalSystemTableInfo);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);
|
if (Status == EFI_NOT_FOUND) {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_REDUNDA_REDIR), ShellInfoObject.HiiHandle);
|
||||||
|
} else {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// remove the < and/or > from the command line now
|
// remove the < and/or > from the command line now
|
||||||
|
@ -1452,7 +1558,6 @@ RunCommand(
|
||||||
SHELL_FREE_NON_NULL(CommandName);
|
SHELL_FREE_NON_NULL(CommandName);
|
||||||
SHELL_FREE_NON_NULL(CommandWithPath);
|
SHELL_FREE_NON_NULL(CommandWithPath);
|
||||||
SHELL_FREE_NON_NULL(PostVariableCmdLine);
|
SHELL_FREE_NON_NULL(PostVariableCmdLine);
|
||||||
SHELL_FREE_NON_NULL(DevPath);
|
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
@ -1591,12 +1696,12 @@ RunScriptFileHandle (
|
||||||
//
|
//
|
||||||
// Now enumerate through the commands and run each one.
|
// Now enumerate through the commands and run each one.
|
||||||
//
|
//
|
||||||
CommandLine = AllocatePool(PcdGet16(PcdShellPrintBufferSize));
|
CommandLine = AllocateZeroPool(PcdGet16(PcdShellPrintBufferSize));
|
||||||
if (CommandLine == NULL) {
|
if (CommandLine == NULL) {
|
||||||
DeleteScriptFileStruct(NewScriptFile);
|
DeleteScriptFileStruct(NewScriptFile);
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
CommandLine2 = AllocatePool(PcdGet16(PcdShellPrintBufferSize));
|
CommandLine2 = AllocateZeroPool(PcdGet16(PcdShellPrintBufferSize));
|
||||||
if (CommandLine2 == NULL) {
|
if (CommandLine2 == NULL) {
|
||||||
FreePool(CommandLine);
|
FreePool(CommandLine);
|
||||||
DeleteScriptFileStruct(NewScriptFile);
|
DeleteScriptFileStruct(NewScriptFile);
|
||||||
|
@ -1732,11 +1837,17 @@ RunScriptFileHandle (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ShellCommandSetEchoState(PreScriptEchoState);
|
|
||||||
|
|
||||||
FreePool(CommandLine);
|
FreePool(CommandLine);
|
||||||
FreePool(CommandLine2);
|
FreePool(CommandLine2);
|
||||||
ShellCommandSetNewScript (NULL);
|
ShellCommandSetNewScript (NULL);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Only if this was the last script reset the state.
|
||||||
|
//
|
||||||
|
if (ShellCommandGetCurrentScriptFile()==NULL) {
|
||||||
|
ShellCommandSetEchoState(PreScriptEchoState);
|
||||||
|
}
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
function definitions for internal to shell functions.
|
function definitions for internal to shell functions.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -109,6 +109,10 @@ typedef struct {
|
||||||
EFI_HANDLE CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
EFI_HANDLE CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
||||||
EFI_HANDLE CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
EFI_HANDLE CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
||||||
EFI_HANDLE CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
EFI_HANDLE CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
||||||
|
EFI_HANDLE CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
||||||
|
EFI_HANDLE CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
||||||
|
EFI_HANDLE CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
||||||
|
EFI_HANDLE CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
|
||||||
} SHELL_INFO;
|
} SHELL_INFO;
|
||||||
|
|
||||||
extern SHELL_INFO ShellInfoObject;
|
extern SHELL_INFO ShellInfoObject;
|
||||||
|
|
Binary file not shown.
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
function declarations for shell environment functions.
|
function declarations for shell environment functions.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -56,7 +56,7 @@ IsVolatileEnv (
|
||||||
&Size,
|
&Size,
|
||||||
Buffer);
|
Buffer);
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
Buffer = AllocatePool(Size);
|
Buffer = AllocateZeroPool(Size);
|
||||||
ASSERT(Buffer != NULL);
|
ASSERT(Buffer != NULL);
|
||||||
Status = gRT->GetVariable((CHAR16*)EnvVarName,
|
Status = gRT->GetVariable((CHAR16*)EnvVarName,
|
||||||
&gShellVariableGuid,
|
&gShellVariableGuid,
|
||||||
|
@ -154,7 +154,7 @@ GetEnvironmentVariableList(
|
||||||
}
|
}
|
||||||
|
|
||||||
NameSize = (UINTN)MaxVarSize;
|
NameSize = (UINTN)MaxVarSize;
|
||||||
VariableName = AllocatePool(NameSize);
|
VariableName = AllocateZeroPool(NameSize);
|
||||||
if (VariableName == NULL) {
|
if (VariableName == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ GetEnvironmentVariableList(
|
||||||
ValSize = 0;
|
ValSize = 0;
|
||||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
|
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL){
|
if (Status == EFI_BUFFER_TOO_SMALL){
|
||||||
VarList->Val = AllocatePool(ValSize);
|
VarList->Val = AllocateZeroPool(ValSize);
|
||||||
if (VarList->Val == NULL) {
|
if (VarList->Val == NULL) {
|
||||||
SHELL_FREE_NON_NULL(VarList);
|
SHELL_FREE_NON_NULL(VarList);
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
@ -184,7 +184,7 @@ GetEnvironmentVariableList(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && VarList != NULL) {
|
if (!EFI_ERROR(Status) && VarList != NULL) {
|
||||||
VarList->Key = AllocatePool(StrSize(VariableName));
|
VarList->Key = AllocateZeroPool(StrSize(VariableName));
|
||||||
if (VarList->Key == NULL) {
|
if (VarList->Key == NULL) {
|
||||||
SHELL_FREE_NON_NULL(VarList->Val);
|
SHELL_FREE_NON_NULL(VarList->Val);
|
||||||
SHELL_FREE_NON_NULL(VarList);
|
SHELL_FREE_NON_NULL(VarList);
|
||||||
|
@ -312,7 +312,7 @@ SetEnvironmentVariables(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ASSERT(StrStr(CurrentString, L"=") != NULL);
|
ASSERT(StrStr(CurrentString, L"=") != NULL);
|
||||||
Node = AllocatePool(sizeof(ENV_VAR_LIST));
|
Node = AllocateZeroPool(sizeof(ENV_VAR_LIST));
|
||||||
ASSERT(Node != NULL);
|
ASSERT(Node != NULL);
|
||||||
Node->Key = AllocateZeroPool((StrStr(CurrentString, L"=") - CurrentString + 1) * sizeof(CHAR16));
|
Node->Key = AllocateZeroPool((StrStr(CurrentString, L"=") - CurrentString + 1) * sizeof(CHAR16));
|
||||||
ASSERT(Node->Key != NULL);
|
ASSERT(Node->Key != NULL);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Provides interface to shell MAN file parser.
|
Provides interface to shell MAN file parser.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -368,7 +368,7 @@ ManBufferFindTitleSection(
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
TitleString = AllocatePool((7*sizeof(CHAR16)) + StrSize(Command));
|
TitleString = AllocateZeroPool((7*sizeof(CHAR16)) + StrSize(Command));
|
||||||
if (TitleString == NULL) {
|
if (TitleString == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
@ -389,24 +389,27 @@ ManBufferFindTitleSection(
|
||||||
; CurrentLocation++);
|
; CurrentLocation++);
|
||||||
|
|
||||||
TitleEnd = StrStr(CurrentLocation, L"\"");
|
TitleEnd = StrStr(CurrentLocation, L"\"");
|
||||||
ASSERT(TitleEnd != NULL);
|
if (TitleEnd == NULL) {
|
||||||
if (BriefDesc != NULL) {
|
Status = EFI_DEVICE_ERROR;
|
||||||
*BriefSize = StrSize(TitleEnd);
|
} else {
|
||||||
*BriefDesc = AllocateZeroPool(*BriefSize);
|
if (BriefDesc != NULL) {
|
||||||
if (*BriefDesc == NULL) {
|
*BriefSize = StrSize(TitleEnd);
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
*BriefDesc = AllocateZeroPool(*BriefSize);
|
||||||
} else {
|
if (*BriefDesc == NULL) {
|
||||||
StrnCpy(*BriefDesc, CurrentLocation, TitleEnd-CurrentLocation);
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
} else {
|
||||||
|
StrnCpy(*BriefDesc, CurrentLocation, TitleEnd-CurrentLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (CurrentLocation = TitleEnd
|
for (CurrentLocation = TitleEnd
|
||||||
; *CurrentLocation != L'\n'
|
; *CurrentLocation != L'\n'
|
||||||
; CurrentLocation++);
|
; CurrentLocation++);
|
||||||
for (
|
for (
|
||||||
; *CurrentLocation == L' ' || *CurrentLocation == L'\n' || *CurrentLocation == L'\r'
|
; *CurrentLocation == L' ' || *CurrentLocation == L'\n' || *CurrentLocation == L'\r'
|
||||||
; CurrentLocation++);
|
; CurrentLocation++);
|
||||||
*Buffer = CurrentLocation;
|
*Buffer = CurrentLocation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool(TitleString);
|
FreePool(TitleString);
|
||||||
|
@ -465,7 +468,7 @@ ManFileFindTitleSection(
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleString = AllocatePool((4*sizeof(CHAR16)) + StrSize(Command));
|
TitleString = AllocateZeroPool((4*sizeof(CHAR16)) + StrSize(Command));
|
||||||
if (TitleString == NULL) {
|
if (TitleString == NULL) {
|
||||||
FreePool(ReadLine);
|
FreePool(ReadLine);
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
|
Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
|
||||||
manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
|
manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -127,9 +127,9 @@ GetNextParameter(
|
||||||
for (NextDelim = *TempParameter ; NextDelim != NULL && *NextDelim != CHAR_NULL ; NextDelim++) {
|
for (NextDelim = *TempParameter ; NextDelim != NULL && *NextDelim != CHAR_NULL ; NextDelim++) {
|
||||||
if (*NextDelim == L'^' && *(NextDelim+1) == L'^') {
|
if (*NextDelim == L'^' && *(NextDelim+1) == L'^') {
|
||||||
CopyMem(NextDelim, NextDelim+1, StrSize(NextDelim) - sizeof(NextDelim[0]));
|
CopyMem(NextDelim, NextDelim+1, StrSize(NextDelim) - sizeof(NextDelim[0]));
|
||||||
} else if (*NextDelim == L'^') {
|
}/* else if (*NextDelim == L'^') {
|
||||||
*NextDelim = L' ';
|
*NextDelim = L' ';
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
while ((*TempParameter)[StrLen(*TempParameter)-1] == L' ') {
|
while ((*TempParameter)[StrLen(*TempParameter)-1] == L' ') {
|
||||||
(*TempParameter)[StrLen(*TempParameter)-1] = CHAR_NULL;
|
(*TempParameter)[StrLen(*TempParameter)-1] = CHAR_NULL;
|
||||||
|
@ -142,7 +142,7 @@ GetNextParameter(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
function to populate Argc and Argv.
|
Function to populate Argc and Argv.
|
||||||
|
|
||||||
This function parses the CommandLine and divides it into standard C style Argc/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
|
parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space
|
||||||
|
@ -419,6 +419,34 @@ CleanUpShellParametersProtocol (
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
IsUnicodeFile(
|
||||||
|
IN CONST CHAR16 *FileName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SHELL_FILE_HANDLE Handle;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINT64 OriginalFilePosition;
|
||||||
|
UINTN CharSize;
|
||||||
|
CHAR16 CharBuffer;
|
||||||
|
|
||||||
|
Status = gEfiShellProtocol->OpenFileByName(FileName, &Handle, EFI_FILE_MODE_READ);
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
gEfiShellProtocol->GetFilePosition(Handle, &OriginalFilePosition);
|
||||||
|
gEfiShellProtocol->SetFilePosition(Handle, 0);
|
||||||
|
CharSize = sizeof(CHAR16);
|
||||||
|
Status = gEfiShellProtocol->ReadFile(Handle, &CharSize, &CharBuffer);
|
||||||
|
if (EFI_ERROR(Status) || CharBuffer != gUnicodeFileTag) {
|
||||||
|
Status = EFI_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);
|
||||||
|
gEfiShellProtocol->CloseFile(Handle);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
|
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
|
||||||
structure by parsing NewCommandLine. The current values are returned to the
|
structure by parsing NewCommandLine. The current values are returned to the
|
||||||
|
@ -513,41 +541,70 @@ UpdateStdInStdOutStdErr(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>>v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>>v ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 12, L' ');
|
||||||
StdErrVarName = CommandLineWalker += 6;
|
StdErrVarName = CommandLineWalker += 6;
|
||||||
ErrAppend = TRUE;
|
ErrAppend = TRUE;
|
||||||
|
if (StrStr(CommandLineWalker, L" 2>>v ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>v ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 12, L' ');
|
||||||
StdOutVarName = CommandLineWalker += 6;
|
StdOutVarName = CommandLineWalker += 6;
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
|
if (StrStr(CommandLineWalker, L" 1>>v ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>v ")) != NULL) {
|
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>v ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
StdOutVarName = CommandLineWalker += 5;
|
StdOutVarName = CommandLineWalker += 5;
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
|
if (StrStr(CommandLineWalker, L" >>v ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >v ")) != NULL) {
|
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >v ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
StdOutVarName = CommandLineWalker += 4;
|
StdOutVarName = CommandLineWalker += 4;
|
||||||
OutAppend = FALSE;
|
OutAppend = FALSE;
|
||||||
|
if (StrStr(CommandLineWalker, L" >v ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>a ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 12, L' ');
|
||||||
StdOutFileName = CommandLineWalker += 6;
|
StdOutFileName = CommandLineWalker += 6;
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
OutUnicode = FALSE;
|
OutUnicode = FALSE;
|
||||||
|
if (StrStr(CommandLineWalker, L" 1>>a ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>> ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdOutFileName = CommandLineWalker += 5;
|
StdOutFileName = CommandLineWalker += 5;
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" 1>> ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >> ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdOutFileName = CommandLineWalker += 4;
|
StdOutFileName = CommandLineWalker += 4;
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" >> ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>a ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
|
@ -555,8 +612,12 @@ UpdateStdInStdOutStdErr(
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
OutUnicode = FALSE;
|
OutUnicode = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" >>a ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>a ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
|
@ -564,8 +625,12 @@ UpdateStdInStdOutStdErr(
|
||||||
OutAppend = FALSE;
|
OutAppend = FALSE;
|
||||||
OutUnicode = FALSE;
|
OutUnicode = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" 1>a ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >a ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
|
@ -573,33 +638,49 @@ UpdateStdInStdOutStdErr(
|
||||||
OutAppend = FALSE;
|
OutAppend = FALSE;
|
||||||
OutUnicode = FALSE;
|
OutUnicode = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" >a ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>> ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdErrFileName != NULL) {
|
if (StdErrFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdErrFileName = CommandLineWalker += 5;
|
StdErrFileName = CommandLineWalker += 5;
|
||||||
ErrAppend = TRUE;
|
ErrAppend = TRUE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" 2>> ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>v ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdErrVarName != NULL) {
|
if (StdErrVarName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdErrVarName = CommandLineWalker += 5;
|
StdErrVarName = CommandLineWalker += 5;
|
||||||
ErrAppend = FALSE;
|
ErrAppend = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" 2>v ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>v ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdOutVarName != NULL) {
|
if (StdOutVarName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdOutVarName = CommandLineWalker += 5;
|
StdOutVarName = CommandLineWalker += 5;
|
||||||
OutAppend = FALSE;
|
OutAppend = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" 1>v ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>a ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdErrFileName != NULL) {
|
if (StdErrFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
|
@ -607,56 +688,81 @@ UpdateStdInStdOutStdErr(
|
||||||
ErrAppend = FALSE;
|
ErrAppend = FALSE;
|
||||||
ErrUnicode = FALSE;
|
ErrUnicode = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" 2>a ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2> ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdErrFileName != NULL) {
|
if (StdErrFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdErrFileName = CommandLineWalker += 4;
|
StdErrFileName = CommandLineWalker += 4;
|
||||||
ErrAppend = FALSE;
|
ErrAppend = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" 2> ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1> ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdOutFileName = CommandLineWalker += 4;
|
StdOutFileName = CommandLineWalker += 4;
|
||||||
OutAppend = FALSE;
|
OutAppend = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" 1> ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" > ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" > ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 6, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdOutFileName = CommandLineWalker += 3;
|
StdOutFileName = CommandLineWalker += 3;
|
||||||
OutAppend = FALSE;
|
OutAppend = FALSE;
|
||||||
}
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" > ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" < ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" < ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 6, L' ');
|
||||||
if (StdInFileName != NULL) {
|
if (StdInFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdInFileName = CommandLineWalker += 3;
|
StdInFileName = CommandLineWalker += 3;
|
||||||
OutAppend = FALSE;
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" < ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <a ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdInFileName != NULL) {
|
if (StdInFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdInFileName = CommandLineWalker += 4;
|
StdInFileName = CommandLineWalker += 4;
|
||||||
OutAppend = FALSE;
|
InUnicode = FALSE;
|
||||||
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" <a ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <v ")) != NULL) {
|
||||||
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdInVarName != NULL) {
|
if (StdInVarName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
StdInVarName = CommandLineWalker += 4;
|
StdInVarName = CommandLineWalker += 4;
|
||||||
OutAppend = FALSE;
|
}
|
||||||
|
if (StrStr(CommandLineWalker, L" <v ") != NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,21 +789,52 @@ UpdateStdInStdOutStdErr(
|
||||||
//
|
//
|
||||||
// Verify not the same and not duplicating something from a split
|
// Verify not the same and not duplicating something from a split
|
||||||
//
|
//
|
||||||
if ((StdErrFileName != NULL && StdOutFileName!= NULL && StringNoCaseCompare(&StdErrFileName, &StdOutFileName) == 0)
|
if (
|
||||||
|
//
|
||||||
|
// Check that no 2 filenames are the same
|
||||||
|
//
|
||||||
|
(StdErrFileName != NULL && StdOutFileName!= NULL && StringNoCaseCompare(&StdErrFileName, &StdOutFileName) == 0)
|
||||||
||(StdErrFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdErrFileName, &StdInFileName ) == 0)
|
||(StdErrFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdErrFileName, &StdInFileName ) == 0)
|
||||||
||(StdOutFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdOutFileName, &StdInFileName ) == 0)
|
||(StdOutFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdOutFileName, &StdInFileName ) == 0)
|
||||||
|
//
|
||||||
|
// Check that no 2 variable names are the same
|
||||||
|
//
|
||||||
||(StdErrVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdInVarName ) == 0)
|
||(StdErrVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdInVarName ) == 0)
|
||||||
||(StdOutVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdOutVarName , &StdInVarName ) == 0)
|
||(StdOutVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdOutVarName , &StdInVarName ) == 0)
|
||||||
||(StdErrVarName != NULL && StdOutVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdOutVarName ) == 0)
|
||(StdErrVarName != NULL && StdOutVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdOutVarName ) == 0)
|
||||||
|
//
|
||||||
|
// When a split (using | operator) is in place some are not allowed
|
||||||
|
//
|
||||||
||(Split != NULL && Split->SplitStdIn != NULL && (StdInVarName != NULL || StdInFileName != NULL))
|
||(Split != NULL && Split->SplitStdIn != NULL && (StdInVarName != NULL || StdInFileName != NULL))
|
||||||
||(Split != NULL && Split->SplitStdOut != NULL && (StdOutVarName != NULL || StdOutFileName != NULL))
|
||(Split != NULL && Split->SplitStdOut != NULL && (StdOutVarName != NULL || StdOutFileName != NULL))
|
||||||
|
//
|
||||||
|
// Check that nothing is trying to be output to 2 locations.
|
||||||
|
//
|
||||||
||(StdErrFileName != NULL && StdErrVarName != NULL)
|
||(StdErrFileName != NULL && StdErrVarName != NULL)
|
||||||
||(StdOutFileName != NULL && StdOutVarName != NULL)
|
||(StdOutFileName != NULL && StdOutVarName != NULL)
|
||||||
||(StdInFileName != NULL && StdInVarName != NULL)
|
||(StdInFileName != NULL && StdInVarName != NULL)
|
||||||
|
//
|
||||||
|
// There should not be extra > or <
|
||||||
|
//
|
||||||
|
||(StrStr(CommandLineCopy, L"<") != NULL)
|
||||||
|
||(StrStr(CommandLineCopy, L">") != NULL)
|
||||||
|
//
|
||||||
|
// Check for no volatile environment variables
|
||||||
|
//
|
||||||
||(StdErrVarName != NULL && !IsVolatileEnv(StdErrVarName))
|
||(StdErrVarName != NULL && !IsVolatileEnv(StdErrVarName))
|
||||||
||(StdOutVarName != NULL && !IsVolatileEnv(StdOutVarName))
|
||(StdOutVarName != NULL && !IsVolatileEnv(StdOutVarName))
|
||||||
|
//
|
||||||
|
// Cant redirect during a reconnect operation.
|
||||||
|
//
|
||||||
||(StrStr(NewCommandLine, L"connect -r") != NULL
|
||(StrStr(NewCommandLine, L"connect -r") != NULL
|
||||||
&& (StdOutVarName != NULL || StdOutFileName != NULL || StdErrFileName != NULL || StdErrVarName != NULL))
|
&& (StdOutVarName != NULL || StdOutFileName != NULL || StdErrFileName != NULL || StdErrVarName != NULL))
|
||||||
|
//
|
||||||
|
// Check that filetypes (Unicode/Ascii) do not change during an append
|
||||||
|
//
|
||||||
|
||(StdOutFileName != NULL && OutUnicode && OutAppend && (!EFI_ERROR(ShellFileExists(StdOutFileName)) && EFI_ERROR(IsUnicodeFile(StdOutFileName))))
|
||||||
|
||(StdErrFileName != NULL && ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && EFI_ERROR(IsUnicodeFile(StdErrFileName))))
|
||||||
|
||(StdOutFileName != NULL && !OutUnicode && OutAppend && (!EFI_ERROR(ShellFileExists(StdOutFileName)) && !EFI_ERROR(IsUnicodeFile(StdOutFileName))))
|
||||||
|
||(StdErrFileName != NULL && !ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && !EFI_ERROR(IsUnicodeFile(StdErrFileName))))
|
||||||
){
|
){
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
|
@ -716,13 +853,12 @@ UpdateStdInStdOutStdErr(
|
||||||
ShellInfoObject.NewEfiShellProtocol->DeleteFileByName(StdErrFileName);
|
ShellInfoObject.NewEfiShellProtocol->DeleteFileByName(StdErrFileName);
|
||||||
}
|
}
|
||||||
Status = ShellOpenFileByName(StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
|
Status = ShellOpenFileByName(StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
|
||||||
ASSERT(TempHandle != NULL);
|
|
||||||
if (!ErrAppend && ErrUnicode && !EFI_ERROR(Status)) {
|
if (!ErrAppend && ErrUnicode && !EFI_ERROR(Status)) {
|
||||||
//
|
//
|
||||||
// Write out the UnicodeFileTag
|
// Write out the gUnicodeFileTag
|
||||||
//
|
//
|
||||||
Size = sizeof(CHAR16);
|
Size = sizeof(CHAR16);
|
||||||
TagBuffer[0] = UnicodeFileTag;
|
TagBuffer[0] = gUnicodeFileTag;
|
||||||
TagBuffer[1] = CHAR_NULL;
|
TagBuffer[1] = CHAR_NULL;
|
||||||
ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
|
ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
|
||||||
}
|
}
|
||||||
|
@ -750,12 +886,14 @@ UpdateStdInStdOutStdErr(
|
||||||
if (TempHandle == NULL) {
|
if (TempHandle == NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
|
if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) {
|
||||||
|
//no-op
|
||||||
|
} else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
|
||||||
//
|
//
|
||||||
// Write out the UnicodeFileTag
|
// Write out the gUnicodeFileTag
|
||||||
//
|
//
|
||||||
Size = sizeof(CHAR16);
|
Size = sizeof(CHAR16);
|
||||||
TagBuffer[0] = UnicodeFileTag;
|
TagBuffer[0] = gUnicodeFileTag;
|
||||||
TagBuffer[1] = CHAR_NULL;
|
TagBuffer[1] = CHAR_NULL;
|
||||||
ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
|
ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
|
||||||
} else if (OutAppend) {
|
} else if (OutAppend) {
|
||||||
|
@ -790,10 +928,6 @@ UpdateStdInStdOutStdErr(
|
||||||
}
|
}
|
||||||
TempHandle = CreateFileInterfaceEnv(StdOutVarName);
|
TempHandle = CreateFileInterfaceEnv(StdOutVarName);
|
||||||
ASSERT(TempHandle != NULL);
|
ASSERT(TempHandle != NULL);
|
||||||
if (!OutUnicode) {
|
|
||||||
TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
|
|
||||||
ASSERT(TempHandle != NULL);
|
|
||||||
}
|
|
||||||
ShellParameters->StdOut = TempHandle;
|
ShellParameters->StdOut = TempHandle;
|
||||||
gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle);
|
gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle);
|
||||||
}
|
}
|
||||||
|
@ -810,10 +944,6 @@ UpdateStdInStdOutStdErr(
|
||||||
}
|
}
|
||||||
TempHandle = CreateFileInterfaceEnv(StdErrVarName);
|
TempHandle = CreateFileInterfaceEnv(StdErrVarName);
|
||||||
ASSERT(TempHandle != NULL);
|
ASSERT(TempHandle != NULL);
|
||||||
if (!ErrUnicode) {
|
|
||||||
TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
|
|
||||||
ASSERT(TempHandle != NULL);
|
|
||||||
}
|
|
||||||
ShellParameters->StdErr = TempHandle;
|
ShellParameters->StdErr = TempHandle;
|
||||||
gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle);
|
gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Member functions of EFI_SHELL_PROTOCOL and functions for creation,
|
Member functions of EFI_SHELL_PROTOCOL and functions for creation,
|
||||||
manipulation, and initialization of EFI_SHELL_PROTOCOL.
|
manipulation, and initialization of EFI_SHELL_PROTOCOL.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -37,6 +37,36 @@ EfiShellClose (
|
||||||
return (FileHandleClose(ConvertShellHandleToEfiFileProtocol(FileHandle)));
|
return (FileHandleClose(ConvertShellHandleToEfiFileProtocol(FileHandle)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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.
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
InternalShellProtocolIsBlockIoPresent(
|
||||||
|
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_HANDLE Handle;
|
||||||
|
|
||||||
|
Handle = NULL;
|
||||||
|
|
||||||
|
DevicePathCopy = (EFI_DEVICE_PATH_PROTOCOL*)DevicePath;
|
||||||
|
Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &DevicePathCopy, &Handle);
|
||||||
|
|
||||||
|
if ((Handle != NULL) && (!EFI_ERROR(Status))) {
|
||||||
|
return (TRUE);
|
||||||
|
}
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Internal worker to determine whether there is a file system somewhere
|
Internal worker to determine whether there is a file system somewhere
|
||||||
upon the device path specified.
|
upon the device path specified.
|
||||||
|
@ -176,7 +206,8 @@ EfiShellSetMap(
|
||||||
// make sure this is a valid to add device path
|
// make sure this is a valid to add device path
|
||||||
//
|
//
|
||||||
///@todo add BlockIo to this test...
|
///@todo add BlockIo to this test...
|
||||||
if (!InternalShellProtocolIsSimpleFileSystemPresent(DevicePath)) {
|
if (!InternalShellProtocolIsSimpleFileSystemPresent(DevicePath)
|
||||||
|
&& !InternalShellProtocolIsBlockIoPresent(DevicePath)) {
|
||||||
return (EFI_INVALID_PARAMETER);
|
return (EFI_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,10 +527,9 @@ EfiShellGetDevicePathFromFilePath(
|
||||||
NewPath = AllocateZeroPool(Size);
|
NewPath = AllocateZeroPool(Size);
|
||||||
ASSERT(NewPath != NULL);
|
ASSERT(NewPath != NULL);
|
||||||
StrCpy(NewPath, Cwd);
|
StrCpy(NewPath, Cwd);
|
||||||
if ((Path[0] == (CHAR16)L'\\') &&
|
if (*Path == L'\\') {
|
||||||
(NewPath[StrLen(NewPath)-1] == (CHAR16)L'\\')
|
Path++;
|
||||||
) {
|
while (ChopLastSlash(NewPath)) ;
|
||||||
((CHAR16*)NewPath)[StrLen(NewPath)-1] = CHAR_NULL;
|
|
||||||
}
|
}
|
||||||
StrCat(NewPath, Path);
|
StrCat(NewPath, Path);
|
||||||
DevicePathForReturn = EfiShellGetDevicePathFromFilePath(NewPath);
|
DevicePathForReturn = EfiShellGetDevicePathFromFilePath(NewPath);
|
||||||
|
@ -621,6 +651,11 @@ EfiShellGetDeviceName(
|
||||||
CHAR8 *Lang;
|
CHAR8 *Lang;
|
||||||
CHAR8 *TempChar;
|
CHAR8 *TempChar;
|
||||||
|
|
||||||
|
UINTN ParentControllerCount;
|
||||||
|
EFI_HANDLE *ParentControllerBuffer;
|
||||||
|
UINTN ParentDriverCount;
|
||||||
|
EFI_HANDLE *ParentDriverBuffer;
|
||||||
|
|
||||||
if (BestDeviceName == NULL ||
|
if (BestDeviceName == NULL ||
|
||||||
DeviceHandle == NULL
|
DeviceHandle == NULL
|
||||||
){
|
){
|
||||||
|
@ -673,7 +708,7 @@ EfiShellGetDeviceName(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Language == NULL) {
|
if (Language == NULL) {
|
||||||
Lang = AllocatePool(AsciiStrSize(CompName2->SupportedLanguages));
|
Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
|
||||||
if (Lang == NULL) {
|
if (Lang == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
@ -683,7 +718,7 @@ EfiShellGetDeviceName(
|
||||||
*TempChar = CHAR_NULL;
|
*TempChar = CHAR_NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Lang = AllocatePool(AsciiStrSize(Language));
|
Lang = AllocateZeroPool(AsciiStrSize(Language));
|
||||||
if (Lang == NULL) {
|
if (Lang == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
@ -699,14 +734,80 @@ EfiShellGetDeviceName(
|
||||||
if (HandleList != NULL) {
|
if (HandleList != NULL) {
|
||||||
FreePool(HandleList);
|
FreePool(HandleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now check the parent controller using this as the child.
|
||||||
|
//
|
||||||
|
if (DeviceNameToReturn == NULL){
|
||||||
|
PARSE_HANDLE_DATABASE_PARENTS(DeviceHandle, &ParentControllerCount, &ParentControllerBuffer);
|
||||||
|
for (LoopVar = 0 ; LoopVar < ParentControllerCount ; LoopVar++) {
|
||||||
|
PARSE_HANDLE_DATABASE_UEFI_DRIVERS(ParentControllerBuffer[LoopVar], &ParentDriverCount, &ParentDriverBuffer);
|
||||||
|
for (HandleCount = 0 ; HandleCount < ParentDriverCount ; HandleCount++) {
|
||||||
|
//
|
||||||
|
// try using that driver's component name with controller and our driver as the child.
|
||||||
|
//
|
||||||
|
Status = gBS->OpenProtocol(
|
||||||
|
ParentDriverBuffer[HandleCount],
|
||||||
|
&gEfiComponentName2ProtocolGuid,
|
||||||
|
(VOID**)&CompName2,
|
||||||
|
gImageHandle,
|
||||||
|
NULL,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
Status = gBS->OpenProtocol(
|
||||||
|
ParentDriverBuffer[HandleCount],
|
||||||
|
&gEfiComponentNameProtocolGuid,
|
||||||
|
(VOID**)&CompName2,
|
||||||
|
gImageHandle,
|
||||||
|
NULL,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Language == NULL) {
|
||||||
|
Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
|
||||||
|
if (Lang == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
|
AsciiStrCpy(Lang, CompName2->SupportedLanguages);
|
||||||
|
TempChar = AsciiStrStr(Lang, ";");
|
||||||
|
if (TempChar != NULL){
|
||||||
|
*TempChar = CHAR_NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Lang = AllocateZeroPool(AsciiStrSize(Language));
|
||||||
|
if (Lang == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
|
AsciiStrCpy(Lang, Language);
|
||||||
|
}
|
||||||
|
Status = CompName2->GetControllerName(CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn);
|
||||||
|
FreePool(Lang);
|
||||||
|
Lang = NULL;
|
||||||
|
if (!EFI_ERROR(Status) && DeviceNameToReturn != NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
SHELL_FREE_NON_NULL(ParentDriverBuffer);
|
||||||
|
if (!EFI_ERROR(Status) && DeviceNameToReturn != NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SHELL_FREE_NON_NULL(ParentControllerBuffer);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// dont return on fail since we will try device path if that bit is on
|
||||||
|
//
|
||||||
if (DeviceNameToReturn != NULL){
|
if (DeviceNameToReturn != NULL){
|
||||||
ASSERT(BestDeviceName != NULL);
|
ASSERT(BestDeviceName != NULL);
|
||||||
StrnCatGrow(BestDeviceName, NULL, DeviceNameToReturn, 0);
|
StrnCatGrow(BestDeviceName, NULL, DeviceNameToReturn, 0);
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// dont return on fail since we will try device path if that bit is on
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
if ((Flags & EFI_DEVICE_NAME_USE_DEVICE_PATH) != 0) {
|
if ((Flags & EFI_DEVICE_NAME_USE_DEVICE_PATH) != 0) {
|
||||||
Status = gBS->LocateProtocol(
|
Status = gBS->LocateProtocol(
|
||||||
|
@ -1630,14 +1731,14 @@ InternalDuplicateShellFileInfo(
|
||||||
{
|
{
|
||||||
EFI_SHELL_FILE_INFO *NewNode;
|
EFI_SHELL_FILE_INFO *NewNode;
|
||||||
|
|
||||||
NewNode = AllocatePool(sizeof(EFI_SHELL_FILE_INFO));
|
NewNode = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
|
||||||
if (NewNode == NULL) {
|
if (NewNode == NULL) {
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
NewNode->FullName = AllocateZeroPool(StrSize(Node->FullName));
|
NewNode->FullName = AllocateZeroPool(StrSize(Node->FullName));
|
||||||
|
|
||||||
NewNode->FileName = AllocateZeroPool(StrSize(Node->FileName));
|
NewNode->FileName = AllocateZeroPool(StrSize(Node->FileName));
|
||||||
NewNode->Info = AllocatePool((UINTN)Node->Info->Size);
|
NewNode->Info = AllocateZeroPool((UINTN)Node->Info->Size);
|
||||||
if ( NewNode->FullName == NULL
|
if ( NewNode->FullName == NULL
|
||||||
|| NewNode->FileName == NULL
|
|| NewNode->FileName == NULL
|
||||||
|| NewNode->Info == NULL
|
|| NewNode->Info == NULL
|
||||||
|
@ -1964,7 +2065,7 @@ ShellSearchHandle(
|
||||||
} else {
|
} else {
|
||||||
NewShellNode->Handle = NULL;
|
NewShellNode->Handle = NULL;
|
||||||
if (*FileList == NULL) {
|
if (*FileList == NULL) {
|
||||||
*FileList = AllocatePool(sizeof(EFI_SHELL_FILE_INFO));
|
*FileList = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
|
||||||
InitializeListHead(&((*FileList)->Link));
|
InitializeListHead(&((*FileList)->Link));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2044,7 +2145,7 @@ ShellSearchHandle(
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
if (*FileList == NULL) {
|
if (*FileList == NULL) {
|
||||||
*FileList = AllocatePool(sizeof(EFI_SHELL_FILE_INFO));
|
*FileList = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
|
||||||
InitializeListHead(&((*FileList)->Link));
|
InitializeListHead(&((*FileList)->Link));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2121,7 +2222,7 @@ EfiShellFindFiles(
|
||||||
RootDevicePath = NULL;
|
RootDevicePath = NULL;
|
||||||
RootFileHandle = NULL;
|
RootFileHandle = NULL;
|
||||||
MapName = NULL;
|
MapName = NULL;
|
||||||
PatternCopy = AllocatePool(StrSize(FilePattern));
|
PatternCopy = AllocateZeroPool(StrSize(FilePattern));
|
||||||
if (PatternCopy == NULL) {
|
if (PatternCopy == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
@ -2186,17 +2287,19 @@ EfiShellOpenFileList(
|
||||||
CHAR16 *Path2;
|
CHAR16 *Path2;
|
||||||
UINTN Path2Size;
|
UINTN Path2Size;
|
||||||
CONST CHAR16 *CurDir;
|
CONST CHAR16 *CurDir;
|
||||||
|
BOOLEAN Found;
|
||||||
|
|
||||||
ShellCommandCleanPath(Path);
|
ShellCommandCleanPath(Path);
|
||||||
|
|
||||||
Path2Size = 0;
|
Path2Size = 0;
|
||||||
Path2 = NULL;
|
Path2 = NULL;
|
||||||
|
|
||||||
ASSERT(FileList != NULL);
|
if (FileList == NULL || *FileList == NULL) {
|
||||||
ASSERT(*FileList != NULL);
|
return (EFI_INVALID_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
if (*Path == L'.' && *(Path+1) == L'\\') {
|
if (*Path == L'.' && *(Path+1) == L'\\') {
|
||||||
Path++;
|
Path+=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -2208,6 +2311,7 @@ EfiShellOpenFileList(
|
||||||
StrnCatGrow(&Path2, &Path2Size, CurDir, 0);
|
StrnCatGrow(&Path2, &Path2Size, CurDir, 0);
|
||||||
if (*Path == L'\\') {
|
if (*Path == L'\\') {
|
||||||
Path++;
|
Path++;
|
||||||
|
while (ChopLastSlash(Path2)) ;
|
||||||
}
|
}
|
||||||
ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
|
ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
|
||||||
StrnCatGrow(&Path2, &Path2Size, Path, 0);
|
StrnCatGrow(&Path2, &Path2Size, Path, 0);
|
||||||
|
@ -2229,6 +2333,7 @@ EfiShellOpenFileList(
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Found = FALSE;
|
||||||
//
|
//
|
||||||
// We had no errors so open all the files (that are not already opened...)
|
// We had no errors so open all the files (that are not already opened...)
|
||||||
//
|
//
|
||||||
|
@ -2238,9 +2343,13 @@ EfiShellOpenFileList(
|
||||||
){
|
){
|
||||||
if (ShellFileListItem->Status == 0 && ShellFileListItem->Handle == NULL) {
|
if (ShellFileListItem->Status == 0 && ShellFileListItem->Handle == NULL) {
|
||||||
ShellFileListItem->Status = EfiShellOpenFileByName (ShellFileListItem->FullName, &ShellFileListItem->Handle, OpenMode);
|
ShellFileListItem->Status = EfiShellOpenFileByName (ShellFileListItem->FullName, &ShellFileListItem->Handle, OpenMode);
|
||||||
|
Found = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Found) {
|
||||||
|
return (EFI_NOT_FOUND);
|
||||||
|
}
|
||||||
return(EFI_SUCCESS);
|
return(EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3190,6 +3299,12 @@ CleanUpShellProtocol (
|
||||||
|
|
||||||
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle1);
|
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle1);
|
||||||
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle2);
|
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle2);
|
||||||
|
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle3);
|
||||||
|
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle4);
|
||||||
|
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle1);
|
||||||
|
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle2);
|
||||||
|
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle3);
|
||||||
|
Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle4);
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
@ -3207,10 +3322,26 @@ NotificationFunction(
|
||||||
IN EFI_KEY_DATA *KeyData
|
IN EFI_KEY_DATA *KeyData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak == NULL) {
|
EFI_INPUT_KEY Key;
|
||||||
return (EFI_UNSUPPORTED);
|
UINTN EventIndex;
|
||||||
|
// ShellPrintEx(-1,-1,L" <Notify> ");
|
||||||
|
if ((KeyData->Key.UnicodeChar == L'c' || KeyData->Key.UnicodeChar == 3) &&
|
||||||
|
(KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))
|
||||||
|
){
|
||||||
|
if (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak == NULL) {
|
||||||
|
return (EFI_UNSUPPORTED);
|
||||||
|
}
|
||||||
|
return (gBS->SignalEvent(ShellInfoObject.NewEfiShellProtocol->ExecutionBreak));
|
||||||
|
} else if ((KeyData->Key.UnicodeChar == L's') &&
|
||||||
|
(KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))
|
||||||
|
){
|
||||||
|
//
|
||||||
|
// just get some key
|
||||||
|
//
|
||||||
|
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
|
||||||
|
gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||||
}
|
}
|
||||||
return (gBS->SignalEvent(ShellInfoObject.NewEfiShellProtocol->ExecutionBreak));
|
return (EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Member functions of EFI_SHELL_PROTOCOL and functions for creation,
|
Member functions of EFI_SHELL_PROTOCOL and functions for creation,
|
||||||
manipulation, and initialization of EFI_SHELL_PROTOCOL.
|
manipulation, and initialization of EFI_SHELL_PROTOCOL.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, 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
|
||||||
|
@ -959,5 +959,18 @@ EFIAPI
|
||||||
InernalEfiShellStartMonitor(
|
InernalEfiShellStartMonitor(
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notification function for keystrokes.
|
||||||
|
|
||||||
|
@param[in] KeyData The key that was pressed.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The operation was successful.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
NotificationFunction(
|
||||||
|
IN EFI_KEY_DATA *KeyData
|
||||||
|
);
|
||||||
#endif //_SHELL_PROTOCOL_HEADER_
|
#endif //_SHELL_PROTOCOL_HEADER_
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue