Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbarm Switch RaspberryPI to use the new boot/init ...
details: https://anonhg.NetBSD.org/src/rev/48304a3ad44b
branches: trunk
changeset: 781361:48304a3ad44b
user: skrll <skrll%NetBSD.org@localhost>
date: Sat Sep 01 17:14:56 2012 +0000
description:
Switch RaspberryPI to use the new boot/init code.
diffstat:
sys/arch/evbarm/conf/files.rpi | 6 +-
sys/arch/evbarm/rpi/rpi_machdep.c | 481 +-------------------------------------
2 files changed, 17 insertions(+), 470 deletions(-)
diffs (truncated from 566 to 300 lines):
diff -r e8aba390038b -r 48304a3ad44b sys/arch/evbarm/conf/files.rpi
--- a/sys/arch/evbarm/conf/files.rpi Sat Sep 01 17:11:56 2012 +0000
+++ b/sys/arch/evbarm/conf/files.rpi Sat Sep 01 17:14:56 2012 +0000
@@ -1,8 +1,12 @@
-# $NetBSD: files.rpi,v 1.1 2012/07/26 06:21:57 skrll Exp $
+# $NetBSD: files.rpi,v 1.2 2012/09/01 17:15:43 skrll Exp $
#
# Raspberry Pi
#
+file arch/arm/arm32/arm32_boot.c
+file arch/arm/arm32/arm32_kvminit.c
+file arch/arm/arm32/arm32_reboot.c
+
file arch/evbarm/rpi/rpi_machdep.c
# Kernel boot arguments
diff -r e8aba390038b -r 48304a3ad44b sys/arch/evbarm/rpi/rpi_machdep.c
--- a/sys/arch/evbarm/rpi/rpi_machdep.c Sat Sep 01 17:11:56 2012 +0000
+++ b/sys/arch/evbarm/rpi/rpi_machdep.c Sat Sep 01 17:14:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rpi_machdep.c,v 1.6 2012/08/22 12:36:35 jakllsch Exp $ */
+/* $NetBSD: rpi_machdep.c,v 1.7 2012/09/01 17:14:56 skrll Exp $ */
/*
* Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
@@ -122,7 +122,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.6 2012/08/22 12:36:35 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.7 2012/09/01 17:14:56 skrll Exp $");
#include "opt_evbarm_boardtype.h"
@@ -158,43 +158,16 @@
#include "ksyms.h"
-static void setup_real_page_tables(void);
BootConfig bootconfig; /* Boot config storage */
static char bootargs[MAX_BOOT_STRING];
char *boot_args = NULL;
-vm_offset_t physical_start;
-vm_offset_t physical_freestart;
-vm_offset_t physical_freeend;
-vm_offset_t physical_end;
-u_int free_pages;
-
-vm_offset_t msgbufphys;
-
-extern char etext[];
-extern char __data_start[], _edata[];
-extern char __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];
-
/*
* Macros to translate between physical and virtual for a subset of the
* kernel address space. *Not* for general use.
*/
-#define KERNEL_BASE_PHYS physical_start
-#define KERN_VTOPHYS(va) \
- ((paddr_t)((vaddr_t)va - KERNEL_BASE + KERNEL_BASE_PHYS))
+#define KERNEL_BASE_PHYS (paddr_t)0
#define KERN_PHYSTOV(pa) \
((vaddr_t)((paddr_t)pa - KERNEL_BASE_PHYS + KERNEL_BASE))
@@ -229,57 +202,6 @@
/* Smallest amount of RAM start.elf could give us. */
#define RPI_MINIMUM_ARM_RAM_SPLIT (128U * 1024 * 1024)
-void
-cpu_reboot(int howto, char *bootstr)
-{
-
- /*
- * If we are still cold then hit the air brakes
- * and crash to earth fast
- */
- if (cold) {
- doshutdownhooks();
- printf("The operating system has halted.\r\n");
- printf("Please press any key to reboot.\r\n");
- cngetc();
- printf("rebooting...\r\n");
- bcm2835_system_reset();
- }
-
- /*
- * 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.\r\n");
- printf("Please press any key to reboot.\r\n");
- cngetc();
- }
-
- printf("rebooting...\r\n");
- bcm2835_system_reset();
-
- /*NOTREACHED*/
-}
/*
* Static device mappings. These peripheral registers are mapped at
@@ -369,12 +291,10 @@
atp->u.mem.size - 1);
continue;
}
- physical_end = atp->u.mem.size;
- physmem = physical_end / PAGE_SIZE;
KASSERT(atp->u.mem.start == 0);
- physical_start = atp->u.mem.start;
bootconfig.dram[bootconfig.dramblocks].address = 0x0;
- bootconfig.dram[bootconfig.dramblocks].pages = physmem;
+ bootconfig.dram[bootconfig.dramblocks].pages =
+ atp->u.mem.size / PAGE_SIZE;
++bootconfig.dramblocks;
}
@@ -431,132 +351,16 @@
parse_linux_atags((void *)KERN_PHYSTOV(rpi_boot_regs[2]));
} else {
bootconfig.dramblocks = 1;
- physical_end = RPI_MINIMUM_ARM_RAM_SPLIT;
- physmem = physical_end / PAGE_SIZE;
- physical_start = 0;
bootconfig.dram[0].address = 0x0;
- bootconfig.dram[0].pages = physmem;
+ bootconfig.dram[0].pages =
+ RPI_MINIMUM_ARM_RAM_SPLIT / PAGE_SIZE;
}
-
- /*
- * 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;
-
-#ifdef VERBOSE_INIT_ARM
- /* Tell the user about the memory */
- printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
- physical_start, physical_end - 1);
-#endif
-
- /*
- * 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();
-
- /*
- * Okay, the kernel starts 8kB in from the bottom of physical
- * memory. We are going to allocate our bootstrap pages upwards
- * from physical_freestart.
- *
- * We need to allocate some fixed page tables to get the kernel
- * going. 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 bounaries. 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("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
- physical_freestart, free_pages, free_pages);
-#endif
-
- /*
- * Moved from cpu_startup() as data_abort_handler() references
- * this during uvm init.
- */
- uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
+ arm32_bootmem_init(bootconfig.dram[0].address,
+ bootconfig.dram[0].pages * PAGE_SIZE, bootconfig.dram[0].address);
+ arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0, rpi_devmap,
+ false);
-#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);
-
cpu_reset_address = bcm2835_system_reset;
#ifdef VERBOSE_INIT_ARM
@@ -574,21 +378,7 @@
boothowto |= BOOTHOWTO;
#endif
-#ifdef KGDB
- if (boothowto & RB_KDB) {
- kgdb_debug_init = 1;
- kgdb_connect(1);
Home |
Main Index |
Thread Index |
Old Index