diff options
author | Guo Mang <mang.guo@intel.com> | 2017-04-27 11:20:30 +0800 |
---|---|---|
committer | Guo Mang <mang.guo@intel.com> | 2017-04-27 11:20:30 +0800 |
commit | 878342a9d5543bd15129f38a4330aa4dd6c71739 (patch) | |
tree | 4e3545d9b983537c46272fd588297054a9b2736e /Core/ShellPkg/Library/UefiShellLevel3CommandsLib | |
parent | 77711a420aeb77cf10af13672c921bb29a0a74c2 (diff) | |
download | edk2-platforms-878342a9d5543bd15129f38a4330aa4dd6c71739.tar.xz |
ShellPkg: Move to new location
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Mang <mang.guo@intel.com>
Diffstat (limited to 'Core/ShellPkg/Library/UefiShellLevel3CommandsLib')
13 files changed, 2875 insertions, 0 deletions
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Alias.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Alias.c new file mode 100644 index 0000000000..5a3b7e5913 --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Alias.c @@ -0,0 +1,194 @@ +/** @file
+ Main file for Alias shell level 3 function.
+
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
+ Copyright (c) 2009 - 2016, 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
+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));
+ if (Alias == NULL) {
+ return (SHELL_OUT_OF_RESOURCES);
+ }
+ 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;
+ CHAR16 *CleanParam2;
+ CONST CHAR16 *ConstAliasVal;
+ BOOLEAN Volatile;
+
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ CleanParam2 = 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, L"alias", ProblemParam);
+ FreePool(ProblemParam);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ ASSERT(FALSE);
+ }
+ } else {
+ Param1 = ShellCommandLineGetRawValue(Package, 1);
+ Param2 = ShellCommandLineGetRawValue(Package, 2);
+
+ if (Param2 != NULL) {
+ CleanParam2 = AllocateCopyPool (StrSize(Param2), Param2);
+ if (CleanParam2 == NULL) {
+ return SHELL_OUT_OF_RESOURCES;
+ }
+
+ if (CleanParam2[0] == L'\"' && CleanParam2[StrLen(CleanParam2)-1] == L'\"') {
+ CleanParam2[StrLen(CleanParam2)-1] = L'\0';
+ CopyMem (CleanParam2, CleanParam2 + 1, StrSize(CleanParam2) - sizeof(CleanParam2[0]));
+ }
+ }
+
+ //
+ // 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(CleanParam2, 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, L"alias");
+ ShellStatus = SHELL_ACCESS_DENIED;
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel3HiiHandle, L"alias", Status);
+ ShellStatus = SHELL_DEVICE_ERROR;
+ }
+ }
+ } else if (ShellCommandLineGetCount(Package) == 2) {
+ //
+ // print out a single alias
+ //
+ ConstAliasVal = gEfiShellProtocol->GetAlias(Param1, &Volatile);
+ if (ConstAliasVal == NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"alias", Param1);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ if (ShellCommandIsOnAliasList(Param1)) {
+ Volatile = FALSE;
+ }
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ALIAS_OUTPUT), gShellLevel3HiiHandle, !Volatile?L' ':L'*', Param1, ConstAliasVal);
+ }
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"alias");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ }
+ //
+ // free the command line package
+ //
+ ShellCommandLineFreeVarList (Package);
+ }
+
+ SHELL_FREE_NON_NULL (CleanParam2);
+ return (ShellStatus);
+}
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c new file mode 100644 index 0000000000..7e7d58d16c --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c @@ -0,0 +1,230 @@ +/** @file
+ Main file for attrib shell level 2 function.
+
+ (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
+ Copyright (c) 2009 - 2014, 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"-sfo", TypeFlag},
+ {NULL, TypeMax}
+ };
+
+/**
+ 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;
+ UINTN Background;
+ UINTN Foreground;
+ CHAR16 *ProblemParam;
+ SHELL_STATUS ShellStatus;
+ CONST CHAR16 *BackColorStr;
+ CONST CHAR16 *ForeColorStr;
+
+ //
+ // Initialize variables
+ //
+ ShellStatus = SHELL_SUCCESS;
+ ProblemParam = NULL;
+ Background = 0;
+ Foreground = 0;
+
+ //
+ // initialize the shell lib (we must be in non-auto-init...)
+ //
+ Status = ShellInitialize();
+ 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, L"cls", ProblemParam);
+ FreePool(ProblemParam);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ ASSERT(FALSE);
+ }
+ } else {
+ //
+ // check for "-?"
+ //
+ if (ShellCommandLineGetFlag(Package, L"-?")) {
+ ASSERT(FALSE);
+ } else if (ShellCommandLineGetFlag (Package, L"-sfo")) {
+ if (ShellCommandLineGetCount (Package) > 1) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"cls");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ Background = (gST->ConOut->Mode->Attribute >> 4) & 0x7;
+ Foreground = gST->ConOut->Mode->Attribute & 0x0F;
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel3HiiHandle, L"cls");
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_CLS_OUTPUT_SFO),
+ gShellLevel3HiiHandle,
+ gST->ConOut->Mode->Attribute,
+ Foreground,
+ Background
+ );
+ }
+ } else {
+ //
+ // If there are 0 value parameters, clear sceen
+ //
+ BackColorStr = ShellCommandLineGetRawValue (Package, 1);
+ ForeColorStr = ShellCommandLineGetRawValue (Package, 2);
+
+ if (BackColorStr == NULL && ForeColorStr == NULL) {
+ //
+ // clear screen
+ //
+ gST->ConOut->ClearScreen (gST->ConOut);
+ } else if (ShellCommandLineGetCount (Package) > 3) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"cls");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ if (BackColorStr != NULL) {
+ if ((ShellStrToUintn (BackColorStr) > 7) || (StrLen (BackColorStr) > 1) || (!ShellIsDecimalDigitCharacter (*BackColorStr))) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"cls", BackColorStr);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ switch (ShellStrToUintn (BackColorStr)) {
+ 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;
+ }
+
+ if (ForeColorStr != NULL) {
+ if ((ShellStrToUintn (ForeColorStr) > 15) || (StrLen (ForeColorStr) > 2) || (!ShellIsDecimalDigitCharacter (*ForeColorStr))) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"cls", ForeColorStr);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ switch (ShellStrToUintn (ForeColorStr)) {
+ case 0:
+ Foreground = EFI_BLACK;
+ break;
+ case 1:
+ Foreground = EFI_BLUE;
+ break;
+ case 2:
+ Foreground = EFI_GREEN;
+ break;
+ case 3:
+ Foreground = EFI_CYAN;
+ break;
+ case 4:
+ Foreground = EFI_RED;
+ break;
+ case 5:
+ Foreground = EFI_MAGENTA;
+ break;
+ case 6:
+ Foreground = EFI_BROWN;
+ break;
+ case 7:
+ Foreground = EFI_LIGHTGRAY;
+ break;
+ case 8:
+ Foreground = EFI_DARKGRAY;
+ break;
+ case 9:
+ Foreground = EFI_LIGHTBLUE;
+ break;
+ case 10:
+ Foreground = EFI_LIGHTGREEN;
+ break;
+ case 11:
+ Foreground = EFI_LIGHTCYAN;
+ break;
+ case 12:
+ Foreground = EFI_LIGHTRED;
+ break;
+ case 13:
+ Foreground = EFI_LIGHTMAGENTA;
+ break;
+ case 14:
+ Foreground = EFI_YELLOW;
+ break;
+ case 15:
+ Foreground = EFI_WHITE;
+ break;
+ }
+ }
+ } else {
+ //
+ // Since foreground color is not modified, so retain
+ // existing foreground color without any change to it.
+ //
+ Foreground = gST->ConOut->Mode->Attribute & 0x0F;
+ }
+
+ if (ShellStatus == SHELL_SUCCESS) {
+ Status = gST->ConOut->SetAttribute (gST->ConOut, (Foreground | Background) & 0x7F);
+ 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);
+}
+
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c new file mode 100644 index 0000000000..a638de8ce2 --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c @@ -0,0 +1,121 @@ +/** @file
+ Main file for Echo shell level 3 function.
+
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
+ Copyright (c) 2009 - 2012, 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;
+ SHELL_STATUS ShellStatus;
+ UINTN ParamCount;
+ CHAR16 *ProblemParam;
+ UINTN Size;
+ CHAR16 *PrintString;
+
+ Size = 0;
+ ProblemParam = NULL;
+ PrintString = 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, &ProblemParam, TRUE, TRUE);
+ if (EFI_ERROR(Status)) {
+ if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"echo", 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++
+ ) {
+ StrnCatGrow(&PrintString, &Size, ShellCommandLineGetRawValue(Package, ParamCount), 0);
+ if (ShellCommandLineGetRawValue(Package, ParamCount+1) != NULL) {
+ StrnCatGrow(&PrintString, &Size, L" ", 0);
+ }
+ }
+ ShellPrintEx(-1, -1, L"%s\r\n", PrintString);
+ SHELL_FREE_NON_NULL(PrintString);
+ }
+
+ //
+ // free the command line package
+ //
+ ShellCommandLineFreeVarList (Package);
+ }
+
+ return (ShellStatus);
+}
+
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c new file mode 100644 index 0000000000..21c5bc81eb --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c @@ -0,0 +1,97 @@ +/** @file
+ Main file for GetMtc shell level 3 function.
+
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
+ Copyright (c) 2009 - 2013, 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, L"getmtc", 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, L"getmtc");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ //
+ // Get the monotonic counter count
+ //
+ Status = gBS->GetNextMonotonicCount(&Mtc);
+ if (Status == EFI_DEVICE_ERROR) {
+ ShellStatus = SHELL_DEVICE_ERROR;
+ } else if (Status == EFI_SECURITY_VIOLATION) {
+ ShellStatus = SHELL_SECURITY_VIOLATION;
+ } else 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);
+}
+
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c new file mode 100644 index 0000000000..a71ade3a20 --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c @@ -0,0 +1,474 @@ +/** @file
+ Main file for Help shell level 3 function.
+
+ Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2014, ARM Limited. All rights reserved. <BR>
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<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>
+#include <Library/HandleParsingLib.h>
+
+#include <Protocol/ShellDynamicCommand.h>
+
+/**
+ function to insert string items into a list in the correct alphabetical place
+
+ the resultant list is a double NULL terminated list of NULL terminated strings.
+
+ upon successful return the memory must be caller freed (unless passed back in
+ via a loop where it will get reallocated).
+
+ @param[in,out] DestList double pointer to the list. may be NULL.
+ @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.
+ @param[in] Item the item to insert.
+
+ @retval EFI_SUCCESS the operation was successful.
+**/
+EFI_STATUS
+LexicalInsertIntoList(
+ IN OUT CHAR16 **DestList,
+ IN OUT UINTN *DestSize,
+ IN CONST CHAR16 *Item
+ )
+{
+ CHAR16 *NewList;
+ INTN LexicalMatchValue;
+ CHAR16 *LexicalSpot;
+ UINTN SizeOfAddedNameInBytes;
+
+ //
+ // If there are none, then just return with success
+ //
+ if (Item == NULL || *Item == CHAR_NULL || StrLen(Item)==0) {
+ return (EFI_SUCCESS);
+ }
+
+ NewList = *DestList;
+
+ SizeOfAddedNameInBytes = StrSize(Item);
+ NewList = ReallocatePool(*DestSize, (*DestSize) + SizeOfAddedNameInBytes, NewList);
+ (*DestSize) = (*DestSize) + SizeOfAddedNameInBytes;
+
+ //
+ // Find the correct spot in the list
+ //
+ for (LexicalSpot = NewList
+ ; LexicalSpot != NULL && LexicalSpot < NewList + (*DestSize)
+ ; LexicalSpot += StrLen(LexicalSpot) + 1
+ ) {
+ //
+ // Get Lexical Comparison Value between PrevCommand and Command list entry
+ //
+ LexicalMatchValue = gUnicodeCollation->StriColl (
+ gUnicodeCollation,
+ (CHAR16 *)LexicalSpot,
+ (CHAR16 *)Item
+ );
+ //
+ // The new item goes before this one.
+ //
+ if (LexicalMatchValue > 0 || StrLen(LexicalSpot) == 0) {
+ if (StrLen(LexicalSpot) != 0) {
+ //
+ // Move this and all other items out of the way
+ //
+ CopyMem(
+ LexicalSpot + (SizeOfAddedNameInBytes/sizeof(CHAR16)),
+ LexicalSpot,
+ (*DestSize) - SizeOfAddedNameInBytes - ((LexicalSpot - NewList) * sizeof(CHAR16))
+ );
+ }
+
+ //
+ // Stick this one in place
+ //
+ StrCpyS(LexicalSpot, SizeOfAddedNameInBytes/sizeof(CHAR16), Item);
+ break;
+ }
+ }
+
+ *DestList = NewList;
+ return (EFI_SUCCESS);
+}
+
+/**
+ function to add each command name from the linked list to the string list.
+
+ the resultant list is a double NULL terminated list of NULL terminated strings.
+
+ @param[in,out] DestList double pointer to the list. may be NULL.
+ @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.
+ @param[in] SourceList the double linked list of commands.
+
+ @retval EFI_SUCCESS the operation was successful.
+**/
+EFI_STATUS
+CopyListOfCommandNames(
+ IN OUT CHAR16 **DestList,
+ IN OUT UINTN *DestSize,
+ IN CONST COMMAND_LIST *SourceList
+ )
+{
+ CONST COMMAND_LIST *Node;
+
+ for ( Node = (COMMAND_LIST*)GetFirstNode(&SourceList->Link)
+ ; SourceList != NULL && !IsListEmpty(&SourceList->Link) && !IsNull(&SourceList->Link, &Node->Link)
+ ; Node = (COMMAND_LIST*)GetNextNode(&SourceList->Link, &Node->Link)
+ ) {
+ LexicalInsertIntoList(DestList, DestSize, Node->CommandString);
+ }
+ return (EFI_SUCCESS);
+}
+
+/**
+ function to add each dynamic command name to the string list.
+
+ the resultant list is a double NULL terminated list of NULL terminated strings.
+
+ @param[in,out] DestList double pointer to the list. may be NULL.
+ @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.
+
+ @retval EFI_SUCCESS the operation was successful.
+ @return an error from HandleProtocol
+**/
+STATIC
+EFI_STATUS
+CopyListOfCommandNamesWithDynamic(
+ IN OUT CHAR16** DestList,
+ IN OUT UINTN *DestSize
+ )
+{
+ EFI_HANDLE *CommandHandleList;
+ CONST EFI_HANDLE *NextCommand;
+ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;
+ EFI_STATUS Status;
+
+ CommandHandleList = GetHandleListByProtocol(&gEfiShellDynamicCommandProtocolGuid);
+
+ //
+ // If there are none, then just return with success
+ //
+ if (CommandHandleList == NULL) {
+ return (EFI_SUCCESS);
+ }
+
+ Status = EFI_SUCCESS;
+
+ //
+ // Append those to the list.
+ //
+ for (NextCommand = CommandHandleList ; *NextCommand != NULL && !EFI_ERROR(Status) ; NextCommand++) {
+ Status = gBS->HandleProtocol(
+ *NextCommand,
+ &gEfiShellDynamicCommandProtocolGuid,
+ (VOID **)&DynamicCommand
+ );
+
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+
+ Status = LexicalInsertIntoList(DestList, DestSize, DynamicCommand->CommandName);
+ }
+
+ SHELL_FREE_NON_NULL(CommandHandleList);
+ return (Status);
+}
+
+
+/**
+ Attempt to print help from a dynamically added command.
+
+ @param[in] CommandToGetHelpOn The unicode name of the command that help is
+ requested on.
+ @param[in] SectionToGetHelpOn Pointer to the section specifier(s).
+ @param[in] PrintCommandText Print the command followed by the help content
+ or just help.
+
+ @retval EFI_SUCCESS The help was displayed
+ @retval EFI_NOT_FOUND The command name could not be found
+ @retval EFI_DEVICE_ERROR The help data format was incorrect.
+**/
+EFI_STATUS
+PrintDynamicCommandHelp(
+ IN CONST CHAR16 *CommandToGetHelpOn,
+ IN CONST CHAR16 *SectionToGetHelpOn,
+ IN BOOLEAN PrintCommandText
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Found;
+ EFI_HANDLE *CommandHandleList;
+ EFI_HANDLE *NextCommand;
+ EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;
+
+ Status = EFI_NOT_FOUND;
+ Found = FALSE;
+ CommandHandleList = NULL;
+
+ CommandHandleList = GetHandleListByProtocol(&gEfiShellDynamicCommandProtocolGuid);
+
+ if (CommandHandleList == NULL) {
+ //
+ // not found or out of resources
+ //
+ return Status;
+ }
+
+ for (NextCommand = CommandHandleList; *NextCommand != NULL; NextCommand++) {
+ Status = gBS->HandleProtocol(
+ *NextCommand,
+ &gEfiShellDynamicCommandProtocolGuid,
+ (VOID **)&DynamicCommand
+ );
+
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+
+ //
+ // Check execution break flag when printing multiple command help information.
+ //
+ if (ShellGetExecutionBreakFlag ()) {
+ break;
+ }
+
+ if ((gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)DynamicCommand->CommandName, (CHAR16*)CommandToGetHelpOn)) ||
+ (gEfiShellProtocol->GetAlias (CommandToGetHelpOn, NULL) != NULL && (gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)DynamicCommand->CommandName, (CHAR16*)(gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL)))))) {
+ // Print as Shell Help if in ManPage format.
+ Status = ShellPrintHelp (DynamicCommand->CommandName, SectionToGetHelpOn,
+ PrintCommandText);
+ if (Status == EFI_DEVICE_ERROR) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_INV),
+ gShellLevel3HiiHandle, DynamicCommand->CommandName);
+ } else if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_NF),
+ gShellLevel3HiiHandle, DynamicCommand->CommandName);
+ } else {
+ Found = TRUE;
+ }
+ }
+ }
+
+ SHELL_FREE_NON_NULL(CommandHandleList);
+
+ return (Found ? EFI_SUCCESS : Status);
+
+}
+
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ {L"-usage", TypeFlag},
+ {L"-section", TypeMaxValue},
+ {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 *SortedCommandList;
+ CONST CHAR16 *CurrentCommand;
+ CHAR16 *CommandToGetHelpOn;
+ CHAR16 *SectionToGetHelpOn;
+ CHAR16 *HiiString;
+ BOOLEAN Found;
+ BOOLEAN PrintCommandText;
+ UINTN SortedCommandListSize;
+
+ PrintCommandText = TRUE;
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ CommandToGetHelpOn = NULL;
+ SectionToGetHelpOn = NULL;
+ SortedCommandList = 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, L"help", 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, L"help");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"help");
+ 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 {
+ PrintCommandText = FALSE;
+ 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 {
+ //
+ // The output of help <command> will display NAME, SYNOPSIS, OPTIONS, DESCRIPTION, and EXAMPLES sections.
+ //
+ StrnCatGrow (&SectionToGetHelpOn, NULL, L"NAME,SYNOPSIS,OPTIONS,DESCRIPTION,EXAMPLES", 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 {
+ SortedCommandList = NULL;
+ SortedCommandListSize = 0;
+ CopyListOfCommandNames(&SortedCommandList, &SortedCommandListSize, ShellCommandGetCommandList(TRUE));
+ CopyListOfCommandNamesWithDynamic(&SortedCommandList, &SortedCommandListSize);
+
+ for (CurrentCommand = SortedCommandList
+ ; CurrentCommand != NULL && *CurrentCommand != CHAR_NULL && CurrentCommand < SortedCommandList + SortedCommandListSize/sizeof(CHAR16)
+ ; CurrentCommand += StrLen(CurrentCommand) + 1
+ ) {
+ //
+ // Checking execution break flag when print multiple command help information.
+ //
+ if (ShellGetExecutionBreakFlag ()) {
+ break;
+ }
+
+ if ((gUnicodeCollation->MetaiMatch(gUnicodeCollation, (CHAR16*)CurrentCommand, CommandToGetHelpOn)) ||
+ (gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL) != NULL && (gUnicodeCollation->MetaiMatch(gUnicodeCollation, (CHAR16*)CurrentCommand, (CHAR16*)(gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL)))))) {
+ //
+ // We have a command to look for help on.
+ //
+ Status = ShellPrintHelp(CurrentCommand, SectionToGetHelpOn, PrintCommandText);
+ if (EFI_ERROR(Status)) {
+ //
+ // now try to match against the dynamic command list and print help
+ //
+ Status = PrintDynamicCommandHelp (CurrentCommand, SectionToGetHelpOn, PrintCommandText);
+ }
+ if (Status == EFI_DEVICE_ERROR) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, CurrentCommand);
+ } else if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CurrentCommand);
+ } else {
+ Found = TRUE;
+ }
+ }
+ }
+
+ //
+ // Search the .man file for Shell applications (Shell external commands).
+ //
+ if (!Found) {
+ Status = ShellPrintHelp(CommandToGetHelpOn, SectionToGetHelpOn, FALSE);
+ if (Status == EFI_DEVICE_ERROR) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, CommandToGetHelpOn);
+ } else if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CommandToGetHelpOn);
+ } else {
+ Found = TRUE;
+ }
+ }
+ }
+
+ if (!Found) {
+ ShellStatus = SHELL_NOT_FOUND;
+ }
+
+ //
+ // free the command line package
+ //
+ ShellCommandLineFreeVarList (Package);
+ }
+ }
+
+ if (CommandToGetHelpOn != NULL && StrCmp(CommandToGetHelpOn, L"*") == 0){
+ //
+ // If '*' then the command entered was 'Help' without qualifiers, This footer
+ // provides additional info on help switches
+ //
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_FOOTER), gShellLevel3HiiHandle);
+ }
+ if (CommandToGetHelpOn != NULL) {
+ FreePool(CommandToGetHelpOn);
+ }
+ if (SectionToGetHelpOn != NULL) {
+ FreePool(SectionToGetHelpOn);
+ }
+ SHELL_FREE_NON_NULL(SortedCommandList);
+
+ return (ShellStatus);
+}
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c new file mode 100644 index 0000000000..ab597060e2 --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c @@ -0,0 +1,107 @@ +/** @file
+ Main file for Pause shell level 3 function.
+
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
+ Copyright (c) 2009 - 2014, 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;
+ Resp = NULL;
+
+ //
+ // 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_NO_SCRIPT), gShellLevel3HiiHandle, L"pause");
+ 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, L"pause", 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, L"pause");
+ 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);
+ }
+
+ if (EFI_ERROR(Status) || Resp == NULL || *Resp == ShellPromptResponseQuit) {
+ ShellCommandRegisterExit(TRUE, 0);
+ ShellStatus = SHELL_ABORTED;
+ }
+
+ if (Resp != NULL) {
+ FreePool(Resp);
+ }
+ }
+
+ //
+ // free the command line package
+ //
+ ShellCommandLineFreeVarList (Package);
+ }
+
+
+ return (ShellStatus);
+}
+
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c new file mode 100644 index 0000000000..639346fb31 --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c @@ -0,0 +1,292 @@ +/** @file
+ Main file for Touch shell level 3 function.
+
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ 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>
+
+/**
+ Do the touch operation on a single handle.
+
+ @param[in] Handle The handle to update the date/time on.
+
+ @retval EFI_ACCESS_DENIED The file referenced by Handle is read only.
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+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);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"gRT->GetTime", Status);
+ return (SHELL_DEVICE_ERROR);
+ }
+
+ CopyMem(&FileInfo->LastAccessTime, &FileInfo->ModificationTime, sizeof(EFI_TIME));
+
+ Status = gEfiShellProtocol->SetFileInfo(Handle, FileInfo);
+
+ FreePool(FileInfo);
+
+ return (Status);
+}
+
+/**
+ Touch a given file and potantially recurse down if it was a directory.
+
+ @param[in] Name The name of this file.
+ @param[in] FS The name of the file system this file is on.
+ @param[in] Handle The handle of this file already opened.
+ @param[in] Rec TRUE to recurse if possible.
+
+ @retval EFI_INVALID_PARAMETER A parameter was invalid.
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+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);
+ if (FS != NULL) {
+ TempSpot = StrStr(FS, L"\\");
+ if (TempSpot != NULL) {
+ *TempSpot = CHAR_NULL;
+ }
+ }
+ }
+ if (FS == NULL) {
+ return (EFI_INVALID_PARAMETER);
+ }
+
+ //
+ // do it
+ //
+ Status = TouchFileByHandle(Handle);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Name);
+ 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_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Walker->FullName);
+ 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, L"touch", 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, L"touch");
+ 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_PARAM_INV), gShellLevel3HiiHandle, L"touch", (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, L"touch", 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_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName);
+ 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_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName);
+ 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);
+}
+
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c new file mode 100644 index 0000000000..50d18e45aa --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c @@ -0,0 +1,327 @@ +/** @file
+ Main file for Type shell level 3 function.
+
+ (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ 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>
+
+/**
+ Display a single file to StdOut.
+
+ If both Ascii and UCS2 are FALSE attempt to discover the file type.
+
+ @param[in] Handle The handle to the file to display.
+ @param[in] Ascii TRUE to force ASCII, FALSE othewise.
+ @param[in] UCS2 TRUE to force UCS2, FALSE othewise.
+
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+TypeFileByHandle (
+ IN SHELL_FILE_HANDLE Handle,
+ IN BOOLEAN Ascii,
+ IN BOOLEAN UCS2
+ )
+{
+ UINTN ReadSize;
+ VOID *Buffer;
+ VOID *AllocatedBuffer;
+ EFI_STATUS Status;
+ UINTN LoopVar;
+ UINTN LoopSize;
+ CHAR16 AsciiChar;
+ CHAR16 Ucs2Char;
+
+ ReadSize = PcdGet32(PcdShellFileOperationSize);
+ AllocatedBuffer = AllocateZeroPool(ReadSize);
+ if (AllocatedBuffer == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+
+ Status = ShellSetFilePosition(Handle, 0);
+ ASSERT_EFI_ERROR(Status);
+
+ while (ReadSize == ((UINTN)PcdGet32(PcdShellFileOperationSize))) {
+ Buffer = AllocatedBuffer;
+ ZeroMem(Buffer, ReadSize);
+ Status = ShellReadFile(Handle, &ReadSize, Buffer);
+ if (EFI_ERROR(Status)){
+ break;
+ }
+
+ if (!(Ascii|UCS2)) {
+ if (*(UINT16*)Buffer == gUnicodeFileTag) {
+ UCS2 = TRUE;
+ } else {
+ Ascii = TRUE;
+ }
+ }
+
+ if (Ascii) {
+ LoopSize = ReadSize;
+ for (LoopVar = 0 ; LoopVar < LoopSize ; LoopVar++) {
+ //
+ // The valid range of ASCII characters is 0x20-0x7E.
+ // Display "." when there is an invalid character.
+ //
+ AsciiChar = CHAR_NULL;
+ AsciiChar = ((CHAR8*)Buffer)[LoopVar];
+ if (AsciiChar == '\r' || AsciiChar == '\n') {
+ //
+ // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)
+ // characters to be displayed as is.
+ //
+ if (AsciiChar == '\n' && ((CHAR8*)Buffer)[LoopVar-1] != '\r') {
+ //
+ // In case Line Feed (0xA) is encountered & Carriage Return (0xD)
+ // was not the previous character, print CR and LF. This is because
+ // Shell 2.0 requires carriage return with line feed for displaying
+ // each new line from left.
+ //
+ ShellPrintEx (-1, -1, L"\r\n");
+ continue;
+ }
+ } else {
+ //
+ // For all other characters which are not printable, display '.'
+ //
+ if (AsciiChar < 0x20 || AsciiChar >= 0x7F) {
+ AsciiChar = '.';
+ }
+ }
+ ShellPrintEx (-1, -1, L"%c", AsciiChar);
+ }
+ } else {
+ if (*(UINT16*)Buffer == gUnicodeFileTag) {
+ //
+ // For unicode files, skip displaying the byte order marker.
+ //
+ Buffer = ((UINT16*)Buffer) + 1;
+ LoopSize = (ReadSize / (sizeof (CHAR16))) - 1;
+ } else {
+ LoopSize = ReadSize / (sizeof (CHAR16));
+ }
+
+ for (LoopVar = 0 ; LoopVar < LoopSize ; LoopVar++) {
+ //
+ // An invalid range of characters is 0x0-0x1F.
+ // Display "." when there is an invalid character.
+ //
+ Ucs2Char = CHAR_NULL;
+ Ucs2Char = ((CHAR16*)Buffer)[LoopVar];
+ if (Ucs2Char == '\r' || Ucs2Char == '\n') {
+ //
+ // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)
+ // characters to be displayed as is.
+ //
+ if (Ucs2Char == '\n' && ((CHAR16*)Buffer)[LoopVar-1] != '\r') {
+ //
+ // In case Line Feed (0xA) is encountered & Carriage Return (0xD)
+ // was not the previous character, print CR and LF. This is because
+ // Shell 2.0 requires carriage return with line feed for displaying
+ // each new line from left.
+ //
+ ShellPrintEx (-1, -1, L"\r\n");
+ continue;
+ }
+ }
+ else if (Ucs2Char < 0x20) {
+ //
+ // For all other characters which are not printable, display '.'
+ //
+ Ucs2Char = L'.';
+ }
+ ShellPrintEx (-1, -1, L"%c", Ucs2Char);
+ }
+ }
+
+ if (ShellGetExecutionBreakFlag()) {
+ break;
+ }
+ }
+ FreePool (AllocatedBuffer);
+ ShellPrintEx (-1, -1, L"\r\n");
+ 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, L"type", 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_PARAM_INV), gShellLevel3HiiHandle, L"type", 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, L"type");
+ 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)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", (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, L"type", 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)
+ ){
+
+ if (ShellGetExecutionBreakFlag()) {
+ break;
+ }
+
+ //
+ // make sure the file opened ok
+ //
+ if (EFI_ERROR(Node->Status)){
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", Node->FileName);
+ 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, L"type", 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, L"type", Node->FileName);
+ 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);
+}
+
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c new file mode 100644 index 0000000000..448f7234dd --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c @@ -0,0 +1,101 @@ +/** @file
+ Main file for NULL named library for level 3 shell command functions.
+
+ (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ 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;
+
+/**
+ return the filename to get help from is not using HII.
+
+ @retval The filename.
+**/
+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_SUCCESS);
+ }
+
+ 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));
+
+ ShellCommandRegisterAlias(L"type", L"cat");
+
+ return (EFI_SUCCESS);
+}
+
+/**
+ Destructor for the library. free any resources.
+
+ @param ImageHandle The image handle of the process.
+ @param SystemTable The EFI System Table pointer.
+**/
+EFI_STATUS
+EFIAPI
+ShellLevel3CommandsLibDestructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ if (gShellLevel3HiiHandle != NULL) {
+ HiiRemovePackages(gShellLevel3HiiHandle);
+ }
+ return (EFI_SUCCESS);
+}
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h new file mode 100644 index 0000000000..be88dd5f28 --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h @@ -0,0 +1,161 @@ +/** @file
+ header file for NULL named library for level 3 shell command functions.
+
+ Copyright (c) 2009 - 2016, 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.
+
+**/
+
+#ifndef _UEFI_SHELL_LEVEL3_COMMANDS_LIB_H_
+#define _UEFI_SHELL_LEVEL3_COMMANDS_LIB_H_
+
+#include <Uefi.h>
+
+#include <Guid/ShellLibHiiGuid.h>
+
+#include <Protocol/Shell.h>
+#include <Protocol/ShellParameters.h>
+#include <Protocol/DevicePath.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/UnicodeCollation.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
+ );
+
+#endif
+
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf new file mode 100644 index 0000000000..a13cd9babf --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf @@ -0,0 +1,74 @@ +## @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.
+#
+# (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
+# Copyright (c) 2009-2015, 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_APPLICATION
+ 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
+ HandleParsingLib
+
+[Guids]
+ gEfiFileInfoGuid ## UNDEFINED
+ gShellLevel3HiiGuid ## SOMETIMES_CONSUMES ## HII
+
+[Pcd.common]
+ gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## CONSUMES
+ gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize ## SOMETIMES_CONSUMES
+ gEfiShellPkgTokenSpaceGuid.PcdShellSupplier ## SOMETIMES_CONSUMES
+
+[Protocols]
+ gEfiShellDynamicCommandProtocolGuid ## SOMETIMES_CONSUMES
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni new file mode 100644 index 0000000000..b027c67335 --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni @@ -0,0 +1,544 @@ +// /**
+//
+// (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+// (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
+// Copyright (c) 2009 - 2013, 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.
+//
+// Module Name:
+//
+// UefiShellLevel3CommandsLib.uni
+//
+// Abstract:
+//
+// String definitions for UEFI Shell 2.0 level 3 commands
+//
+//
+// **/
+
+/=#
+
+#langdef en-US "english"
+
+#string STR_GEN_TOO_MANY #language en-US "%H%s%N: Too many arguments\r\n"
+#string STR_GEN_TOO_FEW #language en-US "%H%s%N: Too few arguments\r\n"
+#string STR_GEN_PARAM_INV #language en-US "%H%s%N: Invalid argument - '%H%s%N'\r\n"
+#string STR_GEN_PROBLEM #language en-US "%H%s%N: Unknown flag - '%H%s%N'\r\n"
+#string STR_GEN_NO_VALUE #language en-US "%H%s%N: Missing argument for flag - '%H%s%N'\r\n"
+#string STR_GEN_ERR_AD #language en-US "%H%s%N: Access denied.\r\n"
+#string STR_GEN_ERR_UK #language en-US "%H%s%N: Status: %r\r\n"
+#string STR_GEN_PARAM_CON #language en-US "%H%s%N: Parameters conflict\r\n"
+#string STR_GEN_PARAM_CONFLICT #language en-US "%H%s%N: Flags conflict with - '%H%s%N' and '%H%s%N'\r\n"
+#string STR_GEN_FILE_OPEN_FAIL #language en-US "%H%s%N: Cannot open file - '%H%s%N'\r\n"
+#string STR_GEN_FILE_AD #language en-US "%H%s%N: Access file error - '%H%s%N'\r\n"
+#string STR_GEN_CRLF #language en-US "\r\n"
+#string STR_GEN_NO_CWD #language en-US "%H%s%N: Current directory not specified\r\n"
+#string STR_GEN_NO_FILES #language en-US "%H%s%N: No matching files were found\r\n"
+#string STR_GEN_DIR_NF #language en-US "%H%s%N: Directory not found - '%H%s%N'\r\n"
+#string STR_GEN_FILE_NF #language en-US "%H%s%N: File not found - '%H%s%N'\r\n"
+#string STR_GEN_IS_DIR #language en-US "%H%s%N: '%H%s%N' is a directory\r\n"
+#string STR_GEN_SFO_HEADER #language en-US "ShellCommand,"%s"\r\n"
+#string STR_NO_SCRIPT #language en-US "The command '%H%s%N' is not allowed outside of a script\r\n"
+
+#string STR_TYP_ERROR #language en-US "%H%s%N: Operation was not successful on '%H%s%N'\r\n"
+
+#string STR_TOUCH_ERROR #language en-US "%H%s%N: Operation was not successful on '%H%s%N'\r\n"
+
+#string STR_VER_OUTPUT_SHELL #language en-US "UEFI %s Shell v%d.%d\r\n"
+#string STR_VER_OUTPUT_SIMPLE #language en-US "%d.%d\r\n"
+#string STR_VER_OUTPUT_UEFI #language en-US "UEFI v%d.%02d (%s, 0x%08x)\r\n"
+#string STR_VER_OUTPUT_SUPPLIER #language en-US "%s\r\n"
+
+#string STR_ECHO_ON #language en-US "Echo is on.\r\n"
+#string STR_ECHO_OFF #language en-US "Echo is off.\r\n"
+
+#string STR_PAUSE_PROMPT #language en-US "Enter 'q' to quit, any other key to continue:\r\n"
+
+#string STR_HELP_NF #language en-US "No help could be found for command '%B%s%N'.\r\n"
+#string STR_HELP_INV #language en-US "The help data for command '%B%s%N' was incorrect format.\r\n"
+#string STR_HELP_SC_HEADER #language en-US "Character Description\r\n"
+ "--------- ---------------------------------------------- \r\n"
+#string STR_HELP_SC_DATA #language en-US "<newline> Ends a command line.\r\n"
+ "<space> Ends an argument, if it is not in a quotation.\r\n"
+ "# Starts a comment.\r\n"
+ "> Used for output redirection.\r\n"
+ "< Used for input redirection.\r\n"
+ "| Used for pipe command support.\r\n"
+ "% Used to delimit a variable or an argument.\r\n"
+ "\" Used to delimit a quotation.\r\n"
+ "^ Prevents the next character from being\r\n"
+ " interpreted as having special meaning.\r\n"
+ " Can be used inside quoted strings.\r\n"
+ "*, ?, [, ] Wildcards to specify multiple similar file names.\r\n"
+#string STR_HELP_COMMAND #language en-US "%H%-14s%N- %s\r\n"
+#string STR_HELP_FOOTER #language en-US "%N\r\nHelp usage:help [%Hcmd%N|%Hpattern%N|%Hspecial%N] [%H-usage%N] [%H-verbose%N] [%H-section name%N][%H-b%N]\r\n"
+
+#string STR_HELP_PAGE_COMMAND #language en-US "%N%s\r\n"
+
+#string STR_ALIAS_OUTPUT #language en-US "%1c %10s:%s\r\n"
+
+#string STR_GET_MTC_OUTPUT #language en-US "%016Lx\r\n"
+#string STR_CLS_OUTPUT_SFO #language en-US "ConOutAttribInfo,"%d","%d","%d"\r\n"
+
+#string STR_GET_HELP_HELP #language en-US ""
+".TH help 0 "Displays help information from the UEFI Shell."\r\n"
+".SH NAME\r\n"
+"Displays the UEFI Shell command list or verbose command help.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"HELP [cmd | pattern | special] [-usage] [-verbose] [-section sectionname][-b]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+" -usage - Displays the usage information for the command. The same as\r\n"
+" specifying "-section NAME" and "-section SYNOPSIS" \r\n"
+" -section - Displays the specified section of the help information.\r\n"
+" -b - Displays one page on screen and allows user to continue\r\n"
+" to next page\r\n"
+" cmd - Specifies a command to display help about.\r\n"
+" pattern - Specifies a pattern which describes the commands to be displayed.\r\n"
+" special - Displays a list of the special characters used in the shell\r\n"
+" command line.\r\n"
+" sectionname - Specifies a section name. Supported options are:\r\n"
+" - NAME\r\n"
+" - SYNOPSIS\r\n"
+" - OPTIONS\r\n"
+" - DESCRIPTION\r\n"
+" - EXAMPLES\r\n"
+" - RETURNVALUES\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. The HELP command displays information about one or more shell commands.\r\n"
+" 2. If no other options are specified, each command will be displayed along\r\n"
+" with a brief description of its function.\r\n"
+" 3. If -verbose is specified, then display all help information for the\r\n"
+" specified commands.\r\n"
+" 4. If -section is specified, only the help section specified will be\r\n"
+" displayed.\r\n"
+" 5. If -usage is specified, then the command, a brief description\r\n"
+" and the usage will be displayed.\r\n"
+" 6. The help text is gathered from UCS-2 text files found in the directory\r\n"
+" where the shell or shell command executable was located. The files have\r\n"
+" the name commandname.\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * To display the list of commands in the UEFI Shell and break after one\r\n"
+" screen:\r\n"
+" Shell> help -b\r\n"
+" \r\n"
+" * To display help information of a Shell command - ls:\r\n"
+" Shell> help ls\r\n"
+" Shell> -? ls\r\n"
+" Shell> ls -?\r\n"
+" \r\n"
+" * To display the list of commands that start with character 'p':\r\n"
+" Shell> help p*\r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+" 0 The help was displayed\r\n"
+" 1 No command help was displayed\r\n"
+
+#string STR_GET_HELP_ALIAS #language en-US ""
+".TH alias 0 "Handles aliases in the Shell."\r\n"
+".SH NAME\r\n"
+"Displays, creates, or deletes UEFI Shell aliases.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"ALIAS [-d|-v] [alias-name] [command-name]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+" -d - Deletes an alias. Command-name must not be specified.\r\n"
+" -v - Makes the alias volatile.\r\n"
+" alias-name - Specifies an alias name.\r\n"
+" command-name - Specifies an original command's name or path.\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. This command displays, creates, or deletes aliases in the UEFI Shell\r\n"
+" environment.\r\n"
+" 2. An alias provides a new name for an existing UEFI Shell\r\n"
+" command or UEFI application. Once the alias is created, it can be used\r\n"
+" to run the command or launch the UEFI application.\r\n"
+" 3. There are some aliases that are predefined in the UEFI Shell environment.\r\n"
+" These aliases provide the MS-DOS and UNIX equivalent names for the file\r\n"
+" manipulation commands.\r\n"
+" 4. Aliases will be retained even after exiting the shell unless the -v option\r\n"
+" is specified. If -v is specified then the alias will not be valid after\r\n"
+" leaving the shell.\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * To display all aliases in the UEFI Shell environment:\r\n"
+" Shell> alias\r\n"
+" \r\n"
+" * To create an alias in the UEFI Shell environment:\r\n"
+" Shell> alias shutdown "reset -s" \r\n"
+" \r\n"
+" * To delete an alias in the UEFI Shell environment:\r\n"
+" Shell> alias -d shutdown\r\n"
+" \r\n"
+" * To add a volatile alias in the current UEFI environment, which has a star *\r\n"
+" at the line head. This volatile alias will disappear at next boot.\r\n"
+" Shell> alias -v fs0 floppy\r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+" SHELL_SUCCESS The action was completed as requested.\r\n"
+" SHELL_INVALID_PARAMETER One of the passed-in parameters was incorrectly\r\n"
+" formatted or its value was out of bounds.\r\n"
+" SHELL_OUT_OF_RESOURCES A request to set a variable in a non-volatile\r\n"
+" fashion could not be completed. The resulting\r\n"
+" non-volatile request has been converted into\r\n"
+" a volatile request.\r\n"
+" SHELL_SECURITY_VIOLATION This function was not performed due to a security\r\n"
+" violation.\r\n"
+
+#string STR_GET_HELP_CLS #language en-US ""
+".TH cls 0 "clear screen"\r\n"
+".SH NAME\r\n"
+"Clears the console output and optionally changes the background and foreground color.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"CLS [background] [foreground] | [-sfo]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+" background - Sets a new background color:\r\n"
+" 0 - Black\r\n"
+" 1 - Blue\r\n"
+" 2 - Green\r\n"
+" 3 - Cyan\r\n"
+" 4 - Red\r\n"
+" 5 - Magenta\r\n"
+" 6 - Yellow\r\n"
+" 7 - Light gray\r\n"
+" foreground - Sets a new foreground color:\r\n"
+" 0 - Black\r\n"
+" 1 - Blue\r\n"
+" 2 - Green\r\n"
+" 3 - Cyan\r\n"
+" 4 - Red\r\n"
+" 5 - Magenta\r\n"
+" 6 - Yellow\r\n"
+" 7 - Light gray\r\n"
+" 8 - Dark gray\r\n"
+" 9 - Light blue\r\n"
+" 10 - Light green\r\n"
+" 11 - Light cyan\r\n"
+" 12 - Light red\r\n"
+" 13 - Light magenta\r\n"
+" 14 - Yellow\r\n"
+" 15 - White\r\n"
+" -sfo - Displays current console color settings in Standard Format\r\n"
+" Output.\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. This command clears the standard output device with an optional\r\n"
+" background and foreground color attribute.\r\n"
+" 2. If background color is not specified, or if background and foreground\r\n"
+" colors are not specified, then the colors do not change.\r\n"
+" 3. When -sfo flag is used, console output is not cleared and instead it\r\n"
+" displays current console foreground and background attribute settings.\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * To clear standard output without changing the background or foreground\r\n"
+" color:\r\n"
+" fs0:\> cls\r\n"
+" \r\n"
+" * To clear standard output and change the background color to cyan:\r\n"
+" fs0:\> cls 3\r\n"
+" \r\n"
+" * To clear standard output and change the background to black and foreground\r\n"
+" to white:\r\n"
+" fs0:\> cls 0 15\r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+" SHELL_SUCCESS The action was completed as requested.\r\n"
+" SHELL_INVALID_PARAMETER One of the passed-in parameters was incorrectly\r\n"
+" formatted or its value was out of bounds.\r\n"
+" SHELL_SECURITY_VIOLATION This function was not performed due to a security\r\n"
+" violation.\r\n"
+" SHELL_NOT_FOUND The requested file was not found.\r\n"
+
+#string STR_GET_HELP_ECHO #language en-US ""
+".TH echo 0 "display text or control text output"\r\n"
+".SH NAME\r\n"
+"Controls script file command echoing or displays a message.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"ECHO [-on|-off]\r\n"
+"ECHO [message]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+" -on - Enables display when reading commands from script files.\r\n"
+" -off - Disables display when reading commands from script files.\r\n"
+" message - Specifies a message to display.\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. The first form of this command controls whether script commands are\r\n"
+" displayed as they are read from the script file. If no argument is given,\r\n"
+" the current "on" or "off" status is displayed.\r\n"
+" 2. The second form prints the given message to the display.\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * To display a message string of 'Hello World':\r\n"
+" fs0:\> echo Hello World\r\n"
+" \r\n"
+" * To turn command echoing on:\r\n"
+" fs0:\> echo -on\r\n"
+" \r\n"
+" * To execute HelloWorld.nsh, and display when reading lines from the script\r\n"
+" file:\r\n"
+" fs0:\> HelloWorld.nsh\r\n"
+" +HelloWorld.nsh> echo Hello World\r\n"
+" \r\n"
+" * To turn command echoing off:\r\n"
+" fs0:\> echo -off\r\n"
+" \r\n"
+" * To display the current echo setting:\r\n"
+" fs0:\> echo\r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+" SHELL_SUCCESS The action was completed as requested.\r\n"
+" SHELL_SECURITY_VIOLATION This function was not performed due to a security\r\n"
+" violation.\r\n"
+
+#string STR_GET_HELP_GETMTC #language en-US ""
+".TH getmtc 0 "gets the MTC count"\r\n"
+".SH NAME\r\n"
+"Gets the MTC from BootServices and displays it.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"GETMTC\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. This command displays the current monotonic counter value. The lower 32\r\n"
+" bits increment every time this command is executed. Every time the system\r\n"
+" is reset, the upper 32 bits will be incremented, and the lower 32 bits\r\n"
+" will be reset to 0.\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * To display the current monotonic counter value:\r\n"
+" fs0:\> getmtc\r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+" SHELL_SUCCESS The action was completed as requested.\r\n"
+" SHELL_DEVICE_ERROR The underlying device was not working correctly.\r\n"
+" SHELL_SECURITY_VIOLATION This function was not performed due to a security\r\n"
+" violation.\r\n"
+
+#string STR_GET_HELP_PAUSE #language en-US ""
+".TH pause 0 "pauses scripts"\r\n"
+".SH NAME\r\n"
+"Pauses a script and waits for an operator to press a key.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"PAUSE [-q]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+" -q - Does not display a test output prompt.\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. The PAUSE command prints a message to the display, then suspends script\r\n"
+" file execution, and waits for keyboard input. Pressing any key resumes\r\n"
+" execution, except for q or Q. If either q or Q is pressed, script\r\n"
+" processing terminates; otherwise, execution continues with the next line\r\n"
+" after the pause command.\r\n"
+" 2. The PAUSE command is available only in scripts. Switch -q can hide the\r\n"
+" message and it's optional.\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * Following script is a sample of 'pause' command:\r\n"
+" fs0:\> type pause.nsh\r\n"
+" #\r\n"
+" # Example script for 'pause' command\r\n"
+" #\r\n"
+" echo pause.nsh begin..\r\n"
+" date\r\n"
+" time\r\n"
+" pause\r\n"
+" echo pause.nsh done.\r\n"
+" \r\n"
+" * To execute the script with echo on:\r\n"
+" fs0:\> pause.nsh\r\n"
+" +pause.nsh> echo pause.nsh begin..\r\n"
+" pause.nsh begin..\r\n"
+" +pause.nsh> date\r\n"
+" 06/19/2001\r\n"
+" +pause.nsh> time\r\n"
+" 00:51:45\r\n"
+" +pause.nsh> pause\r\n"
+" Enter 'q' to quit, or any other key to continue:\r\n"
+" +pause.nsh> echo pause.nsh done.\r\n"
+" pause.nsh done.\r\n"
+" \r\n"
+" * To execute the script with echo off:\r\n"
+" fs0:\> echo -off\r\n"
+" fs0:\> pause.nsh\r\n"
+" pause.nsh begin..\r\n"
+" 06/19/2001\r\n"
+" 00:52:50\r\n"
+" Enter 'q' to quit, or any other key to continue: q\r\n"
+" fs0:\>\r\n"
+
+#string STR_GET_HELP_TOUCH #language en-US ""
+".TH touch 0 "Touch a file to update a directory"\r\n"
+".SH NAME\r\n"
+"Updates the filename timestamp with the current system date and time.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"TOUCH [-r] file [file ...]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+" -r - Sets the update as recurse into subdirectories.\r\n"
+" file - Specifies the name or pattern of the file or directory. There can be multiple \r\n"
+" files on the command-line.\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. This command updates to the current time and date the time and date on\r\n"
+" the file that is specified by the file parameter.\r\n"
+" 2. If multiple files are specified on the command line, it will continue\r\n"
+" processing. It will touch the files one by one and errors will be\r\n"
+" ignored.\r\n"
+" 3. TOUCH cannot change the time and date of read-only files and directories.\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * To update the timestamp of a specific file:\r\n"
+" fs0:\> touch for.nsh\r\n"
+" \r\n"
+" * To touch a directory recursively:\r\n"
+" fs0:\> touch -r efi1.1\r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+" SHELL_SUCCESS The action was completed as requested.\r\n"
+" SHELL_NOT_FOUND The target file or set of files were not found.\r\n"
+" SHELL_SECURITY_VIOLATION This function was not performed due to a security\r\n"
+" violation.\r\n"
+" SHELL_WRITE_PROTECTED The media was write-protected or the file had a\r\n"
+" read-only attribute associated with it.\r\n"
+
+#string STR_GET_HELP_TYPE #language en-US ""
+".TH type 0 "print a file to StdOut"\r\n"
+".SH NAME\r\n"
+"Sends the contents of a file to the standard output device.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"TYPE [-a|-u] file [file...]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+" -a - Displays the file as if it is encoded as 8-bit ASCII\r\n"
+" -u - Displays the file as if it were encoded as UCS-2 Unicode.\r\n"
+" file - Specifies the name of the file to display.\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. This command sends the contents of a file to the standard output device.\r\n"
+" If no options are used, then the command attempts to automatically detect\r\n"
+" the file type. If it fails, then UCS-2 is presumed.\r\n"
+" 2. If the -a option is specified, the file is sent to the standard output\r\n"
+" device as a stream of ASCII characters.\r\n"
+" 3. If the -u option is specified, the file is sent to the standard output\r\n"
+" device as a stream of Unicode (UCS-2) characters.\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * To display a file in UCS-2 format:\r\n"
+" fs0:\> type -u pause.nsh\r\n"
+" \r\n"
+" * To display a file in ASCII format:\r\n"
+" fs0:\> type -a pause.nsh\r\n"
+" \r\n"
+" * To display multiple files:\r\n"
+" fs0:\> type test.*\r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+" SHELL_SUCCESS The action was completed as requested.\r\n"
+" SHELL_INVALID_PARAMETER One of the passed in parameters was incorrectly\r\n"
+" formatted or its value was out of bounds.\r\n"
+" SHELL_SECURITY_VIOLATION This function was not performed due to a security\r\n"
+" violation.\r\n"
+" SHELL_NOT_FOUND The target file or set of files were not found.\r\n"
+
+#string STR_GET_HELP_VER #language en-US ""
+".TH ver 0 "prints out version info"\r\n"
+".SH NAME\r\n"
+"Displays UEFI Firmware version information.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"VER [-s|-terse]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+" -s - Displays only the UEFI Shell version.\r\n"
+" -terse - Displays only the first part of the data.\r\n"
+".SH DESCRIPTION\r\n"
+" \r\n"
+"NOTES:\r\n"
+" 1. This command displays the version information for this UEFI Firmware, or\r\n"
+" the version information for the UEFI Shell itself. The information is\r\n"
+" retrieved through the UEFI System Table or the Shell image.\r\n"
+" \r\n"
+" 2. Standard format for ver output as shown below with a sample:\r\n"
+" UEFI <support-level> Shell v<uefi-shell-version>\r\n"
+" shell-supplier-specific-data\r\n"
+" UEFI v<uefi-firmware-version> (<firmware vendor name>, 0x<firmware vendor\r\n"
+" version as 32-bit hex value> <optional additional vendor version>)\r\n"
+" #\r\n"
+" # Sample \r\n"
+" #\r\n"
+" UEFI Basic Shell v2.0\r\n"
+" Copyright 2008 by Intel(R) Corporation.\r\n"
+" UEFI v2.31 (Intel(R) Corporation., 0x00010100)\r\n"
+" \r\n"
+" 3. UEFI version tag information:\r\n"
+" <support-level>\r\n"
+" 0 = Minimal\r\n"
+" 1 = Scripting\r\n"
+" 2 = Basic\r\n"
+" 3 = Interactive\r\n"
+" <uefi-shell-version>\r\n"
+" Comes from the Shell specification upon which the Shell\r\n"
+" implementation is based.\r\n"
+" <shell-supplier-specific-data>\r\n"
+" Build, copyright, etc.\r\n"
+" <uefi-firmware-version>\r\n"
+" Comes from the UEFI specification upon which the firmware\r\n"
+" implementation is based\r\n"
+" <firmware vendor name>\r\n"
+" Indicates Vendor Name\r\n"
+" <firmware vendor version>\r\n"
+" Indicates Vendor's firmware version\r\n"
+".SH EXAMPLES\r\n"
+" \r\n"
+"EXAMPLES:\r\n"
+" * To display UEFI Firmware version information:\r\n"
+" fs0:\> ver\r\n"
+" \r\n"
+" * To display UEFI Shell version information only:\r\n"
+" Shell> ver -s\r\n"
+".SH RETURNVALUES\r\n"
+" \r\n"
+"RETURN VALUES:\r\n"
+" SHELL_SUCCESS The action was completed as requested.\r\n"
+
diff --git a/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c new file mode 100644 index 0000000000..d0e2b5cb24 --- /dev/null +++ b/Core/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c @@ -0,0 +1,153 @@ +/** @file
+ Main file for Ver shell level 3 function.
+
+ (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+ (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
+ 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, L"ver", 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, L"ver");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ if (ShellCommandLineGetFlag(Package, L"-s")) {
+ if (ShellCommandLineGetFlag(Package, L"-terse") || ShellCommandLineGetFlag(Package, L"-t")){
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellLevel3HiiHandle, L"ver", L"-t or -terse", L"-s");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ 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_OUTPUT_SUPPLIER),
+ gShellLevel3HiiHandle,
+ (CHAR16 *) PcdGetPtr (PcdShellSupplier)
+ );
+
+
+ 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);
+}
+
|