* Add support for running the IQ80310 kernel where KERNEL_BASE !=

physical memory start.  Garbage-collect some cruft while here.
* Move the kernel up to 0xc0000000, giving a 1G/3G kernel/user split.
* Adjust the Integrator startup code accordingly.
This commit is contained in:
thorpej 2002-03-03 21:22:15 +00:00
parent e23381908a
commit e0ea696615
6 changed files with 242 additions and 125 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.evbarm.inc,v 1.9 2002/03/02 22:23:10 thorpej Exp $
# $NetBSD: Makefile.evbarm.inc,v 1.10 2002/03/03 21:22:15 thorpej Exp $
SYSTEM_LD_TAIL_EXTRA=; \
echo "${DBSYM} $@ || true"; \
@ -11,11 +11,17 @@ SYSTEM_FIRST_SFILE= ${THISARM}/integrator/intmmu.S
.endif
.if (${BOARDTYPE} == "iq80310")
SYSTEM_FIRST_OBJ= iq80310_start.o
SYSTEM_FIRST_SFILE= ${THISARM}/iq80310/iq80310_start.S
LINKFLAGS= -T ${THISARM}/conf/ldscript.iq80310
SYSTEM_LD_TAIL_EXTRA+=; \
echo ${OBJCOPY} -S -O srec $@ $@.srec; \
${OBJCOPY} -S -O srec $@ $@.srec; \
echo ${OBJCOPY} -S -O binary $@ $@.bin; \
${OBJCOPY} -S -O binary $@ $@.bin
EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.srec@}
EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.bin@}
.endif

View File

