Stephane Eranian 2005-12-06 08:21:36 -05:00 committed by Vincent Batts
parent cb533a5de5
commit 6a4d7e49dc
29 changed files with 523 additions and 1389 deletions

View file

@ -37,6 +37,8 @@
#include "private.h"
#include "setjmp.h"
#define LD_NAME L"gzip_ia64"
#define memzero(s, n) Memset((VOID *)(s), 0, (n))
#define memcpy(a,b,n) Memcpy((VOID *)(a),(b),(n))
@ -68,6 +70,7 @@ typedef struct segment {
#define CHUNK_FL_VALID 0x1
#define CHUNK_FL_LOAD 0x2
#define CHUNK_FL_X 0x4
#define CHUNK_CAN_LOAD(n) chunks[(n)].flags |= CHUNK_FL_LOAD
#define CHUNK_NO_LOAD(n) chunks[(n)].flags &= ~CHUNK_FL_LOAD
@ -391,6 +394,9 @@ first_block (const char *buf, long blocksize)
continue;
}
if (bswap32(phdrs[i].p_flags) & PF_X)
chunks[i].flags |= CHUNK_FL_X;
CHUNK_CAN_LOAD(i); /* mark no load chunk */
VERB_PRT(3,
@ -433,7 +439,7 @@ first_block (const char *buf, long blocksize)
if (alloc_kmem((void *)low_addr, pages) == -1) {
VOID *new_addr;
ERR_PRT((L"%s : AllocatePages(%d, 0x%lx) for kernel failed\n", LD_NAME, pages, low_addr));
VERB_PRT(1, (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"));
@ -458,7 +464,7 @@ first_block (const char *buf, long blocksize)
/* unsigned arithmetic */
load_offset = (UINTN) (new_addr - ROUNDDOWN((UINTN) low_addr,256*MB));
ERR_PRT((L"low_addr=0x%lx new_addr=0x%lx offset=0x%lx", low_addr, new_addr, load_offset));
VERB_PRT(1, (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
@ -566,6 +572,8 @@ tail:
if (cnt > outcnt) cnt = outcnt;
Memcpy(dst, src, cnt);
if (cp->flags & CHUNK_FL_X)
flush_dcache (dst, cnt);
file_offset += cnt;
outcnt -= cnt;

View file

@ -1,35 +0,0 @@
/*
* Copyright (C) 2001-2003 Hewlett-Packard Co.
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
*
* This file is part of the ELILO, the EFI Linux boot loader.
*
* ELILO is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* ELILO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ELILO; see the file COPYING. If not, write to the Free
* Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Please check out the elilo.txt for complete documentation on how
* to use this program.
*/
#ifndef __GZIP_H__
#define __GZIP_H__
int gzip_probe(unsigned char *, unsigned long);
int gunzip_kernel(fops_fd_t, kdesc_t *);
#define LD_NAME L"gzip_ia64"
#endif /* __GZIP_H__ */

View file

@ -30,6 +30,8 @@
#include "loader.h"
#include "gzip.h"
#define LD_NAME L"gzip_ia64"
static INTN
gzip_probe_format(CHAR16 *kname)
{

File diff suppressed because it is too large Load diff

View file

@ -288,7 +288,7 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
if (alloc_kmem(low_addr, pages) == -1) {
VOID *new_addr;
ERR_PRT((L"%s : AllocatePages(%d, 0x%lx) for kernel failed\n", LD_NAME, pages, low_addr));
VERB_PRT(1, (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"));
@ -387,6 +387,8 @@ load_elf(fops_fd_t fd, kdesc_t *kd)
ret = read_file(fd, filesz, (CHAR8 *)phdrs[i].p_paddr);
if (ret == ELILO_LOAD_ABORTED) goto load_abort;
if (ret == ELILO_LOAD_ERROR) goto out;
if (bswap32(phdrs[i].p_flags) & PF_X)
flush_dcache ((CHAR8 *)phdrs[i].p_paddr, filesz);
/*
* update file position

View file

@ -31,5 +31,7 @@ extern INTN query_fpswa(VOID **);
extern INTN ia64_can_relocate();
extern void flush_dcache (CHAR8 *addr, UINT64 len);
#endif /* __ELILO_PRIVATE_IA64_H__ */

View file

@ -78,6 +78,7 @@ setjmp:
/* __sigsetjmp(__jmp_buf buf, int savemask) */
.proc __sigsetjmp
__sigsetjmp:
//.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
alloc loc1=ar.pfs,2,2,2,0

View file

@ -65,8 +65,11 @@ typedef struct ia64_boot_params {
UINTN initrd_start; /* virtual address where the initial ramdisk begins */
UINTN initrd_size; /* how big is the initial ramdisk */
UINTN vmcode_start; /* virtual address where the boot time vmcode begins */
UINTN vmcode_size; /* how big is the boot module */
UINTN loader_addr; /* start address of boot loader */
UINTN loader_size; /* size of loader code & data */
} boot_params_t;
typedef struct sys_img_options {

View file

@ -39,7 +39,7 @@ extern loader_ops_t plain_loader, gzip_loader;
* IA-64 specific boot paramters initialization routine
*/
INTN
sysdeps_create_boot_params(boot_params_t *bp, CHAR8 *cmdline, memdesc_t *initrd, UINTN *cookie)
sysdeps_create_boot_params(boot_params_t *bp, CHAR8 *cmdline, memdesc_t *initrd, memdesc_t *vmcode, UINTN *cookie)
{
UINTN cols, rows;
SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
@ -64,7 +64,12 @@ sysdeps_create_boot_params(boot_params_t *bp, CHAR8 *cmdline, memdesc_t *initrd,
bp->efi_memdesc_version = mdesc.desc_version;
bp->command_line = (UINTN)cmdline;
bp->initrd_start = (UINTN) initrd->start_addr;
bp->initrd_size = initrd->pgcnt << EFI_PAGE_SHIFT;
bp->initrd_size = initrd->size;
DBG_PRT((L"Got initrd @ 0x%lx (%d bytes)", initrd->start_addr, initrd->size));
bp->vmcode_start = (UINTN) vmcode->start_addr;
bp->vmcode_size = vmcode->size;
DBG_PRT((L"Got vmcode @ 0x%lx (%d bytes)", vmcode->start_addr, vmcode->size));
/* fetch console parameters: */
conout = systab->ConOut;
@ -135,3 +140,20 @@ sysdeps_initrd_get_addr(kdesc_t *kd, memdesc_t *imem)
return 0;
}
/* Flush data cache [addr; addr + len], and sync with icache. */
void
flush_dcache (CHAR8 *addr, UINT64 len)
{
/* Cache line length is at least 32. */
UINT64 a = (UINT64)addr & ~0x1f;
VERB_PRT(3, Print(L"Flush 0x%lx-", a));
/* Flush data. */
for (len = (len + 31) & ~0x1f; len > 0; len -= 0x20, a += 0x20)
asm volatile ("fc %0" : : "r" (a));
/* Sync and serialize. Maybe extra. */
asm volatile (";; sync.i;; srlz.i;;");
VERB_PRT(3, Print(L"0x%lx\n", a));
}