diff --git a/sys/arch/cats/cats/cats_machdep.c b/sys/arch/cats/cats/cats_machdep.c index 2d7953f0517c..7224e0b4e888 100644 --- a/sys/arch/cats/cats/cats_machdep.c +++ b/sys/arch/cats/cats/cats_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: cats_machdep.c,v 1.50 2003/10/04 14:28:28 chris Exp $ */ +/* $NetBSD: cats_machdep.c,v 1.51 2003/10/04 15:43:05 chris Exp $ */ /* * Copyright (c) 1997,1998 Mark Brinicombe. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cats_machdep.c,v 1.50 2003/10/04 14:28:28 chris Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cats_machdep.c,v 1.51 2003/10/04 15:43:05 chris Exp $"); #include "opt_ddb.h" #include "opt_pmap_debug.h" @@ -79,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: cats_machdep.c,v 1.50 2003/10/04 14:28:28 chris Exp #include "ksyms.h" #include "opt_ipkdb.h" +#include "opt_ableelf.h" #include "isa.h" #if NISA > 0 @@ -358,9 +359,7 @@ initarm(bootargs) struct ebsaboot *bootinfo = bootargs; int loop; int loop1; - u_int logical; u_int l1pagetable; - struct exec *kernexec = (struct exec *)KERNEL_TEXT_BASE; pv_addr_t kernel_l1pt; extern u_int cpu_get_control(void); @@ -478,13 +477,16 @@ initarm(bootargs) */ #ifdef VERBOSE_INIT_ARM - printf("Allocating page tables\n"); + printf("Allocating page tables"); #endif /* Update the address of the first free page of physical memory */ physical_freestart = ebsabootinfo.bt_memavail; free_pages -= (physical_freestart - physical_start) / PAGE_SIZE; - + +#ifdef VERBOSE_INIT_ARM + printf(" above %p\n", (void *)physical_freestart); +#endif /* Define a macro to simplify memory allocation */ #define valloc_pages(var, np) \ alloc_pages((var).pv_pa, (np)); \ @@ -575,29 +577,52 @@ initarm(bootargs) #endif /* Now we fill in the L2 pagetable for the kernel static code/data */ +#ifdef ABLEELF + { + extern char etext[], _end[]; + size_t textsize = (uintptr_t) etext - KERNEL_BASE; + size_t totalsize = (uintptr_t) _end - KERNEL_BASE; + u_int logical; + + textsize = round_page(textsize); + totalsize = round_page(totalsize); - if (N_GETMAGIC(kernexec[0]) != ZMAGIC) - panic("Illegal kernel format"); - else { - extern int end; + logical = pmap_map_chunk(l1pagetable, KERNEL_BASE, + physical_start, textsize, + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); - logical = pmap_map_chunk(l1pagetable, KERNEL_TEXT_BASE, - physical_start, kernexec->a_text, - VM_PROT_READ, PTE_CACHE); - logical += pmap_map_chunk(l1pagetable, - KERNEL_TEXT_BASE + logical, - physical_start + logical, kernexec->a_data, - VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); - logical += pmap_map_chunk(l1pagetable, - KERNEL_TEXT_BASE + logical, - physical_start + logical, kernexec->a_bss, - VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); - logical += pmap_map_chunk(l1pagetable, - KERNEL_TEXT_BASE + logical, - physical_start + logical, kernexec->a_syms + sizeof(int) - + *(u_int *)((int)&end + kernexec->a_syms + sizeof(int)), - VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); + (void) pmap_map_chunk(l1pagetable, KERNEL_BASE + logical, + physical_start + logical, totalsize - textsize, + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); } +#else + { + struct exec *kernexec = (struct exec *)KERNEL_TEXT_BASE; + if (N_GETMAGIC(kernexec[0]) != ZMAGIC) + panic("Illegal kernel format"); + else { + extern int end; + u_int logical; + + logical = pmap_map_chunk(l1pagetable, KERNEL_TEXT_BASE, + physical_start, kernexec->a_text, + VM_PROT_READ, PTE_CACHE); + logical += pmap_map_chunk(l1pagetable, + KERNEL_TEXT_BASE + logical, + physical_start + logical, kernexec->a_data, + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); + logical += pmap_map_chunk(l1pagetable, + KERNEL_TEXT_BASE + logical, + physical_start + logical, kernexec->a_bss, + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); + logical += pmap_map_chunk(l1pagetable, + KERNEL_TEXT_BASE + logical, + physical_start + logical, kernexec->a_syms + sizeof(int) + + *(u_int *)((int)&end + kernexec->a_syms + sizeof(int)), + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); + } + } +#endif /* * PATCH PATCH ... diff --git a/sys/arch/cats/conf/GENERIC b/sys/arch/cats/conf/GENERIC index 72a4f4f70f33..2a8aa468af64 100644 --- a/sys/arch/cats/conf/GENERIC +++ b/sys/arch/cats/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.51 2003/09/13 13:30:03 chris Exp $ +# $NetBSD: GENERIC,v 1.52 2003/10/04 15:43:05 chris Exp $ # # GENERIC machine description file # @@ -33,6 +33,10 @@ options INSECURE # disable kernel securelevel options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT options NTP # NTP phase/frequency locked loop +# experimental ELF support when used on a CATS board running ABLE +#options ABLEELF +#makeoptions ABLEELF="1" + # Enable experimental buffer queue strategy for better responsiveness under # high disk I/O load. Use it with caution - it's not proven to be stable yet. #options NEW_BUFQ_STRATEGY diff --git a/sys/arch/cats/conf/Makefile.cats.inc b/sys/arch/cats/conf/Makefile.cats.inc index 8c2ea6131d52..4f3ad087b85c 100644 --- a/sys/arch/cats/conf/Makefile.cats.inc +++ b/sys/arch/cats/conf/Makefile.cats.inc @@ -1,8 +1,14 @@ -# $NetBSD: Makefile.cats.inc,v 1.14 2003/09/21 15:21:03 matt Exp $ +# $NetBSD: Makefile.cats.inc,v 1.15 2003/10/04 15:43:05 chris Exp $ CPPFLAGS+= -D${MACHINE} .if (${OBJECT_FMT} == "ELF") + +.if defined(ABLEELF) && (${ABLEELF} == "1") +# use a standard ELF format, adjusted to align areas +LINKFLAGS= -T ${THISARM}/conf/ldscript.elf + +.else # Need to convert the kernel from ELF to a.out so that the firmware # can load it. @@ -15,3 +21,4 @@ SYSTEM_LD_TAIL_EXTRA+=; \ "${OBJCOPY} -O a.out-arm-netbsd -R .ident -R .arm.atpcs -R .comment $@ $@.aout"; \ ${OBJCOPY} -O a.out-arm-netbsd -R .ident -R .arm.atpcs -R .comment $@ $@.aout .endif +.endif diff --git a/sys/arch/cats/conf/files.cats b/sys/arch/cats/conf/files.cats index eaa03bc41e4e..9584be2ebabf 100644 --- a/sys/arch/cats/conf/files.cats +++ b/sys/arch/cats/conf/files.cats @@ -1,4 +1,4 @@ -# $NetBSD: files.cats,v 1.24 2002/11/03 21:43:32 chris Exp $ +# $NetBSD: files.cats,v 1.25 2003/10/04 15:43:05 chris Exp $ # # CATS-specific configuration info # @@ -12,6 +12,9 @@ defflag IRQSTATS # X server support in console drivers defflag XSERVER +# ABLE booting ELF kernels +defflag ABLEELF + define todservice {} # diff --git a/sys/arch/cats/conf/ldscript.elf b/sys/arch/cats/conf/ldscript.elf new file mode 100644 index 000000000000..fb35c7f17131 --- /dev/null +++ b/sys/arch/cats/conf/ldscript.elf @@ -0,0 +1,75 @@ +/* $NetBSD: ldscript.elf,v 1.1 2003/10/04 15:43:05 chris Exp $ */ + +OUTPUT_ARCH(arm) +ENTRY(KERNEL_BASE_phys) +SECTIONS +{ + KERNEL_BASE_phys = 0xF0000000; + KERNEL_BASE_virt = 0xF0000000; + + /* Kernel start: */ + .start (KERNEL_BASE_phys) : + { + *(.start) + } =0 + + /* Read-only sections, merged into text segment: */ + .text (KERNEL_BASE_virt + SIZEOF(.start)) : + AT (LOADADDR(.start) + SIZEOF(.start)) + { + *(.text) + *(.text.*) + *(.stub) + *(.glue_7t) *(.glue_7) + *(.rodata) *(.rodata.*) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + /* Adjust the address for the data segment to start on the next page + boundary. */ + . = ALIGN(0x8000); + .data : + AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text))) + { + __data_start = . ; + *(.data) + *(.data.*) + } + .sdata : + AT (LOADADDR(.data) + (ADDR(.sdata) - ADDR(.data))) + { + *(.sdata) + *(.sdata.*) + } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .sbss : + { + PROVIDE (__sbss_start = .); + PROVIDE (___sbss_start = .); + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.scommon) + PROVIDE (__sbss_end = .); + PROVIDE (___sbss_end = .); + } + .bss : + { + *(.dynbss) + *(.bss) + *(.bss.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(32 / 8); + } + . = ALIGN(32 / 8); + _end = .; + _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; + PROVIDE (end = .); +}