Quellcode durchsuchen

Patch GNU-EFI to remove the ELILO code

Signed-off-by: Jerry Hoemann <jerry.hoemann@hp.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hp.com>
Nigel Croxon vor 11 Jahren
Ursprung
Commit
b32a578573

+ 4 - 3
gnu-efi-3.0/apps/AllocPages.c

@@ -89,7 +89,7 @@ BS_Code   0000000071902000-00000000721FEFFF 00000000000008FD 000000000000000F
 
 #include <efi.h>
 #include <efilib.h>
-#include <argify.h>
+#include <ParseCmdLine.h>
 
 
 #define MAX_NUM_PAGES 0x000000000F000000
@@ -115,6 +115,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
 	CHAR16 *argv[MAX_ARGS];
 	INTN argc = 0;
 	INTN err = 0;
+	INTN c = 0;
 
 	INTN AllocType = -1;
 	INTN MemType = -1;
@@ -149,9 +150,9 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
 #endif
 	
 #if DEBUG
-	Print(L"Now try argify\n");
+	Print(L"Now try ParseCmdLine\n");
 #endif
-	argc = argify(arglist, info->LoadOptionsSize, argv);
+	argc = ParseCmdLine(argv, arglist, info->LoadOptionsSize);
 #if DEBUG
 	Print(L"argc = %d\n", argc);
 #endif

+ 4 - 3
gnu-efi-3.0/apps/FreePages.c

@@ -60,7 +60,7 @@ Available 00000000709FC000-00000000710E3FFF 00000000000006E8 000000000000000F
 
 #include <efi.h>
 #include <efilib.h>
-#include <argify.h>
+#include <ParseCmdLine.h>
 
 /*
  * FreePages:  __PhysAddr__ __PgCnt__
@@ -88,6 +88,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
 	CHAR16 arglist[MAX_ARGS+1] = {0};
 	CHAR16 *argv[MAX_ARGS];
 	INTN argc = 0;
+	INTN c = 0;
 	INTN err = 0;
 
 	INTN PgCnt = -1;
@@ -119,9 +120,9 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
 #endif
 	
 #if DEBUG
-	Print(L"Now try argify\n");
+	Print(L"Now try ParseCmdLine\n");
 #endif
-	argc = argify(arglist, info->LoadOptionsSize, argv);
+	argc = ParseCmdLine(argv, arglist, info->LoadOptionsSize);
 #if DEBUG
 	Print(L"argc = %d\n", argc);
 #endif

+ 12 - 0
gnu-efi-3.0/inc/ParseCmdLine.h

@@ -0,0 +1,12 @@
+
+
+/*
+ * Turn an CHAR16 * command line into a CHAR16 * argv, INT argc pair.
+ *
+ */
+
+#define MAX_ARGS 512
+
+
+int ParseCmdLine(CHAR16 **argv[],  CHAR16 *buf, int len);
+

+ 0 - 41
gnu-efi-3.0/inc/argify.h

@@ -1,41 +0,0 @@
-
-
-/*
- *  Copyright (C) 2001-2003 Hewlett-Packard Co.
- *      Contributed by Stephane Eranian <eranian@hpl.hp.com>
- *
- *  Copyright (C) 2001 Silicon Graphics, Inc.
- *      Contributed by Brent Casavant <bcasavan@sgi.com>
- *
- *  Copyright (C) 2006-2009 Intel Corporation
- *      Contributed by Fenghua Yu <fenghua.yu@intel.com>
- *      Contributed by Bibo Mao <bibo.mao@intel.com>
- *      Contributed by Chandramouli Narayanan <mouli@linux.intel.com>
- *
- * This file is part of the ELILO, the EFI Linux boot loader.
- *
- *  ELILO is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *
- *  ELILO is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with ELILO; see the file COPYING.  If not, write to the Free
- *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- *  02111-1307, USA.
- *
- * Please check out the elilo.txt for complete documentation on how
- * to use this program.
- */
-
-
-#define MAX_ARGS 256
-
-INTN
-argify(CHAR16 *buf, UINTN len, CHAR16 **argv);
-

+ 1 - 1
gnu-efi-3.0/lib/Makefile

@@ -43,7 +43,7 @@ include $(SRCDIR)/../Make.defaults
 TOPDIR = $(SRCDIR)/..
 
 CDIR = $(TOPDIR)/..
