Finally make the RiscPC boot ELF kernels for real !! ... it now loads a.out

kernels as also ELF ones. Also cleaned up the code a bit and removed a
bunch of errors in the ELF loading code... no wonder it didn't work ! ... I
tried to squeeze about 8000 bytes in one 4096 byte page resulting in a
corrupted bss.
This commit is contained in:
reinoud 2001-09-18 23:23:22 +00:00
parent 8496cf2bd8
commit 72854dc39d
2 changed files with 30 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_machdep.c,v 1.51 2001/07/28 18:12:45 chris Exp $ */
/* $NetBSD: rpc_machdep.c,v 1.52 2001/09/18 23:23:22 reinoud Exp $ */
/*
* Copyright (c) 2000-2001 Reinoud Zandijk.
@ -671,29 +671,33 @@ initarm_new_bootloader(bootconf)
/* Now we fill in the L2 pagetable for the kernel code/data */
l2pagetable = kernel_pt_table[KERNEL_PT_KERNEL];
/*
* The defines are a workaround for a recent problem that occurred
* with ARM 610 processors and some ARM 710 processors
* Other ARM 710 and StrongARM processors don't have a problem.
*/
if (N_GETMAGIC(kernexec[0]) == ZMAGIC) {
/*
* This is a work around for a recent problem that occurred
* with ARM 610 processors and some ARM 710 processors
* Other ARM 710 and StrongARM processors don't have a problem.
*/
#if defined(CPU_ARM6) || defined(CPU_ARM7)
logical = map_chunk(0, l2pagetable, KERNEL_TEXT_BASE,
logical = map_chunk(l1pagetable, l2pagetable, KERNEL_TEXT_BASE,
physical_start, kernexec->a_text,
AP_KRW, PT_CACHEABLE);
#else /* CPU_ARM6 || CPU_ARM7 */
logical = map_chunk(0, l2pagetable, KERNEL_TEXT_BASE,
logical = map_chunk(l1pagetable, l2pagetable, KERNEL_TEXT_BASE,
physical_start, kernexec->a_text,
AP_KR, PT_CACHEABLE);
#endif /* CPU_ARM6 || CPU_ARM7 */
logical += map_chunk(0, l2pagetable, KERNEL_TEXT_BASE + logical,
logical += map_chunk(l1pagetable, l2pagetable, KERNEL_TEXT_BASE + logical,
physical_start + logical, kerneldatasize - kernexec->a_text,
AP_KRW, PT_CACHEABLE);
} else
map_chunk(0, l2pagetable, KERNEL_TEXT_BASE,
} else { /* !ZMAGIC */
/*
* Most likely an ELF kernel ...
* XXX no distinction yet between read only and read/write area's ...
*/
map_chunk(l1pagetable, l2pagetable, KERNEL_TEXT_BASE,
physical_start, kerneldatasize,
AP_KRW, PT_CACHEABLE)
;
AP_KRW, PT_CACHEABLE);
};
#ifdef VERBOSE_INIT_ARM
@ -728,9 +732,9 @@ initarm_new_bootloader(bootconf)
*/
l2pagetable = kernel_pt_table[KERNEL_PT_VMEM];
map_chunk(0, l2pagetable, VMEM_VBASE, videomemory.vidm_pbase,
map_chunk(l1pagetable, l2pagetable, VMEM_VBASE, videomemory.vidm_pbase,
videomemory.vidm_size, AP_KRW, PT_CACHEABLE);
map_chunk(0, l2pagetable, VMEM_VBASE + videomemory.vidm_size,
map_chunk(l1pagetable, l2pagetable, VMEM_VBASE + videomemory.vidm_size,
videomemory.vidm_pbase, videomemory.vidm_size,
AP_KRW, PT_CACHEABLE);

View File

@ -1,5 +1,5 @@
REM > BtNetBSD
REM $NetBSD: BtNetBSD,v 1.10 2001/08/20 12:20:05 wiz Exp $
REM $NetBSD: BtNetBSD,v 1.11 2001/09/18 23:23:23 reinoud Exp $
REM
REM Copyright (c) 2000, 2001 Reinoud Zandijk
REM Copyright (c) 1998, 1999, 2000 Ben Harris
@ -219,7 +219,7 @@ DEF PROCload_kernel_elf(file%)
freepagesbase% = first_mapped_DRAM_index% : REM == first virt address in DRAM0a
start_kernelpage% = freepagesbase%
pv_offset% = KERNEL_BASE - DRAM_addr%(0) : REM XXX hardcoded
REM load the code blocks ?
first% = TRUE
FOR ph% = phdrs% TO phdrs% + (phnum% - 1) * phentsize% STEP phentsize%
@ -228,6 +228,7 @@ DEF PROCload_kernel_elf(file%)
first% = FALSE
offset% = ph%!4
vaddr% = ph%!8
REM physaddr% = ph%!12
filesz% = ph%!16
memsz% = ph%!20
flags% = ph%!24
@ -289,6 +290,7 @@ DEF PROCload_kernel_elf(file%)
REM XXX
kernelpages% = freepagesbase% - start_kernelpage%
IF extradebug% THEN PRINT ''"Number of kernel pages ";kernelpages%;" (";kernelpages%*nbpp%;")"
PROCfinish_relocationtable
ENDPROC
@ -301,11 +303,12 @@ DEF PROCload_chunk(file%, offset%, vaddr%, filesz%, memsz%)
REM filesz% number of bytes to read of `file' for this chunk
REM memsz% number of bytes to clear for this chunk
PRINT ;filesz%;
IF extradebug% PRINT ;" (";~vaddr%;"-";~(vaddr%+filesz%+memsz%);" [till base+";INT((vaddr%+filesz%+memsz%-&F0000000)/1024);"k]) ";
IF extradebug% PRINT ;" (";~vaddr%;"-";~(vaddr%+memsz%);" [till base+";INT((vaddr%+memsz%-&F0000000)/1024);"k]) ";
WHILE filesz% > 0
REM freepagesbase% is first page index in freepages list
fragsz% = nbpp% - (vaddr% MOD nbpp%)
fragsz% = nbpp%
IF fragsz% > filesz% THEN fragsz% = filesz%
fragaddr% = FNblock_vaddr(freepagesbase%)
SYS "OS_GBPB", 3, file%, fragaddr%, fragsz%, offset%
@ -322,11 +325,13 @@ DEF PROCload_chunk(file%, offset%, vaddr%, filesz%, memsz%)
memsz% -= fragsz%
PROCtwirl
ENDWHILE
IF memsz% > 0 PRINT "+";memsz%;
WHILE memsz% > 0
REM freepagesbase% is first page index in freepages list
fragsz = nbpp% - (vaddr% MOD nbpp%)
fragsz% = nbpp%
IF fragsz% > memsz% THEN fragsz% = memsz%
PROCbzero(FNblock_vaddr(freepagesbase%), fragsz%)
REM create a relocation block
@ -907,7 +912,7 @@ DEF PROCget_memory_map
ENDWHILE
PRINT'
IF extradebug% THEN PRINT '"First DRAM index found at index ";first_mapped_DRAM_index%;" DRAM_addr%(0)=0x";~DRAM_addr%(0)
IF first_mapped_DRAM_index%<0 THEN ERROR EXT 1, "No (S)DRAM mapped in this program (weird) ... increase Wimpslot!"
IF first_mapped_DRAM_index%<0 THEN ERROR EXT 1, "No (S)DRAM mapped in this program (wierd) ... increase Wimpslot!"
ENDPROC