Initial BEAGLEBOARD support. Compile tested only so far.

This commit is contained in:
matt 2008-10-22 10:50:56 +00:00
parent fbba39f598
commit f3868737d3
7 changed files with 1655 additions and 0 deletions

View File

@ -0,0 +1,53 @@
/* $NetBSD: beagle.h,v 1.1 2008/10/22 10:50:56 matt Exp $ */
/*
* Copyright (c) 2007 Microsoft
* All rights reserved.
*
* 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 by Microsoft
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR OR CONTRIBUTERS 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.
*/
#ifndef _EVBARM_BEAGLE_BEAGLE_H
#define _EVBARM_BEAGLE_BEAGLE_H
#include <arm/omap/omap2_reg.h>
/*
* Kernel VM space: 192MB at KERNEL_VM_BASE
*/
#define KERNEL_VM_BASE ((KERNEL_BASE + 0x01000000) & ~(0x400000-1))
#define KERNEL_VM_SIZE 0x0C000000
/*
* We devmap IO starting at KERNEL_VM_BASE + KERNEL_VM_SIZE
*/
#define OMAP3530_KERNEL_IO_VBASE (KERNEL_VM_BASE + KERNEL_VM_SIZE)
#define OMAP3530_L4_CORE_VBASE OMAP3530_KERNEL_IO_VBASE
#define OMAP3530_L4_WAKEUP_VBASE (OMAP3530_L4_CORE_VBASE + OMAP3530_L4_CORE_SIZE)
#define OMAP3530_KERNEL_IO_VEND (OMAP3530_L4_WAKEUP_VBASE + OMAP3530_L4_WAKEUP_SIZE)
#define CONSADDR_VA ((CONSADDR - OMAP3530_L4_CORE_BASE) + OMAP3530_L4_CORE_VBASE)
#endif /* _EVBARM_BEAGLE_BEAGLE_H */

View File