@ -0,0 +1,77 @@
/* $NetBSD: ldscript.iq80310,v 1.1 2002/03/03 21:22:15 thorpej Exp $ */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
"elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(KERNEL_BASE_phys)
SECTIONS
{
KERNEL_BASE_phys = 0xa0200000;
KERNEL_BASE_virt = 0xc0200000;
/* 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) + SIZEOF(.text) + (0x8000 - 1)) & ~(0x8000 - 1))
{
__data_start = . ;
*(.data)
*(.data.*)
}
.sdata :
AT (LOADADDR(.data) + SIZEOF(.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 = .);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vmparam.h,v 1.8 2002/03/03 11:23:00 chris Exp $ */
/* $NetBSD: vmparam.h,v 1.9 2002/03/03 21:22:16 thorpej Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
@ -48,10 +48,10 @@
* The line between user space and kernel space
* Mappings >= KERNEL_SPACE_START are constant across all processes
*/
#define KERNEL_SPACE_START 0xa0000000
#define KERNEL_SPACE_START 0xc0000000
/* Various constants used by the MD code*/
#define KERNEL_BASE 0xa0000000
#define KERNEL_BASE 0xc0000000
#define KERNEL_TEXT_BASE (KERNEL_BASE + 0x00200000)
#define ALT_PAGE_TBLS_BASE (KERNEL_BASE + 0x00c00000)
#define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
@ -65,7 +65,7 @@
* buffers is being limited due to lack of VA space.
*/
/*
* The range 0xf1000000 - 0xfcffffff is available for kernel VM space
* The range 0xc1000000 - 0xccffffff is available for kernel VM space
* Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
*/
#define KERNEL_VM_SIZE 0x0C000000

View File

@ -1,4 +1,4 @@
/* $NetBSD: intmmu.S,v 1.2 2001/11/23 17:39:05 thorpej Exp $ */
/* $NetBSD: intmmu.S,v 1.3 2002/03/03 21:22:16 thorpej Exp $ */
/*
* Copyright (c) 2001 ARM Ltd
@ -64,13 +64,13 @@ Lflat:
bgt Lflat
/*
* Map VA 0xa0100000->0xa03fffff to PA 0x00000000->0x002fffff
* Map VA 0xc0100000->0xc03fffff to PA 0x00000000->0x002fffff
*/
mov r3, #(AP_KRW << AP_SECTION_SHIFT)
add r3, r3, #(L1_SECTION)
mov r1, #0x8000 /* page table start */
add r1, r1, #(0xa00 * 4) /* offset to 0xa00xxxxx */
add r1, r1, #(0x001 * 4) /* offset to 0xa01xxxxx */
add r1, r1, #(0xc00 * 4) /* offset to 0xc00xxxxx */
add r1, r1, #(0x001 * 4) /* offset to 0xc01xxxxx */
mov r0, #47
Lkern:
str r3, [r1], #0x0004 /* 0xa010000-0xa03fffff */

View File

@ -1,4 +1,4 @@
/* $NetBSD: iq80310_machdep.c,v 1.32 2002/03/03 11:23:00 chris Exp $ */
/* $NetBSD: iq80310_machdep.c,v 1.33 2002/03/03 21:22:15 thorpej Exp $ */
/*
* Copyright (c) 2001, 2002 Wasabi Systems, Inc.
@ -389,58 +389,12 @@ initarm(void *arg)
}
/*
* Okay, RedBoot has provided us with the following memory map:
*
* Physical Address Range Description
* ----------------------- ----------------------------------
* 0x00000000 - 0x00000fff flash Memory
* 0x00001000 - 0x00001fff 80312 Internal Registers
* 0x00002000 - 0x007fffff flash Memory
* 0x00800000 - 0x7fffffff PCI ATU Outbound Direct Window
* 0x80000000 - 0x83ffffff Primary PCI 32-bit Memory
* 0x84000000 - 0x87ffffff Primary PCI 64-bit Memory
* 0x88000000 - 0x8bffffff Secondary PCI 32-bit Memory
* 0x8c000000 - 0x8fffffff Secondary PCI 64-bit Memory
* 0x90000000 - 0x9000ffff Primary PCI IO Space
* 0x90010000 - 0x9001ffff Secondary PCI IO Space
* 0x90020000 - 0x9fffffff Unused
* 0xa0000000 - 0xbfffffff SDRAM
* 0xc0000000 - 0xefffffff Unused
* 0xf0000000 - 0xffffffff 80200 Internal Registers
*
*
* Virtual Address Range C B Description
* ----------------------- - - ----------------------------------
* 0x00000000 - 0x00000fff Y Y SDRAM
* 0x00001000 - 0x00001fff N N 80312 Internal Registers
* 0x00002000 - 0x007fffff Y N flash Memory
* 0x00800000 - 0x7fffffff N N PCI ATU Outbound Direct Window
* 0x80000000 - 0x83ffffff N N Primary PCI 32-bit Memory
* 0x84000000 - 0x87ffffff N N Primary PCI 64-bit Memory
* 0x88000000 - 0x8bffffff N N Secondary PCI 32-bit Memory
* 0x8c000000 - 0x8fffffff N N Secondary PCI 64-bit Memory
* 0x90000000 - 0x9000ffff N N Primary PCI IO Space
* 0x90010000 - 0x9001ffff N N Secondary PCI IO Space
* 0xa0000000 - 0xa0000fff Y N flash
* 0xa0001000 - 0xbfffffff Y Y SDRAM
* 0xc0000000 - 0xcfffffff Y Y Cache Flush Region
* 0xf0000000 - 0xffffffff N N 80200 Internal Registers
*
* The first level page table is at 0xa0004000. There are also
* 2 second-level tables at 0xa0008000 and 0xa0008400.
*
* This corresponds roughly to the physical memory map, i.e.
* we are quite nearly running VA==PA.
* We are currently running with the MMU enabled and the
* entire address space mapped VA==PA, except for the
* first 64M of RAM is also double-mapped at 0xc0000000.
* There is an L1 page table at 0xa0004000.
*/
/*
* Examine the boot args string for options we need to know about
* now.
*/
#if 0
process_kernel_args((char *)nwbootinfo.bt_args);
#endif
/*
* Fetch the SDRAM start/size from the i80312 SDRAM configration
* registers.
@ -461,9 +415,9 @@ initarm(void *arg)
* physical memory. For now, we're going to set
* physical_freestart to 0xa0200000 (where the kernel
* was loaded), and allocate the memory we need downwards.
* If we get too close to the page tables that RedBoot
* set up, we will panic. We will update physical_freestart
* and physical_freeend later to reflect what pmap_bootstrap()
* If we get too close to the L1 table that we set up, we
* will panic. We will update physical_freestart and
* physical_freeend later to reflect what pmap_bootstrap()
* wants to see.
*
* XXX pmap_bootstrap() needs an enema.
@ -610,14 +564,14 @@ initarm(void *arg)
pmap_link_l2pt(l1pagetable, PROCESS_PAGE_TBLS_BASE, &kernel_ptpt);
/* update the top of the kernel VM */
pmap_curmaxkvaddr = KERNEL_VM_BASE + ((KERNEL_PT_VMDATA_NUM) * 0x00400000) - 1;
pmap_curmaxkvaddr =
KERNEL_VM_BASE + ((KERNEL_PT_VMDATA_NUM) * 0x00400000) - 1;
#ifdef VERBOSE_INIT_ARM
printf("Mapping kernel\n");
#endif
/* Now we fill in the L2 pagetable for the kernel static code/data */
{
extern char etext[], _end[];
size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE;
@ -629,22 +583,12 @@ initarm(void *arg)
logical = 0x00200000; /* offset of kernel in RAM */
/*
* This maps the kernel text/data/bss VA==PA.
*/
logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
physical_start + logical, textsize,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
physical_start + logical, totalsize - textsize,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
#if 0 /* XXX No symbols yet. */
logical += pmap_map_chunk(l1pagetable, KERNEL_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
}
#ifdef VERBOSE_INIT_ARM
@ -780,7 +724,9 @@ initarm(void *arg)
{
extern char _end[];
physical_freestart = (((uintptr_t) _end) + PGOFSET) & ~PGOFSET;
physical_freestart = physical_start +
(((((uintptr_t) _end) + PGOFSET) & ~PGOFSET) -
KERNEL_BASE);
physical_freeend = physical_end;
free_pages = (physical_freeend - physical_freestart) / NBPG;
}
@ -793,14 +739,6 @@ initarm(void *arg)
#endif
setttb(kernel_l1pt.pv_pa);
cpu_tlb_flushID();
{ u_int tmp;
__asm __volatile("mrc p15, 0, %0, c1, c0, 0"
: "=r" (tmp));
tmp |= CPU_CONTROL_MMU_ENABLE;
__asm __volatile("mcr p15, 0, %0, c1, c0, 0; nop; nop; nop"
:
: "r" (tmp));
}
#ifdef VERBOSE_INIT_ARM
printf("done!\n");
@ -844,14 +782,6 @@ initarm(void *arg)
prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
undefined_handler_address = (u_int)undefinedinstruction_bounce;
/* At last !
* We now have the kernel in physical memory from the bottom upwards.
* Kernel page tables are physically above this.
* The kernel is mapped to KERNEL_TEXT_BASE
* The kernel data PTs will handle the mapping of 0xf1000000-0xf3ffffff
* The page tables are mapped to 0xefc00000
*/
/* Initialise the undefined instruction handlers */
printf("undefined ");
undefined_init();
@ -886,39 +816,6 @@ initarm(void *arg)
return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
}
#if 0
void
process_kernel_args(char *args)
{
static char bootargs[MAX_BOOT_STRING + 1];
boothowto = 0;
/* Make a local copy of the bootargs */
strncpy(bootargs, args, MAX_BOOT_STRING);
args = bootargs;
boot_file = bootargs;
/* Skip the kernel image filename */
while (*args != ' ' && *args != 0)
++args;
if (*args != 0)
*args++ = 0;
while (*args == ' ')
++args;
boot_args = args;
printf("bootfile: %s\n", boot_file);
printf("bootargs: %s\n", boot_args);
parse_mi_bootargs(boot_args);
}
#endif
void
consinit(void)
{

View File

@ -0,0 +1,137 @@
/* $NetBSD: iq80310_start.S,v 1.1 2002/03/03 21:22:15 thorpej Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#include <arm/armreg.h>
#include <arm/arm32/pte.h>
.section .start,"ax",%progbits
.global _C_LABEL(iq80310_start)
_C_LABEL(iq80310_start):
/*
* We assume we've been loaded VA==PA, or that the MMU is
* disabled. We will go ahead and disable the MMU here
* so that we don't have to worry about flushing caches, etc.
*/
mrc p15, 0, r2, c1, c0, 0
bic r2, r2, #CPU_CONTROL_MMU_ENABLE
mcr p15, 0, r2, c1, c0, 0
nop
nop
nop
/*
* We want to construct a memory map that maps us
* VA==PA (SDRAM at 0xa0000000) and also double-maps
* that space at 0xc0000000 (where the kernel address
* space starts). We create these mappings uncached
* and unbuffered to be safe.
*
* We also want to map the various devices we want to
* talk to VA==PA during bootstrap.
*
* We just use section mappings for all of this to make it easy.
*
* We will put the L1 table to do all this at 0xa0004000, which
* is also where RedBoot puts it.
*/
/*
* Step 1: Map the entire address space VA==PA.
*/
add r0, pc, #(Ltable - . - 8)
ldr r0, [r0] /* r0 = &l1table */
mov r3, #(AP_KRW << AP_SECTION_SHIFT)
orr r3, r3, #(L1_SECTION)
mov r2, #0x100000 /* advance by 1MB */
mov r1, #0x1000 /* 4096MB */
1:
str r3, [r0], #0x04
add r3, r3, r2
subs r1, r1, #1
bgt 1b
/*
* Step 2: Map VA 0xc0000000->0xc3ffffff to PA 0xa0000000->0xa3ffffff.
*/
add r0, pc, #(Ltable - . - 8) /* r0 = &l1table */
ldr r0, [r0]
mov r3, #(AP_KRW << AP_SECTION_SHIFT)
orr r3, r3, #(L1_SECTION)
orr r3, r3, #0xa0000000
add r0, r0, #(0xc00 * 4) /* offset to 0xc00xxxxx */
mov r1, #0x40 /* 64MB */
1:
str r3, [r0], #0x04
add r3, r3, r2
subs r1, r1, #1
bgt 1b
/* OK! Page table is set up. Give it to the CPU. */
add r0, pc, #(Ltable - . - 8)
ldr r0, [r0]
mcr p15, 0, r0, c2, c0, 0
/* Flush the old TLBs, just in case. */
mcr p15, 0, r0, c8, c7, 0
/* Set the Domain Access register. Very important! */
mov r0, #1
mcr p15, 0, r0, c3, c0, 0
/* OK, let's enable the MMU. */
mrc p15, 0, r2, c1, c0, 0
orr r2, r2, #CPU_CONTROL_MMU_ENABLE
mcr p15, 0, r2, c1, c0, 0
nop
nop
nop
/* ...and now we jump to the "real" kernel entry point! */
add r0, pc, #(Lstart - . - 8)
ldr pc, [r0]
Ltable:
.word 0xa0004000
Lstart:
.word start