release 3.10
https://sourceforge.net/projects/elilo/files/elilo/elilo-3.10/ (sans a few CVS directories)
This commit is contained in:
parent
34d8003a54
commit
4e87874a03
35 changed files with 412 additions and 235 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
/*
|
||||
|
|
|
@ -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 && (t<f)) { \
|
||||
while (n--) { \
|
||||
*t++ = *f++; \
|
||||
} \
|
||||
} else if (t && f && n && (t>f)) { \
|
||||
t += n; \
|
||||
f += n; \
|
||||
while (n--) { \
|
||||
*t-- = *f--; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
@ -343,6 +353,7 @@ extern UINTN param_size;
|
|||
|
||||
extern VOID *kernel_start;
|
||||
extern UINTN kernel_size;
|
||||
extern VOID *kernel_load_address;
|
||||
|
||||
extern VOID *initrd_start;
|
||||
extern UINTN initrd_size;
|
||||
|
@ -370,8 +381,8 @@ start_kernel(VOID *kentry, boot_params_t *bp)
|
|||
UINT32 kernel_entry;
|
||||
UINT16 kernel_cs;
|
||||
} jumpvector;
|
||||
UINTN njump;
|
||||
VOID *jump_start;
|
||||
uint64_t temp;
|
||||
|
||||
/*
|
||||
* Disable interrupts.
|
||||
|
@ -379,11 +390,20 @@ start_kernel(VOID *kentry, boot_params_t *bp)
|
|||
asm volatile ( "cli" : : );
|
||||
|
||||
/*
|
||||
* Relocate initrd, if present.
|
||||
* Relocate kernel (if needed), and initrd (if present).
|
||||
* Copy kernel first, in case kernel was loaded overlapping where we're
|
||||
* planning to copy the initrd. This assumes that the initrd didn't
|
||||
* get loaded overlapping where we're planning to copy the kernel, but
|
||||
* that's pretty unlikely since we couldn't alloc that space for the
|
||||
* kernel (or the kernel would already be there).
|
||||
*/
|
||||
if (kernel_start != kernel_load_address) {
|
||||
MEMCPY(kernel_start, kernel_load_address, kernel_size);
|
||||
}
|
||||
|
||||
if (bp->s.initrd_start) {
|
||||
MEMCPY(INITRD_START, bp->s.initrd_start, bp->s.initrd_size);
|
||||
temp = bp->s.initrd_start;
|
||||
MEMCPY(INITRD_START, temp , bp->s.initrd_size);
|
||||
bp->s.initrd_start = INITRD_START;
|
||||
}
|
||||
/*
|
||||
|
@ -434,14 +454,15 @@ start_kernel(VOID *kentry, boot_params_t *bp)
|
|||
|
||||
/*
|
||||
* Jump to kernel entry point.
|
||||
*
|
||||
* Cast is to tell gcc that we know we're going from
|
||||
* 64-bit ptr to 32-bit integer.
|
||||
*/
|
||||
jumpvector.kernel_entry=kentry;
|
||||
jumpvector.kernel_entry=(UINT32)((UINT64)kentry);
|
||||
jumpvector.kernel_cs=0x10;
|
||||
njump = &jumpvector;
|
||||
jump_start = (VOID *)&jumpvector;
|
||||
//asm volatile ( "mov %0, %%rcx" : : "m" (&jumpvector) );
|
||||
asm volatile ( "mov %0, %%rcx" : : "m" (jump_start) );
|
||||
//asm volatile ( "mov %0, %%rcx" : : "m" (njump) );
|
||||
asm volatile ( "ljmp *(%%rcx)" : :);
|
||||
/* Never come back to here. */
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue