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>
6 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 Module Name: EfiDevice.c
24 Execute the passed in file like a series of commands. The ; can be used on
25 a single line to indicate multiple commands per line. The Ascii text file
26 can contain any number of lines. The following line termination forms are
28 LF : Unix, Mac OS X*, BeOS
29 CR+LF: MS-DOS*, Microsoft Windows*
30 CR : Commodore, Apple II, and really Mac OS
31 LF+CR: for simplicity and completeness
34 Argv[1] - Device Name:path for the file to load
36 script fv1:\script.txt
38 @param Argc Number of command arguments in Argv
39 @param Argv Array of strings that represent the parsed command line.
40 Argv[0] is the command name
67 File
= EfiOpen (Argv
[1], EFI_FILE_MODE_READ
, 0);
69 AsciiPrint (" %a is not a valid path\n", Argv
[1]);
73 Status
= EfiReadAllocatePool (File
, &Address
, &Size
);
74 if (!EFI_ERROR (Status
)) {
75 // Loop through each line in the text file
76 for (Ptr
= (CHAR8
*)Address
; (Ptr
< (((CHAR8
*)Address
) + Size
)) && !EFI_ERROR (Status
); Ptr
+= CmdLineSize
) {
77 for (CmdLineSize
= 0, ScanPtr
= Ptr
; ; CmdLineSize
++, ScanPtr
++) {
78 // look for the end of the line
79 if ((*ScanPtr
== EBL_CR
) || (*ScanPtr
== EBL_LF
)) {
80 // convert to NULL as this is what input routine would do
82 if ((*(ScanPtr
+ 1) == EBL_CR
) || (*(ScanPtr
+ 1) == EBL_LF
)) {
83 // if its a set get the 2nd EOL char
93 Status
= ProcessCmdLine (Ptr
, CmdLineSize
);
105 GLOBAL_REMOVE_IF_UNREFERENCED
const EBL_COMMAND_TABLE mScriptTemplate
[] = {
108 " device:path; load an ascii file and execute it like commands",
116 Initialize the commands in this in this file
120 EblInitializeScriptCmd (
124 if (FeaturePcdGet (PcdEmbeddedScriptCmd
)) {
125 EblAddCommands (mScriptTemplate
, sizeof (mScriptTemplate
)/sizeof (EBL_COMMAND_TABLE
));