Imported Debian patch 3.7-2 debian/3.7-2
authorBdale Garbee <bdale@gag.com>
Wed, 5 Sep 2007 15:38:41 +0000 (16:38 +0100)
committerBdale Garbee <bdale@gag.com>
Tue, 20 May 2008 05:09:40 +0000 (23:09 -0600)
ChangeLog
Make.defaults
choosers/simple.c
choosers/textmenu.c
config.c
debian/changelog
elilo.c
fileops.c
glue_netfs.c
tools/eliloalt.c
util.c

index d2cbe27a8012fc359b483683292aa0b7178fcf0d..1a08d9e8dd35d2fa2cc15d90efc23e3066a90ecf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,77 @@
+2007-07-19 Jason Fleischli <jason.fleischli@hp.com>
+       * Integrated x86_64 support patches from Chandramouli Narayanan
+         <mouli@linux.intel.com> changes summarized in following bullets.
+       * alloc.c -- adds patch contributors credit to copyright
+       * alloc.c -- adds uefi_call_wrapper around BS->function calls
+       * alloc.c -- adds call to Print on VERB_PRT
+       * alternate.c -- adds patch contributors credit around copyright
+       * alternate.c -- adds uefi_call_wrapper around RT->function calls
+       * simple.c -- adds patch contributors credit to copyright
+       * simple.c -- adds uefi_call_wrapper around ip->ReadKeyStroke
+       * textmenu.c -- adds patch contributors credit to copyright
+       * textmenu.c -- adds uefi_call_wrapper around ClearScreen &
+         SetTextAttr
+       * textmenu.c -- adds uefi_call_wrapper around ip->ReadKeyStroke
+       * elilo.c -- adds patch contributors credit to copyright
+       * elilo.c -- fixes version number for ELILO_VERSION macro to current
+       * elilo.c -- adds uefi_call_wrapper around BS->function calls
+       * elilo.c -- adds uefi_call_wrapper around RT->function calls
+       * fileops.c -- adds patch contributors credit to copyright
+       * fileops.c -- adds uefi_call_wrapper around BS->function calls
+       * fileops.c -- adds uefi_call_wrapper around RT->function calls
+       * fileops.c -- adds uefi_call_wrapper around blkio->function calls
+       * localfs.c -- adds patch contributors credit to copyright
+       * localfs.c -- changed EFI_HANDLE *dev declaration to non-pointer type
+       * localfs.c -- adds uefi_call_wrapper around lfs->volume->functions
+       * localfs.c -- adds uefi_call_wrapper around BS->function calls
+       * netfs.c -- adds patch contributors credit to copyright
+       * netfs.c -- adds uefi_call_wrapper around nfs->pxe->function calls
+       * netfs.c -- adds uefi_call_wrapper around BS->function calls
+       * getopt.c -- changed int to char in StrChr() function
+       * Make.defaults -- adds patch contributors credit to copyright
+       * Make.defaults -- adds cflag for efi function wrapper
+       * Makefile -- adds patch contributors credit to copyright
+       * Makefile -- x86_64 subdir and a new rule for .S
+       * util.c -- adds patch contributors credit to copyright
+       * util.c -- adds uefi_call_wrapper to systab->functions
+       * util.c -- adds uefi_call_wrapper to conin->functions
+       * util.c -- adds uefi_call_wrapper to BS->functions
+       * util.c -- doubles ELILO_MEMMAP_SIZE_DEFAULT in get_memmap() function
+       * bootparams.c -- uses ia32 params for x86_64 addition.. hmmmm?
+       * config.c -- adds patch contributors credit to copyright
+       * config.c -- adds define reference for x86_64.conf
+       * config.c -- in config_error() removes use of va_list which maps to
+         the gnu C-lib iface __gnuc_va_list. Replaces the use of _IPrint on
+         the va_list with direct use of IPrint(systab->ConOut, msg);
+         *maintainer note, this probably introduces a bug, in light of this
+         note from the patch submitter --> "On some x86_64 systems with
+         EFI1.10 firmware I tested, early boot messages did not appear on console. 
+         However, I didn't encounter this behavior on x86_64 systems with UEFI2.0 
+         firmware"
+       * elf.h -- adds #def for x86_64
+       * glue_netfs.c -- adds patch contributors credit to copyright
+       * glue_netfs.c -- adds define for x86_64.conf
+       * sysdeps.h -- adds patch contributors credit to copyright
+       * sysdeps.h -- add include reference for new x86_64 subdir
+       * x86_64/ -- new subdir - all based on elilo/ia32 subdir
+       * x86_64/bin_to_h.c -- new file, stream fed binary to hex converter
+       * x86_64/bzimage.c -- new file, binary compressed kernel support
+       * x86_64/gzip.c -- new file, embedded gzip
+       * x86_64/gzip_loader.c -- new file, embedded gzip
+       * x86_64/gzip.h -- new file, embedded gzip
+       * x86_64/inflate.c -- new file, a pkzip method 8 embedded decompressor
+       * x86_64/Makefile -- new file
+       * x86_64/plain_loader.c -- new file, for loading non-compressed kernels
+       * x86_64/private.h -- new file
+       * x86_64/rmswitch.S -- new file, RealMode assembly module
+       * x86_64/sysdeps.h -- new file, system stuff for x86_64, e820 mapping
+         added.
+       * x86_64/sysdeps.c -- new file, system stuff for x86_64
+       * elilo.txt -- documentation update, add Intel to copyright
+       * README.gnu-efi -- documentation update for x86_64
+2006-01-27 Alex Williamson <alex.williamson@hp.com>
+       * Found a couple more places where vmcode isn't zeroed, causing the
+         option to get carried over to labels it shouldn't.
 2006-01-09 Brett Johnson <brett@hp.com>
        * Released 3.6
 2005-12-22 Alex Williamson <alex.williamson@hp.com>
