Imported Upstream version 3.10 upstream/3.10
authorBdale Garbee <bdale@gag.com>
Fri, 3 Apr 2009 22:13:12 +0000 (16:13 -0600)
committerBdale Garbee <bdale@gag.com>
Fri, 3 Apr 2009 22:13:12 +0000 (16:13 -0600)
67 files changed:
ChangeLog
Make.defaults
alloc.c
alternate.c
bootparams.c
choosers/CVS/Entries [new file with mode: 0644]
choosers/CVS/Repository [new file with mode: 0644]
choosers/CVS/Root [new file with mode: 0644]
choosers/simple.c
choosers/textmenu.c
devschemes/CVS/Entries [new file with mode: 0644]
devschemes/CVS/Repository [new file with mode: 0644]
devschemes/CVS/Root [new file with mode: 0644]
docs/CVS/Entries [new file with mode: 0644]
docs/CVS/Repository [new file with mode: 0644]
docs/CVS/Root [new file with mode: 0644]
elilo.c
elilo.h
examples/CVS/Entries [new file with mode: 0644]
examples/CVS/Repository [new file with mode: 0644]
examples/CVS/Root [new file with mode: 0644]
examples/netboot/CVS/Entries [new file with mode: 0644]
examples/netboot/CVS/Repository [new file with mode: 0644]
examples/netboot/CVS/Root [new file with mode: 0644]
examples/textmenu_chooser/CVS/Entries [new file with mode: 0644]
examples/textmenu_chooser/CVS/Repository [new file with mode: 0644]
examples/textmenu_chooser/CVS/Root [new file with mode: 0644]
fs/CVS/Entries [new file with mode: 0644]
fs/CVS/Repository [new file with mode: 0644]
fs/CVS/Root [new file with mode: 0644]
fs/ext2fs.c
fs/netfs.c
ia32/CVS/Entries [new file with mode: 0644]
ia32/CVS/Repository [new file with mode: 0644]
ia32/CVS/Root [new file with mode: 0644]
ia32/bzimage.c
ia32/gzip.c
ia32/plain_loader.c
ia32/sysdeps.h
ia32/system.c
ia64/CVS/Entries [new file with mode: 0644]
ia64/CVS/Repository [new file with mode: 0644]
ia64/CVS/Root [new file with mode: 0644]
ia64/fpswa.c
ia64/gzip.c
ia64/longjmp.S
ia64/plain_loader.c
ia64/setjmp.S
ia64/sysdeps.h
inflate.c
initrd.c
loader.c
tools/CVS/Entries [new file with mode: 0644]
tools/CVS/Repository [new file with mode: 0644]
tools/CVS/Root [new file with mode: 0644]
util.c
x86_64/CVS/CVS/Entries [new file with mode: 0644]
x86_64/CVS/CVS/Repository [new file with mode: 0644]
x86_64/CVS/CVS/Root [new file with mode: 0644]
x86_64/CVS/Entries [new file with mode: 0644]
x86_64/CVS/Repository [new file with mode: 0644]
x86_64/CVS/Root [new file with mode: 0644]
x86_64/bzimage.c
x86_64/gzip.c
x86_64/plain_loader.c
x86_64/sysdeps.h
x86_64/system.c

index 2dbab82305276e6575fad21c83b52482fe809dfd..998cdc7116c438959b7ce43b522fcc9f40266f8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2008-04-02 signed off by Jason Fleischli <jason.fleischli@hp.com>
+       * elilo 3.10 release commit
+       * Bumped version string to 3.10
+       * added PTR_FMT 32bit & 64bit pointer translation for correct output
+       * elilo hang bugfix x86_64 non-standard kernels with non-traditional start address 
+         elilo will pull the start address from the kernel elf header for 2.6
+         or newer kernels, map memory and use that start address, else use standard
+         1MB default start address. And handle case of overlapping kernels
+         and initrds in memory. Patch contributor Stuart Hayes @ Dell,
+         thanks Stuart!
+       * ported kernel start adress fix to ia32
+       * eliminated all possible compiler warnings except those actually
+         caused by gnu-efi that cant be fixed here.
+       * Debug output improvement, added pauses with visual feedback when
+         user sets debug & verbose options.
+       * bugfix added missing find_bits function definition back into ia32
+         subtree
+       * bugfix loader_probe now correctly errors out if no loaders
+         registered.
+2008-01-11 signed off by Jason Fleischli <jason.fleischli@hp.com>
+       * Various compile warning cleanups.
 2008-01-03 signed off by Jason Fleischli <jason.fleischli@hp.com>
        * Patch contribution from Scott Davilla <davilla@4pi.com>
          when x is zero for the first call to add_memory_region, e820_map[-1] 
index 0558a58ea3bc84ac295e1198d20b1dbe7c592083..061b75c565a9ae57c58d84133acb6c4866c6f3d9 100644 (file)
@@ -68,7 +68,7 @@ CPPFLAGS   = -DCONFIG_$(ARCH)
 
 OPTIMFLAGS = -O2 
 DEBUGFLAGS = -Wall
-CFLAGS     = $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
+CFLAGS     = $(OPTIMFLAGS) -fno-strict-aliasing -fpic -fshort-wchar $(DEBUGFLAGS)
 LDFLAGS           = -nostdlib -znocombreloc
 INSTALL           = install
 
diff --git a/alloc.c b/alloc.c
index 358939ac1d957bdb5b8f6d44d80115bf16ffd086..f0878044c1c7ad7b3fba24b1e1d95d6c1f0daef4 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -105,12 +105,12 @@ alloc(UINTN size, EFI_MEMORY_TYPE type)
 
        status = uefi_call_wrapper(BS->AllocatePool, 3, type, size, &tmp);
        if (EFI_ERROR(status)) {
-               ERR_PRT((L"allocator: AllocatePool(%d, %d, 0x%x) failed (%r)\n", type, size, status));
+               ERR_PRT((L"allocator: AllocatePool(%d, %d) failed (%r)\n", type, size, status));
                return NULL;
        }
        alloc_add(tmp, size, ALLOC_POOL);
 
-        DBG_PRT((L"alloc: allocated %d bytes @[0x%lx-0x%lx]\n", size, tmp, tmp+size));
+        DBG_PRT((L"alloc: allocated %d bytes @[" PTR_FMT "-" PTR_FMT "]\n", size, tmp, tmp+size));
 
        return tmp;
 }
@@ -158,10 +158,10 @@ free(VOID *addr)
                if (p->addr == addr) goto found;
        }
        /* not found */
-        VERB_PRT(1, Print(L"allocator: invalid free @ 0x%lx\n", addr));
+        VERB_PRT(1, Print(L"allocator: invalid free @ " PTR_FMT "\n", addr));
        return; 
 found:
