summaryrefslogtreecommitdiff
path: root/EmbeddedPkg/Ebl/Script.c
diff options
context:
space:
mode:
authorAJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524>2009-12-06 01:57:05 +0000
committerAJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524>2009-12-06 01:57:05 +0000
commit2ef2b01e07c02db339f34004445734a2dbdd80e1 (patch)
tree19532a6be8d8bdb0aef04bd00c1efb582f6dc841 /EmbeddedPkg/Ebl/Script.c
parentf7753a96ba1653ddd31b01c198a352f6332ac404 (diff)
downloadedk2-platforms-2ef2b01e07c02db339f34004445734a2dbdd80e1.tar.xz
Adding support for BeagleBoard.
ArmPkg - Supoprt for ARM specific things that can change as the architecture changes. Plus semihosting JTAG drivers. EmbeddedPkg - Generic support for an embeddded platform. Including a light weight command line shell. BeagleBoardPkg - Platform specifics for BeagleBoard. SD Card works, but USB has issues. Looks like a bug in the open source USB stack (Our internal stack works fine). git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9518 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmbeddedPkg/Ebl/Script.c')
-rw-r--r--EmbeddedPkg/Ebl/Script.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/EmbeddedPkg/Ebl/Script.c b/EmbeddedPkg/Ebl/Script.c
new file mode 100644
index 0000000000..2229005d1c
--- /dev/null
+++ b/EmbeddedPkg/Ebl/Script.c
@@ -0,0 +1,126 @@
+/** @file
+ Script command allows the execution of commands from a text file
+
+ Copyright (c) 2007, Intel Corporation<BR>
+ Portions copyright (c) 2008-2009, Apple Inc. All rights reserved.
+
+ All rights reserved. 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: EfiDevice.c
+
+**/
+
+#include "Ebl.h"
+
+
+/**
+ Execute the passed in file like a series of commands. The ; can be used on
+ a single line to indicate multiple commands per line. The Ascii text file
+ can contain any number of lines. The following line termination forms are
+ supported:
+ LF : Unix, Mac OS X*, BeOS
+ CR+LF: MS-DOS*, Microsoft Windows*
+ CR : Commodore, Apple II, and realy Mac OS
+ LF+CR: for simplicity and completeness
+
+ Argv[0] - "script"
+ Argv[1] - Device Name:path for the file to load
+
+ script fv1:\script.txt
+
+ @param Argc Number of command arguments in Argv
+ @param Argv Array of strings that represent the parsed command line.
+ Argv[0] is the comamnd name
+
+ @return EFI_SUCCESS
+
+**/
+EFI_STATUS
+EblScriptCmd (
+ IN UINTN Argc,
+ IN CHAR8 **Argv
+ )
+{
+ EFI_STATUS Status;
+ EFI_OPEN_FILE *File;
+ VOID *Address;
+ UINTN Size;
+ CHAR8 *Ptr;
+ CHAR8 *ScanPtr;
+ UINTN CmdLineSize;
+
+
+
+ if (Argc < 2) {
+ // file name required
+ return EFI_SUCCESS;
+ }
+
+ File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);
+ if (File == NULL) {
+ AsciiPrint (" %a is not a valid path\n", Argv[1]);
+ return EFI_SUCCESS;
+ }
+
+ Status = EfiReadAllocatePool (File, &Address, &Size);
+ if (!EFI_ERROR (Status)) {
+ // Loop through each line in the text file
+ for (Ptr = (CHAR8 *)Address; (Ptr < (((CHAR8 *)Address) + Size)) && !EFI_ERROR (Status); Ptr += CmdLineSize) {
+ for (CmdLineSize = 0, ScanPtr = Ptr; ; CmdLineSize++, ScanPtr++) {
+ // look for the end of the line
+ if ((*ScanPtr == EBL_CR) || (*ScanPtr == EBL_LF)) {
+ // convert to NULL as this is what input routine would do
+ *ScanPtr = 0;
+ if ((*(ScanPtr + 1) == EBL_CR) || (*(ScanPtr + 1) == EBL_LF)) {
+ // if its a set get the 2nd EOL char
+ CmdLineSize++;
+ *(ScanPtr + 1) = 0;
+ }
+ CmdLineSize++;
+ break;
+ }
+
+ }
+
+ Status = ProcessCmdLine (Ptr, CmdLineSize);
+ }
+
+ FreePool (Address);
+ }
+
+ EfiClose (File);
+ return Status;
+}
+
+
+
+GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mScriptTemplate[] = {
+ {
+ "script",
+ " device:path; load an ascii file and execute it like commands",
+ NULL,
+ EblScriptCmd
+ }
+};
+
+
+/**
+ Initialize the commands in this in this file
+**/
+
+VOID
+EblInitializeScriptCmd (
+ VOID
+ )
+{
+ if (FeaturePcdGet (PcdEmbeddedScriptCmd)) {
+ EblAddCommands (mScriptTemplate, sizeof (mScriptTemplate)/sizeof (EBL_COMMAND_TABLE));
+ }
+}
+