1// /** 2// 3// (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR> 4// Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR> 5// This program and the accompanying materials 6// are licensed and made available under the terms and conditions of the BSD License 7// which accompanies this distribution. The full text of the license may be found at 8// http://opensource.org/licenses/bsd-license.php 9// 10// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12// 13// Module Name: 14// 15// UefiShellLevel2CommandsLib.uni 16// 17// Abstract: 18// 19// String definitions for UEFI Shell 2.0 level 1 commands 20// 21// 22// **/ 23 24/=# 25 26#langdef en-US "english" 27 28#string STR_NO_SCRIPT #language en-US "The command '%H%s%N' is incorrect outside of a script\r\n" 29#string STR_GEN_PROBLEM #language en-US "%H%s%N: Unknown flag - '%H%s%N'\r\n" 30#string STR_GEN_PROBLEM_VAL #language en-US "%H%s%N: Bad value - '%H%s%N' for flag - '%H%s%N'\r\n" 31#string STR_GEN_PROBLEM_SCRIPT #language en-US "The argument '%B%s%N' is incorrect. Line: %d\r\n" 32#string STR_GEN_INV_VAR #language en-US "The script's Indexvar '%B%s%N' is incorrect\r\n" 33#string STR_GEN_TOO_FEW #language en-US "%H%s%N: Too few arguments\r\n" 34#string STR_GEN_TOO_MANY #language en-US "%H%s%N: Too many arguments\r\n" 35#string STR_GEN_PARAM_INV #language en-US "%H%s%N: Invalid argument - '%H%s%N'\r\n" 36 37#string STR_TEXT_AFTER_THEN #language en-US "%H%s%N: Then cannot be followed by anything\r\n" 38#string STR_SYNTAX_AFTER_BAD #language en-US "%H%s%N: Syntax after '%H%s%N' is incorrect\r\n" 39#string STR_SYNTAX_IN #language en-US "Syntax after analyzing %s\r\n" 40#string STR_SYNTAX_NO_MATCHING #language en-US "No matching '%H%s%N' for '%H%s%N' statement found. Line: %d\r\n" 41#string STR_INVALID_BINOP #language en-US "Binary operator not found first in '%H%s%N'\r\n" 42#string STR_SYNTAX_STARTING #language en-US "Syntax after %s\r\n" 43 44#string STR_STALL_FAILED #language en-US "%H%s%N: BootService Stall() failed\r\n" 45 46#string STR_GET_HELP_EXIT #language en-US "" 47".TH exit 0 "exits the script or shell"\r\n" 48".SH NAME\r\n" 49"Exits the UEFI Shell or the current script.\r\n" 50".SH SYNOPSIS\r\n" 51" \r\n" 52"EXIT [/b] [exit-code]\r\n" 53".SH OPTIONS\r\n" 54" \r\n" 55" /b - Indicates that only the current UEFI shell script should be\r\n" 56" terminated. Ignored if not used within a script.\r\n" 57" exit-code - If exiting a UEFI shell script, the value that will be placed\r\n" 58" into the environment variable lasterror. If exiting an instance\r\n" 59" of the UEFI shell, the value that will be returned to the\r\n" 60" caller. If not specified, then 0 will be returned.\r\n" 61".SH DESCRIPTION\r\n" 62" \r\n" 63"NOTES:\r\n" 64" 1. This command exits the UEFI Shell or, if /b is specified, the current\r\n" 65" script.\r\n" 66".SH EXAMPLES\r\n" 67" \r\n" 68"EXAMPLES:\r\n" 69" * To exit shell successfully:\r\n" 70" Shell> exit\r\n" 71" \r\n" 72" * To exit the current UEFI shell script:\r\n" 73" Shell> exit /b \r\n" 74" \r\n" 75" * To exit a UEFI shell script with exit-code value returned to the caller:\r\n" 76" Shell> exit 0\r\n" 77".SH RETURNVALUES\r\n" 78" \r\n" 79"RETURN VALUES:\r\n" 80" 0 Exited normally\r\n" 81" exit-code The return value specified as an option.\r\n" 82 83#string STR_GET_HELP_FOR #language en-US "" 84".TH for 0 "starts a for loop"\r\n" 85".SH NAME\r\n" 86"Starts a loop based on 'for' syntax.\r\n" 87".SH SYNOPSIS\r\n" 88" \r\n" 89"FOR %indexvar IN set\r\n" 90" command [arguments]\r\n" 91" [command [arguments]]\r\n" 92" ...\r\n" 93"ENDFOR\r\n" 94" \r\n" 95"FOR %indexvar RUN (start end [step])\r\n" 96" command [arguments]\r\n" 97" [command [arguments]]\r\n" 98" ...\r\n" 99"ENDFOR\r\n" 100".SH OPTIONS\r\n" 101" \r\n" 102" %indexvar - Variable name used to index a set\r\n" 103" set - Set to be searched\r\n" 104" command [arguments] - Command to be executed with optional arguments\r\n" 105".SH DESCRIPTION\r\n" 106" \r\n" 107"NOTES:\r\n" 108" 1. The FOR command executes one or more commands for each item in a set of\r\n" 109" items. The set may be text strings or filenames or a mixture of both,\r\n" 110" separated by spaces (if not in a quotation).\r\n" 111" 2. If the length of an element in the set is between 0 and 256, and if the\r\n" 112" string contains wildcards, the string will be treated as a file name\r\n" 113" containing wildcards, and be expanded before command is executed.\r\n" 114" 3. If after expansion no such files are found, the literal string itself is\r\n" 115" kept. %indexvar is any alphabet character from 'a' to 'z' or 'A' to 'Z',\r\n" 116" and they are case sensitive. It should not be a digit (0-9) because\r\n" 117" %digit will be interpreted as a positional argument on the command line\r\n" 118" that launches the script. The namespace for index variables is separate\r\n" 119" from that for environment variables, so if %indexvar has the same name as\r\n" 120" an existing environment variable, the environment variable will remain\r\n" 121" unchanged by the FOR loop.\r\n" 122" 4. Each command is executed once for each item in the set, with any\r\n" 123" occurrence of %indexvar in the command replacing with the current item.\r\n" 124" In the second format of FOR ... ENDFOR statement, %indexvar will be\r\n" 125" assigned a value from start to end with an interval of step. Start and\r\n" 126" end can be any integer whose length is less than 7 digits excluding sign,\r\n" 127" and it can also applied to step with one exception of zero. Step is\r\n" 128" optional, if step is not specified it will be automatically determined by\r\n" 129" following rule:\r\n" 130" if start <= end then step = 1, otherwise step = -1.\r\n" 131" start, end and step are divided by space.\r\n" 132".SH EXAMPLES\r\n" 133" \r\n" 134"EXAMPLES:\r\n" 135" * Sample FOR loop - listing all .txt files:\r\n" 136" echo -off\r\n" 137" for %a in *.txt\r\n" 138" echo %a exists\r\n" 139" endfor\r\n" 140" \r\n" 141" # \r\n" 142" # If in current directory, there are 2 files named file1.txt and file2.txt\r\n" 143" # then the output of the sample script will be as shown below.\r\n" 144" # \r\n" 145" Sample1> echo -off\r\n" 146" file1.txt exists\r\n" 147" file2.txt exists\r\n" 148" \r\n" 149" * Theoretically it is legal for 2 nested FOR commands to use the same\r\n" 150" alphabet letter as their index variable, for instance, a: \r\n" 151" #\r\n" 152" # Sample FOR loop from 1 to 3 with step 1\r\n" 153" #\r\n" 154" echo -off\r\n" 155" for %a run (1 3)\r\n" 156" echo %a\r\n" 157" endfor\r\n" 158" \r\n" 159" #\r\n" 160" # Sample FOR loop from 3 down to 1 with step -1\r\n" 161" #\r\n" 162" echo -off\r\n" 163" for %a run (3 1 -1)\r\n" 164" echo %a\r\n" 165" endfor\r\n" 166" \r\n" 167" #\r\n" 168" # Sample FOR loop - 2 nested for using same index variable\r\n" 169" #\r\n" 170" echo -off\r\n" 171" for %a in value1 value2\r\n" 172" for %a in value3 value4\r\n" 173" echo %a\r\n" 174" endfor\r\n" 175" endfor\r\n" 176" \r\n" 177" Note: When processing first FOR and before seeing the ENDFOR, the index\r\n" 178" variable %a has the value "value1", so in second FOR, the %a has\r\n" 179" been already defined and it will be replaced with the current value\r\n" 180" of %a. The string after substitution becomes FOR value1 in value3\r\n" 181" value4, which is not a legal FOR command. Thus only when the value\r\n" 182" of %a is also a single alphabet letter, the script will be executed\r\n" 183" without error. If 2 independent FOR commands use the same index\r\n" 184" variable, when the second FOR is encountered, the first FOR has\r\n" 185" already freed the variable so there will be no problem in this case.\r\n" 186 187#string STR_GET_HELP_ENDFOR #language en-US "" 188".TH endfor 0 "ends a for loop"\r\n" 189".SH NAME\r\n" 190"Ends a 'for' loop.\r\n" 191".SH SYNOPSIS\r\n" 192"See 'for' for usage.\r\n" 193".SH EXAMPLES\r\n" 194"See 'for' for examples.\r\n" 195 196#string STR_GET_HELP_GOTO #language en-US "" 197".TH goto 0 "moves to a label"\r\n" 198".SH NAME\r\n" 199"Moves around the point of execution in a script.\r\n" 200".SH SYNOPSIS\r\n" 201" \r\n" 202"GOTO label\r\n" 203".SH OPTIONS\r\n" 204" \r\n" 205" label - Specifies a location in batch file\r\n" 206".SH DESCRIPTION\r\n" 207" \r\n" 208"NOTES:\r\n" 209" 1. The GOTO command directs script file execution to the line in the script\r\n" 210" file after the given label. The command is not supported from the\r\n" 211" interactive shell.\r\n" 212" 2. A label is a line beginning with a colon (:). It can appear either after\r\n" 213" the GOTO command, or before the GOTO command. The search for label is\r\n" 214" done forward in the script file, from the current file position. If the\r\n" 215" end of the file is reached, the search resumes at the top of the file and\r\n" 216" continues until label is found or the starting point is reached. If label\r\n" 217" is not found, the script process terminates and an error message is\r\n" 218" displayed. If a label is encountered but there is no GOTO command\r\n" 219" executed, the label lines are ignored.\r\n" 220" 3. Using GOTO command to jump into another for loop is not allowed,\r\n" 221" but jumping into an if statement is legal.\r\n" 222".SH EXAMPLES\r\n" 223" \r\n" 224"EXAMPLES:\r\n" 225" * This is a script:\r\n" 226" goto Done\r\n" 227" ...\r\n" 228" :Done\r\n" 229" cleanup.nsh\r\n" 230 231#string STR_GET_HELP_ENDIF #language en-US "" 232".TH endif 0 "ends an if block"\r\n" 233".SH NAME\r\n" 234"Ends the block of a script controlled by an 'if' statement.\r\n" 235".SH SYNOPSIS\r\n" 236"See 'if' for usage.\r\n" 237".SH EXAMPLES\r\n" 238"See 'if' for examples.\r\n" 239 240#string STR_GET_HELP_IF #language en-US "" 241".TH if 0 "controls the execution of a block of a script"\r\n" 242".SH NAME\r\n" 243"Executes commands in specified conditions.\r\n" 244".SH SYNOPSIS\r\n" 245" \r\n" 246"IF [NOT] EXIST filename THEN\r\n" 247" command [arguments]\r\n" 248" [command [arguments]]\r\n" 249" ...\r\n" 250"[ELSE\r\n" 251" command [arguments]\r\n" 252" [command [arguments]]\r\n" 253" ...\r\n" 254" ]\r\n" 255"ENDIF\r\n" 256" \r\n" 257"IF [/i] [NOT] string1 == string2 THEN\r\n" 258" command [arguments]\r\n" 259" [command [arguments]]\r\n" 260" ...\r\n" 261"[ELSE\r\n" 262" command [arguments]\r\n" 263" [command [arguments]]\r\n" 264" ...\r\n" 265" ]\r\n" 266"ENDIF\r\n" 267"if [/i][/s] ConditionalExpression THEN\r\n" 268" command [arguments]\r\n" 269" [command [arguments]]\r\n" 270" ...\r\n" 271"[ELSE\r\n" 272" command [arguments]\r\n" 273" [command [arguments]]\r\n" 274" ...\r\n" 275" ]\r\n" 276"ENDIF\r\n" 277".SH DESCRIPTION\r\n" 278" \r\n" 279"NOTES:\r\n" 280" 1. The IF command executes one or more commands before the ELSE or ENDIF\r\n" 281" commands, if the specified condition is TRUE; otherwise commands between\r\n" 282" ELSE (if present) and ENDIF are executed.\r\n" 283" 2. In the first usage of IF, the EXIST condition is true when the file\r\n" 284" specified by filename exists. The filename argument may include device\r\n" 285" and path information. Also wildcard expansion is supported by this form.\r\n" 286" If more than one file matches the wildcard pattern, the condition\r\n" 287" evaluates to TRUE.\r\n" 288" 3. In the second usage, the string1 == string2 condition is TRUE if the two\r\n" 289" strings are identical. Here the comparison can be case sensitive or\r\n" 290" insensitive, it depends on the optional switch /i. If /i is specified,\r\n" 291" it will compare strings in the case insensitive manner; otherwise, it\r\n" 292" compares strings in the case sensitive manner.\r\n" 293" 4. In the third usage, general purpose comparison is supported using\r\n" 294" expressions optionally separated by AND or OR. Since < and > are used for\r\n" 295" redirection, the expressions use common two character (FORTRAN)\r\n" 296" abbreviations for the operators (augmented with unsigned equivalents):\r\n" 297" - Expressions : Conditional expressions are evaluated strictly from left\r\n" 298" to right. Complex conditionals requiring precedence may\r\n" 299" be implemented as nested IFs.\r\n" 300" The expressions used in the third usage can have the\r\n" 301" following syntax:\r\n" 302" conditional-expression := expression |\r\n" 303" expression and expression |\r\n" 304" expression or expression\r\n" 305" expression := expr | not expr\r\n" 306" expr := item binop item | boolfunc(string)\r\n" 307" item := mapfunc(string) | string\r\n" 308" mapfunc := efierror | pierror | oemerror\r\n" 309" boolfunc := isint | exists | available | profile\r\n" 310" binop := gt | lt | eq | ne | ge | le | == | ugt | ult |\r\n" 311" uge | ule\r\n" 312" - Comparisons : By default, comparisons are done numerically if the\r\n" 313" strings on both sides of the operator are numbers\r\n" 314" (as defined below) and in case sensitive character sort\r\n" 315" order otherwise. Spaces separate the operators from\r\n" 316" operands.\r\n" 317" 5. The /s option forces string comparisons and the /i option forces\r\n" 318" case-insensitive string comparisons. If either of these is used, the\r\n" 319" signed or unsigned versions of the operators have the same results.\r\n" 320" The /s and /i apply to the entire line and must appear at the start of\r\n" 321" the line (just after the if itself). The two may appear in either order.\r\n" 322" 6. When performing comparisons, the Unicode Byte Ordering Character is\r\n" 323" ignored at the beginning of any argument.\r\n" 324" 7. Comparison Operator Definition:\r\n" 325" gt : Greater than\r\n" 326" ugt : Unsigned Greater than\r\n" 327" lt : Less than\r\n" 328" ult : Unsigned Less than\r\n" 329" ge : Greater than or equal\r\n" 330" uge : Unsigned greater than or equal\r\n" 331" le : Less than or equal\r\n" 332" ule : Unsigned less than or equal\r\n" 333" ne : Not equal\r\n" 334" eq : Equals (semantically equivalent to ==)\r\n" 335" == : Equals (semantically equivalent to eq)\r\n" 336" 8. Error Mapping Functions are used to convert integers into UEFI, PI or OEM\r\n" 337" error codes.\r\n" 338" Functions used to convert integers into UEFI, PI or OEM error codes:\r\n" 339" UefiError : Sets top nibble of parameter to 1000 binary (0x8)\r\n" 340" PiError : Sets top nibble of parameter to 1010 binary (0xA)\r\n" 341" OemError : Sets top nibble of parameter to 1100 binary (0xC)\r\n" 342" Each function maps the small positive parameter into its equivalent error\r\n" 343" classification.\r\n" 344" For example:\r\n" 345" if %lasterror% == EfiError(8) then # Check for write protect.\r\n" 346" ...\r\n" 347" 9. Boolean Functions may only be used to modify operators in comparisons.\r\n" 348" The following built-in Boolean functions are also available:\r\n" 349" IsInt : Evaluates to true if the parameter string that follows\r\n" 350" is a number (as defined below) and false otherwise.\r\n" 351" Exists : Evaluates to true if the file specified by string exists\r\n" 352" is in the current working directory or false if not.\r\n" 353" Available : Evaluates to true if the file specified by string is in the\r\n" 354" current working directory or current path.\r\n" 355" Profile : Determines whether the parameter string matches one of the\r\n" 356" profile names in the profiles environment variable.\r\n" 357" 10. No spaces are allowed between function names and the open parenthesis,\r\n" 358" between the open parenthesis and the string or between the string and\r\n" 359" the closed parenthesis. Constant strings containing spaces must be\r\n" 360" quoted.\r\n" 361" 11. To avoid ambiguity and current or future incompatibility, users are\r\n" 362" strongly encouraged to surround constant strings that contain\r\n" 363" parenthesis with quotes in if statements.\r\n" 364" 12. Allowable number formats are decimal numbers and C-style case\r\n" 365" insensitive hexadecimal numbers. Numbers may be preceded by a\r\n" 366" "-" indicating a negative number.\r\n" 367" Examples:\r\n" 368" 13\r\n" 369" 46\r\n" 370" -0x3FFF\r\n" 371" 0x3fff\r\n" 372" 0x1234\r\n" 373" 13. Unsigned values must be less than 264. Signed integer values are bounded\r\n" 374" by -/+263.\r\n" 375" 14. Numbers are internally represented in two's compliment form. The\r\n" 376" representation of the number in the string has no bearing on the way\r\n" 377" that number is treated in an numeric expression - type is assigned by\r\n" 378" the operator. So, for example, -1 lt 2 is true but -1 ult 2 is false.\r\n" 379" 15. The IF command is only available in scripts.\r\n" 380" 16. The ELSE command is optional in an IF/ELSE statement.\r\n" 381".SH EXAMPLES\r\n" 382" \r\n" 383"EXAMPLES:\r\n" 384" * Sample script for "if" command usages 1 and 2:\r\n" 385" if exist fs0:\myscript.nsh then\r\n" 386" myscript myarg1 myarg2\r\n" 387" endif\r\n" 388" if %myvar% == runboth then\r\n" 389" myscript1\r\n" 390" myscript2\r\n" 391" else\r\n" 392" echo ^%myvar^% != runboth\r\n" 393" endif\r\n" 394" Note: In this example, if the script file myscript.nsh exists in fs0:\,\r\n" 395" this script will be launched with 2 arguments, myarg1 and myarg2.\r\n" 396" After that, environment variable %myvar% is checked to see if its\r\n" 397" value is runboth, if so, script myscript1 and myscript2 will be\r\n" 398" executed one after the other, otherwise a message %myvar% != runboth\r\n" 399" is printed.\r\n" 400" \r\n" 401" * Sample script for "if" command usage 3:\r\n" 402" :Redo\r\n" 403" echo Enter 0-6 or q to quit\r\n" 404" # assumes "input y" stores a character of user input into variable y\r\n" 405" InputCh MyVar\r\n" 406" if x%MyVar% eq x then\r\n" 407" echo Empty line. Try again\r\n" 408" goto Redo\r\n" 409" endif\r\n" 410" if IsInt(%MyVar%) and %MyVar% le 6 then\r\n" 411" myscript1 %MyVar%\r\n" 412" goto Redo\r\n" 413" endif\r\n" 414" if /i %MyVar% ne q then\r\n" 415" echo Invalid input\r\n" 416" goto Redo\r\n" 417" endif\r\n" 418" Note: In this example, the script requests user input and uses the if\r\n" 419" command for input validation. It checks for empty line first and\r\n" 420" then range checks the input.\r\n" 421 422#string STR_GET_HELP_SHIFT #language en-US "" 423".TH shift 0 "move parameters 1 down"\r\n" 424".SH NAME\r\n" 425"Shifts in-script parameter positions.\r\n" 426".SH SYNOPSIS\r\n" 427" \r\n" 428"SHIFT\r\n" 429".SH DESCRIPTION\r\n" 430" \r\n" 431"NOTES:\r\n" 432" 1. The SHIFT command shifts the contents of a UEFI Shell script's positional\r\n" 433" parameters so that %1 is discarded, %2 is copied to %1, %3 is copied to\r\n" 434" %2, %4 is copied to %3 and so on. This allows UEFI Shell scripts to\r\n" 435" process script parameters from left to right.\r\n" 436" 2. This command does not change the UEFI shell environment variable\r\n" 437" lasterror.\r\n" 438" 3. The SHIFT command is available only in UEFI Shell scripts.\r\n" 439".SH EXAMPLES\r\n" 440" \r\n" 441"EXAMPLES:\r\n" 442" * Following script is a sample of 'shift' command:\r\n" 443" fs0:\> type shift.nsh\r\n" 444" #\r\n" 445" # shift.nsh\r\n" 446" # \r\n" 447" echo %1 %2 %3\r\n" 448" shift\r\n" 449" echo %1 %2\r\n" 450" \r\n" 451" * To execute the script with echo on:\r\n" 452" fs0:\> shift.nsh welcome UEFI world\r\n" 453" shift.nsh> echo welcome UEFI world\r\n" 454" welcome UEFI world\r\n" 455" shift\r\n" 456" echo UEFI world\r\n" 457" UEFI world\r\n" 458" \r\n" 459" * To execute the script with echo off:\r\n" 460" fs0:\> echo -off\r\n" 461" fs0:\> shift.nsh welcome UEFI world\r\n" 462" welcome UEFI world\r\n" 463" UEFI world\r\n" 464 465#string STR_GET_HELP_ELSE #language en-US "" 466".TH else 0 "part of an 'if' conditional statement"\r\n" 467".SH NAME\r\n" 468"Identifies the code executed when 'if' is FALSE.\r\n" 469".SH SYNOPSIS\r\n" 470"See 'else' for usage.\r\n" 471".SH EXAMPLES\r\n" 472"See 'if' for examples.\r\n" 473 474#string STR_GET_HELP_STALL #language en-US "" 475".TH stall 0 "stall the operation"\r\n" 476".SH NAME\r\n" 477"Stalls the operation for a specified number of microseconds.\r\n" 478".SH SYNOPSIS\r\n" 479" \r\n" 480"STALL time\r\n" 481".SH OPTIONS\r\n" 482" \r\n" 483" time - The number of microseconds for the processor to stall.\r\n" 484".SH DESCRIPTION\r\n" 485" \r\n" 486"NOTES:\r\n" 487" 1. This command would be used to establish a timed STALL of operations\r\n" 488" during a script.\r\n" 489" 2. Microseconds is in decimal units.\r\n" 490".SH EXAMPLES\r\n" 491" \r\n" 492"EXAMPLES:\r\n" 493" * To stall the processor for 1000000 microseconds:\r\n" 494" Shell> stall 1000000\r\n" 495".SH RETURNVALUES\r\n" 496" \r\n" 497"RETURN VALUES:\r\n" 498" SHELL_SUCCESS The action was completed as requested.\r\n" 499" SHELL_NOT_FOUND The requested option was not found.\r\n" 500" SHELL_INVALID_PARAMETER One of the passed in parameters was incorrectly\r\n" 501" formatted or its value was out of bounds.\r\n" 502" SHELL_DEVICE_ERROR There was a hardware error associated with this\r\n" 503" request.\r\n" 504 505