-        DBG_PRT((L"free: %s @0x%lx size=%ld\n", 
+        DBG_PRT((L"free: %s @" PTR_FMT " size=%d\n", 
                p->type == ALLOC_POOL ? L"Pool": L"Page", 
                addr, p->size));
 
@@ -195,7 +195,7 @@ free_all(VOID)
 
        while(used_allocs) {
 
-               DBG_PRT((L"free_all %a @ 0x%lx\n", used_allocs->type == ALLOC_POOL ? "pool" : "pages", used_allocs->addr));
+               DBG_PRT((L"free_all %a @ " PTR_FMT "\n", used_allocs->type == ALLOC_POOL ? "pool" : "pages", used_allocs->addr));
        
                if (used_allocs->type == ALLOC_POOL)
                        uefi_call_wrapper(BS->FreePool, 1, used_allocs->addr);
@@ -212,6 +212,19 @@ free_all(VOID)
        }
 }
 
+INTN
+alloc_kmem_anywhere(VOID **start_addr, UINTN pgcnt)
+{
+       void * tmp;
+       if ((tmp = alloc_pages(pgcnt, EfiLoaderData, AllocateAnyPages, *start_addr)) == 0) return -1;
+
+       kmem_addr  = tmp;
+       kmem_pgcnt = pgcnt;
+       *start_addr = tmp;
+
+       return 0;
+}
+
 INTN
 alloc_kmem(VOID *start_addr, UINTN pgcnt)
 {
@@ -226,13 +239,13 @@ alloc_kmem(VOID *start_addr, UINTN pgcnt)
 VOID
 free_kmem(VOID)
 {
-       DBG_PRT((L"free_kmem before (%lx, %ld)\n", kmem_addr, kmem_pgcnt));
+       DBG_PRT((L"free_kmem before (" PTR_FMT ", %d)\n", kmem_addr, kmem_pgcnt));
        if (kmem_addr && kmem_pgcnt != 0) {
                free(kmem_addr);
                kmem_addr  = NULL;
                kmem_pgcnt = 0;
        }
-       DBG_PRT((L"free_kmem after (%lx, %ld)\n", kmem_addr, kmem_pgcnt));
+       DBG_PRT((L"free_kmem after (" PTR_FMT ", %d)\n", kmem_addr, kmem_pgcnt));
 }
 
 VOID
index 992e9bdc57db5113954b8508fc94b3be6ef71114..691adc74aaa647a0ed429c16eb7259a21e611620 100644 (file)
@@ -56,7 +56,7 @@ static EFI_GUID altk_guid={0,};
  *       Please note that no fatal error is reported by this function
  */
 INTN
-alternate_kernel(CHAR16 *buffer, INTN size)
+alternate_kernel(CHAR16 *buffer, UINTN size)
 {
        EFI_STATUS status;
        INTN ret = -1;
index 1a2c54b3b0e388697d2b174b3e154f33d4390472..da3d6642ae5e5603fa325dcc70cbba7a51704ee6 100644 (file)
@@ -78,7 +78,7 @@ create_boot_params(CHAR16 *args, memdesc_t *initrd, memdesc_t *vmcode, UINTN *co
                return 0;
        }
 
-       VERB_PRT(3, Print(L"boot params @ 0x%lx\n", bp));
+       VERB_PRT(3, Print(L"boot params @ " PTR_FMT "\n", bp));
 
 /* XXX: need to fix this for 3.5 */
 #ifdef CONFIG_ia64
diff --git a/choosers/CVS/Entries b/choosers/CVS/Entries
new file mode 100644 (file)
index 0000000..a35ed42
--- /dev/null
@@ -0,0 +1,6 @@
+/Makefile/1.1.1.1/Tue Aug 19 16:43:15 2003//
+/simple.h/1.1.1.1/Tue Aug 19 16:43:19 2003//
+/textmenu.h/1.1.1.1/Tue Aug 19 16:43:26 2003//
+/simple.c/1.7/Tue Feb 12 22:16:50 2008//
+/textmenu.c/1.9/Tue Feb 12 22:16:50 2008//
+D
diff --git a/choosers/CVS/Repository b/choosers/CVS/Repository
new file mode 100644 (file)
index 0000000..1dc4311
--- /dev/null
@@ -0,0 +1 @@
+elilo/choosers
diff --git a/choosers/CVS/Root b/choosers/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
index 552508661367fc822fd5c23c6c5b3d031acc9bc3..9d90fd6a8c9280285e2546c8c14c0a2782a7b013 100644 (file)
@@ -220,7 +220,7 @@ display_message(VOID)
 {
        fops_fd_t fd;
        EFI_STATUS status;
-       INTN len, i;
+       UINTN len, i;
        CHAR16 *filename;
        CHAR8 buf[256];
 
index 400d4f6489013df9abbcd2d619b73e7376aa2aba..57e3eaed90aa6799eba23c832719a7dd7bf5421b 100644 (file)
@@ -186,12 +186,12 @@ paint_menu(VOID)
 }
 
 static INTN
-read_message_file(INTN msg, INT8 *buf, INTN max)
+read_message_file(INTN msg, UINT8 *buf, UINTN max)
 {
        CHAR16 *filename;
        fops_fd_t message_fd;
        EFI_STATUS status;
-       INTN len = max;
+       UINTN len = max;
 
        if (msg > 10) return 0;
 
diff --git a/devschemes/CVS/Entries b/devschemes/CVS/Entries
new file mode 100644 (file)
index 0000000..0c4589e
--- /dev/null
@@ -0,0 +1,3 @@
+/Makefile/1.1.1.1/Tue Aug 19 16:43:44 2003//
+/simple.c/1.1.1.1/Tue Aug 19 16:43:40 2003//
+D
diff --git a/devschemes/CVS/Repository b/devschemes/CVS/Repository
new file mode 100644 (file)
index 0000000..113f9e4
--- /dev/null
@@ -0,0 +1 @@
+elilo/devschemes
diff --git a/devschemes/CVS/Root b/devschemes/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
diff --git a/docs/CVS/Entries b/docs/CVS/Entries
new file mode 100644 (file)
index 0000000..b47f5e9
--- /dev/null
@@ -0,0 +1,10 @@
+/devschemes.txt/1.1.1.1/Tue Aug 19 16:43:58 2003//
+/edd30.txt/1.1.1.1/Thu Feb 14 18:35:48 2002//
+/eliloalt.txt/1.1.1.1/Tue Aug 19 16:43:53 2003//
+/elilovars.txt/1.1.1.1/Tue Aug 19 16:44:19 2003//
+/fpswa.txt/1.1.1.1/Tue Aug 19 16:44:26 2003//
+/netbooting.txt/1.2/Fri Feb 20 22:30:38 2004//
+/simple_chooser.txt/1.1.1.1/Tue Aug 19 16:44:13 2003//
+/textmenu_chooser.txt/1.1.1.1/Tue Aug 19 16:44:08 2003//
+/elilo.txt/1.2/Fri Jul 20 19:10:30 2007//
+D
diff --git a/docs/CVS/Repository b/docs/CVS/Repository
new file mode 100644 (file)
index 0000000..d9749c6
--- /dev/null
@@ -0,0 +1 @@
+elilo/docs
diff --git a/docs/CVS/Root b/docs/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
diff --git a/elilo.c b/elilo.c
index ad1b555a2218ee9d155f556ec277006f19d9cfae..50ee71c585e7d5dbab647d7d20e3fb895cb6af7d 100644 (file)
--- a/elilo.c
+++ b/elilo.c
 #include "loader.h"
 #include "config.h" /* for config_init() */
 
-#define ELILO_VERSION                  L"3.8"
+#define ELILO_VERSION                  L"3.10"
 #define ELILO_SHARED_CMDLINE_OPTS      L"pPMC:aDhd:i:vVc:E"
 
 elilo_config_t elilo_opt;
 
 EFI_SYSTEM_TABLE *systab;      /* pointer to EFI system table */
 
+extern INTN wait_timeout (UINTN);
+
 /*
  * Load the Linux kernel in memory from the boot media
  * Output:
@@ -127,11 +129,12 @@ kernel_load(EFI_HANDLE image, CHAR16 *kname, kdesc_t *kd, memdesc_t *imem, memde
                        return ELILO_LOAD_RETRY;        
        }
 
-       VERB_PRT(3, Print(L"kernel loaded in [0x%lx-0x%lx] entry=0x%lx\n", 
-                         (unsigned long)kd->kstart, (unsigned long)kd->kend, (unsigned long)kd->kentry));
+       VERB_PRT(3, Print(L"kernel loaded in [" PTR_FMT "-" PTR_FMT "] entry=" PTR_FMT "\n", 
+                         kd->kstart, kd->kend, kd->kentry));
 
        if (elilo_opt.initrd[0]) {
 
+               /* ramdisk image is moved to the top of available extended memory later by start_kernel() */
                if (sysdeps_initrd_get_addr(kd, imem) == -1) goto exit_error;
 
                switch(load_file(elilo_opt.initrd, imem)) {
@@ -242,6 +245,9 @@ do_launch:
 
        VERB_PRT(3, Print(L"final cmdline(%d): %s\n", r, cmdline));
 
+       /* Give user time to see the output before launch */
+       if (elilo_opt.debug || elilo_opt.verbose) r = wait_timeout(300);
+
        /* free resources associated with file accesses (before ExitBootServices) */
        close_devices();
 
@@ -455,7 +461,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *system_tab)
                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));
+       VERB_PRT(5,Print(L"Loaded at " PTR_FMT " size=%ld bytes code=%d data=%d\n", info->ImageBase, info->ImageSize, info->ImageCodeType, info->ImageDataType));
        /*
         * verify EDD3.0 status. Users may have to reboot 
         */
@@ -599,7 +605,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *system_tab)
                                goto do_exit;
                }
        }
-       DBG_PRT((L"Optind=%d optarg=%x argc=%d", Optind, Optarg, argc));
+       DBG_PRT((L"Optind=%d optarg=" PTR_FMT " argc=%d", Optind, Optarg, argc));
 
        /*
         * we can't defer this phase any longer...
diff --git a/elilo.h b/elilo.h
index 74f740d0082f31c360b6f6802c742dc0a5cd4425..ae43705b74e1707d819e4339fdc06bae6e4a5646 100644 (file)
--- a/elilo.h
+++ b/elilo.h
 
 #include <efi.h>
 
+#ifdef CONFIG_ia32
+#define PTR_FMT L"0x%x"
+#else
+#define PTR_FMT L"0x%lx"
+#endif
+
 #include "elilo_debug.h"
 
 #include "fileops.h"
@@ -150,6 +156,7 @@ extern VOID *alloc_pages(UINTN, EFI_MEMORY_TYPE, EFI_ALLOCATE_TYPE, VOID *);
 extern VOID free_pages(VOID *);
 extern VOID free_all(VOID);
 extern INTN alloc_kmem(VOID *, UINTN);
+extern INTN alloc_kmem_anywhere(VOID **, UINTN);
 extern VOID free_kmem(VOID);
 extern VOID free_all_memory(VOID);
 
@@ -183,7 +190,7 @@ extern CHAR16 *get_config_file(VOID);
 extern INTN load_file(CHAR16 *, memdesc_t *);
 
 /* from alternate.c */
-extern INTN alternate_kernel(CHAR16 *, INTN);
+extern INTN alternate_kernel(CHAR16 *, UINTN);
 
 /* from bootparams.c */
 extern VOID *create_boot_params (CHAR16 *, memdesc_t *, memdesc_t *, UINTN *);
diff --git a/examples/CVS/Entries b/examples/CVS/Entries
new file mode 100644 (file)
index 0000000..e5b9381
--- /dev/null
@@ -0,0 +1,2 @@
+D/netboot////
+D/textmenu_chooser////
diff --git a/examples/CVS/Repository b/examples/CVS/Repository
new file mode 100644 (file)
index 0000000..74109b7
--- /dev/null
@@ -0,0 +1 @@
+elilo/examples
diff --git a/examples/CVS/Root b/examples/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
diff --git a/examples/netboot/CVS/Entries b/examples/netboot/CVS/Entries
new file mode 100644 (file)
index 0000000..85497e3
--- /dev/null
@@ -0,0 +1,3 @@
+/dhcpd-pxe.conf/1.1.1.1/Tue Jun 26 19:06:45 2001//
+/dhcpd.conf/1.1.1.1/Mon Mar  4 22:07:25 2002//
+D
diff --git a/examples/netboot/CVS/Repository b/examples/netboot/CVS/Repository
new file mode 100644 (file)
index 0000000..3654f07
--- /dev/null
@@ -0,0 +1 @@
+elilo/examples/netboot
diff --git a/examples/netboot/CVS/Root b/examples/netboot/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
diff --git a/examples/textmenu_chooser/CVS/Entries b/examples/textmenu_chooser/CVS/Entries
new file mode 100644 (file)
index 0000000..88509c8
--- /dev/null
@@ -0,0 +1,5 @@
+/elilo-textmenu.conf/1.1.1.1/Mon Mar  4 22:25:06 2002//
+/general.msg/1.1.1.1/Mon Mar  4 22:25:32 2002//
+/params.msg/1.1.1.1/Mon Mar  4 22:25:39 2002//
+/textmenu-message.msg/1.1.1.1/Mon Mar  4 22:23:34 2002//
+D
diff --git a/examples/textmenu_chooser/CVS/Repository b/examples/textmenu_chooser/CVS/Repository
new file mode 100644 (file)
index 0000000..881448e
--- /dev/null
@@ -0,0 +1 @@
+elilo/examples/textmenu_chooser
diff --git a/examples/textmenu_chooser/CVS/Root b/examples/textmenu_chooser/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
diff --git a/fs/CVS/Entries b/fs/CVS/Entries
new file mode 100644 (file)
index 0000000..c6795ce
--- /dev/null
@@ -0,0 +1,13 @@
+/Makefile/1.1.1.1/Thu Aug 14 00:13:04 2003//
+/ext2_fs.h/1.1.1.1/Tue Jun 26 19:06:45 2001//
+/ext2_fs_i.h/1.1.1.1/Tue Jun 26 19:06:45 2001//
+/ext2_fs_sb.h/1.1.1.1/Tue Jun 26 19:06:45 2001//
+/ext2_private.h/1.1.1.1/Tue Aug 19 16:45:05 2003//
+/ext2fs.h/1.1.1.1/Tue Aug 19 16:45:10 2003//
+/fs.h/1.1.1.1/Tue Jun 26 19:06:45 2001//
+/localfs.h/1.1.1.1/Tue Aug 19 16:44:53 2003//
+/netfs.h/1.1.1.1/Tue Aug 19 16:45:01 2003//
+/localfs.c/1.2/Fri Jul 20 19:09:57 2007//
+/ext2fs.c/1.3/Thu Apr  2 19:49:29 2009//
+/netfs.c/1.3/Thu Apr  2 19:49:29 2009//
+D
diff --git a/fs/CVS/Repository b/fs/CVS/Repository
new file mode 100644 (file)
index 0000000..b8990a8
--- /dev/null
@@ -0,0 +1 @@
+elilo/fs
diff --git a/fs/CVS/Root b/fs/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
index bec47fe8e8652940a67e4a22c40b90db7acf1f19..a0a9d876f563c65cb60ff4d015d03820ea714a90 100644 (file)
@@ -142,7 +142,7 @@ read_bytes(EFI_BLOCK_IO *blkio, UINT32 mediaid, UINTN offset, VOID *addr, UINTN
                return ret;
        }
 
