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 beagle and marvell to use the new boo...



details:   https://anonhg.NetBSD.org/src/rev/3dca9fe86f3a
branches:  trunk
changeset: 781321:3dca9fe86f3a
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Sep 01 00:20:49 2012 +0000

description:
Switch beagle and marvell to use the new boot/init code.

diffstat:

 sys/arch/evbarm/beagle/beagle_machdep.c   |  511 +-----------------------------
 sys/arch/evbarm/conf/files.beagle         |    7 +-
 sys/arch/evbarm/conf/files.marvell        |    6 +-
 sys/arch/evbarm/marvell/marvell_machdep.c |  409 +-----------------------
 4 files changed, 39 insertions(+), 894 deletions(-)

diffs (truncated from 1103 to 300 lines):

diff -r 320b356facfc -r 3dca9fe86f3a sys/arch/evbarm/beagle/beagle_machdep.c
--- a/sys/arch/evbarm/beagle/beagle_machdep.c   Sat Sep 01 00:15:11 2012 +0000
+++ b/sys/arch/evbarm/beagle/beagle_machdep.c   Sat Sep 01 00:20:49 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: beagle_machdep.c,v 1.19 2012/08/29 19:10:16 matt Exp $ */
+/*     $NetBSD: beagle_machdep.c,v 1.20 2012/09/01 00:20:49 matt Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.19 2012/08/29 19:10:16 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.20 2012/09/01 00:20:49 matt Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -181,46 +181,16 @@
 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;
-
 /* Same things, but for the free (unused by the kernel) memory. */
-static paddr_t physical_freestart, physical_freeend;
-static u_int free_pages;
-
-/* Physical address of the message buffer. */
-paddr_t msgbufphys;
 
 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];
-
 /*
  * 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
+#define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
 
 /* Prototypes */
 
@@ -229,7 +199,6 @@
 static void kgdb_port_init(void);
 #endif
 
-static void setup_real_page_tables(void);
 static void init_clocks(void);
 #if defined(OMAP_3530) || defined(TI_DM37XX)
 static void omap3_cpu_clk(void);
@@ -247,88 +216,6 @@
 #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();
-               pmf_system_shutdown(boothowto);
-               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
-#if NPRCM > 0
-               prcm_cold_reset();
-#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();
-
-       pmf_system_shutdown(boothowto);
-
-       /* 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
-#if NPRCM > 0
-       prcm_cold_reset();
-#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
@@ -417,9 +304,10 @@
 #undef _S
 
 #ifdef DDB
-static void beagle_db_trap(int where)
+static void
+beagle_db_trap(int where)
 {
-#if  NOMAPWDT32K > 0
+#if NOMAPWDT32K > 0
        static int oldwatchdogstate;
 
        if (where) {
@@ -515,134 +403,23 @@
         * 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();
+       bootconfig.dram[0].address = KERNEL_BASE_PHYS & -0x400000;
+       bootconfig.dram[0].pages = MEMSIZE_BYTES;
 
-       /*
-        * Moved from cpu_startup() as data_abort_handler() references
-        * this during uvm init.
-        */
-       uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
-
-#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);
+       arm32_bootmem_init(bootconfig.dram[0].address, MEMSIZE_BYTES,
+           KERNEL_BASE_PHYS);
+       arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0, devmap, false);
 
-       /*
-        * 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);
+       /* we've a specific device_register routine */
+       //evbarm_device_register = beagle_device_register;
 
-       /* 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
+       db_trap_callback = beagle_db_trap;
 
-#ifdef KGDB
-       if (boothowto & RB_KDB) {
-               kgdb_debug_init = 1;
-               kgdb_connect(1);
-       }



Home | Main Index | Thread Index | Old Index