udk2010.up2.shell initial release.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10874 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey
2010-09-14 05:18:09 +00:00
parent 52fb4d3d13
commit a405b86d27
102 changed files with 30419 additions and 1040 deletions

View File

@ -0,0 +1,162 @@
/** @file
Main file for Alias shell level 3 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
#include <Library/ShellLib.h>
/**
Print out each alias registered with the Shell.
@retval STATUS_SUCCESS the printout was sucessful
@return any return code from GetNextVariableName except EFI_NOT_FOUND
**/
SHELL_STATUS
EFIAPI
PrintAllShellAlias(
VOID
)
{
CONST CHAR16 *ConstAllAliasList;
CHAR16 *Alias;
CONST CHAR16 *Command;
CHAR16 *Walker;
BOOLEAN Volatile;
Volatile = FALSE;
ConstAllAliasList = gEfiShellProtocol->GetAlias(NULL, NULL);
if (ConstAllAliasList == NULL) {
return (SHELL_SUCCESS);
}
Alias = AllocateZeroPool(StrSize(ConstAllAliasList));
Walker = (CHAR16*)ConstAllAliasList;
do {
CopyMem(Alias, Walker, StrSize(Walker));
Walker = StrStr(Alias, L";");
if (Walker != NULL) {
Walker[0] = CHAR_NULL;
Walker = Walker + 1;
}
Command = gEfiShellProtocol->GetAlias(Alias, &Volatile);
if (ShellCommandIsOnAliasList(Alias)) {
Volatile = FALSE;
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ALIAS_OUTPUT), gShellLevel3HiiHandle, !Volatile?L' ':L'*', Alias, Command);
} while (Walker != NULL && Walker[0] != CHAR_NULL);
FreePool(Alias);
return (SHELL_SUCCESS);
}
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-v", TypeFlag},
{L"-d", TypeFlag},
{NULL, TypeMax}
};
/**
Function for 'alias' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunAlias (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Param1;
CONST CHAR16 *Param2;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
Param1 = ShellCommandLineGetRawValue(Package, 1);
Param2 = ShellCommandLineGetRawValue(Package, 2);
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
}
if (ShellCommandLineGetCount(Package) == 1) {
//
// print out alias'
//
Status = PrintAllShellAlias();
} else if (ShellCommandLineGetFlag(Package, L"-d")) {
//
// delete an alias
//
Status = gEfiShellProtocol->SetAlias(Param1, NULL, TRUE, FALSE);
} else if (ShellCommandLineGetCount(Package) == 3) {
//
// must be adding an alias
//
Status = gEfiShellProtocol->SetAlias(Param2, Param1, FALSE, ShellCommandLineGetFlag(Package, L"-v"));
if (EFI_ERROR(Status)) {
if (Status == EFI_ACCESS_DENIED) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel3HiiHandle);
ShellStatus = SHELL_ACCESS_DENIED;
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel3HiiHandle, Status);
ShellStatus = SHELL_DEVICE_ERROR;
}
}
} else if (ShellCommandLineGetCount(Package) == 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
}
return (ShellStatus);
}

View File

@ -0,0 +1,135 @@
/** @file
Main file for attrib shell level 2 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
/**
Function for 'cls' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunCls (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *Message;
UINTN Background;
UINTN ForeColor;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Param1;
ShellStatus = SHELL_SUCCESS;
ProblemParam = NULL;
Background = 0;
//
// Initialize variables
//
Message = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
} else {
//
// If there are 0 value parameters, clear sceen
//
Param1 = ShellCommandLineGetRawValue(Package, 1);
if (Param1 == NULL) {
//
// clear screen
//
gST->ConOut->ClearScreen (gST->ConOut);
} else if (ShellCommandLineGetCount(Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (StrDecimalToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, Param1);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
switch (StrDecimalToUintn(Param1)) {
case 0:
Background = EFI_BACKGROUND_BLACK;
break;
case 1:
Background = EFI_BACKGROUND_BLUE;
break;
case 2:
Background = EFI_BACKGROUND_GREEN;
break;
case 3:
Background = EFI_BACKGROUND_CYAN;
break;
case 4:
Background = EFI_BACKGROUND_RED;
break;
case 5:
Background = EFI_BACKGROUND_MAGENTA;
break;
case 6:
Background = EFI_BACKGROUND_BROWN;
break;
case 7:
Background = EFI_BACKGROUND_LIGHTGRAY;
break;
}
ForeColor = (~StrDecimalToUintn(Param1)) & 0xF;
Status = gST->ConOut->SetAttribute (gST->ConOut, ForeColor | Background);
ASSERT_EFI_ERROR(Status);
Status = gST->ConOut->ClearScreen (gST->ConOut);
ASSERT_EFI_ERROR(Status);
}
}
}
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
//
// return the status
//
return (ShellStatus);
}

View File

@ -0,0 +1,116 @@
/** @file
Main file for Echo shell level 3 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
#include <Library/ShellLib.h>
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-on", TypeFlag},
{L"-off", TypeFlag},
{NULL, TypeMax}
};
/**
Function for 'echo' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunEcho (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
// CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINTN ParamCount;
// ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParseEx (ParamList, &Package, NULL, TRUE, TRUE);
// if (EFI_ERROR(Status)) {
// if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
// ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
// FreePool(ProblemParam);
// ShellStatus = SHELL_INVALID_PARAMETER;
// } else {
// ASSERT(FALSE);
// }
// } else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
}
if (ShellCommandLineGetFlag(Package, L"-on")) {
//
// Turn it on
//
ShellCommandSetEchoState(TRUE);
} else if (ShellCommandLineGetFlag(Package, L"-off")) {
//
// turn it off
//
ShellCommandSetEchoState(FALSE);
} else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
//
// output its current state
//
if (ShellCommandGetEchoState()) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_ON), gShellLevel3HiiHandle);
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_OFF), gShellLevel3HiiHandle);
}
} else {
//
// print the line
//
for ( ParamCount = 1
; ShellCommandLineGetRawValue(Package, ParamCount) != NULL
; ParamCount++
) {
if (ShellCommandLineGetRawValue(Package, ParamCount+1) != NULL) {
ShellPrintEx(-1, -1, L"%s ", ShellCommandLineGetRawValue(Package, ParamCount));
} else {
ShellPrintEx(-1, -1, L"%s", ShellCommandLineGetRawValue(Package, ParamCount));
}
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), gShellLevel3HiiHandle);
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
// }
return (ShellStatus);
}

View File

@ -0,0 +1,101 @@
/** @file
Main file for GetMtc shell level 3 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
#include <Library/ShellLib.h>
/**
Function for 'getmtc' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunGetMtc (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINT64 Mtc;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
} else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// Get the monotonic counter count
//
Status = gBS->GetNextMonotonicCount(&Mtc);
switch(Status) {
case EFI_DEVICE_ERROR:
ShellStatus = SHELL_DEVICE_ERROR;
break;
case EFI_SECURITY_VIOLATION:
ShellStatus = SHELL_SECURITY_VIOLATION;
break;
default:
if (EFI_ERROR(Status)) {
ShellStatus = SHELL_DEVICE_ERROR;
}
}
//
// print it...
//
if (ShellStatus == SHELL_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GET_MTC_OUTPUT), gShellLevel3HiiHandle, Mtc);
}
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
}
return (ShellStatus);
}

View File

@ -0,0 +1,183 @@
/** @file
Main file for Help shell level 3 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
#include <Library/ShellLib.h>
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-usage", TypeFlag},
{L"-section", TypeValue},
{L"-verbose", TypeFlag},
{L"-v", TypeFlag},
{NULL, TypeMax}
};
/**
Function for 'help' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunHelp (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CHAR16 *OutText;
CONST COMMAND_LIST *CommandList;
CONST COMMAND_LIST *Node;
CHAR16 *CommandToGetHelpOn;
CHAR16 *SectionToGetHelpOn;
CHAR16 *HiiString;
BOOLEAN Found;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
OutText = NULL;
CommandToGetHelpOn = NULL;
SectionToGetHelpOn = NULL;
Found = FALSE;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// Check for conflicting parameters.
//
if (ShellCommandLineGetFlag(Package, L"-usage")
&&ShellCommandLineGetFlag(Package, L"-section")
&&(ShellCommandLineGetFlag(Package, L"-verbose") || ShellCommandLineGetFlag(Package, L"-v"))
){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// Get the command name we are getting help on
//
ASSERT(CommandToGetHelpOn == NULL);
StrnCatGrow(&CommandToGetHelpOn, NULL, ShellCommandLineGetRawValue(Package, 1), 0);
if (CommandToGetHelpOn == NULL && ShellCommandLineGetFlag(Package, L"-?")) {
//
// If we dont have a command and we got a simple -?
// we are looking for help on help command.
//
StrnCatGrow(&CommandToGetHelpOn, NULL, L"help", 0);
}
if (CommandToGetHelpOn == NULL) {
StrnCatGrow(&CommandToGetHelpOn, NULL, L"*", 0);
ASSERT(SectionToGetHelpOn == NULL);
StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME", 0);
} else {
ASSERT(SectionToGetHelpOn == NULL);
//
// Get the section name for the given command name
//
if (ShellCommandLineGetFlag(Package, L"-section")) {
StrnCatGrow(&SectionToGetHelpOn, NULL, ShellCommandLineGetValue(Package, L"-section"), 0);
} else if (ShellCommandLineGetFlag(Package, L"-usage")) {
StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME,SYNOPSIS", 0);
} else if (ShellCommandLineGetFlag(Package, L"-verbose") || ShellCommandLineGetFlag(Package, L"-v")) {
} else {
StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME", 0);
}
}
if (gUnicodeCollation->StriColl(gUnicodeCollation, CommandToGetHelpOn, L"special") == 0) {
//
// we need info on the special characters
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_SC_HEADER), gShellLevel3HiiHandle);
HiiString = HiiGetString(gShellLevel3HiiHandle, STRING_TOKEN(STR_HELP_SC_DATA), NULL);
ShellPrintEx(-1, -1, L"%s", HiiString);
FreePool(HiiString);
Found = TRUE;
} else {
CommandList = ShellCommandGetCommandList();
ASSERT(CommandList != NULL);
for ( Node = (COMMAND_LIST*)GetFirstNode(&CommandList->Link)
; CommandList != NULL && !IsListEmpty(&CommandList->Link) && !IsNull(&CommandList->Link, &Node->Link)
; Node = (COMMAND_LIST*)GetNextNode(&CommandList->Link, &Node->Link)
){
if (gUnicodeCollation->MetaiMatch(gUnicodeCollation, Node->CommandString, CommandToGetHelpOn)) {
//
// We have a command to look for help on.
//
Status = gEfiShellProtocol->GetHelpText(Node->CommandString, SectionToGetHelpOn, &OutText);
if (EFI_ERROR(Status) || OutText == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, Node->CommandString);
ShellStatus = SHELL_NOT_FOUND;
} else {
while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {
OutText[StrLen(OutText)-1] = CHAR_NULL;
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_COMMAND), gShellLevel3HiiHandle, Node->CommandString, OutText);
FreePool(OutText);
OutText = NULL;
Found = TRUE;
}
}
}
}
if (!Found && ShellStatus == SHELL_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CommandToGetHelpOn);
ShellStatus = SHELL_NOT_FOUND;
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
}
}
if (CommandToGetHelpOn != NULL) {
FreePool(CommandToGetHelpOn);
}
if (SectionToGetHelpOn != NULL) {
FreePool(SectionToGetHelpOn);
}
return (ShellStatus);
}

View File

@ -0,0 +1,106 @@
/** @file
Main file for Pause shell level 3 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-q", TypeFlag},
{NULL, TypeMax}
};
/**
Function for 'pause' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunPause (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
SHELL_PROMPT_RESPONSE *Resp;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
if (!gEfiShellProtocol->BatchIsActive()) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_SCRIPT_ONLY), gShellLevel3HiiHandle);
return (SHELL_UNSUPPORTED);
}
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
} else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (!ShellCommandLineGetFlag(Package, L"-q")) {
Status = ShellPromptForResponseHii(ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_PAUSE_PROMPT), gShellLevel3HiiHandle, (VOID**)&Resp);
} else {
Status = ShellPromptForResponse(ShellPromptResponseTypeQuitContinue, NULL, (VOID**)&Resp);
}
ASSERT_EFI_ERROR(Status);
if (Resp == NULL || *Resp == ShellPromptResponseQuit) {
ShellCommandRegisterExit(TRUE);
ShellStatus = SHELL_ABORTED;
}
if (Resp != NULL) {
FreePool(Resp);
}
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
}
return (ShellStatus);
}

View File

@ -0,0 +1,265 @@
/** @file
Main file for Touch shell level 3 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
#include <Library/ShellLib.h>
EFI_STATUS
EFIAPI
TouchFileByHandle (
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
EFI_FILE_INFO *FileInfo;
FileInfo = gEfiShellProtocol->GetFileInfo(Handle);
if ((FileInfo->Attribute & EFI_FILE_READ_ONLY) != 0){
return (EFI_ACCESS_DENIED);
}
Status = gRT->GetTime(&FileInfo->ModificationTime, NULL);
ASSERT_EFI_ERROR(Status);
CopyMem(&FileInfo->LastAccessTime, &FileInfo->ModificationTime, sizeof(EFI_TIME));
Status = gEfiShellProtocol->SetFileInfo(Handle, FileInfo);
FreePool(FileInfo);
return (Status);
}
EFI_STATUS
EFIAPI
DoTouchByHandle (
IN CONST CHAR16 *Name,
IN CHAR16 *FS,
IN SHELL_FILE_HANDLE Handle,
IN BOOLEAN Rec
)
{
EFI_STATUS Status;
EFI_SHELL_FILE_INFO *FileList;
EFI_SHELL_FILE_INFO *Walker;
CHAR16 *TempSpot;
Status = EFI_SUCCESS;
FileList = NULL;
Walker = NULL;
if (FS == NULL) {
FS = StrnCatGrow(&FS, NULL, Name, 0);
TempSpot = StrStr(FS, L"\\");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
}
//
// do it
//
Status = TouchFileByHandle(Handle);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Name, Status);
return (Status);
}
//
// if it's a directory recurse...
//
if (FileHandleIsDirectory(Handle) == EFI_SUCCESS && Rec) {
//
// get each file under this directory
//
if (EFI_ERROR(gEfiShellProtocol->FindFilesInDir(Handle, &FileList))) {
Status = EFI_INVALID_PARAMETER;
}
//
// recurse on each
//
for (Walker = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
; FileList != NULL && !IsNull(&FileList->Link, &Walker->Link) && !EFI_ERROR(Status)
; Walker = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Walker->Link)
){
if ( (StrCmp(Walker->FileName, L".") != 0)
&& (StrCmp(Walker->FileName, L"..") != 0)
){
//
// Open the file since we need that handle.
//
Status = gEfiShellProtocol->OpenFileByName (Walker->FullName, &Walker->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Walker->FullName, Status);
Status = EFI_ACCESS_DENIED;
} else {
Status = DoTouchByHandle(Walker->FullName, FS, Walker->Handle, TRUE);
gEfiShellProtocol->CloseFile(Walker->Handle);
Walker->Handle = NULL;
}
}
}
//
// free stuff
//
if (FileList != NULL && EFI_ERROR(gEfiShellProtocol->FreeFileList(&FileList))) {
Status = EFI_INVALID_PARAMETER;
}
}
return (Status);
}
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-r", TypeFlag},
{NULL, TypeMax}
};
/**
Function for 'touch' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunTouch (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
CONST CHAR16 *Param;
SHELL_STATUS ShellStatus;
UINTN ParamCount;
EFI_SHELL_FILE_INFO *FileList;
EFI_SHELL_FILE_INFO *Node;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
ParamCount = 0;
FileList = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
}
if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
//
// we insufficient parameters
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// get a list with each file specified by parameters
// if parameter is a directory then add all the files below it to the list
//
for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
; Param != NULL
; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
){
Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, &FileList);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, (CHAR16*)Param);
ShellStatus = SHELL_NOT_FOUND;
break;
}
//
// make sure we completed the param parsing sucessfully...
// Also make sure that any previous action was sucessful
//
if (ShellStatus == SHELL_SUCCESS) {
//
// check that we have at least 1 file
//
if (FileList == NULL || IsListEmpty(&FileList->Link)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, Param);
continue;
} else {
//
// loop through the list and make sure we are not aborting...
//
for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
){
//
// make sure the file opened ok
//
if (EFI_ERROR(Node->Status)){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Node->FileName, Node->Status);
ShellStatus = SHELL_NOT_FOUND;
continue;
}
Status = DoTouchByHandle(Node->FullName, NULL, Node->Handle, ShellCommandLineGetFlag(Package, L"-r"));
if (EFI_ERROR(Status) && Status != EFI_ACCESS_DENIED) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Node->FileName, Status);
ShellStatus = SHELL_NOT_FOUND;
}
}
}
}
//
// Free the fileList
//
if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
Status = ShellCloseFileMetaArg(&FileList);
ASSERT_EFI_ERROR(Status);
}
FileList = NULL;
}
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
}
if (ShellGetExecutionBreakFlag()) {
return (SHELL_ABORTED);
}
return (ShellStatus);
}

View File

@ -0,0 +1,239 @@
/** @file
Main file for Type shell level 3 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
#include <Library/ShellLib.h>
EFI_STATUS
EFIAPI
TypeFileByHandle (
IN EFI_HANDLE Handle,
BOOLEAN Ascii,
BOOLEAN UCS2
)
{
UINTN ReadSize;
VOID *Buffer;
EFI_STATUS Status;
UINTN LoopVar;
CHAR16 AsciiChar;
ReadSize = PcdGet16(PcdShellFileOperationSize);
Buffer = AllocatePool(ReadSize);
if (Buffer == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
Status = ShellSetFilePosition(Handle, 0);
ASSERT_EFI_ERROR(Status);
while (ReadSize == ((UINTN)PcdGet16(PcdShellFileOperationSize))){
ZeroMem(Buffer, ReadSize);
Status = ShellReadFile(Handle, &ReadSize, Buffer);
if (EFI_ERROR(Status)){
break;
}
if (!(Ascii|UCS2)){
if (*(UINT16*)Buffer == UnicodeFileTag) {
UCS2 = TRUE;
Buffer = ((UINT16*)Buffer) + 1;
} else {
Ascii = TRUE;
}
}
//
// We want to use plain Print function here! (no color support for files)
//
if (Ascii){
for (LoopVar = 0 ; LoopVar < ReadSize ; LoopVar++) {
AsciiChar = CHAR_NULL;
AsciiChar = ((CHAR8*)Buffer)[LoopVar];
if (AsciiChar == CHAR_NULL) {
AsciiChar = '.';
}
Print(L"%c", AsciiChar);
}
} else {
Print(L"%s", Buffer);
}
}
Status = Print(L"\r\n", Buffer);
return (Status);
}
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-a", TypeFlag},
{L"-u", TypeFlag},
{NULL, TypeMax}
};
/**
Function for 'type' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunType (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
CONST CHAR16 *Param;
SHELL_STATUS ShellStatus;
UINTN ParamCount;
EFI_SHELL_FILE_INFO *FileList;
EFI_SHELL_FILE_INFO *Node;
BOOLEAN AsciiMode;
BOOLEAN UnicodeMode;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
ParamCount = 0;
FileList = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
}
AsciiMode = ShellCommandLineGetFlag(Package, L"-a");
UnicodeMode = ShellCommandLineGetFlag(Package, L"-u");
if (AsciiMode && UnicodeMode) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"-a & -u");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
//
// we insufficient parameters
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// get a list with each file specified by parameters
// if parameter is a directory then add all the files below it to the list
//
for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
; Param != NULL
; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
){
Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ, &FileList);
if (EFI_ERROR(Status)) {
ShellStatus = SHELL_NOT_FOUND;
break;
}
//
// make sure we completed the param parsing sucessfully...
// Also make sure that any previous action was sucessful
//
if (ShellStatus == SHELL_SUCCESS) {
//
// check that we have at least 1 file
//
if (FileList == NULL || IsListEmpty(&FileList->Link)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, Param);
continue;
} else {
//
// loop through the list and make sure we are not aborting...
//
for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
){
//
// make sure the file opened ok
//
if (EFI_ERROR(Node->Status)){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Node->FileName, Node->Status);
ShellStatus = SHELL_NOT_FOUND;
continue;
}
//
// make sure its not a directory
//
if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_IS_DIR), gShellLevel3HiiHandle, Node->FileName);
ShellStatus = SHELL_NOT_FOUND;
continue;
}
//
// do it
//
Status = TypeFileByHandle(Node->Handle, AsciiMode, UnicodeMode);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TYP_ERROR), gShellLevel3HiiHandle, Node->FileName, Status);
ShellStatus = SHELL_INVALID_PARAMETER;
}
ASSERT(ShellStatus == SHELL_SUCCESS);
}
}
}
//
// Free the fileList
//
if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
Status = ShellCloseFileMetaArg(&FileList);
}
ASSERT_EFI_ERROR(Status);
FileList = NULL;
}
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
}
if (ShellGetExecutionBreakFlag()) {
return (SHELL_ABORTED);
}
return (ShellStatus);
}

View File

@ -0,0 +1,94 @@
/** @file
Main file for NULL named library for level 3 shell command functions.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
CONST CHAR16 gShellLevel3FileName[] = L"ShellCommands";
EFI_HANDLE gShellLevel3HiiHandle = NULL;
STATIC CONST EFI_GUID gShellLevel3HiiGuid = \
{ \
0x4344558d, 0x4ef9, 0x4725, { 0xb1, 0xe4, 0x33, 0x76, 0xe8, 0xd6, 0x97, 0x4f } \
};
CONST CHAR16*
EFIAPI
ShellCommandGetManFileNameLevel3 (
VOID
)
{
return (gShellLevel3FileName);
}
/**
Constructor for the Shell Level 3 Commands library.
Install the handlers for level 3 UEFI Shell 2.0 commands.
@param ImageHandle the image handle of the process
@param SystemTable the EFI System Table pointer
@retval EFI_SUCCESS the shell command handlers were installed sucessfully
@retval EFI_UNSUPPORTED the shell level required was not found.
**/
EFI_STATUS
EFIAPI
ShellLevel3CommandsLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
gShellLevel3HiiHandle = NULL;
//
// if shell level is less than 3 do nothing
//
if (PcdGet8(PcdShellSupportLevel) < 3) {
return (EFI_UNSUPPORTED);
}
gShellLevel3HiiHandle = HiiAddPackages (&gShellLevel3HiiGuid, gImageHandle, UefiShellLevel3CommandsLibStrings, NULL);
if (gShellLevel3HiiHandle == NULL) {
return (EFI_DEVICE_ERROR);
}
//
// install our shell command handlers that are always installed
//
// Note: that Time, Timezone, and Date are part of level 2 library
//
ShellCommandRegisterCommandName(L"type", ShellCommandRunType , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_TYPE));
ShellCommandRegisterCommandName(L"touch", ShellCommandRunTouch , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_TOUCH));
ShellCommandRegisterCommandName(L"ver", ShellCommandRunVer , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_VER));
ShellCommandRegisterCommandName(L"alias", ShellCommandRunAlias , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_ALIAS));
ShellCommandRegisterCommandName(L"cls", ShellCommandRunCls , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_CLS));
ShellCommandRegisterCommandName(L"echo", ShellCommandRunEcho , ShellCommandGetManFileNameLevel3, 3, L"", FALSE, gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_ECHO));
ShellCommandRegisterCommandName(L"pause", ShellCommandRunPause , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_PAUSE));
ShellCommandRegisterCommandName(L"getmtc", ShellCommandRunGetMtc , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_GETMTC));
ShellCommandRegisterCommandName(L"help", ShellCommandRunHelp , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_HELP));
return (EFI_SUCCESS);
}
/**
Destructor for the library. free any resources.
**/
EFI_STATUS
EFIAPI
ShellLevel3CommandsLibDestructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
if (gShellLevel3HiiHandle != NULL) {
HiiRemovePackages(gShellLevel3HiiHandle);
}
return (EFI_SUCCESS);
}

