2 Script command allows the execution of commands from a text file
4 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 Module Name: EfiDevice.c
23 Execute the passed in file like a series of commands. The ; can be used on
24 a single line to indicate multiple commands per line. The Ascii text file
25 can contain any number of lines. The following line termination forms are
27 LF : Unix, Mac OS X*, BeOS
28 CR+LF: MS-DOS*, Microsoft Windows*
29 CR : Commodore, Apple II, and really Mac OS
30 LF+CR: for simplicity and completeness
33 Argv[1] - Device Name:path for the file to load
35 script fv1:\script.txt
37 @param Argc Number of command arguments in Argv
38 @param Argv Array of strings that represent the parsed command line.
39 Argv[0] is the command name
65 File
= EfiOpen (Argv
[1], EFI_FILE_MODE_READ
, 0);
67 AsciiPrint (" %a is not a valid path\n", Argv
[1]);
71 Status
= EfiReadAllocatePool (File
, &Address
, &Size
);
72 if (!EFI_ERROR (Status
)) {
73 // Loop through each line in the text file
74 for (Ptr
= (CHAR8
*)Address
; (Ptr
< (((CHAR8
*)Address
) + Size
)) && !EFI_ERROR (Status
); Ptr
+= CmdLineSize
) {
75 for (CmdLineSize
= 0, ScanPtr
= Ptr
; ; CmdLineSize
++, ScanPtr
++) {
76 // look for the end of the line
77 if ((*ScanPtr
== EBL_CR
) || (*ScanPtr
== EBL_LF
)) {
78 // convert to NULL as this is what input routine would do
80 if ((*(ScanPtr
+ 1) == EBL_CR
) || (*(ScanPtr
+ 1) == EBL_LF
)) {
81 // if its a set get the 2nd EOL char
91 Status
= ProcessCmdLine (Ptr
, CmdLineSize
);
103 GLOBAL_REMOVE_IF_UNREFERENCED
const EBL_COMMAND_TABLE mScriptTemplate
[] = {
106 " device:path; load an ascii file and execute it like commands",
114 Initialize the commands in this in this file
118 EblInitializeScriptCmd (
122 if (FeaturePcdGet (PcdEmbeddedScriptCmd
)) {
123 EblAddCommands (mScriptTemplate
, sizeof (mScriptTemplate
)/sizeof (EBL_COMMAND_TABLE
));