index 0a90776e0e2783c2fd7a3291460594addc86169f..0558a58ea3bc84ac295e1198d20b1dbe7c592083 100644 (file)
@@ -1,6 +1,7 @@
 #
 #  Copyright (C) 2001-2003 Hewlett-Packard Co.
 #      Contributed by Stephane Eranian <eranian@hpl.hp.com>
+#      Contributed by Chandramouli Narayanan<mouli@linux.intel.com>
 #
 # This file is part of ELILO, the LINUX EFI boot loader.
 #
@@ -54,7 +55,7 @@ CONFIG_machspec_netconfig=y
 # They are installed as part of the GNU-EFI package installation
 #
 EFIINC    = /usr/include/efi
-GNUEFILIB   = /usr/lib
+GNUEFILIB  = /usr/lib
 EFILIB    = /usr/lib
 EFICRT0           = /usr/lib
 
@@ -67,7 +68,7 @@ CPPFLAGS   = -DCONFIG_$(ARCH)
 
 OPTIMFLAGS = -O2 
 DEBUGFLAGS = -Wall
-CFLAGS    = $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
+CFLAGS     = $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
 LDFLAGS           = -nostdlib -znocombreloc
 INSTALL           = install
 
@@ -105,6 +106,12 @@ AR         = $(prefix)ar
 RANLIB         = $(prefix)ranlib
 OBJCOPY                = $(prefix)objcopy
 
+# Use Modified binutils that supports x86_64 using UEFI ABI
+ifeq ($(ARCH), x86_64)
+        CFLAGS   += -DEFI_FUNCTION_WRAPPER
+       OBJCOPY   = /usr/bin/objcopy
+endif
+
 ifeq ($(ARCH),ia64)
  GCC_VERSION=$(shell $(CROSS_COMPILE)$(CC) -v 2>&1 | fgrep 'gcc version' | cut -f3 -d' ' | cut -f1 -d'.')
 