-       DBG_PRT((L"readblock(%x, %d, %d, %d, %x)", blkio, mediaid, base, buffer_size, buffer));
+       DBG_PRT((L"readblock(PTR_FMT ", %d, %ld, %d, " PTR_FMT ")", blkio, mediaid, base, buffer_size, buffer));
 
        status = uefi_call_wrapper(blkio->ReadBlocks, 5, blkio, mediaid, base, buffer_size, buffer); 
        if (EFI_ERROR(status)) {
@@ -903,7 +903,7 @@ ext2fs_install_one(EFI_HANDLE dev, VOID **intf)
        }
        
        if (sb.s_magic != EXT2_SUPER_MAGIC) {
-               DBG_PRT((L"bad magic 0x%x\n", sb.s_magic));
+               DBG_PRT((L"bad magic "PTR_FMT"\n", sb.s_magic));
                return EFI_INVALID_PARAMETER;
        }
        
index 063f4e538b632af3eb15289e50d9499c1d9de103..abef2abc33190940f5d0ea8cd623177bb7032a13 100644 (file)
@@ -323,7 +323,7 @@ netfs_open(netfs_interface_t *this, CHAR16 *name, UINTN *fd)
 retry:
        f->netbuf_size = f->netbuf_maxsize;
 
-       DBG_PRT((L"\nbefore netbuf:0x%lx netbuf_size=%ld\n", f->netbuf, f->netbuf_size));
+       DBG_PRT((L"\nbefore netbuf:" PTR_FMT " netbuf_size=%d\n", f->netbuf, f->netbuf_size));
 
        /* 
         * For EFI versions older than 14.61:
@@ -349,7 +349,7 @@ retry:
                            NULL, 
                            FALSE);
 
-       DBG_PRT((L"after Mftp=%r netbuf:0x%lx netbuf_size=%ld blocksize=%ld\n", 
+       DBG_PRT((L"after Mftp=%r netbuf:" PTR_FMT " netbuf_size=%d blocksize=%d\n", 
                status, 
                f->netbuf, 
                f->netbuf_size, 
diff --git a/ia32/CVS/Entries b/ia32/CVS/Entries
new file mode 100644 (file)
index 0000000..fa43e88
--- /dev/null
@@ -0,0 +1,12 @@
+/Makefile/1.2/Tue Feb 17 23:42:40 2004//
+/bin_to_h.c/1.1.1.1/Wed Feb 20 01:07:55 2002//
+/config.c/1.1.1.1/Tue Aug 19 16:45:43 2003//
+/gzip_loader.c/1.2/Thu Dec  1 21:42:59 2005//
+/private.h/1.1.1.1/Tue Aug 19 16:45:55 2003//
+/rmswitch.S/1.1.1.1/Wed Feb 20 01:07:55 2002//
+/bzimage.c/1.2/Thu Apr  2 19:49:29 2009//
+/gzip.c/1.4/Thu Apr  2 19:49:29 2009//
+/plain_loader.c/1.2/Thu Apr  2 19:49:29 2009//
+/sysdeps.h/1.4/Thu Apr  2 19:49:29 2009//
+/system.c/1.8/Thu Apr  2 19:49:29 2009//
+D
diff --git a/ia32/CVS/Repository b/ia32/CVS/Repository
new file mode 100644 (file)
index 0000000..0651ef2
--- /dev/null
@@ -0,0 +1 @@
+elilo/ia32
diff --git a/ia32/CVS/Root b/ia32/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
index aac1d378ac571d039d823e780b59674c4c4f38e7..0dd07722fb33701042e5264b08d8e7e0032fe7f1 100644 (file)
@@ -47,7 +47,7 @@ bzImage_probe(CHAR16 *kname)
        DBG_PRT((L"probe_bzImage_boot()\n"));
 
        if (!kname) {
-               ERR_PRT((L"kname == %xh", kname));
+               ERR_PRT((L"kname == " PTR_FMT, kname));
                free_kmem();
                return -1;
        }
@@ -110,7 +110,7 @@ bzImage_probe(CHAR16 *kname)
        param_size = (bootsect[0x1F1] + 1) * 512;
        param_start = alloc(param_size, EfiLoaderData);
 
-       DBG_PRT((L"param_size=%d param_start=%x", param_size, param_start));
+       DBG_PRT((L"param_size=%d param_start=" PTR_FMT, param_size, param_start));
 
        if (!param_start) {
                ERR_PRT((L"Could not allocate %d bytes of setup data.",
@@ -141,7 +141,7 @@ bzImage_probe(CHAR16 *kname)
 
        { 
                UINT8 *c = ((UINT8 *)param_start)+514;
-               DBG_PRT((L"param_start(c=%x): %c-%c-%c-%c", 
+               DBG_PRT((L"param_start(c=" PTR_FMT "): %c-%c-%c-%c", 
                        c, (CHAR16)c[0],(CHAR16) c[1], (CHAR16)c[2], (CHAR16)c[3]));
        }
        if (CompareMem(((UINT8 *)param_start) + 514, "HdrS", 4)) {
@@ -158,13 +158,38 @@ bzImage_probe(CHAR16 *kname)
         * Allocate memory for kernel.
         */
 
-       if (alloc_kmem(kernel_start, EFI_SIZE_TO_PAGES(kernel_size))) {
-               ERR_PRT((L"Could not allocate kernel memory."));
-               return -1;
-       } else {
-               VERB_PRT(3, Print(L"kernel_start: 0x%x  kernel_size: %d\n", 
-                       kernel_start, kernel_size));
-       }
+        /*
+         * Get correct address for kernel from header, if applicable & available. 
+         */
+        if ((param_start->s.hdr_major == 2) &&
+            (param_start->s.hdr_minor >= 6) &&
+            (param_start->s.kernel_start >= DEFAULT_KERNEL_START)) {
+                kernel_start = (void *)param_start->s.kernel_start;
+                VERB_PRT(3, Print(L"kernel header suggests kernel start at address "PTR_FMT"\n",
+                        kernel_start));
+        }
+
+        kernel_load_address = kernel_start;
+
+        if (alloc_kmem(kernel_start, EFI_SIZE_TO_PAGES(kernel_size)) != 0) {
+                /*
+                 * Couldn't get desired address--just load it anywhere and move it later.
+                 * (Easier than relocating kernel, and also works with non-relocatable kernels.)
+                 */
+                if (alloc_kmem_anywhere(&kernel_load_address, EFI_SIZE_TO_PAGES(kernel_size)) != 0) {
+                        ERR_PRT((L"Could not allocate memory for kernel."));
+                        free(param_start);
+                        param_start = NULL;
+                        param_size = 0;
+                        fops_close(fd);
+                        return -1;
+                }
+        }
+
+        VERB_PRT(3, Print(L"kernel_start: "PTR_FMT"  kernel_size: %d  loading at: "PTR_FMT"\n",
+                kernel_start, kernel_size, kernel_load_address));
+
+
        /*
         * Now read the rest of the kernel image into memory.
         */
@@ -172,7 +197,7 @@ bzImage_probe(CHAR16 *kname)
        DBG_PRT((L"reading kernel image...\n"));
 
        size = kernel_size;
-       efi_status = fops_read(fd, kernel_start, &size);
+       efi_status = fops_read(fd, kernel_load_address, &size);
        if (EFI_ERROR(efi_status) || size < 0x10000) {
                ERR_PRT((L"Error reading kernel image %s.", kname));
                free(param_start);
@@ -200,7 +225,7 @@ bzImage_load(CHAR16 *kname, kdesc_t *kd)
        DBG_PRT((L"load_bzImage_boot()\n"));
 
        if (!kname || !kd) {
-               ERR_PRT((L"kname=0x%x  kd=0x%x", kname, kd));
+               ERR_PRT((L"kname=" PTR_FMT "  kd=" PTR_FMT, kname, kd));
                free(param_start);
                param_start = NULL;
                param_size = 0;
@@ -210,7 +235,7 @@ bzImage_load(CHAR16 *kname, kdesc_t *kd)
        kd->kstart = kd->kentry = kernel_start;
        kd->kend = ((UINT8 *)kd->kstart) + kernel_size;
 
-       DBG_PRT((L"kstart=0x%x  kentry=0x%x  kend=0x%x\n", kd->kstart, kd->kentry, kd->kend));
+       DBG_PRT((L"kstart=" PTR_FMT "  kentry=" PTR_FMT "  kend=" PTR_FMT "\n", kd->kstart, kd->kentry, kd->kend));
 
        return 0;
 }
index fff5f6d52ba1eb3f5804aa69e376c89b8ecd4436..cc801ad770a53a87ba06926d5026633e120d0c90 100644 (file)
@@ -153,7 +153,7 @@ gzip_free(void *where)
 int
 fill_inbuf(void)
 {
-       INTN expected, nread;
+       UINTN expected, nread;
        EFI_STATUS status;
 
        expected = nread = INBUFSIZE;
@@ -277,7 +277,7 @@ analyze_chunks(void)
  * the relevant header information.
  */
 int
-first_block (const char *buf, long blocksize)
+first_block (const unsigned char *buf, long blocksize)
 {
        Elf32_Ehdr *elf;
        Elf32_Phdr *phdrs;
@@ -297,13 +297,13 @@ first_block (const char *buf, long blocksize)
        phnum = elf->e_phnum;
 
        VERB_PRT(3, { 
-               Print(L"Entry point 0x%lx\n", elf->e_entry);
+               Print(L"Entry point "PTR_FMT"\n", elf->e_entry);
                Print(L"%d program headers\n", phnum);
                Print(L"%d segment headers\n", elf->e_shnum);
        });
 
        if (offs + phnum * sizeof(*phdrs) > (unsigned) blocksize) {
-               ERR_PRT((L"%s : ELF program headers not in first block (%ld)\n", LD_NAME, offs));
+               ERR_PRT((L"%s : ELF program headers not in first block (%d)\n", LD_NAME, offs));
                return -1;
        }
 
@@ -345,15 +345,15 @@ first_block (const char *buf, long blocksize)
 
                if (phdrs[i].p_type != PT_LOAD) {
                        CHUNK_NO_LOAD(i); /* mark no load chunk */
-                       DBG_PRT((L"%s : skipping segment %ld\n", LD_NAME, i));
+                       DBG_PRT((L"%s : skipping segment %d\n", LD_NAME, i));
                        continue;
                }
 
                CHUNK_CAN_LOAD(i); /* mark no load chunk */
 
                VERB_PRT(3, 
-               Print(L"\n%s : segment %ld vaddr [0x%lx-0x%lx] offset %ld filesz %ld "
-                       "memsz=%ld bss_sz=%ld\n",
+               Print(L"\n%s : segment %d vaddr ["PTR_FMT"-"PTR_FMT"] offset %d filesz %d "
+                       "memsz=%d bss_sz=%d\n",
                        LD_NAME, 1+i, chunks[i].addr, chunks[i].addr+phdrs[i].p_filesz, 
                        chunks[i].offset, chunks[i].size, memsz, chunks[i].bss_sz));
                
@@ -364,12 +364,12 @@ first_block (const char *buf, long blocksize)
        }
 
        if (low_addr & (EFI_PAGE_SIZE - 1)) {
-               ERR_PRT((L"%s : low_addr not page aligned 0x%lx\n", LD_NAME, low_addr));
+               ERR_PRT((L"%s : low_addr not page aligned "PTR_FMT"\n", LD_NAME, low_addr));
                goto error;
        }
        analyze_chunks();
 
-       DBG_PRT((L"%s : %d program headers entry=0x%lx\nlowest_addr=0x%lx highest_addr=0x%lx\n", 
+       DBG_PRT((L"%s : %d program headers entry=" PTR_FMT "\nlowest_addr="PTR_FMT" highest_addr="PTR_FMT"\n", 
                        LD_NAME,
                        phnum, kernel_entry, low_addr, max_addr));
 
@@ -384,9 +384,9 @@ first_block (const char *buf, long blocksize)
 
        /* allocate memory for the kernel */
        if (alloc_kmem((void *)low_addr, pages) == -1) {
-               ERR_PRT((L"%s : AllocatePages(%d, 0x%lx) for kernel failed\n", 
+               ERR_PRT((L"%s : AllocatePages(%d, "PTR_FMT") for kernel failed\n", 
                        LD_NAME, pages, low_addr));
-               ERR_PRT((L"%s : Could not load kernel at 0x%lx\n", LD_NAME, low_addr));
+               ERR_PRT((L"%s : Could not load kernel at "PTR_FMT"\n", LD_NAME, low_addr));
                ERR_PRT((L"%s : Bailing\n", LD_NAME));
                goto error;
        }
@@ -430,12 +430,12 @@ flush_window(void)
        static const CHAR8 helicopter[4] = { '|' , '/' , '-' , '\\' };
        static UINTN heli_count;
        struct segment *cp;
-       char    *src, *dst;
+       unsigned char   *src, *dst;
        long    cnt;
 
        if (!outcnt) return;
 
-       DBG_PRT((L"%s : flush_window outnct=%d file_offset=%ld\n", LD_NAME, outcnt, file_offset));
+       DBG_PRT((L"%s : flush_window outnct=%d file_offset=%d\n", LD_NAME, outcnt, file_offset));
 
        Print(L"%c\b",helicopter[heli_count++%4]);
 
@@ -468,7 +468,7 @@ tail:
                file_offset += skip;
                outcnt      -= skip;
        }
-       dst = (char *)cp->addr + (file_offset - cp->offset);
+       dst = (unsigned char *)cp->addr + (file_offset - cp->offset);
        cnt = cp->offset + cp->size - file_offset;
        if (cnt > outcnt) 
                cnt = outcnt;
@@ -482,7 +482,7 @@ tail:
        /* See if we are at the end of this chunk */
        if (file_offset == cp->offset + cp->size) {
                if (cp->bss_sz) {
-                       dst = (char *)cp->addr + cp->size;
+                       dst = (unsigned char *)cp->addr + cp->size;
                        Memset(dst, 0, cp->bss_sz);
                }
                nextchunk();
index ac4c573d99c21e828af028019df2792bf4b221fa..5ad1a94ed6bd3defc4c09f5bbc2b9723469d5385 100644 (file)
@@ -111,7 +111,7 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
        }        
        VERB_PRT(3, {
                Print(L"ELF Header information: \n");
-               Print(L"\tEntry point 0x%x\n", (ehdr.e_entry & PADDR_MASK));
+               Print(L"\tEntry point "PTR_FMT"\n", (ehdr.e_entry & PADDR_MASK));
                Print(L"\t%d program headers\n", ehdr.e_phnum);
                Print(L"\t%d segment headers\n", ehdr.e_shnum);
        });
@@ -145,8 +145,8 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
                paddr = (phdrs[i].p_paddr & PADDR_MASK);
                memsz = phdrs[i].p_memsz;
 
-               DBG_PRT((L"Phdr %d paddr [0x%x-0x%x] offset 0x%x"
-                       " filesz 0x%x memsz=0x%x bss_sz=0x%x p_type=0x%x\n",
+               DBG_PRT((L"Phdr %d paddr ["PTR_FMT"-"PTR_FMT"] offset "PTR_FMT""
+                       " filesz "PTR_FMT" memsz="PTR_FMT" bss_sz="PTR_FMT" p_type="PTR_FMT"\n",
                        1+i, paddr, paddr+phdrs[i].p_filesz, phdrs[i].p_offset, 
                        phdrs[i].p_filesz, memsz, 
                        (memsz - phdrs[i].p_filesz), phdrs[i].p_type));
@@ -160,7 +160,7 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
        }
 
        if ((UINTN)low_addr & (EFI_PAGE_SIZE - 1)) {
-               ERR_PRT((L"%s : kernel low address 0x%x not page aligned\n", 
+               ERR_PRT((L"%s : kernel low address "PTR_FMT" not page aligned\n", 
                        LD_NAME, low_addr));
                goto out;
        }
@@ -176,16 +176,16 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
        kd->kentry = (VOID *)(ehdr.e_entry & PADDR_MASK);
        
        VERB_PRT(3, {
-               Print(L"Lowest PhysAddr: 0x%x\nTotalMemSize:%d bytes (%d pages)\n",
+               Print(L"Lowest PhysAddr: "PTR_FMT"\nTotalMemSize:%d bytes (%d pages)\n",
                        low_addr, total_size, pages);
-               Print(L"Kernel entry @ 0x%x\n", kd->kentry);
+               Print(L"Kernel entry @ "PTR_FMT"\n", kd->kentry);
        });
        
        /* now allocate memory for the kernel at the exact requested spot */
        if (alloc_kmem(low_addr, pages) == -1) {
-               ERR_PRT((L"%s : AllocatePages(%d, 0x%lx) for kernel failed\n", 
+               ERR_PRT((L"%s : AllocatePages(%d, "PTR_FMT") for kernel failed\n", 
                        LD_NAME, pages, low_addr));
-               ERR_PRT((L"%s : Could not alloc %d pages for the kernel at 0x%lx "
+               ERR_PRT((L"%s : Could not alloc %d pages for the kernel at "PTR_FMT""
                        " and relocation is not not been implemented!\n", 
                        LD_NAME, pages, low_addr));
                goto load_abort;
@@ -206,7 +206,7 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
                if (phdrs[i].p_type != PT_LOAD)
                        continue;
 
-               VERB_PRT(3, Print(L"poffs: 0x%x (phdrs[%d].p_offset)\n", 
+               VERB_PRT(3, Print(L"poffs: "PTR_FMT" (phdrs[%d].p_offset)\n", 
                        phdrs[i].p_offset, i));
 
                filesz = phdrs[i].p_filesz;
@@ -221,9 +221,9 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
 
                VERB_PRT(4, {
                        Print(L"\nHeader #%d\n", i);
-                       Print(L"Offset in file 0x%x\n", phdrs[i].p_offset);
-                       Print(L"Physical addr 0x%x\n", low_addr);
-                       Print(L"BSS size 0x%x bytes\n", bss_sz);
+                       Print(L"Offset in file "PTR_FMT"\n", phdrs[i].p_offset);
+                       Print(L"Physical addr "PTR_FMT"\n", low_addr);
+                       Print(L"BSS size %d bytes\n", bss_sz);
                });
 
                /*
index ecfb5366937558d03ab425e9b3c7b4317b07c2e8..bb3dc7efd2cb46ea577a6f855ea34cbcec7af584 100644 (file)
@@ -35,6 +35,9 @@
 #define ELILO_ARCH     "IA-32" /* ASCII string */
 #define PADDR_MASK     0xfffffff
 
+#define INITRD_START   (15*1024*1024)
+#define DEFAULT_KERNEL_START   0x100000
+
 /* for now use library versions */
 #define Memset(a,v,n)  SetMem((a),(n),(v))
 #define Memcpy(a,b,n)  CopyMem((a),(b),(n))
@@ -299,11 +302,17 @@ typedef union ia32_boot_params {
        UINT8 *t = (UINT8 *)(to); \
        UINT8 *f = (UINT8 *)(from); \
        UINTN n = cnt; \
-       if (t && f && n) { \
-               while (n--) { \
-                       *t++ = *f++; \
-               } \
-       } \
+       if (t && f && n && (t<f)) { \
+               while (n--) { \
+                        *t++ = *f++; \
+                } \
+        } else if (t && f && n && (t>f)) { \
+                t += n; \
+                f += n; \
+                while (n--) { \
+                        *t-- = *f--; \
+                } \
+        } \
 }
 
 #define MEMSET(ptr, size, val) { \
@@ -338,6 +347,7 @@ extern UINTN kernel_size;
 
 extern VOID *initrd_start;
 extern UINTN initrd_size;
+extern VOID *kernel_load_address;
 
 extern dt_addr_t gdt_addr;
 extern dt_addr_t idt_addr;
@@ -357,19 +367,31 @@ extern INTN ia32_use_legacy_free_boot();
 static inline void
 start_kernel(VOID *kentry, boot_params_t *bp)
 {
+       UINT32  temp;
+
        /*
         * Disable interrupts.
         */
        asm volatile ( "cli" : : );
 
-       /*
-        * Relocate initrd, if present.
-        */
+        /*
+         * Relocate kernel (if needed), and initrd (if present).
+         * Copy kernel first, in case kernel was loaded overlapping where we're
+         * planning to copy the initrd.  This assumes that the initrd didn't
+         * get loaded overlapping where we're planning to copy the kernel, but
+         * that's pretty unlikely since we couldn't alloc that space for the
+         * kernel (or the kernel would already be there).
+         */
+        if (kernel_start != kernel_load_address) {
+                MEMCPY(kernel_start, kernel_load_address, kernel_size);
+        }
+
+        if (bp->s.initrd_start) {
+                temp =  bp->s.initrd_start;
+                MEMCPY(INITRD_START, temp , bp->s.initrd_size);
+                bp->s.initrd_start = INITRD_START;
+        }
 
-       if (bp->s.initrd_start) {
-               MEMCPY(15 * 1024 * 1024, bp->s.initrd_start, bp->s.initrd_size);
-               bp->s.initrd_start = 15 * 1024 * 1024;
-       }
        /*
         * Copy boot sector, setup data and command line
         * to final resting place.  We need to copy
index 00a1f0a3d9e8ed299544e014d3b6be624a503e14..078d40650a2aca096be6704653f0549a65b7e544 100644 (file)
@@ -97,7 +97,10 @@ UINTN high_base_mem = 0x90000;
 UINTN high_ext_mem = 32 * 1024 * 1024;
 
 /* This starting address will hold true for all of the loader types for now */
-VOID *kernel_start = (VOID *)0x100000; /* 1M */
+VOID *kernel_start = (VOID *)DEFAULT_KERNEL_START;
+
+/* The kernel may load elsewhere if EFI firmware reserves kernel_start */
+VOID *kernel_load_address = (VOID *)DEFAULT_KERNEL_START;
 
 VOID *initrd_start = NULL;
 UINTN initrd_size = 0;
@@ -131,16 +134,16 @@ sysdeps_initrd_get_addr(kdesc_t *kd, memdesc_t *imem)
        DBG_PRT((L"initrd_get_addr()\n"));
 
        if (!kd || !imem) {
-               ERR_PRT((L"kd=0x%x imem=0x%x", kd, imem));
+               ERR_PRT((L"kd=" PTR_FMT " imem=" PTR_FMT, kd, imem));
                return -1;
        }
 
-       VERB_PRT(3, Print(L"kstart=0x%x  kentry=0x%x  kend=0x%x\n", 
+       VERB_PRT(3, Print(L"kstart=" PTR_FMT "  kentry=" PTR_FMT "  kend=" PTR_FMT "\n", 
                kd->kstart, kd->kentry, kd->kend));
 
        imem->start_addr = kd->kend;
 
-       VERB_PRT(3, Print(L"initrd start_addr=0x%x pgcnt=%d\n", 
+       VERB_PRT(3, Print(L"initrd start_addr=" PTR_FMT " pgcnt=%d\n", 
                imem->start_addr, imem->pgcnt));
 
        return 0;
@@ -156,6 +159,24 @@ sysdeps_free_boot_params(boot_params_t *bp)
        free_memmap(&md);
 }
 
+static VOID find_bits(unsigned long mask, UINT8 *first, UINT8* len) {
+       unsigned char bit_pos = 0, bit_len = 0;
+       *first =0;
+       *len = 0;
+       if (mask == 0)
+               return;
+       while (!(mask & 0x1)) {
+               mask = mask >> 1;
+               bit_pos++;
+       }
+       while (mask & 0x1) {
+               mask = mask >> 1;
+               bit_len++;
+       }
+       *first = bit_pos;
+       *len = bit_len;
+}
+
 /*
  * Get video information.
  */
@@ -163,10 +184,11 @@ static INTN get_video_info(boot_params_t * bp) {
         EFI_GUID GopProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
         EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop_interface;
         EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Gop_info;
-        EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE   *Gop_mode;
-        EFI_HANDLE *Gop_handle;
+        EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE   *Gop_mode = NULL;
+        EFI_HANDLE *Gop_handle = NULL;
         EFI_STATUS efi_status;
-        UINTN size, size1;
+        UINTN size = 0;
+        UINTN size1;
         UINT8 i;
 
        efi_status = uefi_call_wrapper(
@@ -204,7 +226,7 @@ static INTN get_video_info(boot_params_t * bp) {
                                3,
                                *Gop_handle,
                                &GopProtocol,
-                               &Gop_interface);
+                               (VOID **) &Gop_interface);
 
                if (EFI_ERROR(efi_status)) {
                        continue;
@@ -428,7 +450,7 @@ sysdeps_create_boot_params(
        DBG_PRT((L"fill_boot_params()\n"));
 
        if (!bp || !cmdline || !initrd || !cookie) {
-               ERR_PRT((L"bp=0x%x  cmdline=0x%x  initrd=0x%x cookie=0x%x",
+               ERR_PRT((L"bp=" PTR_FMT "  cmdline=" PTR_FMT "  initrd=" PTR_FMT " cookie=" PTR_FMT,
                        bp, cmdline, initrd, cookie));
 
                if (param_start != NULL) {
@@ -515,7 +537,7 @@ sysdeps_create_boot_params(
         * Initial RAMdisk and root device stuff.
         */
 
-       DBG_PRT((L"initrd->start_addr=0x%x  initrd->pgcnt=%d\n",
+       DBG_PRT((L"initrd->start_addr=" PTR_FMT "  initrd->pgcnt=%d\n",
                initrd->start_addr, initrd->pgcnt));
 
        /* These RAMdisk flags are not needed, just zero them. */
@@ -597,7 +619,7 @@ sysdeps_create_boot_params(
 #define WAIT_FOR_KEY() \
 { \
        EFI_INPUT_KEY key; \
-       while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key) != EFI_SUCCESS) { \
+       while (uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &key) != EFI_SUCCESS) { \
                ; \
        } \
 }
@@ -697,7 +719,9 @@ sysdeps_create_boot_params(
 
        if (!get_video_info(bp)) goto do_memmap;
 
-       efi_status = ST->ConOut->QueryMode(
+       efi_status = uefi_call_wrapper(
+               ST->ConOut->QueryMode,
+               4,
                ST->ConOut,
                ST->ConOut->Mode->Mode,
                &cols,
diff --git a/ia64/CVS/Entries b/ia64/CVS/Entries
new file mode 100644 (file)
index 0000000..6157a21
--- /dev/null
@@ -0,0 +1,15 @@
+/Makefile/1.1.1.1/Tue Aug 19 16:46:53 2003//
+/config.c/1.1.1.1/Tue Aug 19 16:46:58 2003//
+/gzip_loader.c/1.2/Thu Dec  1 21:42:59 2005//
+/memcpy.S/1.1.1.1/Tue Aug 19 16:46:20 2003//
+/memset.S/1.1.1.1/Tue Aug 19 16:46:13 2003//
+/private.h/1.2/Fri Sep 16 16:25:52 2005//
+/setjmp.h/1.1.1.1/Wed Aug  1 08:45:17 2001//
+/system.c/1.4/Thu Dec  1 21:42:59 2005//
+/fpswa.c/1.2/Tue Feb 12 22:16:51 2008//
+/gzip.c/1.5/Tue Feb 12 22:16:51 2008//
+/longjmp.S/1.2/Tue Feb 12 22:16:51 2008//
+/plain_loader.c/1.4/Tue Feb 12 22:16:51 2008//
+/setjmp.S/1.4/Tue Feb 12 22:16:51 2008//
+/sysdeps.h/1.3/Tue Feb 12 22:16:51 2008//
+D
diff --git a/ia64/CVS/Repository b/ia64/CVS/Repository
new file mode 100644 (file)
index 0000000..cb65f9c
--- /dev/null
@@ -0,0 +1 @@
+elilo/ia64
diff --git a/ia64/CVS/Root b/ia64/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
index a19d7cb0ac50266f77d76e86eedda0d66f67bc85..daa86e1d169bbf2e4c633e96f6c4faeb258ca6d4 100644 (file)
@@ -132,7 +132,7 @@ check_fpswa(EFI_HANDLE image, EFI_HANDLE dev, CHAR16 *fpswa_file)
 #endif
        };
        UINTN j, count = sizeof(fpswa_filenames)/sizeof(CHAR16 *);
-       INTN cookie;
+       UINTN cookie;
        CHAR16 devname[FILENAME_MAXLEN];
        
        if (fpswa_file) {
index 01e28c85fe886e8ceca15527230d30135d74a87c..a27d622d57db7677d7334b0d78a16e9f0f6481f3 100644 (file)
@@ -161,7 +161,7 @@ gzip_free(void *where)
 int
 fill_inbuf(void)
 {
-       INTN expected, nread;
+       UINTN expected, nread;
        EFI_STATUS status;
 
        expected = nread = INBUFSIZE;
@@ -309,7 +309,7 @@ analyze_chunks(void)
  * the relevant header information.
  */
 int
-first_block (const char *buf, long blocksize)
+first_block (const unsigned char *buf, long blocksize)
 {
        Elf64_Ehdr *elf;
        Elf64_Phdr *phdrs;
@@ -439,7 +439,7 @@ first_block (const char *buf, long blocksize)
        if (alloc_kmem((void *)low_addr, pages) == -1) {
                VOID *new_addr;
 
-               VERB_PRT(1, (L"%s : AllocatePages(%d, 0x%lx) for kernel failed\n", LD_NAME, pages, low_addr));
+               VERB_PRT(1, Print(L"%s : AllocatePages(%d, 0x%lx) for kernel failed\n", LD_NAME, pages, low_addr));
 
                if (ia64_can_relocate() == 0) {
                        ERR_PRT((L"relocation is disabled, cannot load kernel"));
@@ -464,7 +464,7 @@ first_block (const char *buf, long blocksize)
                /* unsigned arithmetic */
                 load_offset = (UINTN) (new_addr - ROUNDDOWN((UINTN) low_addr,256*MB));
 
-               VERB_PRT(1, (L"low_addr=0x%lx new_addr=0x%lx offset=0x%lx", low_addr, new_addr, load_offset));
+               VERB_PRT(1, Print(L"low_addr=0x%lx new_addr=0x%lx offset=0x%lx", low_addr, new_addr, load_offset));
 
                /*
                 * correct various addresses for non-zero load_offset
@@ -526,7 +526,7 @@ flush_window(void)
        static const CHAR8 helicopter[4] = { '|' , '/' , '-' , '\\' };
        static UINTN heli_count;
        struct segment *cp;
-       char    *src, *dst;
+       unsigned char   *src, *dst;
        long    cnt;
 
        if (!outcnt) return;
@@ -565,7 +565,7 @@ tail:
                file_offset += skip;
                outcnt      -= skip;
        }
-       dst = (char *)cp->addr + (file_offset - cp->offset);
+       dst = (unsigned char *)cp->addr + (file_offset - cp->offset);
 
        cnt = cp->offset + cp->size - file_offset;
 
@@ -582,7 +582,7 @@ tail:
        /* See if we are at the end of this chunk */
        if (file_offset == cp->offset + cp->size) {
                if (cp->bss_sz) {
-                       dst = (char *)cp->addr + cp->size;
+                       dst = (unsigned char *)cp->addr + cp->size;
                        Memset(dst, 0, cp->bss_sz);
                }
                nextchunk();
index 8b668933b7ad4e9ca802ea93b1de54d22d1c7b3d..23dec8687bf97d5cf577d1290fc706650537e3b2 100644 (file)
@@ -159,4 +159,4 @@ longjmp:
        invala                  // virt. -> phys. regnum mapping may change
        mov pr=r24,-1
        br.ret.dptk.few rp
-       .endp __longjmp
+       .endp longjmp
index 150f7a0154bdbe79b712d19e75c13f03bf19281d..ad38885f8f49e66a223e0bf41e38294cfa2122b3 100644 (file)
@@ -288,7 +288,7 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
        if (alloc_kmem(low_addr, pages) == -1) {
                VOID *new_addr;
 
-               VERB_PRT(1, (L"%s : AllocatePages(%d, 0x%lx) for kernel failed\n", LD_NAME, pages, low_addr));
+               VERB_PRT(1, Print(L"%s : AllocatePages(%d, 0x%lx) for kernel failed\n", LD_NAME, pages, low_addr));
 
                if (ia64_can_relocate() == 0) {
                        ERR_PRT((L"relocation is disabled, cannot load kernel"));
index 4bc2103b79b8bc21e6f8e398b140b156335f5af8..4c83d0333128133d748c2bcc8399ae1fffe8fd0a 100644 (file)
@@ -81,6 +81,7 @@ setjmp:
        .proc __sigsetjmp
 __sigsetjmp:
        //.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
+       .body
        alloc loc1=ar.pfs,2,2,2,0
        mov r16=ar.unat
        ;;
@@ -89,6 +90,7 @@ __sigsetjmp:
        add r3=8,in0
        ;;
        st8.spill.nta [r2]=sp,16        // r12 (sp)
+       ;;
        st8.spill.nta [r3]=gp,16        // r1 (gp)
        ;;
        st8.nta [r2]=r16,16             // save caller's unat
@@ -96,13 +98,13 @@ __sigsetjmp:
        add r8=0xa0,in0
        ;;
        st8.spill.nta [r2]=r4,16        // r4
+       ;;
        st8.spill.nta [r3]=r5,16        // r5
        add r9=0xb0,in0
        ;;
        stf.spill.nta [r8]=f2,32
        stf.spill.nta [r9]=f3,32
        mov loc0=rp
-       .body
        ;;
        stf.spill.nta [r8]=f4,32
        stf.spill.nta [r9]=f5,32
@@ -139,6 +141,7 @@ __sigsetjmp:
        stf.spill.nta [r9]=f31
 
        st8.spill.nta [r2]=r6,16        // r6
+       ;;
        st8.spill.nta [r3]=r7,16        // r7
        ;;
        mov r23=ar.bsp
index e11e6b729a95d63f4b388775b114ccd3243caee3..9d893e6c5dfb3616a9c5a040179c051bfd460e47 100644 (file)
@@ -86,7 +86,7 @@ start_kernel(VOID *kentry, VOID *bp)
         asm volatile ("mov r28=%1; br.sptk.few %0" :: "b"(kentry),"r"(bp));
 }
 
-static inline const UINT64
+static inline UINT64
 __ia64_swab64 (UINT64 x)
 {
        UINT64 result;
@@ -95,13 +95,13 @@ __ia64_swab64 (UINT64 x)
        return result;
 }
 
-static inline const UINT32
+static inline UINT32
 __ia64_swab32 (UINT32 x)
 {
        return __ia64_swab64(x) >> 32;
 }
 
-static inline const UINT16
+static inline UINT16
 __ia64_swab16(UINT16 x)
 {
        return __ia64_swab64(x) >> 48;
index 843c93be3e046b267b5509662c099bf78ce54ef5..157dfc2f466967f236f7d703bb9794e524e0dba1 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -1094,10 +1094,10 @@ static int gunzip(void)
            error("Input has invalid flags\n");
            return -1;
     }
-    (ulg)get_byte();   /* Get timestamp */
-    ((ulg)get_byte()) << 8;
-    ((ulg)get_byte()) << 16;
-    ((ulg)get_byte()) << 24;
+    (void)get_byte();  /* Get timestamp - 4 bytes */
+    (void)get_byte();
+    (void)get_byte();
+    (void)get_byte();
 
     (void)get_byte();  /* Ignore extra flags for the moment */
     (void)get_byte();  /* Ignore OS type for the moment */
index ac3b91db4a5b8b88374110a6384f283d6fc96b5f..581abda225eeb66b2fb382892e26dfe402f84127 100644 (file)
--- a/initrd.c
+++ b/initrd.c
@@ -77,9 +77,9 @@ load_file(CHAR16 *filename, memdesc_t *image)
                         filename));
                goto error;
        }
-       VERB_PRT(2, Print(L"%s image: total_size: %ld bytes base: 0x%lx "
+       VERB_PRT(2, Print(L"%s image: total_size: %d bytes base: " PTR_FMT " "
                          "pages %d\n", filename, image->size,
-                         (UINTN)start_addr, pgcnt));
+                         start_addr, pgcnt));
 
        Print(L"Loading file %s...", filename);
 
index 290531cbe19517e513bdc5d01cefdf4dfe5de0a1..f0708bd91f47040eed840ac7b402d6b0eb734df8 100644 (file)
--- a/loader.c
+++ b/loader.c
@@ -38,12 +38,18 @@ loader_ops_t *
 loader_probe(CHAR16 *kname)
 {
        loader_ops_t *ops;
+       UINTN n = 0;
 
        for (ops= ldops_list; ops; ops = ops->next) {
+               n++;
+               VERB_PRT(3, Print(L"Probing loader: %s\n", ops->ld_name));
                if (ops->ld_probe(kname) == 0) {
                        return ops;
                }
        }
+       if (!n) {
+               ERR_PRT((L"No loaders registered"));
+       }
        return NULL;
 }
 
diff --git a/tools/CVS/Entries b/tools/CVS/Entries
new file mode 100644 (file)
index 0000000..14dba2d
--- /dev/null
@@ -0,0 +1,3 @@
+/Makefile/1.1.1.1/Tue Aug 19 16:47:54 2003//
+/eliloalt.c/1.1.1.1/Tue Aug 19 16:47:59 2003//
+D
diff --git a/tools/CVS/Repository b/tools/CVS/Repository
new file mode 100644 (file)
index 0000000..f44a1d8
--- /dev/null
@@ -0,0 +1 @@
+elilo/tools
diff --git a/tools/CVS/Root b/tools/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
diff --git a/util.c b/util.c
index 84e76cc56f9c74d882e411a0115448aa0b9c91c5..f5e0072031bd749b8a3b247a280a84f1b4a234c0 100644 (file)
--- a/util.c
+++ b/util.c
@@ -134,8 +134,10 @@ wait_timeout(UINTN timeout)
                        ERR_PRT((L"waitkey WaitForEvent failed %r", status));
                        return -1;
                }
+               if (timeout % 10 == 1) Print(L".");
 
        } while (timeout-- && idx == 0);        
+       Print(L"\n");
 
        /*
         * SetTimer(timer, TimerCancel, 0) is causing problems on IA-32 and gcc3
@@ -248,7 +250,7 @@ split_args(CHAR16 *buffer, CHAR16 *kname, CHAR16 *args)
 INTN
 read_file(UINTN fd, UINTN total_size, CHAR8 *buffer)
 {
-       INTN size, j=0;
+       UINTN size, j=0;
        EFI_STATUS status;
        CHAR16 helicopter[4] = { L'|' , L'/' , L'-' , L'\\' };
        INTN ret = ELILO_LOAD_SUCCESS;
@@ -315,7 +317,7 @@ get_memmap(mmap_desc_t *desc)
                }
                desc->map_size += ELILO_MEMMAP_INC;
        }
-       DBG_PRT((L"final get_memmap map_size=%ld", desc->map_size));
+       DBG_PRT((L"final get_memmap map_size=%d", desc->map_size));
 
        return 0;
 }
diff --git a/x86_64/CVS/CVS/Entries b/x86_64/CVS/CVS/Entries
new file mode 100644 (file)
index 0000000..1784810
--- /dev/null
@@ -0,0 +1 @@
+D
diff --git a/x86_64/CVS/CVS/Repository b/x86_64/CVS/CVS/Repository
new file mode 100644 (file)
index 0000000..443a5cb
--- /dev/null
@@ -0,0 +1 @@
+elilo/x86_64/CVS
diff --git a/x86_64/CVS/CVS/Root b/x86_64/CVS/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
diff --git a/x86_64/CVS/Entries b/x86_64/CVS/Entries
new file mode 100644 (file)
index 0000000..0beaa15
--- /dev/null
@@ -0,0 +1,14 @@
+D/CVS////
+/Makefile/1.1/Fri Jul 20 19:10:01 2007//
+/bin_to_h.c/1.1/Fri Jul 20 19:10:01 2007//
+/config.c/1.1/Fri Jul 20 19:10:01 2007//
+/gzip.h/1.1/Fri Jul 20 19:10:01 2007//
+/gzip_loader.c/1.1/Fri Jul 20 19:10:01 2007//
+/inflate.c/1.1/Fri Jul 20 19:10:01 2007//
+/private.h/1.1/Fri Jul 20 19:10:01 2007//
+/rmswitch.S/1.1/Fri Jul 20 19:10:01 2007//
+/gzip.c/1.2/Tue Feb 12 22:16:51 2008//
+/bzimage.c/1.2/Thu Apr  2 19:49:29 2009//
+/plain_loader.c/1.2/Thu Apr  2 19:49:29 2009//
+/sysdeps.h/1.4/Thu Apr  2 19:49:29 2009//
+/system.c/1.5/Thu Apr  2 19:49:29 2009//
diff --git a/x86_64/CVS/Repository b/x86_64/CVS/Repository
new file mode 100644 (file)
index 0000000..41959ab
--- /dev/null
@@ -0,0 +1 @@
+elilo/x86_64
diff --git a/x86_64/CVS/Root b/x86_64/CVS/Root
new file mode 100644 (file)
index 0000000..9b37eff
--- /dev/null
@@ -0,0 +1 @@
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
index 2eb4f462c272db7c18066a6b98f0acbebd5e2d76..8ecae37a596b8242ab175e8098207ed79ec17c59 100644 (file)
@@ -158,13 +158,37 @@ bzImage_probe(CHAR16 *kname)
         * Allocate memory for kernel.
         */
 
-       if (alloc_kmem(kernel_start, EFI_SIZE_TO_PAGES(kernel_size))) {
-               ERR_PRT((L"Could not allocate kernel memory."));
-               return -1;
-       } else {
-               VERB_PRT(3, Print(L"kernel_start: 0x%x  kernel_size: %d\n", 
-                       kernel_start, kernel_size));
+       /*
+        * Get correct address for kernel from header, if applicable & available. 
+        */
+       if ((param_start->s.hdr_major == 2) &&
+           (param_start->s.hdr_minor >= 6) &&
+           (param_start->s.kernel_start >= DEFAULT_KERNEL_START)) {
+               kernel_start = (void *)param_start->s.kernel_start;
+               VERB_PRT(3, Print(L"kernel header suggests kernel start at address "PTR_FMT"\n", 
+                       kernel_start));
        }
+
+       kernel_load_address = kernel_start;
+
+       if (alloc_kmem(kernel_start, EFI_SIZE_TO_PAGES(kernel_size)) != 0) {
+               /*
+                * Couldn't get desired address--just load it anywhere and move it later.
+                * (Easier than relocating kernel, and also works with non-relocatable kernels.)
+                */
+               if (alloc_kmem_anywhere(&kernel_load_address, EFI_SIZE_TO_PAGES(kernel_size)) != 0) {
+                       ERR_PRT((L"Could not allocate memory for kernel."));
+                       free(param_start);
+                       param_start = NULL;
+                       param_size = 0;
+                       fops_close(fd);
+                       return -1;
+               }
+       }
+
+       VERB_PRT(3, Print(L"kernel_start: "PTR_FMT"  kernel_size: %d  loading at: "PTR_FMT"\n", 
+               kernel_start, kernel_size, kernel_load_address));
+
        /*
         * Now read the rest of the kernel image into memory.
         */
@@ -172,7 +196,7 @@ bzImage_probe(CHAR16 *kname)
        DBG_PRT((L"reading kernel image...\n"));
 
        size = kernel_size;
-       efi_status = fops_read(fd, kernel_start, &size);
+       efi_status = fops_read(fd, kernel_load_address, &size);
        if (EFI_ERROR(efi_status) || size < 0x10000) {
                ERR_PRT((L"Error reading kernel image %s.", kname));
                free(param_start);
@@ -200,7 +224,7 @@ bzImage_load(CHAR16 *kname, kdesc_t *kd)
        DBG_PRT((L"load_bzImage_boot()\n"));
 
        if (!kname || !kd) {
-               ERR_PRT((L"kname=0x%x  kd=0x%x", kname, kd));
+               ERR_PRT((L"kname="PTR_FMT"  kd="PTR_FMT"", kname, kd));
                free(param_start);
                param_start = NULL;
                param_size = 0;
@@ -210,7 +234,7 @@ bzImage_load(CHAR16 *kname, kdesc_t *kd)
        kd->kstart = kd->kentry = kernel_start;
        kd->kend = ((UINT8 *)kd->kstart) + kernel_size;
 
-       DBG_PRT((L"kstart=0x%x  kentry=0x%x  kend=0x%x\n", kd->kstart, kd->kentry, kd->kend));
+       DBG_PRT((L"kstart="PTR_FMT"  kentry="PTR_FMT"  kend="PTR_FMT"\n", kd->kstart, kd->kentry, kd->kend));
 
        return 0;
 }
index fdac155221959ba1628e26bad2d77d0c78b3367e..c683c503bb59917b51b786a93261ec30bbe3be1e 100644 (file)
@@ -156,7 +156,7 @@ gzip_free(void *where)
 int
 fill_inbuf(void)
 {
-       INTN expected, nread;
+       UINTN expected, nread;
        EFI_STATUS status;
 
        expected = nread = INBUFSIZE;
@@ -280,7 +280,7 @@ analyze_chunks(void)
  * the relevant header information.
  */
 int
-first_block (const char *buf, long blocksize)
+first_block (const unsigned char *buf, long blocksize)
 {
        Elf64_Ehdr *elf;
        Elf64_Phdr *phdrs;
@@ -433,7 +433,7 @@ flush_window(void)
        static const CHAR8 helicopter[4] = { '|' , '/' , '-' , '\\' };
        static UINTN heli_count;
        struct segment *cp;
-       char    *src, *dst;
+       unsigned char   *src, *dst;
        long    cnt;
 
        if (!outcnt) return;
@@ -471,7 +471,7 @@ tail:
                file_offset += skip;
                outcnt      -= skip;
        }
-       dst = (char *)cp->addr + (file_offset - cp->offset);
+       dst = (unsigned char *)cp->addr + (file_offset - cp->offset);
        cnt = cp->offset + cp->size - file_offset;
        if (cnt > outcnt) 
                cnt = outcnt;
@@ -485,7 +485,7 @@ tail:
        /* See if we are at the end of this chunk */
        if (file_offset == cp->offset + cp->size) {
                if (cp->bss_sz) {
-                       dst = (char *)cp->addr + cp->size;
+                       dst = (unsigned char *)cp->addr + cp->size;
                        Memset(dst, 0, cp->bss_sz);
                }
                nextchunk();
index 13cc9e5b264aa7060f90fc6efebd5b8f2140bc63..0e1b5be66cbe8c902b8157a69008141239f2ff16 100644 (file)
@@ -119,7 +119,7 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
        }        
        VERB_PRT(3, {
                Print(L"ELF Header information: \n");
-               Print(L"\tEntry point 0x%x\n", (ehdr.e_entry & PADDR_MASK));
+               Print(L"\tEntry point "PTR_FMT"\n", (ehdr.e_entry & PADDR_MASK));
                Print(L"\t%d program headers\n", ehdr.e_phnum);
                Print(L"\t%d segment headers\n", ehdr.e_shnum);
        });
@@ -153,8 +153,8 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
                paddr = (phdrs[i].p_paddr & PADDR_MASK);
                memsz = phdrs[i].p_memsz;
 
-               DBG_PRT((L"Phdr %d paddr [0x%x-0x%x] offset 0x%x"
-                       " filesz 0x%x memsz=0x%x bss_sz=0x%x p_type=0x%x\n",
+               DBG_PRT((L"Phdr %d paddr ["PTR_FMT"-"PTR_FMT"] offset "PTR_FMT""
+                       " filesz "PTR_FMT" memsz="PTR_FMT" bss_sz="PTR_FMT" p_type="PTR_FMT"\n",
                        1+i, paddr, paddr+phdrs[i].p_filesz, phdrs[i].p_offset, 
                        phdrs[i].p_filesz, memsz, 
                        (memsz - phdrs[i].p_filesz), phdrs[i].p_type));
@@ -168,7 +168,7 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
        }
 
        if ((UINTN)low_addr & (EFI_PAGE_SIZE - 1)) {
-               ERR_PRT((L"%s : kernel low address 0x%x not page aligned\n", 
+               ERR_PRT((L"%s : kernel low address "PTR_FMT" not page aligned\n", 
                        LD_NAME, low_addr));
                goto out;
        }
@@ -184,9 +184,9 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
        kd->kentry = (VOID *)(ehdr.e_entry & PADDR_MASK);
        
        VERB_PRT(3, {
-               Print(L"Lowest PhysAddr: 0x%x\nTotalMemSize:%d bytes (%d pages)\n",
+               Print(L"Lowest PhysAddr: "PTR_FMT"\nTotalMemSize:%d bytes (%d pages)\n",
                        low_addr, total_size, pages);
-               Print(L"Kernel entry @ 0x%x\n", kd->kentry);
+               Print(L"Kernel entry @ "PTR_FMT"\n", kd->kentry);
        });
        
        /* now allocate memory for the kernel at the exact requested spot */
@@ -213,7 +213,7 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
                if (phdrs[i].p_type != PT_LOAD)
                        continue;
 
-               VERB_PRT(3, Print(L"poffs: 0x%x (phdrs[%d].p_offset)\n", 
+               VERB_PRT(3, Print(L"poffs: "PTR_FMT" (phdrs[%d].p_offset)\n", 
                        phdrs[i].p_offset, i));
 
                filesz = phdrs[i].p_filesz;
@@ -228,9 +228,9 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
 
                VERB_PRT(4, {
                        Print(L"\nHeader #%d\n", i);
-                       Print(L"Offset in file 0x%x\n", phdrs[i].p_offset);
-                       Print(L"Physical addr 0x%x\n", low_addr);
-                       Print(L"BSS size 0x%x bytes\n", bss_sz);
+                       Print(L"Offset in file "PTR_FMT"\n", phdrs[i].p_offset);
+                       Print(L"Physical addr "PTR_FMT"\n", low_addr);
+                       Print(L"BSS size %d bytes\n", bss_sz);
                });
 
                /*
index af89cb186f8a74d080ad79fdd9759985fe6a381f..338aa40bfbb6aa4ed28f2e543fe6ad0dfc52b559 100644 (file)
  */
 #define INITRD_START   (50*1024*1024)
 
+/* Default start address for kernel. */
+#define DEFAULT_KERNEL_START   0x100000
+
+
 /*
  * This version must match the one in the kernel.
  *
@@ -307,10 +311,16 @@ typedef union x86_64_boot_params {
        UINT8 *t = (UINT8 *)(to); \
        UINT8 *f = (UINT8 *)(from); \
        UINTN n = cnt; \
-       if (t && f && n) { \
+       if (t && f && n && (t<f)) { \
                while (n--) { \
                        *t++ = *f++; \
                } \
+       } else if (t && f && n && (t>f)) { \
+               t += n; \
+               f += n; \
+               while (n--) { \
+                       *t-- = *f--; \
+               } \
        } \
 }
 
@@ -343,6 +353,7 @@ extern UINTN param_size;
 
 extern VOID *kernel_start;
 extern UINTN kernel_size;
+extern VOID *kernel_load_address;
 
 extern VOID *initrd_start;
 extern UINTN initrd_size;
@@ -370,8 +381,8 @@ start_kernel(VOID *kentry, boot_params_t *bp)
                UINT32  kernel_entry;
                UINT16  kernel_cs;
        } jumpvector;
-       UINTN   njump;
        VOID    *jump_start;
+       uint64_t temp;
 
        /*
         * Disable interrupts.
@@ -379,11 +390,20 @@ start_kernel(VOID *kentry, boot_params_t *bp)
        asm volatile ( "cli" : : );
 
        /*
-        * Relocate initrd, if present.
+        * Relocate kernel (if needed), and initrd (if present).
+        * Copy kernel first, in case kernel was loaded overlapping where we're
+        * planning to copy the initrd.  This assumes that the initrd didn't
+        * get loaded overlapping where we're planning to copy the kernel, but
+        * that's pretty unlikely since we couldn't alloc that space for the
+        * kernel (or the kernel would already be there).
         */
+       if (kernel_start != kernel_load_address) {
+               MEMCPY(kernel_start, kernel_load_address, kernel_size);
+       }
 
        if (bp->s.initrd_start) {
-               MEMCPY(INITRD_START, bp->s.initrd_start, bp->s.initrd_size);
+               temp =  bp->s.initrd_start;
+               MEMCPY(INITRD_START, temp , bp->s.initrd_size);
                bp->s.initrd_start = INITRD_START;
        }
        /*
@@ -434,14 +454,15 @@ start_kernel(VOID *kentry, boot_params_t *bp)
 
        /*
         * Jump to kernel entry point.
+        *
+        * Cast is to tell gcc that we know we're going from
+        * 64-bit ptr to 32-bit integer.
         */
-       jumpvector.kernel_entry=kentry;
+       jumpvector.kernel_entry=(UINT32)((UINT64)kentry);
        jumpvector.kernel_cs=0x10;
-       njump = &jumpvector;
        jump_start = (VOID *)&jumpvector;
        //asm volatile ( "mov %0, %%rcx" : : "m" (&jumpvector) );
        asm volatile ( "mov %0, %%rcx" : : "m" (jump_start) );
-       //asm volatile ( "mov %0, %%rcx" : : "m" (njump) );
        asm volatile ( "ljmp *(%%rcx)" : :);
        /* Never come back to here. */
 }
index 72c094fad9381745c86b9b2b4e3d49b46e615a91..6874acc51aa32e2eea7b9d07231a06e916211624 100644 (file)
@@ -105,7 +105,10 @@ UINTN high_base_mem = 0x90000;
 UINTN high_ext_mem = 32 * 1024 * 1024;
 
 /* This starting address will hold true for all of the loader types for now */
-VOID *kernel_start = (VOID *)0x100000; /* 1M */
+VOID *kernel_start = (void *)DEFAULT_KERNEL_START;
+
+/* The kernel may load elsewhere if EFI firmware reserves kernel_start */
+VOID *kernel_load_address = DEFAULT_KERNEL_START; 
 
 VOID *initrd_start = NULL;
 UINTN initrd_size = 0;
@@ -139,16 +142,16 @@ sysdeps_initrd_get_addr(kdesc_t *kd, memdesc_t *imem)
        DBG_PRT((L"initrd_get_addr()\n"));
 
        if (!kd || !imem) {
-               ERR_PRT((L"kd=0x%x imem=0x%x", kd, imem));
+               ERR_PRT((L"kd="PTR_FMT" imem="PTR_FMT"", kd, imem));
                return -1;
        }
 
-       VERB_PRT(3, Print(L"kstart=0x%x  kentry=0x%x  kend=0x%x\n", 
+       VERB_PRT(3, Print(L"kstart="PTR_FMT"  kentry="PTR_FMT"  kend="PTR_FMT"\n", 
                kd->kstart, kd->kentry, kd->kend));
 
        imem->start_addr = kd->kend;
 
-       VERB_PRT(3, Print(L"initrd start_addr=0x%x pgcnt=%d\n", 
+       VERB_PRT(3, Print(L"initrd start_addr="PTR_FMT" pgcnt=%d\n", 
                imem->start_addr, imem->pgcnt));
 
        return 0;
@@ -160,7 +163,7 @@ sysdeps_free_boot_params(boot_params_t *bp)
        mmap_desc_t md;
 
        ZeroMem(&md, sizeof md);
-       md.md = (VOID *)bp->s.efi_mem_map;
+       md.md = (VOID *)(UINT64)bp->s.efi_mem_map;
        free_memmap(&md);
 }
 
@@ -189,10 +192,11 @@ static INTN get_video_info(boot_params_t * bp) {
         EFI_GUID GopProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
         EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop_interface;
         EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Gop_info;
-        EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE   *Gop_mode;
-        EFI_HANDLE *Gop_handle;
+        EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE   *Gop_mode = NULL;
+        EFI_HANDLE *Gop_handle = NULL;
         EFI_STATUS efi_status;
-        UINTN size, size1;
+        UINTN size = 0;
+        UINTN size1;
         UINT8 i;
 
        efi_status = uefi_call_wrapper(
@@ -459,7 +463,7 @@ sysdeps_create_boot_params(
        DBG_PRT((L"fill_boot_params()\n"));
 
        if (!bp || !cmdline || !initrd || !cookie) {
-               ERR_PRT((L"bp=0x%x  cmdline=0x%x  initrd=0x%x cookie=0x%x",
+               ERR_PRT((L"bp="PTR_FMT"  cmdline="PTR_FMT"  initrd="PTR_FMT" cookie="PTR_FMT"",
                        bp, cmdline, initrd, cookie));
 
                if (param_start != NULL) {
@@ -546,7 +550,7 @@ sysdeps_create_boot_params(
         * Initial RAMdisk and root device stuff.
         */
 
-       DBG_PRT((L"initrd->start_addr=0x%x  initrd->pgcnt=%d\n",
+       DBG_PRT((L"initrd->start_addr="PTR_FMT"  initrd->pgcnt=%d\n",
                initrd->start_addr, initrd->pgcnt));
 
        /* These RAMdisk flags are not needed, just zero them. */
@@ -554,7 +558,7 @@ sysdeps_create_boot_params(
 
        if (initrd->start_addr && initrd->pgcnt) {
                /* %%TBD - This will probably have to be changed. */
-               bp->s.initrd_start = (UINT32)initrd->start_addr;
+               bp->s.initrd_start = (UINT32)(UINT64)initrd->start_addr;
                bp->s.initrd_size = (UINT32)(initrd->size);
                /*
                 * This is the RAMdisk root device for RedHat 2.2.x
@@ -598,7 +602,7 @@ sysdeps_create_boot_params(
        /*
         * Kernel entry point.
         */
-       bp->s.kernel_start = (UINT32)kernel_start;
+       bp->s.kernel_start = (UINT32)(UINT64)kernel_start;
 
        /*
         * When changing stuff in the parameter structure compare