+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]
OPTIMFLAGS = -O2
DEBUGFLAGS = -Wall
-CFLAGS = $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
+CFLAGS = $(OPTIMFLAGS) -fno-strict-aliasing -fpic -fshort-wchar $(DEBUGFLAGS)
LDFLAGS = -nostdlib -znocombreloc
INSTALL = install
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;
}
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));
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);
}
}
+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)
{
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
* 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;
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
--- /dev/null
+/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
--- /dev/null
+elilo/choosers
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
{
fops_fd_t fd;
EFI_STATUS status;
- INTN len, i;
+ UINTN len, i;
CHAR16 *filename;
CHAR8 buf[256];
}
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;
--- /dev/null
+/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
--- /dev/null
+elilo/devschemes
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
--- /dev/null
+/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
--- /dev/null
+elilo/docs
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
#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:
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)) {
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();
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
*/
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...
#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"
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);
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 *);
--- /dev/null
+D/netboot////
+D/textmenu_chooser////
--- /dev/null
+elilo/examples
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
--- /dev/null
+/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
--- /dev/null
+elilo/examples/netboot
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
--- /dev/null
+/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
--- /dev/null
+elilo/examples/textmenu_chooser
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
--- /dev/null
+/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
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
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)) {
}
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;
}
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:
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,
--- /dev/null
+/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
--- /dev/null
+elilo/ia32
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
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;
}
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.",
{
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)) {
* 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.
*/
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);
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;
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;
}
int
fill_inbuf(void)
{
- INTN expected, nread;
+ UINTN expected, nread;
EFI_STATUS status;
expected = nread = INBUFSIZE;
* 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;
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;
}
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));
}
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));
/* 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;
}
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]);
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;
/* 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();
}
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);
});
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));
}
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;
}
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;
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;
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);
});
/*
#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))
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) { \
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;
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
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;
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;
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.
*/
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(
3,
*Gop_handle,
&GopProtocol,
- &Gop_interface);
+ (VOID **) &Gop_interface);
if (EFI_ERROR(efi_status)) {
continue;
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) {
* 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. */
#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) { \
; \
} \
}
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,
--- /dev/null
+/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
--- /dev/null
+elilo/ia64
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
#endif
};
UINTN j, count = sizeof(fpswa_filenames)/sizeof(CHAR16 *);
- INTN cookie;
+ UINTN cookie;
CHAR16 devname[FILENAME_MAXLEN];
if (fpswa_file) {
int
fill_inbuf(void)
{
- INTN expected, nread;
+ UINTN expected, nread;
EFI_STATUS status;
expected = nread = INBUFSIZE;
* 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;
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"));
/* 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
static const CHAR8 helicopter[4] = { '|' , '/' , '-' , '\\' };
static UINTN heli_count;
struct segment *cp;
- char *src, *dst;
+ unsigned char *src, *dst;
long cnt;
if (!outcnt) return;
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;
/* 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();
invala // virt. -> phys. regnum mapping may change
mov pr=r24,-1
br.ret.dptk.few rp
- .endp __longjmp
+ .endp longjmp
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"));
.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
;;
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
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
stf.spill.nta [r9]=f31
st8.spill.nta [r2]=r6,16 // r6
+ ;;
st8.spill.nta [r3]=r7,16 // r7
;;
mov r23=ar.bsp
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;
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;
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 */
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);
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;
}
--- /dev/null
+/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
--- /dev/null
+elilo/tools
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
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
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;
}
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;
}
--- /dev/null
+elilo/x86_64/CVS
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
--- /dev/null
+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//
--- /dev/null
+elilo/x86_64
--- /dev/null
+fleischli@elilo.cvs.sourceforge.net:/cvsroot/elilo
* 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.
*/
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);
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;
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;
}
int
fill_inbuf(void)
{
- INTN expected, nread;
+ UINTN expected, nread;
EFI_STATUS status;
expected = nread = INBUFSIZE;
* 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;
static const CHAR8 helicopter[4] = { '|' , '/' , '-' , '\\' };
static UINTN heli_count;
struct segment *cp;
- char *src, *dst;
+ unsigned char *src, *dst;
long cnt;
if (!outcnt) return;
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;
/* 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();
}
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);
});
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));
}
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;
}
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 (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;
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);
});
/*
*/
#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.
*
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--; \
+ } \
} \
}
extern VOID *kernel_start;
extern UINTN kernel_size;
+extern VOID *kernel_load_address;
extern VOID *initrd_start;
extern UINTN initrd_size;
UINT32 kernel_entry;
UINT16 kernel_cs;
} jumpvector;
- UINTN njump;
VOID *jump_start;
+ uint64_t 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) {
- 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;
}
/*
/*
* 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. */
}
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;
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;
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);
}
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(
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) {
* 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. */
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
/*
* 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