index 91ab8a94002742b08a3e9e51b451364ac88e06a8..552508661367fc822fd5c23c6c5b3d031acc9bc3 100644 (file)
@@ -1,6 +1,10 @@
 /* 
  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
  *     Contributed by Stephane Eranian <eranian@hpl.hp.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.
  *
@@ -136,7 +140,8 @@ reprint:
        first_time = 0;
 
        for (;;) {
-               while ((status=ip->ReadKeyStroke(ip, &key)) == EFI_NOT_READY);
+               while ((status = uefi_call_wrapper(ip->ReadKeyStroke, 2, ip, &key))
+                                == EFI_NOT_READY);
                if (EFI_ERROR(status)) {
                        ERR_PRT((L"select_kernel readkey: %r", status));
                        return -1;
index 7fc2ec141db633e0ef2a07cb86d086160c6c9d83..400d4f6489013df9abbcd2d619b73e7376aa2aba 100644 (file)
@@ -1,6 +1,10 @@
 /* 
  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
  *     Contributed by Richard Hirst <rhirst@linuxcare.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.
  *
@@ -45,8 +49,8 @@ static CHAR16 PromptBuf[CMDLINE_MAXLEN];
 #define DEF_ATTR       EFI_TEXT_ATTR(EFI_LIGHTGRAY,EFI_BLACK)
 
 
-#define ClearScreen()  ST->ConOut->ClearScreen(ST->ConOut)
-#define SetTextAttr(a) ST->ConOut->SetAttribute(ST->ConOut, a)
+#define ClearScreen()  uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut)
+#define SetTextAttr(a) uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, a)
 
 static INTN
 tohex(INTN c)
@@ -249,7 +253,8 @@ reprint:
        SetTextAttr(CurrentAttr);
 
        for (;;) {
-               while ((status=ip->ReadKeyStroke(ip, &key)) == EFI_NOT_READY);
+               while ((status = uefi_call_wrapper(ip->ReadKeyStroke, 2, ip, &key)) 
+                       == EFI_NOT_READY);
                if (EFI_ERROR(status)) {
                        SetTextAttr(EFI_TEXT_ATTR(EFI_LIGHTGRAY,EFI_BLACK));
                        ClearScreen();
@@ -295,7 +300,7 @@ reprint:
                        if (i) {
                                msgbuf[i] = 0;
                                paint_msg(msgbuf);
-                               while ((status=ip->ReadKeyStroke(ip, &key)) == EFI_NOT_READY);
+                               while ((status= uefi_call_wrapper(ip->ReadKeyStroke, 2, ip, &key)) == EFI_NOT_READY);
                                goto reprint;
                        }
                }
index e24c0c0198613c2338215e4302ed12428e7c4295..00cd0236bd22a3be2e6ce6c85f761e9e7746cbc4 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1,6 +1,9 @@
 /*
  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
  *     Contributed by Stephane Eranian <eranian@hpl.hp.com>
+ *     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.
  *
@@ -42,6 +45,8 @@
 #define ELILO_ARCH_DEFAULT_CONFIG      L"elilo-ia64.conf"
 #elif defined (CONFIG_ia32)
 #define ELILO_ARCH_DEFAULT_CONFIG      L"elilo-ia32.conf"
+#elif defined (CONFIG_x86_64)
+#define ELILO_ARCH_DEFAULT_CONFIG       L"elilo-x86_64.conf"
 #else
 #error "You need to specfy your default arch config file"
 #endif
@@ -204,14 +209,8 @@ static fops_fd_t config_fd;
 static VOID 
 config_error(CHAR16 *msg,...)
 {
-    va_list ap;
-    extern UINTN _IPrint (UINTN, UINTN, SIMPLE_TEXT_OUTPUT_INTERFACE *, CHAR16 *, CHAR8 *, va_list);
-
     Print(L"near line %d: ",line_num);
-
-    va_start(ap,msg);
-    _IPrint((UINTN)-1, (UINTN)-1, systab->ConOut, msg, NULL, ap);
-    va_end(ap);
+    IPrint(systab->ConOut, msg);
     Print(L"\n");
 }
 
@@ -305,7 +304,7 @@ find_option(config_option_group_t *grp, CHAR16 *str)
  *     - TOK_ERR: in case of (parsing) error
  */
 static token_t
-get_token(CHAR16 *str, UINTN maxlen)
+get_token_core(CHAR16 *str, UINTN maxlen, BOOLEAN rhs)
 {
     INTN ch, escaped;
     CHAR16 *here;
@@ -321,7 +320,7 @@ get_token(CHAR16 *str, UINTN maxlen)
        while ((ch = next()), ch != '\n') if (ch == CHAR_EOF) return TOK_EOF;
        line_num++;
     }
-    if (ch == '=') return TOK_EQUAL;
+    if (ch == '=' && !rhs) return TOK_EQUAL;
 
     if (ch == '"') {
        here = str;
@@ -374,7 +373,7 @@ get_token(CHAR16 *str, UINTN maxlen)
        }
        else {
            if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '#' ||
-             ch == '=' || ch == CHAR_EOF) {
+             ch == CHAR_EOF || (ch == '=' && !rhs)) {
                again(ch);
                *here = 0;
                return TOK_STR;
@@ -387,6 +386,18 @@ get_token(CHAR16 *str, UINTN maxlen)
     return TOK_ERR;
 }
 
