From 3384f0373c8758e5ddd08f489ad7110898dd5406 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Fri, 3 Apr 2009 16:13:12 -0600 Subject: [PATCH] Imported Upstream version 3.10 --- ChangeLog | 21 ++++++++++ Make.defaults | 2 +- alloc.c | 27 +++++++++---- alternate.c | 2 +- bootparams.c | 2 +- choosers/CVS/Entries | 6 +++ choosers/CVS/Repository | 1 + choosers/CVS/Root | 1 + choosers/simple.c | 2 +- choosers/textmenu.c | 4 +- devschemes/CVS/Entries | 3 ++ devschemes/CVS/Repository | 1 + devschemes/CVS/Root | 1 + docs/CVS/Entries | 10 +++++ docs/CVS/Repository | 1 + docs/CVS/Root | 1 + elilo.c | 16 +++++--- elilo.h | 9 ++++- examples/CVS/Entries | 2 + examples/CVS/Repository | 1 + examples/CVS/Root | 1 + examples/netboot/CVS/Entries | 3 ++ examples/netboot/CVS/Repository | 1 + examples/netboot/CVS/Root | 1 + examples/textmenu_chooser/CVS/Entries | 5 +++ examples/textmenu_chooser/CVS/Repository | 1 + examples/textmenu_chooser/CVS/Root | 1 + fs/CVS/Entries | 13 ++++++ fs/CVS/Repository | 1 + fs/CVS/Root | 1 + fs/ext2fs.c | 4 +- fs/netfs.c | 4 +- ia32/CVS/Entries | 12 ++++++ ia32/CVS/Repository | 1 + ia32/CVS/Root | 1 + ia32/bzimage.c | 51 ++++++++++++++++++------ ia32/gzip.c | 30 +++++++------- ia32/plain_loader.c | 24 +++++------ ia32/sysdeps.h | 46 +++++++++++++++------ ia32/system.c | 48 ++++++++++++++++------ ia64/CVS/Entries | 15 +++++++ ia64/CVS/Repository | 1 + ia64/CVS/Root | 1 + ia64/fpswa.c | 2 +- ia64/gzip.c | 14 +++---- ia64/longjmp.S | 2 +- ia64/plain_loader.c | 2 +- ia64/setjmp.S | 5 ++- ia64/sysdeps.h | 6 +-- inflate.c | 8 ++-- initrd.c | 4 +- loader.c | 6 +++ tools/CVS/Entries | 3 ++ tools/CVS/Repository | 1 + tools/CVS/Root | 1 + util.c | 6 ++- x86_64/CVS/CVS/Entries | 1 + x86_64/CVS/CVS/Repository | 1 + x86_64/CVS/CVS/Root | 1 + x86_64/CVS/Entries | 14 +++++++ x86_64/CVS/Repository | 1 + x86_64/CVS/Root | 1 + x86_64/bzimage.c | 42 ++++++++++++++----- x86_64/gzip.c | 10 ++--- x86_64/plain_loader.c | 20 +++++----- x86_64/sysdeps.h | 35 ++++++++++++---- x86_64/system.c | 28 +++++++------ 67 files changed, 441 insertions(+), 152 deletions(-) create mode 100644 choosers/CVS/Entries create mode 100644 choosers/CVS/Repository create mode 100644 choosers/CVS/Root create mode 100644 devschemes/CVS/Entries create mode 100644 devschemes/CVS/Repository create mode 100644 devschemes/CVS/Root create mode 100644 docs/CVS/Entries create mode 100644 docs/CVS/Repository create mode 100644 docs/CVS/Root create mode 100644 examples/CVS/Entries create mode 100644 examples/CVS/Repository create mode 100644 examples/CVS/Root create mode 100644 examples/netboot/CVS/Entries create mode 100644 examples/netboot/CVS/Repository create mode 100644 examples/netboot/CVS/Root create mode 100644 examples/textmenu_chooser/CVS/Entries create mode 100644 examples/textmenu_chooser/CVS/Repository create mode 100644 examples/textmenu_chooser/CVS/Root create mode 100644 fs/CVS/Entries create mode 100644 fs/CVS/Repository create mode 100644 fs/CVS/Root create mode 100644 ia32/CVS/Entries create mode 100644 ia32/CVS/Repository create mode 100644 ia32/CVS/Root create mode 100644 ia64/CVS/Entries create mode 100644 ia64/CVS/Repository create mode 100644 ia64/CVS/Root create mode 100644 tools/CVS/Entries create mode 100644 tools/CVS/Repository create mode 100644 tools/CVS/Root create mode 100644 x86_64/CVS/CVS/Entries create mode 100644 x86_64/CVS/CVS/Repository create mode 100644 x86_64/CVS/CVS/Root create mode 100644 x86_64/CVS/Entries create mode 100644 x86_64/CVS/Repository create mode 100644 x86_64/CVS/Root diff --git a/ChangeLog b/ChangeLog index 2dbab82..998cdc7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2008-04-02 signed off by Jason Fleischli + * 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 + * Various compile warning cleanups. 2008-01-03 signed off by Jason Fleischli * Patch contribution from Scott Davilla when x is zero for the first call to add_memory_region, e820_map[-1] diff --git a/Make.defaults b/Make.defaults index 0558a58..061b75c 100644 --- a/Make.defaults +++ b/Make.defaults @@ -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 358939a..f087804 100644 --- 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 diff --git a/alternate.c b/alternate.c index 992e9bd..691adc7 100644 --- a/alternate.c +++ b/alternate.c @@ -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; diff --git a/bootparams.c b/bootparams.c index 1a2c54b..da3d664 100644 --- a/bootparams.c +++ b/bootparams.c @@ -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 index 0000000..a35ed42 --- /dev/null +++ b/choosers/CVS/Entries @@ -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 index 0000000..1dc4311 --- /dev/null +++ b/choosers/CVS/Repository @@ -0,0 +1 @@ +elilo/choosers diff --git a/choosers/CVS/Root b/choosers/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/choosers/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/choosers/simple.c b/choosers/simple.c index 5525086..9d90fd6 100644 --- a/choosers/simple.c +++ b/choosers/simple.c @@ -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]; diff --git a/choosers/textmenu.c b/choosers/textmenu.c index 400d4f6..57e3eae 100644 --- a/choosers/textmenu.c +++ b/choosers/textmenu.c @@ -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 index 0000000..0c4589e --- /dev/null +++ b/devschemes/CVS/Entries @@ -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 index 0000000..113f9e4 --- /dev/null +++ b/devschemes/CVS/Repository @@ -0,0 +1 @@ +elilo/devschemes diff --git a/devschemes/CVS/Root b/devschemes/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/devschemes/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/docs/CVS/Entries b/docs/CVS/Entries new file mode 100644 index 0000000..b47f5e9 --- /dev/null +++ b/docs/CVS/Entries @@ -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 index 0000000..d9749c6 --- /dev/null +++ b/docs/CVS/Repository @@ -0,0 +1 @@ +elilo/docs diff --git a/docs/CVS/Root b/docs/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/docs/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/elilo.c b/elilo.c index ad1b555..50ee71c 100644 --- a/elilo.c +++ b/elilo.c @@ -46,13 +46,15 @@ #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 74f740d..ae43705 100644 --- a/elilo.h +++ b/elilo.h @@ -31,6 +31,12 @@ #include +#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 index 0000000..e5b9381 --- /dev/null +++ b/examples/CVS/Entries @@ -0,0 +1,2 @@ +D/netboot//// +D/textmenu_chooser//// diff --git a/examples/CVS/Repository b/examples/CVS/Repository new file mode 100644 index 0000000..74109b7 --- /dev/null +++ b/examples/CVS/Repository @@ -0,0 +1 @@ +elilo/examples diff --git a/examples/CVS/Root b/examples/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/examples/CVS/Root @@ -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 index 0000000..85497e3 --- /dev/null +++ b/examples/netboot/CVS/Entries @@ -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 index 0000000..3654f07 --- /dev/null +++ b/examples/netboot/CVS/Repository @@ -0,0 +1 @@ +elilo/examples/netboot diff --git a/examples/netboot/CVS/Root b/examples/netboot/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/examples/netboot/CVS/Root @@ -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 index 0000000..88509c8 --- /dev/null +++ b/examples/textmenu_chooser/CVS/Entries @@ -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 index 0000000..881448e --- /dev/null +++ b/examples/textmenu_chooser/CVS/Repository @@ -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 index 0000000..9b37eff --- /dev/null +++ b/examples/textmenu_chooser/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/fs/CVS/Entries b/fs/CVS/Entries new file mode 100644 index 0000000..c6795ce --- /dev/null +++ b/fs/CVS/Entries @@ -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 index 0000000..b8990a8 --- /dev/null +++ b/fs/CVS/Repository @@ -0,0 +1 @@ +elilo/fs diff --git a/fs/CVS/Root b/fs/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/fs/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/fs/ext2fs.c b/fs/ext2fs.c index bec47fe..a0a9d87 100644 --- a/fs/ext2fs.c +++ b/fs/ext2fs.c @@ -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; } diff --git a/fs/netfs.c b/fs/netfs.c index 063f4e5..abef2ab 100644 --- a/fs/netfs.c +++ b/fs/netfs.c @@ -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 index 0000000..fa43e88 --- /dev/null +++ b/ia32/CVS/Entries @@ -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 index 0000000..0651ef2 --- /dev/null +++ b/ia32/CVS/Repository @@ -0,0 +1 @@ +elilo/ia32 diff --git a/ia32/CVS/Root b/ia32/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/ia32/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/ia32/bzimage.c b/ia32/bzimage.c index aac1d37..0dd0772 100644 --- a/ia32/bzimage.c +++ b/ia32/bzimage.c @@ -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; } diff --git a/ia32/gzip.c b/ia32/gzip.c index fff5f6d..cc801ad 100644 --- a/ia32/gzip.c +++ b/ia32/gzip.c @@ -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(); diff --git a/ia32/plain_loader.c b/ia32/plain_loader.c index ac4c573..5ad1a94 100644 --- a/ia32/plain_loader.c +++ b/ia32/plain_loader.c @@ -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); }); /* diff --git a/ia32/sysdeps.h b/ia32/sysdeps.h index ecfb536..bb3dc7e 100644 --- a/ia32/sysdeps.h +++ b/ia32/sysdeps.h @@ -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 && (tf)) { \ + 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 diff --git a/ia32/system.c b/ia32/system.c index 00a1f0a..078d406 100644 --- a/ia32/system.c +++ b/ia32/system.c @@ -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 index 0000000..6157a21 --- /dev/null +++ b/ia64/CVS/Entries @@ -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 index 0000000..cb65f9c --- /dev/null +++ b/ia64/CVS/Repository @@ -0,0 +1 @@ +elilo/ia64 diff --git a/ia64/CVS/Root b/ia64/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/ia64/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/ia64/fpswa.c b/ia64/fpswa.c index a19d7cb..daa86e1 100644 --- a/ia64/fpswa.c +++ b/ia64/fpswa.c @@ -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) { diff --git a/ia64/gzip.c b/ia64/gzip.c index 01e28c8..a27d622 100644 --- a/ia64/gzip.c +++ b/ia64/gzip.c @@ -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(); diff --git a/ia64/longjmp.S b/ia64/longjmp.S index 8b66893..23dec86 100644 --- a/ia64/longjmp.S +++ b/ia64/longjmp.S @@ -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 diff --git a/ia64/plain_loader.c b/ia64/plain_loader.c index 150f7a0..ad38885 100644 --- a/ia64/plain_loader.c +++ b/ia64/plain_loader.c @@ -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")); diff --git a/ia64/setjmp.S b/ia64/setjmp.S index 4bc2103..4c83d03 100644 --- a/ia64/setjmp.S +++ b/ia64/setjmp.S @@ -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 diff --git a/ia64/sysdeps.h b/ia64/sysdeps.h index e11e6b7..9d893e6 100644 --- a/ia64/sysdeps.h +++ b/ia64/sysdeps.h @@ -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; diff --git a/inflate.c b/inflate.c index 843c93b..157dfc2 100644 --- 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 */ diff --git a/initrd.c b/initrd.c index ac3b91d..581abda 100644 --- 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); diff --git a/loader.c b/loader.c index 290531c..f0708bd 100644 --- 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 index 0000000..14dba2d --- /dev/null +++ b/tools/CVS/Entries @@ -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 index 0000000..f44a1d8 --- /dev/null +++ b/tools/CVS/Repository @@ -0,0 +1 @@ +elilo/tools diff --git a/tools/CVS/Root b/tools/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/tools/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/util.c b/util.c index 84e76cc..f5e0072 100644 --- 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 index 0000000..1784810 --- /dev/null +++ b/x86_64/CVS/CVS/Entries @@ -0,0 +1 @@ +D diff --git a/x86_64/CVS/CVS/Repository b/x86_64/CVS/CVS/Repository new file mode 100644 index 0000000..443a5cb --- /dev/null +++ b/x86_64/CVS/CVS/Repository @@ -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 index 0000000..9b37eff --- /dev/null +++ b/x86_64/CVS/CVS/Root @@ -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 index 0000000..0beaa15 --- /dev/null +++ b/x86_64/CVS/Entries @@ -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 index 0000000..41959ab --- /dev/null +++ b/x86_64/CVS/Repository @@ -0,0 +1 @@ +elilo/x86_64 diff --git a/x86_64/CVS/Root b/x86_64/CVS/Root new file mode 100644 index 0000000..9b37eff --- /dev/null +++ b/x86_64/CVS/Root @@ -0,0 +1 @@ +fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo diff --git a/x86_64/bzimage.c b/x86_64/bzimage.c index 2eb4f46..8ecae37 100644 --- a/x86_64/bzimage.c +++ b/x86_64/bzimage.c @@ -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; } diff --git a/x86_64/gzip.c b/x86_64/gzip.c index fdac155..c683c50 100644 --- a/x86_64/gzip.c +++ b/x86_64/gzip.c @@ -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(); diff --git a/x86_64/plain_loader.c b/x86_64/plain_loader.c index 13cc9e5..0e1b5be 100644 --- a/x86_64/plain_loader.c +++ b/x86_64/plain_loader.c @@ -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); }); /* diff --git a/x86_64/sysdeps.h b/x86_64/sysdeps.h index af89cb1..338aa40 100644 --- a/x86_64/sysdeps.h +++ b/x86_64/sysdeps.h @@ -47,6 +47,10 @@ */ #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 && (tf)) { \ + 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. */ } diff --git a/x86_64/system.c b/x86_64/system.c index 72c094f..6874acc 100644 --- a/x86_64/system.c +++ b/x86_64/system.c @@ -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 -- 2.30.2