@ -0,0 +1,973 @@
/* $NetBSD: beagle_machdep.c,v 1.1 2008/10/22 10:50:56 matt Exp $ */
/*
* Machine dependent functions for kernel setup for TI OSK5912 board.
* Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c
*
* Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
* Written by Hiroyuki Bessho for Genetec Corporation.
*
* 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. The name of Genetec Corporation may not be used to endorse or
* promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``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 GENETEC CORPORATION
* 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.
*
* Copyright (c) 2001 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.
*
* Copyright (c) 1997,1998 Mark Brinicombe.
* Copyright (c) 1997,1998 Causality Limited.
* All rights reserved.
*
* 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 by Mark Brinicombe
* for the NetBSD Project.
* 4. The name of the company nor the name of the author may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR OR CONTRIBUTORS 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.
*
* Copyright (c) 2007 Microsoft
* All rights reserved.
*
* 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 by Microsoft
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR OR CONTRIBUTERS 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 <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.1 2008/10/22 10:50:56 matt Exp $");
#include "opt_machdep.h"
#include "opt_ddb.h"
#include "opt_kgdb.h"
#include "opt_ipkdb.h"
#include "opt_md.h"
#include "opt_com.h"
#include "opt_omap.h"
#include "md.h"
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/exec.h>
#include <sys/proc.h>
#include <sys/msgbuf.h>
#include <sys/reboot.h>
#include <sys/termios.h>
#include <sys/ksyms.h>
#include <uvm/uvm_extern.h>
#include <sys/conf.h>
#include <dev/cons.h>
#include <dev/md.h>
#include <machine/db_machdep.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
#ifdef KGDB
#include <sys/kgdb.h>
#endif
#include <machine/bootconfig.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/frame.h>
#include <arm/armreg.h>
#include <arm/undefined.h>
#include <arm/arm32/machdep.h>
#include <arm/omap/omap_com.h>
#include <arm/omap/omap_var.h>
#include <arm/omap/omap_wdtvar.h>
#include <evbarm/beagle/beagle.h>
#include "omapwdt32k.h"
/*
* Address to call from cpu_reset() to reset the machine.
* This is machine architecture dependant as it varies depending
* on where the ROM appears when you turn the MMU off.
*/
u_int cpu_reset_address = 0;
/* Define various stack sizes in pages */
#define IRQ_STACK_SIZE 1
#define FIQ_STACK_SIZE 1
#define ABT_STACK_SIZE 1
#ifdef IPKDB
#define UND_STACK_SIZE 2
#else
#define UND_STACK_SIZE 1
#endif
BootConfig bootconfig; /* Boot config storage */
char *boot_args = NULL;
char *boot_file = NULL;
/* Physical address of the beginning of SDRAM. */
paddr_t physical_start;
/* Physical address of the first byte after the end of SDRAM. */
paddr_t physical_end;
/* Number of pages of memory. */
int physmem = 0;
/* Same things, but for the free (unused by the kernel) memory. */
static paddr_t physical_freestart, physical_freeend;
static u_int free_pages;
/* Physical and virtual addresses for some global pages */
pv_addr_t fiqstack;
pv_addr_t irqstack;
pv_addr_t undstack;
pv_addr_t abtstack;
pv_addr_t kernelstack; /* stack for SVC mode */
/* Physical address of the message buffer. */
paddr_t msgbufphys;
extern u_int data_abort_handler_address;
extern u_int prefetch_abort_handler_address;
extern u_int undefined_handler_address;
extern char KERNEL_BASE_phys[];
extern char etext[], __data_start[], _edata[], __bss_start[], __bss_end__[];
extern char _end[];
#define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */
#define KERNEL_PT_KERNEL 1 /* Page table for mapping kernel */
#define KERNEL_PT_KERNEL_NUM 4
#define KERNEL_PT_VMDATA (KERNEL_PT_KERNEL+KERNEL_PT_KERNEL_NUM)
/* Page tables for mapping kernel VM */
#define KERNEL_PT_VMDATA_NUM 4 /* start with 16MB of KVM */
#define NUM_KERNEL_PTS (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
pv_addr_t kernel_pt_table[NUM_KERNEL_PTS];
extern struct user *proc0paddr;
/*
* Macros to translate between physical and virtual for a subset of the
* kernel address space. *Not* for general use.
*/
#define KERNEL_BASE_PHYS ((paddr_t)&KERNEL_BASE_phys)
#if 0
#define KERN_VTOPHYS(va) \
((paddr_t)((vaddr_t)va - KERNEL_BASE + KERNEL_BASE_PHYS))
#define KERN_PHYSTOV(pa) \
((vaddr_t)((paddr_t)pa - KERNEL_BASE_PHYS + KERNEL_BASE))
#else
#define KERN_VTOPHYS(va) ((paddr_t)(va))
#define KERN_PHYSTOV(pa) ((vaddr_t)(pa))
#endif
/* Prototypes */
void consinit(void);
#ifdef KGDB
static void kgdb_port_init(void);
#endif
static void setup_real_page_tables(void);
static void init_clocks(void);
bs_protos(bs_notimpl);
#include "com.h"
#if NCOM > 0
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
#endif
/*
* void cpu_reboot(int howto, char *bootstr)
*
* Reboots the system
*
* Deal with any syncing, unmounting, dumping and shutdown hooks,
* then reset the CPU.
*/
void
cpu_reboot(int howto, char *bootstr)
{
#ifdef DIAGNOSTIC
/* info */
printf("boot: howto=%08x curproc=%p\n", howto, curproc);
#endif
/*
* If we are still cold then hit the air brakes
* and crash to earth fast
*/
if (cold) {
doshutdownhooks();
printf("The operating system has halted.\n");
printf("Please press any key to reboot.\n\n");
cngetc();
printf("rebooting...\n");
#if NOMAPWDT32K > 0
omapwdt32k_reboot();
#endif
cpu_reset();
/*NOTREACHED*/
}
/* Disable console buffering */
/* cnpollc(1);*/
/*
* If RB_NOSYNC was not specified sync the discs.
* Note: Unless cold is set to 1 here, syslogd will die during the
* unmount. It looks like syslogd is getting woken up only to find
* that it cannot page part of the binary in as the filesystem has
* been unmounted.
*/
if (!(howto & RB_NOSYNC))
bootsync();
/* Say NO to interrupts */
splhigh();
/* Do a dump if requested. */
if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
dumpsys();
/* Run any shutdown hooks */
doshutdownhooks();
/* Make sure IRQ's are disabled */
IRQdisable;
if (howto & RB_HALT) {
printf("The operating system has halted.\n");
printf("Please press any key to reboot.\n\n");
cngetc();
}
printf("rebooting...\n");
#if NOMAPWDT32K > 0
omapwdt32k_reboot();
#endif
cpu_reset();
/*NOTREACHED*/
}
/*
* Static device mappings. These peripheral registers are mapped at
* fixed virtual addresses very early in initarm() so that we can use
* them while booting the kernel, and stay at the same address
* throughout whole kernel's life time.
*
* We use this table twice; once with bootstrap page table, and once
* with kernel's page table which we build up in initarm().
*
* Since we map these registers into the bootstrap page table using
* pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
* registers segment-aligned and segment-rounded in order to avoid
* using the 2nd page tables.
*/
#define _A(a) ((a) & ~L1_S_OFFSET)
#define _S(s) (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
static const struct pmap_devmap devmap[] = {
{
/*
* Map the first 1MB of L4 Core area
* this gets us the console UART, GP timers, interrupt
* controller and GPIO5.
*/
.pd_va = _A(OMAP3530_L4_CORE_VBASE),
.pd_pa = _A(OMAP3530_L4_CORE_BASE),
.pd_size = _S(1 << 20),
.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
.pd_cache = PTE_NOCACHE
},
{
/*
* Map the first 1MB of L4 Wakeup area
* this gets us GPIO[1-4] and Clock Management regs
*/
.pd_va = _A(OMAP3530_L4_WAKEUP_VBASE),
.pd_pa = _A(OMAP3530_L4_WAKEUP_BASE),
.pd_size = _S(1 << 20),
.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
.pd_cache = PTE_NOCACHE
},
{0}
};
#undef _A
#undef _S
#ifdef DDB
static void sdp_db_trap(int where)
{
#if NOMAPWDT32K > 0
static int oldwatchdogstate;
if (where) {
oldwatchdogstate = omapwdt32k_enable(0);
} else {
omapwdt32k_enable(oldwatchdogstate);
}
#endif
}
#endif
void sdp_putchar(char c);
void
sdp_putchar(char c)
{
unsigned char *com0addr = (char *)CONSADDR_VA;
int timo = 150000;
while ((com0addr[5 * 4] & 0x20) == 0)
if (--timo == 0)
break;
com0addr[0] = c;
while ((com0addr[5 * 4] & 0x20) == 0)
if (--timo == 0)
break;
}
/*
* u_int initarm(...)
*
* Initial entry point on startup. This gets called before main() is
* entered.
* It should be responsible for setting up everything that must be
* in place when main is called.
* This includes
* Taking a copy of the boot configuration structure.
* Initialising the physical console so characters can be printed.
* Setting up page tables for the kernel
* Relocating the kernel to the bottom of physical memory
*/
u_int
initarm(void *arg)
{
#if 1
sdp_putchar('d');
#endif
/*
* When we enter here, we are using a temporary first level
* translation table with section entries in it to cover the OBIO
* peripherals and SDRAM. The temporary first level translation table
* is at the end of SDRAM.
*/
/* Heads up ... Setup the CPU / MMU / TLB functions. */
if (set_cpufuncs())
panic("cpu not recognized!");
init_clocks();
/* The console is going to try to map things. Give pmap a devmap. */
pmap_devmap_register(devmap);
consinit();
#if 1
sdp_putchar('h');
#endif
#ifdef KGDB
kgdb_port_init();
#endif
#ifdef VERBOSE_INIT_ARM
/* Talk to the user */
printf("\nNetBSD/evbarm (SDP24xx) booting ...\n");
#endif
#ifdef BOOT_ARGS
char mi_bootargs[] = BOOT_ARGS;
parse_mi_bootargs(mi_bootargs);
#endif
#ifdef VERBOSE_INIT_ARM
printf("initarm: Configuring system ...\n");
#endif
/*
* Set up the variables that define the availability of physical
* memory.
*/
physical_start = KERNEL_BASE_PHYS;
#define MEMSIZE_BYTES (MEMSIZE * 1024 * 1024)
physical_end = (physical_start & ~(0x400000-1)) + MEMSIZE_BYTES;
physmem = (physical_end - physical_start) / PAGE_SIZE;
/* Fake bootconfig structure for the benefit of pmap.c. */
bootconfig.dramblocks = 1;
bootconfig.dram[0].address = physical_start;
bootconfig.dram[0].pages = physmem;
/*
* Our kernel is at the beginning of memory, so set our free space to
* all the memory after the kernel.
*/
physical_freestart = KERN_VTOPHYS(round_page((vaddr_t) _end));
physical_freeend = physical_end;
free_pages = (physical_freeend - physical_freestart) / PAGE_SIZE;
/*
* This is going to do all the hard work of setting up the first and
* and second level page tables. Pages of memory will be allocated
* and mapped for other structures that are required for system
* operation. When it returns, physical_freestart and free_pages will
* have been updated to reflect the allocations that were made. In
* addition, kernel_l1pt, kernel_pt_table[], systempage, irqstack,
* abtstack, undstack, kernelstack, msgbufphys will be set to point to
* the memory that was allocated for them.
*/
setup_real_page_tables();
/*
* Moved from cpu_startup() as data_abort_handler() references
* this during uvm init.
*/
proc0paddr = (struct user *)kernelstack.pv_va;
lwp0.l_addr = proc0paddr;
#ifdef VERBOSE_INIT_ARM
printf("bootstrap done.\n");
#endif
arm32_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL);
/*
* Pages were allocated during the secondary bootstrap for the
* stacks for different CPU modes.
* We must now set the r13 registers in the different CPU modes to
* point to these stacks.
* Since the ARM stacks use STMFD etc. we must set r13 to the top end
* of the stack memory.
*/
#ifdef VERBOSE_INIT_ARM
printf("init subsystems: stacks ");
#endif
set_stackptr(PSR_FIQ32_MODE, fiqstack.pv_va + FIQ_STACK_SIZE * PAGE_SIZE);
set_stackptr(PSR_IRQ32_MODE, irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
set_stackptr(PSR_ABT32_MODE, abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
set_stackptr(PSR_UND32_MODE, undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
/*
* Well we should set a data abort handler.
* Once things get going this will change as we will need a proper
* handler.
* Until then we will use a handler that just panics but tells us
* why.
* Initialisation of the vectors will just panic on a data abort.
* This just fills in a slightly better one.
*/
#ifdef VERBOSE_INIT_ARM
printf("vectors ");
#endif
data_abort_handler_address = (u_int)data_abort_handler;
prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
undefined_handler_address = (u_int)undefinedinstruction_bounce;
/* Initialise the undefined instruction handlers */
#ifdef VERBOSE_INIT_ARM
printf("undefined ");
#endif
undefined_init();
/* Load memory into UVM. */
#ifdef VERBOSE_INIT_ARM
printf("page ");
#endif
uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
atop(physical_freestart), atop(physical_freeend),
VM_FREELIST_DEFAULT);
/* Boot strap pmap telling it where the kernel page table is */
#ifdef VERBOSE_INIT_ARM
printf("pmap ");
#endif
pmap_bootstrap(KERNEL_VM_BASE, KERNEL_VM_BASE + KERNEL_VM_SIZE);
#ifdef VERBOSE_INIT_ARM
printf("done.\n");
#endif
#ifdef IPKDB
/* Initialise ipkdb */
ipkdb_init();
if (boothowto & RB_KDB)
ipkdb_connect(0);
#endif
#ifdef KGDB
if (boothowto & RB_KDB) {
kgdb_debug_init = 1;
kgdb_connect(1);
}
#endif
#ifdef DDB
db_trap_callback = sdp_db_trap;
db_machine_init();
/* Firmware doesn't load symbols. */
ddb_init(0, NULL, NULL);
if (boothowto & RB_KDB)
Debugger();
#endif
printf("initarm done.\n");
/* We return the new stack pointer address */
return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
}
void arm11_pmc_ccnt_init(void);
static void
init_clocks(void)
{
#ifdef NOTYET
static volatile uint32_t * const clksel_reg = (volatile uint32_t *) (OMAP3530_L4_WAKEUP_VBASE + OMAP2_CM_BASE + OMAP2_CM_CLKSEL_MPU - OMAP3530_L4_WAKEUP_BASE);
uint32_t v;
sdp_putchar('E');
v = *clksel_reg;
sdp_putchar('F');
if (v != OMAP3530_CM_CLKSEL_MPU_FULLSPEED) {
printf("Changed CPU speed from half (%d) ", v);
*clksel_reg = OMAP3530_CM_CLKSEL_MPU_FULLSPEED;
printf("to full speed.\n");
}
sdp_putchar('G');
#endif
arm11_pmc_ccnt_init();
}
#ifndef CONSADDR
#error Specify the address of the console UART with the CONSADDR option.
#endif
#ifndef CONSPEED
#define CONSPEED 115200
#endif
#ifndef CONMODE
#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
#endif
static const bus_addr_t consaddr = CONSADDR;
static const int conspeed = CONSPEED;
static const int conmode = CONMODE;
void
consinit(void)
{
bus_space_handle_t bh;
static int consinit_called = 0;
if (consinit_called != 0)
return;
consinit_called = 1;
sdp_putchar('e');
if (bus_space_map(&omap_a4x_bs_tag, consaddr, OMAP_COM_SIZE, 0, &bh))
panic("Serial console can not be mapped.");
if (comcnattach(&omap_a4x_bs_tag, consaddr, conspeed,
OMAP_COM_FREQ, COM_TYPE_NORMAL, conmode))
panic("Serial console can not be initialized.");
bus_space_unmap(&omap_a4x_bs_tag, bh, OMAP_COM_SIZE);
sdp_putchar('f');
sdp_putchar('g');
}
#ifdef KGDB
#ifndef KGDB_DEVADDR
#error Specify the address of the kgdb UART with the KGDB_DEVADDR option.
#endif
#ifndef KGDB_DEVRATE
#define KGDB_DEVRATE 115200
#endif
#ifndef KGDB_DEVMODE
#define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
#endif
static const vaddr_t comkgdbaddr = KGDB_DEVADDR;
static const int comkgdbspeed = KGDB_DEVRATE;
static const int comkgdbmode = KGDB_DEVMODE;
void
static kgdb_port_init(void)
{
static int kgdbsinit_called = 0;
if (kgdbsinit_called != 0)
return;
kgdbsinit_called = 1;
bus_space_handle_t bh;
if (bus_space_map(&omap_a4x_bs_tag, comkgdbaddr, OMAP_COM_SIZE, 0, &bh))
panic("kgdb port can not be mapped.");
if (com_kgdb_attach(&omap_a4x_bs_tag, comkgdbaddr, comkgdbspeed,
OMAP_COM_FREQ, COM_TYPE_NORMAL, comkgdbmode))
panic("KGDB uart can not be initialized.");
bus_space_unmap(&omap_a4x_bs_tag, bh, OMAP_COM_SIZE);
}
#endif
static void
setup_real_page_tables(void)
{
/*
* We need to allocate some fixed page tables to get the kernel going.
*
* We are going to allocate our bootstrap pages from the beginning of
* the free space that we just calculated. We allocate one page
* directory and a number of page tables and store the physical
* addresses in the kernel_pt_table array.
*
* The kernel page directory must be on a 16K boundary. The page
* tables must be on 4K boundaries. What we do is allocate the
* page directory on the first 16K boundary that we encounter, and
* the page tables on 4K boundaries otherwise. Since we allocate
* at least 3 L2 page tables, we are guaranteed to encounter at
* least one 16K aligned region.
*/
#ifdef VERBOSE_INIT_ARM
printf("Allocating page tables\n");
#endif
/*
* Define a macro to simplify memory allocation. As we allocate the
* memory, make sure that we don't walk over our temporary first level
* translation table.
*/
#define valloc_pages(var, np) \
(var).pv_pa = physical_freestart; \
physical_freestart += ((np) * PAGE_SIZE); \
if (physical_freestart > (physical_freeend - L1_TABLE_SIZE)) \
panic("initarm: out of memory"); \
free_pages -= (np); \
(var).pv_va = KERN_PHYSTOV((var).pv_pa); \
memset((char *)(var).pv_va, 0, ((np) * PAGE_SIZE));
int loop, pt_index;
pt_index = 0;
kernel_l1pt.pv_pa = 0;
kernel_l1pt.pv_va = 0;
printf("%s: physical_freestart %#lx\n", __func__, physical_freestart);
for (loop = 0; loop <= NUM_KERNEL_PTS; ++loop) {
/* Are we 16KB aligned for an L1 ? */
if ((physical_freestart & (L1_TABLE_SIZE - 1)) == 0
&& kernel_l1pt.pv_pa == 0) {
valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
} else {
valloc_pages(kernel_pt_table[pt_index],
L2_TABLE_SIZE / PAGE_SIZE);
++pt_index;
}
}
pt_index=0;
printf("%s: kernel_l1pt: %#lx:%#lx\n", __func__, kernel_l1pt.pv_va, kernel_l1pt.pv_pa);
printf("%s: kernel_pt_table:\n", __func__);
for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
printf("\t%#lx:%#lx\n", kernel_pt_table[pt_index].pv_va, kernel_pt_table[pt_index].pv_pa);
++pt_index;
}
/* This should never be able to happen but better confirm that. */
if (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE-1)) != 0)
panic("initarm: Failed to align the kernel page directory");
/*
* Allocate a page for the system page mapped to V0x00000000
* This page will just contain the system vectors and can be
* shared by all processes.
*/
valloc_pages(systempage, 1);
systempage.pv_va = ARM_VECTORS_HIGH;
/* Allocate stacks for all modes */
valloc_pages(fiqstack, FIQ_STACK_SIZE);
valloc_pages(irqstack, IRQ_STACK_SIZE);
valloc_pages(abtstack, ABT_STACK_SIZE);
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, UPAGES);
/* Allocate the message buffer. */
pv_addr_t msgbuf;
int msgbuf_pgs = round_page(MSGBUFSIZE) / PAGE_SIZE;
valloc_pages(msgbuf, msgbuf_pgs);
msgbufphys = msgbuf.pv_pa;
/*
* Ok we have allocated physical pages for the primary kernel
* page tables
*/
#ifdef VERBOSE_INIT_ARM
printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
#endif
/*
* Now we start construction of the L1 page table
* We start by mapping the L2 page tables into the L1.
* This means that we can replace L1 mappings later on if necessary
*/
vaddr_t l1_va = kernel_l1pt.pv_va;
paddr_t l1_pa = kernel_l1pt.pv_pa;
/* Map the L2 pages tables in the L1 page table */
pmap_link_l2pt(l1_va, ARM_VECTORS_HIGH & ~(0x00400000 - 1),
&kernel_pt_table[KERNEL_PT_SYS]);
for (loop = 0; loop < KERNEL_PT_KERNEL_NUM; loop++)
pmap_link_l2pt(l1_va, KERNEL_BASE + loop * 0x00400000,
&kernel_pt_table[KERNEL_PT_KERNEL + loop]);
for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; loop++)
pmap_link_l2pt(l1_va, KERNEL_VM_BASE + loop * 0x00400000,
&kernel_pt_table[KERNEL_PT_VMDATA + loop]);
/* update the top of the kernel VM */
pmap_curmaxkvaddr =
KERNEL_VM_BASE + (KERNEL_PT_VMDATA_NUM * 0x00400000);
#ifdef VERBOSE_INIT_ARM
printf("Mapping kernel\n");
#endif
/* Now we fill in the L2 pagetable for the kernel static code/data */
#define round_L_page(x) (((x) + L2_L_OFFSET) & L2_L_FRAME)
size_t textsize = round_L_page(etext - KERNEL_BASE_phys);
size_t totalsize = round_L_page(_end - KERNEL_BASE_phys);
/* offset of kernel in RAM */
u_int offset = 0;
/* Map text section read-only. */
offset += pmap_map_chunk(l1_va, physical_start + offset,
physical_start + offset, textsize,
VM_PROT_READ|VM_PROT_EXECUTE, PTE_CACHE);
/* Map data and bss sections read-write. */
offset += pmap_map_chunk(l1_va, physical_start + offset,
physical_start + offset, totalsize - textsize,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
#ifdef VERBOSE_INIT_ARM
printf("Constructing L2 page tables\n");
#endif
/* Map the stack pages */
pmap_map_chunk(l1_va, fiqstack.pv_va, fiqstack.pv_pa,
FIQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
pmap_map_chunk(l1_va, irqstack.pv_va, irqstack.pv_pa,
IRQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
pmap_map_chunk(l1_va, abtstack.pv_va, abtstack.pv_pa,
ABT_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
pmap_map_chunk(l1_va, undstack.pv_va, undstack.pv_pa,
UND_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
pmap_map_chunk(l1_va, kernelstack.pv_va, kernelstack.pv_pa,
UPAGES * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
pmap_map_chunk(l1_va, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
L1_TABLE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_PAGETABLE);
for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
pmap_map_chunk(l1_va, kernel_pt_table[loop].pv_va,
kernel_pt_table[loop].pv_pa, L2_TABLE_SIZE,
VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
}
/* Map the vector page. */
pmap_map_entry(l1_va, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
/*
* Map integrated peripherals at same address in first level page
* table so that we can continue to use console.
*/
pmap_devmap_bootstrap(l1_va, devmap);
#ifdef VERBOSE_INIT_ARM
/* Tell the user about where all the bits and pieces live. */
printf("%22s Physical Virtual Num\n", " ");
printf("%22s Starting Ending Starting Ending Pages\n", " ");
static const char mem_fmt[] =
"%20s: 0x%08lx 0x%08lx 0x%08lx 0x%08lx %d\n";
static const char mem_fmt_nov[] =
"%20s: 0x%08lx 0x%08lx %d\n";
printf(mem_fmt, "SDRAM", physical_start, physical_end-1,
KERN_PHYSTOV(physical_start), KERN_PHYSTOV(physical_end-1),
physmem);
printf(mem_fmt, "text section",
KERN_VTOPHYS(physical_start), KERN_VTOPHYS(etext-1),
(vaddr_t)KERNEL_BASE_phys, (vaddr_t)etext-1,
(int)(textsize / PAGE_SIZE));
printf(mem_fmt, "data section",
KERN_VTOPHYS(__data_start), KERN_VTOPHYS(_edata),
(vaddr_t)__data_start, (vaddr_t)_edata,
(int)((round_page((vaddr_t)_edata)
- trunc_page((vaddr_t)__data_start)) / PAGE_SIZE));
printf(mem_fmt, "bss section",
KERN_VTOPHYS(__bss_start), KERN_VTOPHYS(__bss_end__),
(vaddr_t)__bss_start, (vaddr_t)__bss_end__,
(int)((round_page((vaddr_t)__bss_end__)
- trunc_page((vaddr_t)__bss_start)) / PAGE_SIZE));
printf(mem_fmt, "L1 page directory",
kernel_l1pt.pv_pa, kernel_l1pt.pv_pa + L1_TABLE_SIZE - 1,
kernel_l1pt.pv_va, kernel_l1pt.pv_va + L1_TABLE_SIZE - 1,
L1_TABLE_SIZE / PAGE_SIZE);
printf(mem_fmt, "Exception Vectors",
systempage.pv_pa, systempage.pv_pa + PAGE_SIZE - 1,
(vaddr_t)ARM_VECTORS_HIGH, (vaddr_t)ARM_VECTORS_HIGH + PAGE_SIZE - 1,
1);
printf(mem_fmt, "FIQ stack",
fiqstack.pv_pa, fiqstack.pv_pa + (FIQ_STACK_SIZE * PAGE_SIZE) - 1,
fiqstack.pv_va, fiqstack.pv_va + (FIQ_STACK_SIZE * PAGE_SIZE) - 1,
FIQ_STACK_SIZE);
printf(mem_fmt, "IRQ stack",
irqstack.pv_pa, irqstack.pv_pa + (IRQ_STACK_SIZE * PAGE_SIZE) - 1,
irqstack.pv_va, irqstack.pv_va + (IRQ_STACK_SIZE * PAGE_SIZE) - 1,
IRQ_STACK_SIZE);
printf(mem_fmt, "ABT stack",
abtstack.pv_pa, abtstack.pv_pa + (ABT_STACK_SIZE * PAGE_SIZE) - 1,
abtstack.pv_va, abtstack.pv_va + (ABT_STACK_SIZE * PAGE_SIZE) - 1,
ABT_STACK_SIZE);
printf(mem_fmt, "UND stack",
undstack.pv_pa, undstack.pv_pa + (UND_STACK_SIZE * PAGE_SIZE) - 1,
undstack.pv_va, undstack.pv_va + (UND_STACK_SIZE * PAGE_SIZE) - 1,
UND_STACK_SIZE);
printf(mem_fmt, "SVC stack",
kernelstack.pv_pa, kernelstack.pv_pa + (UPAGES * PAGE_SIZE) - 1,
kernelstack.pv_va, kernelstack.pv_va + (UPAGES * PAGE_SIZE) - 1,
UPAGES);
printf(mem_fmt_nov, "Message Buffer",
msgbufphys, msgbufphys + msgbuf_pgs * PAGE_SIZE - 1, msgbuf_pgs);
printf(mem_fmt, "Free Memory", physical_freestart, physical_freeend-1,
KERN_PHYSTOV(physical_freestart), KERN_PHYSTOV(physical_freeend-1),
free_pages);
#endif
/*
* Now we have the real page tables in place so we can switch to them.
* Once this is done we will be running with the REAL kernel page
* tables.
*/
/* Switch tables */
#ifdef VERBOSE_INIT_ARM
printf("switching to new L1 page table @%#lx...", l1_pa);
#endif
cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
setttb(l1_pa);
cpu_tlb_flushID();
cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
#ifdef VERBOSE_INIT_ARM
printf("OK.\n");
#endif
}

View File

@ -0,0 +1,312 @@
/*
* Machine dependant startup code for BEAGLEBOARD boards.
* Based on omap_start.S
*
* Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved.
* Written by Hiroyuki Bessho for Genetec Corporation.
*
* 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. The name of Genetec Corporation may not be used to endorse or
* promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``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 GENETEC CORPORATION
* 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.
*
* Copyright (c) 2003
* Ichiro FUKUHARA <ichiro@ichiro.org>.
* All rights reserved.
*
* 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 by Ichiro FUKUHARA.
* 4. The name of the company nor the name of the author may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``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 ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD 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.
*
* Copyright (c) 2007 Microsoft
* All rights reserved.
*
* 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 by Microsoft
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR OR CONTRIBUTERS 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 "opt_omap.h"
#include "opt_com.h"
#include "assym.h"
#include <machine/asm.h>
#include <arm/armreg.h>
#undef DOMAIN_CLIENT /* assym.h defines as 1, but pte.h defines as 0x01 */
#include <arm/arm32/pmap.h>
#include <arm/omap/omap2_obioreg.h>
#include <evbarm/beagle/beagle.h>
RCSID("$NetBSD: beagle_start.S,v 1.1 2008/10/22 10:50:56 matt Exp $")
#define Invalidate_I_cache(reg) \
mcr p15, 0, reg, c7, c5, 0 /* Invalidate Entire I cache */
/*
* Kernel start routine for BEAGLEBOARD boards.
* At this point, this code has been loaded into SDRAM
* and the MMU is off
*/
.section .start,"ax",%progbits
.global _C_LABEL(beagle_start)
_C_LABEL(beagle_start):
/* Move into supervisor mode and disable IRQs/FIQs. */
mrs r0, cpsr
bic r0, r0, #PSR_MODE
orr r0, r0, #(I32_bit | F32_bit | PSR_SVC32_MODE)
msr cpsr, r0
/*
* Set up a preliminary mapping in the MMU to allow us to run
* at KERNEL_BASE with caches on.
*/
/* Build page table from scratch */
ldr r0, Ltemp_l1_table
mov r1, r0 /* Save the page table address. */
/* Zero the entire table so all virtual addresses are invalid. */
mov r2, #L1_TABLE_SIZE /* in bytes */
mov r3, #0
mov r4, r3
mov r5, r3
mov r6, r3
mov r7, r3
mov r8, r3
mov r10, r3
mov r11, r3
1: stmia r1!, {r3-r8,r10-r11}
stmia r1!, {r3-r8,r10-r11}
stmia r1!, {r3-r8,r10-r11}
stmia r1!, {r3-r8,r10-r11}
subs r2, r2, #(4 * 4 * 8) /* bytes per loop */
bne 1b
/* Now create our entries per the mmu_init_table. */
l1table .req r0
va .req r1
pa .req r2
n_sec .req r3
attr .req r4
itable .req r5
l1sfrm .req r6
adr itable, mmu_init_table
ldr l1sfrm, Ll1_s_frame
b 3f
2: str pa, [l1table, va]
add va, va, #4
add pa, pa, #(L1_S_SIZE)
adds n_sec, n_sec, #-1
bhi 2b
3: ldmia itable!, {va,pa,n_sec,attr}
/* Convert va to l1 offset: va = 4 * (va >> L1_S_SHIFT) */
mov va, va, LSR #L1_S_SHIFT
mov va, va, LSL #2
/* Convert pa to l1 entry: pa = (pa & L1_S_FRAME) | attr */
and pa, pa, l1sfrm
orr pa, pa, attr
cmp n_sec, #0
bne 2b
.unreq va
.unreq pa
.unreq n_sec
.unreq attr
.unreq itable
.unreq l1table
.unreq l1sfrm
/*
* In theory, because the MMU is off, we shouldn't need all of this,
* but let's not take any chances and do a typical sequence to set
* the Translation Table Base.
*/
Invalidate_I_cache(r0)
mcr p15, 0, r0, c7, c14, 0 /* Clean and Invalidate Entire Data Cache */
ldr r2, Lctl_ID_dis /* Disable I+D caches */
mrc p15, 0, r1, c1, c0, 0 /* " " " */
and r1, r1, r2 /* " " " */
mcr p15, 0, r1, c1, c0, 0 /* " " " */
#ifdef NOTYET
/*
* XXX Restrict cache size is reported to be unsupported on SDP2340
* XXX your CPU mileage may vary... as yet there is not generalized way to do this
*/
ldr r2, Lauxctl_CZ_restrict /* Restrict cache size */
mrc p15, 0, r1, c1, c0, 1 /* " " " */
orr r1, r1, r2 /* " " " */
mcr p15, 0, r1, c1, c0, 1 /* " " " */
#endif
mcr p15, 0, r0, c7, c10, 4 /* Drain the write buffers. */
mcr p15, 0, r0, c2, c0, 0 /* Set Translation Table Base */
mcr p15, 0, r0, c8, c7, 0 /* Invalidate TLBs */
/* Set the Domain Access register. Very important! */
mov r0, #((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT)
mcr p15, 0, r0, c3, c0, 0
/*
* Enable the MMU, etc.
*/
mrc p15, 0, r0, c1, c0, 0
ldr r1, Lcontrol_wax
and r0, r0, r1
ldr r1, Lcontrol_clr
mvn r1, r1
and r0, r0, r1
ldr r1, Lcontrol_set
orr r0, r0, r1
mcr p15, 0, r0, c1, c0, 0
/*
* Ensure that the coprocessor has finished turning on the MMU.
*/
mrc p15, 0, r0, c2, c0, 0 /* Read an arbitrary value. */
mov r0, r0 /* Stall until read completes. */
/*
* Jump to start in locore.S, which in turn will call initarm and main.
*/
b start /* Jump to start (flushes pipeline). */
nop
nop
nop
nop
/* NOTREACHED */
Ll1_s_frame:
.word L1_S_FRAME
Ltemp_l1_table:
/* Put the temporary L1 translation table at the end of SDRAM. */
.word 0x80000000 + MEMSIZE * 0x100000 - L1_TABLE_SIZE
/*
* Coprocessor register initialization values
*/
# define CPU_AUXCTL_CZ (1 << 6) /* Restrict Cache Size */
/* bits to set in the Control Register */
Lcontrol_set:
.word CPU_CONTROL_MMU_ENABLE | \
CPU_CONTROL_AFLT_ENABLE | \
CPU_CONTROL_DC_ENABLE | \
CPU_CONTROL_WBUF_ENABLE | \
CPU_CONTROL_32BP_ENABLE | \
CPU_CONTROL_32BD_ENABLE | \
CPU_CONTROL_LABT_ENABLE | \
CPU_CONTROL_SYST_ENABLE | \
CPU_CONTROL_IC_ENABLE
/* bits to clear in the Control Register */
Lcontrol_clr:
.word 0
/* bits to "write as existing" in the Control Register */
Lcontrol_wax:
.word (3 << 30) | \
(1 << 29) | \
(1 << 28) | \
(3 << 26) | \
(3 << 19) | \
(1 << 17)
/* bits to disable the caches */
Lctl_ID_dis:
.word ~(CPU_CONTROL_IC_ENABLE|CPU_CONTROL_DC_ENABLE)
/* bit to restrict cache size */
Lauxctl_CZ_restrict:
.word CPU_AUXCTL_CZ
/* We'll modify va and pa at run time so we can use relocatable addresses. */
#define MMU_INIT(va,pa,n_sec,attr) \
.word va ; \
.word pa ; \
.word n_sec ; \
.word attr ;
mmu_init_table:
/* Map KERNEL_BASE VA to SDRAM PA, write-back cacheable */
MMU_INIT(KERNEL_BASE, KERNEL_BASE,
(MEMSIZE * L1_S_SIZE + L1_S_SIZE - 1) / L1_S_SIZE,
L1_S_PROTO | L1_S_AP(AP_KRW) | L1_S_B | L1_S_C)
/* Map first 1MB of L4 CORE (so console will work) */
MMU_INIT(OMAP3530_L4_CORE_VBASE, OMAP3530_L4_CORE_BASE,
1,
L1_S_PROTO | L1_S_AP(AP_KRW))
/* Map first 1MB of L4 WAKEUP (so console will work) */
MMU_INIT(OMAP3530_L4_WAKEUP_VBASE, OMAP3530_L4_WAKEUP_BASE,
1,
L1_S_PROTO | L1_S_AP(AP_KRW))
/* end of table */
MMU_INIT(0, 0, 0, 0)

View File

@ -0,0 +1,256 @@
#
# $NetBSD: BEAGLEBOARD,v 1.1 2008/10/22 10:50:56 matt Exp $
#
# BEAGLEBOARD -- TI OMAP 3530 Eval Board Kernel
#
include "arch/evbarm/conf/std.beagle"
# estimated number of users
maxusers 32
# Standard system options
options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT
#options NTP # NTP phase/frequency locked loop
# CPU options
options CPU_CORTEXA8
options OMAP_3530
options PMAPCOUNTERS
# Architecture options
# File systems
file-system FFS # UFS
#file-system LFS # log-structured file system
file-system MFS # memory file system
file-system NFS # Network file system
#file-system ADOSFS # AmigaDOS-compatible file system
#file-system EXT2FS # second extended file system (linux)
#file-system CD9660 # ISO 9660 + Rock Ridge file system
file-system MSDOSFS # MS-DOS file system
#file-system FDESC # /dev/fd
#file-system KERNFS # /kern
#file-system NULLFS # loopback file system
#file-system PORTAL # portal filesystem (still experimental)
#file-system PROCFS # /proc
#file-system UMAPFS # NULLFS + uid and gid remapping
#file-system UNION # union file system
file-system TMPFS # memory file system
file-system PTYFS # /dev/pts/N support
# File system options
#options QUOTA # UFS quotas
#options FFS_EI # FFS Endian Independant support
#options NFSSERVER
#options SOFTDEP
options WAPBL # File system journaling support - Experimental
#options FFS_NO_SNAPSHOT # No FFS snapshot support
# Networking options
#options GATEWAY # packet forwarding
options INET # IP + ICMP + TCP + UDP
options INET6 # IPV6
#options IPSEC # IP security
#options IPSEC_ESP # IP security (encryption part; define w/ IPSEC)
#options IPSEC_NAT_T # IPsec NAT traversal (NAT-T)
#options IPSEC_DEBUG # debug for IP security
#options MROUTING # IP multicast routing
#options PIM # Protocol Independent Multicast
#options NS # XNS
#options NSIP # XNS tunneling over IP
#options ISO,TPIP # OSI
#options EON # OSI tunneling over IP
#options CCITT,LLC,HDLC # X.25
#options NETATALK # AppleTalk networking
#options PFIL_HOOKS # pfil(9) packet filter hooks
#options PPP_BSDCOMP # BSD-Compress compression support for PPP
#options PPP_DEFLATE # Deflate compression support for PPP
#options PPP_FILTER # Active filter support for PPP (requires bpf)
#options TCP_DEBUG # Record last TCP_NDEBUG packets with SO_DEBUG
options NFS_BOOT_BOOTP
options NFS_BOOT_DHCP
#options NFS_BOOT_BOOTSTATIC
#options NFS_BOOTSTATIC_MYIP="\"192.168.1.4\""
#options NFS_BOOTSTATIC_GWIP="\"192.168.1.1\""
#options NFS_BOOTSTATIC_MASK="\"255.255.255.0\""
#options NFS_BOOTSTATIC_SERVADDR="\"192.168.1.1\""
#options NFS_BOOTSTATIC_SERVER="\"192.168.1.1:/nfs/sdp2430\""
options NFS_BOOT_RWSIZE=1024
# Compatibility options
#options COMPAT_43 # 4.3BSD compatibility.
options COMPAT_40 # NetBSD 4.0 compatibility.
options COMPAT_30 # NetBSD 3.0 compatibility.
#options COMPAT_20 # NetBSD 2.0 compatibility.
#options COMPAT_16 # NetBSD 1.6 compatibility.
#options COMPAT_15 # NetBSD 1.5 compatibility.
#options COMPAT_14 # NetBSD 1.4 compatibility.
#options COMPAT_13 # NetBSD 1.3 compatibility.
#options COMPAT_12 # NetBSD 1.2 compatibility.
#options COMPAT_11 # NetBSD 1.1 compatibility.
#options COMPAT_10 # NetBSD 1.0 compatibility.
#options COMPAT_09 # NetBSD 0.9 compatibility.
#options TCP_COMPAT_42 # 4.2BSD TCP/IP bug compat. Not recommended.
#options COMPAT_BSDPTY # /dev/[pt]ty?? ptys.
# Shared memory options
options SYSVMSG # System V-like message queues
options SYSVSEM # System V-like semaphores
#options SEMMNI=10 # number of semaphore identifiers
#options SEMMNS=60 # number of semaphores in system
#options SEMUME=10 # max number of undo entries per process
#options SEMMNU=30 # number of undo structures in system
options SYSVSHM # System V-like memory sharing
#options SHMMAXPGS=1024 # 1024 pages is the default
# Device options
#options MEMORY_DISK_HOOKS # boottime setup of ramdisk
#options MEMORY_DISK_ROOT_SIZE=8192 # Size in blocks
#options MEMORY_DISK_DYNAMIC
#options MINIROOTSIZE=1000 # Size in blocks
#options MEMORY_DISK_IS_ROOT # use memory disk as root
# Miscellaneous kernel options
options KTRACE # system call tracing, a la ktrace(1)
#options LKM # loadable kernel modules
#options KMEMSTATS # kernel memory statistics
#options SCSIVERBOSE # Verbose SCSI errors
#options MIIVERBOSE # Verbose MII autoconfuration messages
#options DDB_KEYCODE=0x40
#options USERCONF # userconf(4) support
#options PIPE_SOCKETPAIR # smaller, but slower pipe(2)
# Development and Debugging options
#options PERFCTRS # performance counters
options DIAGNOSTIC # internally consistency checks
#options DEBUG
#options PMAP_DEBUG # Enable pmap_debug_level code
#options IPKDB # remote kernel debugging
options VERBOSE_INIT_ARM # verbose bootstraping messages
options DDB # in-kernel debugger
options DDB_ONPANIC=1
options DDB_HISTORY_SIZE=100 # Enable history editing in DDB
#options KGDB
makeoptions DEBUG="-g" # compile full symbol table
options SYMTAB_SPACE=300000
## USB Debugging options
options USB_DEBUG
options OHCI_DEBUG
options UHUB_DEBUG
# Valid options for BOOT_ARGS:
# single Boot to single user only
# kdb Give control to kernel debugger
# ask Ask for file name to reboot from
# pmapdebug=<n> If PMAP_DEBUG, set pmap_debug_level to <n>
# memorydisk=<n> Set memorydisk size to <n> KB
# quiet Show aprint_naive output
# verbose Show aprint_normal and aprint_verbose output
options BOOT_ARGS="\"\""
config netbsd root on ? type ?
# The main bus device
mainbus0 at root
# The boot cpu
cpu0 at mainbus?
# Specify the memory size in megabytes.
options MEMSIZE=128
# L3 Interconnect
L3i0 at mainbus?
# OBIO
obio0 at mainbus? base 0x48000000 size 0x1000000 # L4 CORE
obio1 at mainbus? base 0x48300000 size 0x0040000 # L4 WAKEUP
obio2 at mainbus? base 0x49000000 size 0x0100000 # L4 PERIPHERAL
obio3 at mainbus? base 0x54000000 size 0x0800000 # L4 EMUL
# General Purpose Memory Controller
gpmc0 at mainbus? base 0x6e000000
# Interrupt Controller
omapicu0 at obio0 addr 0x48200000 size 0x1000 intrbase 0
omapgpio0 at obio1 addr 0x48310000 size 0x0400 intrbase 96 intr 29
#omapgpio1 at obio2 addr 0x49050000 size 0x0400 intrbase 128 intr 30
#omapgpio2 at obio2 addr 0x49052000 size 0x0400 intrbase 160 intr 31
#omapgpio3 at obio2 addr 0x49054000 size 0x0400 intrbase 192 intr 32
omapgpio4 at obio2 addr 0x49056000 size 0x0400 intrbase 224 intr 33
#omapgpio5 at obio2 addr 0x49058000 size 0x0400 intrbase 256 intr 34
gpio* at omapgpio?
# # I2C Controller
# omapi2c0 at tipb? addr 0xfffb3800 intr 36 mult 4
# iic* at omapi2c?
# # omap's own i2c address
# options OMAP_I2C_ADDRESS=0xe
# # i2c bus clock low and high times in ns
# options I2C_LOW_TIME_nSEC=1500
# options I2C_HIGH_TIME_nSEC=1000
# On-board 16550 UARTs
com0 at obio2 addr 0x49020000 intr 74 mult 4 # UART3 (console)
options CONSADDR=0x49020000, CONSPEED=57600
#options CONSADDR=0x49020000, CONSPEED=115200
# Operating System Timer
omapmputmr0 at obio2 addr 0x49032000 intr 38 # GP Timer 2
# Statistics Timer
omapmputmr1 at obio2 addr 0x49034000 intr 39 # GP Timer 3
# Microtime Reference Timer
omapmputmr2 at obio2 addr 0x49036000 intr 40 # GP Timer 4
options OMAP_MPU_TIMER_CLOCK_FREQ=12000000
# Watchdog timers
omapwdt32k* at obio2 addr 0x49030000 size 2048 # WDT3
#omapwdt32k* at obio1 addr 0x4830c000 size 2048 # WDT1
#omapwdt32k* at obio1 addr 0x48314000 size 2048 # WDT2
# On-board USB
##ohci* at obio0 addr 0x48064400 size 0x0400 intr 75
##usb* at ohci?
##uhub* at usb?
##umass* at uhub? port ? configuration ? interface ?
##wd* at umass?
# Hardware clocking and power management
options HWCLOCK
options HWCLOCK_MACHINE="<arch/arm/omap/hwclock_omap1.h>"
options OMAP_CK_REF_SPEED=12000000
# Pseudo-Devices
# disk/mass storage pseudo-devices
pseudo-device md 1 # memory disk device (ramdisk)
#pseudo-device vnd # disk-like interface to files
#pseudo-device fss 4 # file system snapshot device
# network pseudo-devices
pseudo-device bpfilter # Berkeley packet filter
pseudo-device loop # network loopback
#pseudo-device kttcp # network loopback
# miscellaneous pseudo-devices
pseudo-device pty # pseudo-terminals
pseudo-device rnd # /dev/random and in-kernel generator
#options RND_COM
#pseudo-device clockctl # user control of clock subsystem
pseudo-device ksyms # /dev/ksyms

View File

@ -0,0 +1,18 @@
# $NetBSD: files.beagle,v 1.1 2008/10/22 10:50:56 matt Exp $
#
# TI OMAP2 evaluation board configuration info
#
file arch/evbarm/beagle/beagle_machdep.c
# Kernel boot arguments
defparam opt_machdep.h BOOT_ARGS
# CPU support and integrated peripherals
include "arch/arm/omap/files.omap2"
# NS16550 compatible serial ports
attach com at obio with obiouart
file arch/arm/omap/obio_com.c obiouart
defparam opt_com.h CONSADDR CONSPEED CONMODE

View File

@ -0,0 +1,15 @@
# $NetBSD: mk.beagle,v 1.1 2008/10/22 10:50:56 matt Exp $
# gcc doesn't know about cortex-a8
CPPFLAGS+= -mcpu=arm1136jf-s
SYSTEM_FIRST_OBJ= beagle_start.o
SYSTEM_FIRST_SFILE= ${THISARM}/beagle/beagle_start.S
KERNEL_BASE_PHYS=0x80300000
KERNEL_BASE_VIRT=0x80300000
SYSTEM_LD_TAIL_EXTRA+=; \
echo ${OBJCOPY} -S -O binary $@ $@.bin; \
${OBJCOPY} -S -O binary $@ $@.bin; \
EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.bin@}

View File

@ -0,0 +1,28 @@
# $NetBSD: std.beagle,v 1.1 2008/10/22 10:50:56 matt Exp $
#
# standard NetBSD/evbarm for BEAGLEBAORD options
machine evbarm arm
include "conf/std" # MI standard options
# Pull in BEAGLEBAORD config definitions.
include "arch/evbarm/conf/files.beagle"
options EXEC_ELF32
options EXEC_SCRIPT
# To support easy transit to ../arch/arm/arm32
options ARM32
options ARM11_PMC
options ARM11_PMC_CCNT_HZ=500000000
options __HAVE_FAST_SOFTINTS # should be in types.h
#options PROCESS_ID_IS_CURLWP
options KERNEL_BASE_EXT=0x80000000
makeoptions LOADADDRESS="0x80300000"
makeoptions BOARDTYPE="beagle"
makeoptions BOARDMKFRAG="${THISARM}/conf/mk.beagle"
makeoptions CPPFLAGS+="-I$S/../../../include"
options ARM_INTR_IMPL="<arch/arm/omap/omap2_intr.h>"
options ARM_GENERIC_TODR