-FILES = argify boxdraw smbios console crc data debug dpath  \
+FILES = ParseCmdLine boxdraw smbios console crc data debug dpath  \
         error event guid hand hw init lock   \
         misc print sread str \
 	runtime/rtlock runtime/efirtlib runtime/rtstr runtime/vm runtime/rtdata  \

+ 38 - 0
gnu-efi-3.0/lib/ParseCmdLine.c

@@ -0,0 +1,38 @@
+
+/*
+ *  Turn an CHAR16 * command line into a CHAR16 * argv, INT argc pair.
+ *
+ */
+
+
+#include <efi.h>
+#include <efilib.h>
+#include <ParseCmdLine.h>
+
+
+
+int ParseCmdLine(CHAR16 **argv[],  CHAR16 *LoadOptions, int LoadOptionSize)
+{
+    CHAR16 *buf = LoadOptions;
+    int     len = LoadOptionSize;
+    int	    i;	  // Index into buf
+
+    int argc = 0;	// Count of argv entries
+    argv[argc++] = LoadOptions ? LoadOptions: "##NoName##";
+
+    for ( i = 0;  len > 0;   len-= 2, i++)  {
+	if ( buf[i] == L' ' ) {
+	    // end of current argv entry, start next?
+	    buf[i] = NULL;
+	    do {
+	    	len -= 2;
+		i++;
+	    } while( (buf[i] == L' ') && (len > 0) );
+	    argv[argc] =  &buf[i];
+	    if ( len > 0 ) argc++;
+	}
+    }
+    argv[argc] = NULL;
+
+    return argc;
+}

+ 0 - 97
gnu-efi-3.0/lib/argify.c

@@ -1,97 +0,0 @@
-
-/*
- *  Copyright (C) 2001-2003 Hewlett-Packard Co.
- *      Contributed by Stephane Eranian <eranian@hpl.hp.com>
- *
- *  Copyright (C) 2001 Silicon Graphics, Inc.
- *      Contributed by Brent Casavant <bcasavan@sgi.com>
- *
- *  Copyright (C) 2006-2009 Intel Corporation
- *      Contributed by Fenghua Yu <fenghua.yu@intel.com>
- *      Contributed by Bibo Mao <bibo.mao@intel.com>
- *      Contributed by Chandramouli Narayanan <mouli@linux.intel.com>
- *
- * This file is part of the ELILO, the EFI Linux boot loader.
- *
- *  ELILO is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *
- *  ELILO is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with ELILO; see the file COPYING.  If not, write to the Free
- *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- *  02111-1307, USA.
- *
- * Please check out the elilo.txt for complete documentation on how
- * to use this program.
- */
-
-
-#include <efi.h>
-#include <efilib.h>
-#include <argify.h>
-
-
-
-#define	MAX_ARGS 256
-
-#define CHAR_SPACE L' '
-
-#define DEBUG 0
-
-INTN
-argify(CHAR16 *buf, UINTN len, CHAR16 **argv)   
-{
-
-        UINTN     i=0, j=0;
-        CHAR16   *p = buf;
-	
-        if (buf == 0) { 
-		argv[0] = NULL;
-		return 0;
-	}
-	/* len represents the number of bytes, not the number of 16 bytes chars */
-	len = len >> 1;
-
-	/*
-	 * Here we use CHAR_NULL as the terminator rather than the length
-	 * because it seems like the EFI shell return rather bogus values for it.
-	 * Apparently, we are guaranteed to find the '\0' character in the buffer
-	 * where the real input arguments stop, so we use it instead.
-	 */
-	for(;;) {
-		while (buf[i] == CHAR_SPACE && buf[i] != CHAR_NULL && i < len) i++;
-
-		if (buf[i] == CHAR_NULL || i == len) goto end;
-
-		p = buf+i;
-		i++;
-
-		while (buf[i] != CHAR_SPACE && buf[i] != CHAR_NULL && i < len) i++;
-
-		argv[j++] = p;
-
-		if (buf[i] == CHAR_NULL) goto end;
-
-		buf[i]  = CHAR_NULL;
-
-		if (i == len)  goto end;
-
-		i++;
-
-		if (j == MAX_ARGS-1) {
-			Print(L"too many arguments (%d) truncating\n", j);
-			goto end;
-		}
-	}
-end:
-        argv[j] = NULL;
-	return j;
-}
-