+static token_t
+get_token(CHAR16 *str, UINTN maxlen)
+{
+    return get_token_core(str, maxlen, FALSE);
+}
+
+static token_t
+get_token_rhs(CHAR16 *str, UINTN maxlen)
+{
+    return get_token_core(str, maxlen, TRUE);
+}
+
 static INTN
 image_check(boot_image_t *img)
 {
@@ -680,7 +691,7 @@ do_string_core(config_option_t *p, CHAR16 *str, UINTN maxlen, CHAR16 *msg)
        /*
         * now get the value
         */
-       tok = get_token(str, maxlen);
+       tok = get_token_rhs(str, maxlen);
        if (tok != TOK_STR) {
                config_error(L"Option %s expects %s", p->name, msg);
                return -1;
@@ -936,6 +947,37 @@ find_description(CHAR16 *label)
        return NULL;
 }
 
+static void
+add_root_to_options(CHAR16 *options, CHAR16 *root, CHAR16 *vmcode)
+{
+       CHAR16 *o, ko[CMDLINE_MAXLEN];
+
+       if (vmcode[0]) {
+               for (o = options; *o; o++) {
+                       if (*o == '-' && *(o+1) == '-')
+                               break;
+               }
+               if (! *o) {
+                       /* no separator found, add one */
+                       StrCpy(o, L" -- ");
+                       o++;
+               }
+
+               /* advance past separator and whitespace */
+               o += 2;
+               while (*o == ' ') o++;
+       } else {
+               o = options;
+       }
+
+       /* insert root param at this point */
+       StrCpy(ko, o);
+       StrCpy(o, L"root=");
+       StrCat(o, root);
+       StrCat(o, L" ");
+       StrCat(o, ko);
+}
+
 INTN
 find_label(CHAR16 *label, CHAR16 *kname, CHAR16 *options, CHAR16 *initrd, CHAR16 *vmcode)
 {
@@ -958,15 +1000,12 @@ find_label(CHAR16 *label, CHAR16 *kname, CHAR16 *options, CHAR16 *initrd, CHAR16
        /*
         * when the label does not exist, we still propagate the global options
         */
-       if (global_config.root[0]) {
-               StrCpy(options, L" root=");
-               StrCat(options, global_config.root);
-       }
-
        if (global_config.options[0]) {
                StrCat(options, L" ");
                StrCat(options, global_config.options);
        }
+       if (global_config.root[0])
+               add_root_to_options(options, global_config.root, global_config.vmcode);
        if (global_config.readonly) StrCat(options, L" ro");
 
        if (global_config.initrd[0]) StrCpy(initrd, global_config.initrd);
@@ -979,21 +1018,33 @@ find_label(CHAR16 *label, CHAR16 *kname, CHAR16 *options, CHAR16 *initrd, CHAR16
 found:
        StrCpy(kname, img->kname);
 
+       /* per image initrd has precedence over global initrd */
+       if (img->initrd[0]) 
+               StrCpy(initrd, img->initrd);
+       else
+               StrCpy(initrd, global_config.initrd);
+
+       /* per image vmcode has precedence over global vmcode */
+       if (img->vmcode[0]) 
+               StrCpy(vmcode, img->vmcode);
+       else
+               StrCpy(vmcode, global_config.vmcode);
+
        /*
         * literal option overrides any other image-based or global option
         *
         * In any case, the image option has priority over the global option
         */
        if (img->literal == 0) {
-               if (img->root[0] || global_config.root[0]) {
-                       StrCat(options, L"root=");
-                       StrCat(options, img->root[0] ? img->root : global_config.root);
-               }
                /* XXX: check max length */
                if (img->options[0] || global_config.options[0]) {
                        StrCat(options, L" ");
                        StrCat(options, img->options[0] ? img->options: global_config.options);
                }
+               if (img->root[0] || global_config.root[0]) {
+                       add_root_to_options(options, img->root[0] 
+                                           ? img->root : global_config.root, vmcode);
+               }
                if (img->readonly || global_config.readonly) {
                        StrCat(options, L" ro");
                }
@@ -1002,17 +1053,6 @@ found:
                StrCpy(options, img->options);
        }
 
-       /* per image initrd has precedence over global initrd */
-       if (img->initrd[0]) 
-               StrCpy(initrd, img->initrd);
-       else if (global_config.initrd[0])
-               StrCpy(initrd, global_config.initrd);
-
-       if (img->vmcode[0]) 
-               StrCpy(vmcode, img->vmcode);
-       else if (global_config.vmcode[0])
-               StrCpy(vmcode, global_config.vmcode);
-
        /*
         * point to architecture dependent options for this image
         */
index a4fb2743d6ae49a6735508fc1c07f2e5a7c60338..c3243186af94786201214f7ed422fda610a67b0c 100644 (file)
@@ -1,3 +1,11 @@
+elilo (3.7-2) unstable; urgency=low
+
+  * fix ugly merge problem I caused while preparing 3.7-1 
+  * apply patches from Aron Griffis accepted by upstream but not in a released
+    tarball yet
+
+ -- Bdale Garbee <bdale@gag.com>  Wed, 05 Sep 2007 16:38:41 +0100
+
 elilo (3.7-1) unstable; urgency=low
 
   * new upstream version
diff --git a/elilo.c b/elilo.c
index 6bdd6bd28a86d781f6451b69f906ac962348b4e0..2773f3f469193b195052e5c18d1a42be15bef751 100644 (file)
--- a/elilo.c
+++ b/elilo.c
@@ -1,5 +1,5 @@
 /* 
- * elilo.c - IA-64/IA-32 EFI Linux loader
+ * elilo.c - IA-64/IA-32/x86_64 EFI Linux loader
  *
  *  Copyright (C) 1999-2003 Hewlett-Packard Co.
  *     Contributed by David Mosberger <davidm@hpl.hp.com>.
@@ -8,6 +8,11 @@
  *  Copyright (C) 1999-2000 VA Linux Systems
  *       Contributed by Johannes Erdfelt <jerdfelt@valinux.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
@@ -41,7 +46,7 @@
 #include "loader.h"
 #include "config.h" /* for config_init() */
 
-#define ELILO_VERSION                  L"3.4"
+#define ELILO_VERSION                  L"3.7"
 #define ELILO_SHARED_CMDLINE_OPTS      L"pPMC:aDhd:i:vVc:E"
 
 elilo_config_t elilo_opt;
@@ -244,7 +249,7 @@ do_launch:
        if ((bp=create_boot_params(cmdline, &imem, &mmem, &cookie)) == 0) goto error;
 
        /* terminate bootservices */
-       status = BS->ExitBootServices(image, cookie);
+       status = uefi_call_wrapper(BS->ExitBootServices, 2, image, cookie);
        if (EFI_ERROR(status)) goto bad_exit;
 
        start_kernel(kd.kentry, bp);
@@ -307,7 +312,7 @@ fixupargs(EFI_LOADED_IMAGE *info)
 
 #define FAKE_ELILONAME L"elilo-forced"
 
-       status = BS->HandleProtocol (info->DeviceHandle, &PxeBaseCodeProtocol, (VOID **)&pxe);
+       status = uefi_call_wrapper(BS->HandleProtocol, 3, info->DeviceHandle, &PxeBaseCodeProtocol, (VOID **)&pxe);
        if (EFI_ERROR(status)) return;
 
        default_load_options      = info->LoadOptions;
@@ -365,7 +370,7 @@ check_edd30(VOID)
        UINT8           bool = FALSE;
        INTN            ret = -1;
 
-       status = RT->GetVariable(L"EDD30", &edd30_guid, NULL, &l, &bool);
+       status = uefi_call_wrapper(RT->GetVariable, 5, L"EDD30", &edd30_guid, NULL, &l, &bool);
        if (status == EFI_BUFFER_TOO_SMALL || (bool != TRUE && bool != FALSE)) {
                ERR_PRT((L"Warning: EDD30 EFI variable is not boolean value: forcing it to TRUE"));
                return -1;
@@ -395,7 +400,7 @@ force_edd30(VOID)
        UINT8           bool;
 
        bool = TRUE;
-       status = RT->SetVariable(L"EDD30", &edd30_guid, EDD30_ATTR, l, &bool);
+       status = uefi_call_wrapper(RT->SetVariable, 5, L"EDD30", &edd30_guid, EDD30_ATTR, l, &bool);
        if (EFI_ERROR(status)) {
                ERR_PRT((L"can't set EDD30 variable: ignoring it"));
                return -1;
@@ -439,19 +444,18 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *system_tab)
         * mode.
         * XXX: clean this up !
         */
-       BS->SetWatchdogTimer(0, 0x0, 0, NULL);
+       uefi_call_wrapper(BS->SetWatchdogTimer, 4, 0, 0x0, 0, NULL);
 
        /* initialize memory allocator */
        if (alloc_init() == -1) return EFI_LOAD_ERROR;
 
-       status = BS->HandleProtocol(image, &LoadedImageProtocol, (VOID **) &info);
+       status = uefi_call_wrapper(BS->HandleProtocol, 3, image, &LoadedImageProtocol, (VOID **) &info);
        if (EFI_ERROR(status)) {
                ERR_PRT((L"image handle does not support LOADED_IMAGE protocol"));
                return EFI_LOAD_ERROR;
        }
 
        VERB_PRT(5,Print(L"Loaded at 0x%lx size=%d bytes code=%d data=%d\n", info->ImageBase, info->ImageSize, info->ImageCodeType, info->ImageDataType));
-
        /*
         * verify EDD3.0 status. Users may have to reboot 
         */
index 85f348527a5591d9772b819da961b7e7e37baa9d..1a43479f97fcdbbff8a7584c34804d3b62982574 100644 (file)
--- a/fileops.c
+++ b/fileops.c
@@ -1,6 +1,9 @@
 /*
  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
  *     Contributed by Stephane Eranian <eranian@hpl.hp.com>
+ *     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.
  *
@@ -135,7 +138,7 @@ glue_filesystem(EFI_GUID *proto, EFI_HANDLE dev, fops_fs_glue_t glue)
        VOID *intf = NULL;
        EFI_STATUS status;
 
-       status = BS->HandleProtocol(dev, proto, &intf);
+       status = uefi_call_wrapper(BS->HandleProtocol, 3, dev, proto, &intf);
        if (EFI_ERROR(status)) {
                ERR_PRT((L"unable to locate %g: should not happen", proto));
                return NULL; /* should not happen */
@@ -358,6 +361,8 @@ fops_setdefaults(struct config_file *defconf, CHAR16 *kname, UINTN maxlen, CHAR1
 #define FILEOPS_ARCH_DEFAULT_CONFIG    L"elilo-ia64.conf"
 #elif defined (CONFIG_ia32)
 #define FILEOPS_ARCH_DEFAULT_CONFIG    L"elilo-ia32.conf"
+#elif defined (CONFIG_x86_64)
+#define FILEOPS_ARCH_DEFAULT_CONFIG    L"elilo-x86_64.conf"
 #else
 #error "You need to specfy your default arch config file"
 #endif
@@ -455,7 +460,7 @@ add_dev_tab(EFI_GUID *proto, EFI_HANDLE boot_handle, UINTN size, fops_fs_glue_t
        /*
         * get the actual device handles now
         */
-       status = BS->LocateHandle(ByProtocol, proto, NULL, &size, tab);
+       status = uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, proto, NULL, &size, tab);
        if (status != EFI_SUCCESS) {
                ERR_PRT((L"failed to get handles for proto %g size=%d: %r", proto, size, status));
                free(tab);
@@ -536,7 +541,7 @@ find_filesystems(EFI_HANDLE boot_handle)
         */
        for(fs = fs_tab; *fs; fs++) {
                size = 0;
-               BS->LocateHandle(ByProtocol, &(*fs)->proto, NULL, &size, NULL);
+               uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, &(*fs)->proto, NULL, &size, NULL);
                total += size;
        }
        if (total == 0) {
@@ -560,7 +565,7 @@ find_filesystems(EFI_HANDLE boot_handle)
        for(fs = fs_tab; *fs; fs++) {
                size = 0;
 
-               BS->LocateHandle(ByProtocol, &(*fs)->proto, NULL, &size, NULL);
+               uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, &(*fs)->proto, NULL, &size, NULL);
                if (size == 0) continue;
 
                add_dev_tab(&(*fs)->proto, boot_handle, size, (*fs)->glue);
index 5de36298256574621cb70f45bb58b360c8ac74fa..51a38cec02ca5ce353d40f092fa480159fd80e99 100644 (file)
@@ -1,6 +1,10 @@
 /*
  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
  *     Contributed by Stephane Eranian <eranian@hpl.hp.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.
  *
@@ -167,6 +171,8 @@ netfs_setdefaults(VOID *intf, config_file_t *config, CHAR16 *kname, UINTN maxlen
 #    define CONFIG_ARCH_EXTENSION L"-ia64.conf\0"
 #  elif defined (CONFIG_ia32)
 #    define CONFIG_ARCH_EXTENSION L"-ia64.conf\0"
+#  elif defined (CONFIG_x86_64)
+#    define CONFIG_ARCH_EXTENSION L"-x86_64.conf\0"
 #  else
 #    error "You need to specfy your default arch config file"
 #  endif            
index e370e0abe0469963f51ee4ba53520fec58911773..1c9709a11f950f55b491778723bbbb3ba0158e3c 100644 (file)
@@ -32,7 +32,6 @@
  * be run by root.
  */
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -48,9 +47,8 @@
 #define ELILOALT_VERSION       "0.02"
 
 #define ELILO_ALT_NAME "EliloAlt"
-#define OLDEFIVAR_DIR  "/proc/efi/vars"
-#define NEWEFIVAR_DIR  "/sys/firmware/efi/vars"
-#define ELILO_ALTVAR   ELILO_ALT_NAME"-00000000-0000-0000-0000-000000000000"
+#define EFIVAR_DIR     "/proc/efi/vars"
+#define ELILO_ALTVAR   EFIVAR_DIR"/"ELILO_ALT_NAME"-00000000-0000-0000-0000-000000000000"
 
 #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
@@ -83,11 +81,6 @@ typedef struct _efi_variable_t {
 } __attribute__((packed)) efi_variable_t;
 
 static char *elilo_alt_name = ELILO_ALT_NAME;
-static char *efi_vars_dir = NULL;
-static char *elilo_altvar = NULL;
-static char *elilo_newvar = NULL;
-static char *elilo_delvar = NULL;
-unsigned char efivars_version = -1; 
 
 static struct option cmd_options[]={
        { "version", 0, 0, 1},
@@ -136,9 +129,9 @@ check_proc_efi(int find_entry)
        if (getuid() != 0) {
                fatal_error("This program must be run as root\n");
        }
-       efi_vars = opendir(efi_vars_dir);
+       efi_vars = opendir(EFIVAR_DIR);
        if (efi_vars == NULL) {
-               fatal_error("Cannot access %s\n", efi_vars_dir);
+               fatal_error("Cannot access %s\n", EFIVAR_DIR);
        }
        if (!find_entry) {
                closedir(efi_vars);
@@ -150,9 +143,9 @@ check_proc_efi(int find_entry)
                        break;
        }
        if (entry == NULL) {
-               fatal_error("Cannot find entry in %s\n", efi_vars_dir);
+               fatal_error("Cannot find entry in %s\n", EFIVAR_DIR);
        }
-       sprintf(name, "%s/%s", efi_vars_dir, entry->d_name);
+       sprintf(name, "%s/%s", EFIVAR_DIR, entry->d_name);
        closedir(efi_vars);
        return name;
 }
@@ -164,17 +157,10 @@ delete_var(void)
        int fd, r, i;
 
        check_proc_efi(0);
-       
-       if (efivars_version == 1) {
-               fd = open(elilo_altvar, O_WRONLY);
-               if (fd == -1) {
-                       fatal_error("variable not defined\n");
-               }
-        } else {
-               fd = open(elilo_delvar, O_WRONLY);
-               if (fd == -1) {
-                       fatal_error("can't open %s\n", elilo_delvar);
-               }
+
+       fd = open(ELILO_ALTVAR, O_WRONLY);
+       if (fd == -1) {
+               fatal_error("variable not defined\n");
        }
 
        memset(&var, 0, sizeof(var));
@@ -190,7 +176,7 @@ delete_var(void)
        
        r = write(fd, &var, sizeof(var));
        if (r != sizeof(var)) {
-               fatal_error("Variable %s defined but invalid content\n", elilo_altvar);
+               fatal_error("Variable %s defined but invalid content\n", ELILO_ALTVAR);
        }
        close(fd);
 }
@@ -205,7 +191,7 @@ print_var(void)
 
        check_proc_efi(0);
 
-       fd = open(elilo_altvar, O_RDONLY);
+       fd = open(ELILO_ALTVAR, O_RDONLY);
        if (fd == -1) {
                fatal_error("variable not defined\n");
        }
@@ -214,7 +200,7 @@ print_var(void)
 
        r = read(fd, &var, sizeof(var));
        if (r != sizeof(var)) {
-               fatal_error("Variable %s defined but invalid content\n", elilo_altvar);
+               fatal_error("Variable %s defined but invalid content\n", ELILO_ALTVAR);
        }
        printf("EliloAlt=\"");
        for(i=0; i < var.datasize; i+=1){
@@ -243,19 +229,11 @@ set_var(char *cmdline)
                fatal_error("Variable content is too long, must be <= 512 characters\n");
        }
 
-       if (efivars_version == 1) {
-               fd = open(name, O_WRONLY);
-               if (fd == -1) {
-                       fatal_error("can't open %s: %s\n", name,
-                                   strerror(errno));
-                }
-        } else {
-               fd = open(elilo_newvar, O_WRONLY);
-               if (fd == -1) {
-                       fatal_error("can't open %s: %s\n", elilo_newvar,
-                                   strerror(errno));
-                }
+       fd = open(name, O_WRONLY);
+       if (fd == -1) {
+               fatal_error("can't open %s: %s\n", ELILO_ALTVAR, strerror(errno));
        }
+
        memset(&var, 0, sizeof(var));
 
        for (i=0; i < sizeof(elilo_alt_name); i++) {
@@ -278,7 +256,7 @@ set_var(char *cmdline)
        
        r = write(fd, &var, sizeof(var));
        if (r != sizeof(var)) {
-               fatal_error("Variable %s defined but invalid content %d\n", elilo_altvar, r);
+               fatal_error("Variable %s defined but invalid content %d\n", ELILO_ALTVAR, r);
        }
        close(fd);
 
@@ -288,26 +266,6 @@ int
 main(int argc, char **argv)
 {
        int c;
-       struct stat statbuf;
-
-       if (stat(OLDEFIVAR_DIR, &statbuf) == 0) {
-               efi_vars_dir = strdup(OLDEFIVAR_DIR);
-               efivars_version = 1;
-        } else if (stat(NEWEFIVAR_DIR, &statbuf) == 0) {
-               efi_vars_dir = strdup(NEWEFIVAR_DIR);
-               elilo_newvar = malloc(strlen(efi_vars_dir) +
-                                     strlen("new_var") + 2);
-               sprintf(elilo_newvar, "%s/%s", efi_vars_dir, "new_var");
-               elilo_delvar = malloc(strlen(efi_vars_dir) +
-                                     strlen("del_var") + 2);
-               sprintf(elilo_delvar, "%s/%s", efi_vars_dir, "del_var");
-               efivars_version = 2;
-       } else {
-               fatal_error("No EFI vars dir found\n\ttried:\n\t%s\n\t%s",
-                           OLDEFIVAR_DIR, NEWEFIVAR_DIR);
-       }
-       elilo_altvar = malloc(strlen(efi_vars_dir)+strlen(ELILO_ALTVAR)+2);
-       sprintf(elilo_altvar, "%s/%s", efi_vars_dir, ELILO_ALTVAR);
 
        while ((c=getopt_long(argc, argv,"hdps:", cmd_options, 0)) != -1) {
                switch(c) {
diff --git a/util.c b/util.c
index 85babf4fa82359140ef0037f99dd1e0555c5a4bc..84e76cc56f9c74d882e411a0115448aa0b9c91c5 100644 (file)
--- a/util.c
+++ b/util.c
@@ -5,6 +5,11 @@
  *  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
 static INTN
 read_keypress(EFI_INPUT_KEY *key)
 {
-       return systab->ConIn->ReadKeyStroke(systab->ConIn, key);
+       return uefi_call_wrapper(systab->ConIn->ReadKeyStroke,
+                               2,
+                               systab->ConIn,
+                               key);
 }
 
 
@@ -55,7 +63,10 @@ check_abort(VOID)
 inline VOID
 reset_input(VOID)
 {
-       systab->ConIn->Reset(systab->ConIn, 1);
+       uefi_call_wrapper(systab->ConIn->Reset,
+                       2,
+                       systab->ConIn,
+                       1);
 }
 
 #if 0
@@ -71,9 +82,9 @@ wait_keypress_abort(VOID)
        Print(L"Hit ENTER to continue or ANY other key to cancel");
 
        /* cleanup buffer first */
-       while (conin->ReadKeyStroke(conin, &key) == EFI_SUCCESS);
+       while (uefi_call_wrapper(conin->ReadKeyStroke, 2, conin, &key) == EFI_SUCCESS);
 
-       while ((status=conin->ReadKeyStroke(conin, &key)) == EFI_NOT_READY );
+       while ((status=uefi_call_wrapper(conin->ReadKeyStroke,2, conin, &key)) == EFI_NOT_READY );
 
        if (EFI_ERROR(status)) return ELILO_LOAD_ERROR;
 
@@ -102,13 +113,13 @@ wait_timeout(UINTN timeout)
        if (timeout == 0) return 0;
 
        /* Create a timeout timer */
-       status = BS->CreateEvent(EVT_TIMER, 0, NULL, NULL, &timer);
+       status = uefi_call_wrapper(BS->CreateEvent, 5, EVT_TIMER, 0, NULL, NULL, &timer);
        if (EFI_ERROR(status)) {
                ERR_PRT((L" waitkey CreateEvent failed %r", status));
                return -1;
        }
        /* In 100ns increments */
-       status = BS->SetTimer(timer, TimerPeriodic, TENTH_SEC);
+       status = uefi_call_wrapper(BS->SetTimer, 3, timer, TimerPeriodic, TENTH_SEC);
        if (EFI_ERROR(status)) {
                ERR_PRT((L"waitkey SetTimer failed %r", status));
                return -1;
@@ -118,7 +129,7 @@ wait_timeout(UINTN timeout)
        list[1] = systab->ConIn->WaitForKey;
 
        do {
-               status = BS->WaitForEvent(2, list, &idx);
+               status = uefi_call_wrapper(BS->WaitForEvent, 3, 2, list, &idx);
                if (EFI_ERROR(status)) {
                        ERR_PRT((L"waitkey WaitForEvent failed %r", status));
                        return -1;
@@ -130,13 +141,13 @@ wait_timeout(UINTN timeout)
         * SetTimer(timer, TimerCancel, 0) is causing problems on IA-32 and gcc3
         * I do not know why it dies with EFI12.35. So let's fake a key stroke.
         */
-       status = BS->SetTimer(timer, TimerCancel, 0);
+       status = uefi_call_wrapper(BS->SetTimer, 3, timer, TimerCancel, 0);
        if (EFI_ERROR(status)) {
                ERR_PRT((L"waitkey SetTimer(TimerCancel) failed %r", status));
                return -1;
        }
 
-       BS->CloseEvent(timer);
+       uefi_call_wrapper(BS->CloseEvent, 1, timer);
 
        return idx ? 1 : 0;
 }
@@ -278,7 +289,7 @@ read_file(UINTN fd, UINTN total_size, CHAR8 *buffer)
 INTN
 get_memmap(mmap_desc_t *desc)
 {
-#define        ELILO_MEMMAP_SIZE_DEFAULT       EFI_PAGE_SIZE
+#define        ELILO_MEMMAP_SIZE_DEFAULT       (EFI_PAGE_SIZE*2)
 #define        ELILO_MEMMAP_INC                (sizeof(EFI_MEMORY_DESCRIPTOR)<<1)
 
        EFI_STATUS status;
@@ -292,7 +303,8 @@ get_memmap(mmap_desc_t *desc)
                        ERR_PRT((L"failed to allocate memory map buffer"));
                        return -1;
                }
-               status = (*BS->GetMemoryMap)(&desc->map_size, desc->md, &desc->cookie, &desc->desc_size, &desc->desc_version);
+               status = uefi_call_wrapper(BS->GetMemoryMap, 5, &desc->map_size, desc->md, 
+                                       &desc->cookie, &desc->desc_size, &desc->desc_version);
                if (status == EFI_SUCCESS) break;
 
                free(desc->md);