View File

@ -0,0 +1,156 @@
/** @file
header file for NULL named library for level 3 shell command functions.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <ShellBase.h>
#include <Protocol/EfiShell.h>
#include <Protocol/EfiShellParameters.h>
#include <Protocol/DevicePath.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/UnicodeCollation.h>
#include <Protocol/DevicePathToText.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/ShellCommandLib.h>
#include <Library/ShellLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/HiiLib.h>
#include <Library/FileHandleLib.h>
extern EFI_HANDLE gShellLevel3HiiHandle;
/**
Function for 'type' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunType (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Function for 'touch' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunTouch (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Function for 'ver' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunVer (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Function for 'alias' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunAlias (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Function for 'cls' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunCls (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Function for 'echo' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunEcho (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Function for 'pause' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunPause (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Function for 'getmtc' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunGetMtc (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Function for 'help' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunHelp (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);

View File

@ -0,0 +1,68 @@
## @file
# Provides shell level 3 functions
# Note that the interactive versions of the time, date, and timezone functions are handled in the level 2 library.
#
# Copyright (c) 2009-2010, Intel Corporation. All rights reserved. <BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
##
[Defines]
INF_VERSION = 0x00010006
BASE_NAME = UefiShellLevel3CommandsLib
FILE_GUID = 71374B42-85D7-4753-AD17-AA84C3A0EB93
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
CONSTRUCTOR = ShellLevel3CommandsLibConstructor
DESTRUCTOR = ShellLevel3CommandsLibDestructor
[Sources.common]
# note that time, timezone, and date are part of the level 2 library
Type.c
Touch.c
Ver.c
UefiShellLevel3CommandsLib.uni
UefiShellLevel3CommandsLib.c
UefiShellLevel3CommandsLib.h
Cls.c
Alias.c
Echo.c
Pause.c
GetMtc.c
Help.c
[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
MemoryAllocationLib
BaseLib
BaseMemoryLib
DebugLib
ShellCommandLib
ShellLib
UefiLib
UefiRuntimeServicesTableLib
UefiBootServicesTableLib
PcdLib
HiiLib
FileHandleLib
[Guids]
gEfiFileInfoGuid
[Pcd.common]
gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel
gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize

View File

@ -0,0 +1,145 @@
/** @file
Main file for Ver shell level 3 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel3CommandsLib.h"
#include <Library/ShellLib.h>
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-s", TypeFlag},
{L"-terse", TypeFlag},
{L"-t", TypeFlag},
{L"-_pa", TypeFlag},
{NULL, TypeMax}
};
/**
Function for 'ver' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunVer (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINT8 Level;
Level = PcdGet8(PcdShellSupportLevel);
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
}
if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
//
// we have too many parameters
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ShellCommandLineGetFlag(Package, L"-s")) {
ShellPrintHiiEx (
0,
gST->ConOut->Mode->CursorRow,
NULL,
STRING_TOKEN (STR_VER_OUTPUT_SIMPLE),
gShellLevel3HiiHandle,
gEfiShellProtocol->MajorVersion,
gEfiShellProtocol->MinorVersion
);
} else {
ShellPrintHiiEx (
0,
gST->ConOut->Mode->CursorRow,
NULL,
STRING_TOKEN (STR_VER_OUTPUT_SHELL),
gShellLevel3HiiHandle,
SupportLevel[Level],
gEfiShellProtocol->MajorVersion,
gEfiShellProtocol->MinorVersion
);
if (!ShellCommandLineGetFlag(Package, L"-terse") && !ShellCommandLineGetFlag(Package, L"-t")){
ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_VER_EXTRA_STRING),
gShellLevel3HiiHandle
);
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_VER_OUTPUT_UEFI),
gShellLevel3HiiHandle,
(gST->Hdr.Revision&0xffff0000)>>16,
(gST->Hdr.Revision&0x0000ffff),
gST->FirmwareVendor,
gST->FirmwareRevision
);
}
}
//
// implementation specific support for displaying processor architecture
//
if (ShellCommandLineGetFlag(Package, L"-_pa")) {
ShellPrintEx(-1, -1, L"%d\r\n", sizeof(UINTN)==sizeof(UINT64)?64:32);
}
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
}
return (ShellStatus);
}