Home | History | Annotate | Line # | Download | only in mini2440
mini2440_machdep.c revision 1.2
      1  1.1  nisimura /*-
      2  1.1  nisimura  * Copyright (c) 2012 The NetBSD Foundation, Inc.
      3  1.1  nisimura  * All rights reserved.
      4  1.1  nisimura  *
      5  1.1  nisimura  * This code is derived from software contributed to The NetBSD Foundation
      6  1.1  nisimura  * by Paul Fleischer <paul (at) xpg.dk>
      7  1.1  nisimura  *
      8  1.1  nisimura  * Redistribution and use in source and binary forms, with or without
      9  1.1  nisimura  * modification, are permitted provided that the following conditions
     10  1.1  nisimura  * are met:
     11  1.1  nisimura  * 1. Redistributions of source code must retain the above copyright
     12  1.1  nisimura  *    notice, this list of conditions and the following disclaimer.
     13  1.1  nisimura  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  nisimura  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  nisimura  *    documentation and/or other materials provided with the distribution.
     16  1.1  nisimura  *
     17  1.1  nisimura  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     18  1.1  nisimura  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19  1.1  nisimura  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20  1.1  nisimura  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     21  1.1  nisimura  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22  1.1  nisimura  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23  1.1  nisimura  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  1.1  nisimura  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25  1.1  nisimura  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26  1.1  nisimura  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27  1.1  nisimura  * POSSIBILITY OF SUCH DAMAGE.
     28  1.1  nisimura  */
     29  1.1  nisimura /* This file is based on arch/evbarm/smdk2xx0/smdk2410_machdep.c */
     30  1.1  nisimura /*
     31  1.1  nisimura  * Copyright (c) 2002, 2003 Fujitsu Component Limited
     32  1.1  nisimura  * Copyright (c) 2002, 2003, 2005 Genetec Corporation
     33  1.1  nisimura  * All rights reserved.
     34  1.1  nisimura  *
     35  1.1  nisimura  * Redistribution and use in source and binary forms, with or without
     36  1.1  nisimura  * modification, are permitted provided that the following conditions
     37  1.1  nisimura  * are met:
     38  1.1  nisimura  * 1. Redistributions of source code must retain the above copyright
     39  1.1  nisimura  *    notice, this list of conditions and the following disclaimer.
     40  1.1  nisimura  * 2. Redistributions in binary form must reproduce the above copyright
     41  1.1  nisimura  *    notice, this list of conditions and the following disclaimer in the
     42  1.1  nisimura  *    documentation and/or other materials provided with the distribution.
     43  1.1  nisimura  * 3. Neither the name of The Fujitsu Component Limited nor the name of
     44  1.1  nisimura  *    Genetec corporation may not be used to endorse or promote products
     45  1.1  nisimura  *    derived from this software without specific prior written permission.
     46  1.1  nisimura  *
     47  1.1  nisimura  * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
     48  1.1  nisimura  * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     49  1.1  nisimura  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     50  1.1  nisimura  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     51  1.1  nisimura  * DISCLAIMED.  IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
     52  1.1  nisimura  * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     53  1.1  nisimura  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     54  1.1  nisimura  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
     55  1.1  nisimura  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     56  1.1  nisimura  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     57  1.1  nisimura  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     58  1.1  nisimura  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     59  1.1  nisimura  * SUCH DAMAGE.
     60  1.1  nisimura  */
     61  1.1  nisimura /*
     62  1.1  nisimura  * Copyright (c) 2001,2002 ARM Ltd
     63  1.1  nisimura  * All rights reserved.
     64  1.1  nisimura  *
     65  1.1  nisimura  * Redistribution and use in source and binary forms, with or without
     66  1.1  nisimura  * modification, are permitted provided that the following conditions
     67  1.1  nisimura  * are met:
     68  1.1  nisimura  * 1. Redistributions of source code must retain the above copyright
     69  1.1  nisimura  *    notice, this list of conditions and the following disclaimer.
     70  1.1  nisimura  * 2. Redistributions in binary form must reproduce the above copyright
     71  1.1  nisimura  *    notice, this list of conditions and the following disclaimer in the
     72  1.1  nisimura  *    documentation and/or other materials provided with the distribution.
     73  1.1  nisimura  * 3. The name of the company may not be used to endorse or promote
     74  1.1  nisimura  *    products derived from this software without specific prior written
     75  1.1  nisimura  *    permission.
     76  1.1  nisimura  *
     77  1.1  nisimura  * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND
     78  1.1  nisimura  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     79  1.1  nisimura  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     80  1.1  nisimura  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ARM LTD
     81  1.1  nisimura  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     82  1.1  nisimura  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     83  1.1  nisimura  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     84  1.1  nisimura  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     85  1.1  nisimura  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     86  1.1  nisimura  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     87  1.1  nisimura  * POSSIBILITY OF SUCH DAMAGE.
     88  1.1  nisimura  *
     89  1.1  nisimura  */
     90  1.1  nisimura 
     91  1.1  nisimura /*
     92  1.1  nisimura  * Copyright (c) 1997,1998 Mark Brinicombe.
     93  1.1  nisimura  * Copyright (c) 1997,1998 Causality Limited.
     94  1.1  nisimura  * All rights reserved.
     95  1.1  nisimura  *
     96  1.1  nisimura  * Redistribution and use in source and binary forms, with or without
     97  1.1  nisimura  * modification, are permitted provided that the following conditions
     98  1.1  nisimura  * are met:
     99  1.1  nisimura  * 1. Redistributions of source code must retain the above copyright
    100  1.1  nisimura  *    notice, this list of conditions and the following disclaimer.
    101  1.1  nisimura  * 2. Redistributions in binary form must reproduce the above copyright
    102  1.1  nisimura  *    notice, this list of conditions and the following disclaimer in the
    103  1.1  nisimura  *    documentation and/or other materials provided with the distribution.
    104  1.1  nisimura  * 3. All advertising materials mentioning features or use of this software
    105  1.1  nisimura  *    must display the following acknowledgement:
    106  1.1  nisimura  *	This product includes software developed by Mark Brinicombe
    107  1.1  nisimura  *	for the NetBSD Project.
    108  1.1  nisimura  * 4. The name of the company nor the name of the author may be used to
    109  1.1  nisimura  *    endorse or promote products derived from this software without specific
    110  1.1  nisimura  *    prior written permission.
    111  1.1  nisimura  *
    112  1.1  nisimura  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
    113  1.1  nisimura  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    114  1.1  nisimura  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    115  1.1  nisimura  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
    116  1.1  nisimura  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    117  1.1  nisimura  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    118  1.1  nisimura  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    119  1.1  nisimura  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    120  1.1  nisimura  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    121  1.1  nisimura  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    122  1.1  nisimura  * SUCH DAMAGE.
    123  1.1  nisimura  *
    124  1.1  nisimura  * Machine dependant functions for kernel setup for integrator board
    125  1.1  nisimura  *
    126  1.1  nisimura  * Created      : 24/11/97
    127  1.1  nisimura  */
    128  1.1  nisimura 
    129  1.1  nisimura /*
    130  1.1  nisimura  * Machine dependant functions for kernel setup for FriendlyARM MINI2440
    131  1.1  nisimura  */
    132  1.1  nisimura 
    133  1.1  nisimura #include <sys/cdefs.h>
    134  1.2  nisimura __KERNEL_RCSID(0, "$NetBSD: mini2440_machdep.c,v 1.2 2012/02/03 00:33:08 nisimura Exp $");
    135  1.1  nisimura 
    136  1.1  nisimura #include "opt_ddb.h"
    137  1.1  nisimura #include "opt_kgdb.h"
    138  1.1  nisimura #include "opt_pmap_debug.h"
    139  1.1  nisimura #include "opt_md.h"
    140  1.1  nisimura 
    141  1.1  nisimura #include <sys/param.h>
    142  1.1  nisimura #include <sys/device.h>
    143  1.1  nisimura #include <sys/systm.h>
    144  1.1  nisimura #include <sys/kernel.h>
    145  1.1  nisimura #include <sys/exec.h>
    146  1.1  nisimura #include <sys/proc.h>
    147  1.1  nisimura #include <sys/msgbuf.h>
    148  1.1  nisimura #include <sys/reboot.h>
    149  1.1  nisimura #include <sys/termios.h>
    150  1.1  nisimura #include <sys/ksyms.h>
    151  1.1  nisimura #include <sys/mount.h>
    152  1.1  nisimura 
    153  1.1  nisimura #include <net/if.h>
    154  1.1  nisimura #include <net/if_ether.h>
    155  1.1  nisimura #include <net/if_media.h>
    156  1.1  nisimura 
    157  1.1  nisimura #include <uvm/uvm_extern.h>
    158  1.1  nisimura 
    159  1.1  nisimura #include <dev/cons.h>
    160  1.1  nisimura #include <dev/md.h>
    161  1.1  nisimura 
    162  1.1  nisimura #include <machine/db_machdep.h>
    163  1.1  nisimura #include <ddb/db_sym.h>
    164  1.1  nisimura #include <ddb/db_extern.h>
    165  1.1  nisimura #ifdef KGDB
    166  1.1  nisimura #include <sys/kgdb.h>
    167  1.1  nisimura #endif
    168  1.1  nisimura 
    169  1.1  nisimura #include <sys/exec_elf.h>
    170  1.1  nisimura 
    171  1.1  nisimura #include <sys/bus.h>
    172  1.1  nisimura #include <machine/cpu.h>
    173  1.1  nisimura #include <machine/frame.h>
    174  1.1  nisimura #include <machine/intr.h>
    175  1.1  nisimura #include <arm/undefined.h>
    176  1.1  nisimura 
    177  1.1  nisimura #include <machine/autoconf.h>
    178  1.1  nisimura 
    179  1.1  nisimura #include <arm/arm32/machdep.h>
    180  1.1  nisimura 
    181  1.1  nisimura #include <arm/s3c2xx0/s3c2440reg.h>
    182  1.1  nisimura #include <arm/s3c2xx0/s3c2440var.h>
    183  1.1  nisimura 
    184  1.1  nisimura #include <arch/evbarm/mini2440/mini2440_bootinfo.h>
    185  1.1  nisimura 
    186  1.1  nisimura #include "ksyms.h"
    187  1.1  nisimura 
    188  1.1  nisimura #ifndef	SDRAM_START
    189  1.1  nisimura #define	SDRAM_START	S3C2440_SDRAM_START
    190  1.1  nisimura #endif
    191  1.1  nisimura #ifndef	SDRAM_SIZE
    192  1.1  nisimura #define	SDRAM_SIZE	(64*1024*1024) /* 64 Mb */
    193  1.1  nisimura #endif
    194  1.1  nisimura 
    195  1.1  nisimura /*
    196  1.1  nisimura  * Address to map I/O registers in early initialize stage.
    197  1.1  nisimura  */
    198  1.1  nisimura #define MINI2440_IO_VBASE	0xfd000000
    199  1.1  nisimura 
    200  1.1  nisimura /* Kernel text starts 2MB in from the bottom of the kernel address space. */
    201  1.1  nisimura #define KERNEL_OFFSET		0x00200000
    202  1.1  nisimura #define	KERNEL_TEXT_BASE	(KERNEL_BASE + KERNEL_OFFSET)
    203  1.1  nisimura #define	KERNEL_VM_BASE		(KERNEL_BASE + 0x01000000)
    204  1.1  nisimura 
    205  1.1  nisimura /*
    206  1.1  nisimura  * The range 0xc1000000 - 0xccffffff is available for kernel VM space
    207  1.1  nisimura  * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
    208  1.1  nisimura  */
    209  1.1  nisimura #define KERNEL_VM_SIZE		0x0C000000
    210  1.1  nisimura 
    211  1.1  nisimura /*
    212  1.1  nisimura  * Address to call from cpu_reset() to reset the machine.
    213  1.1  nisimura  * This is machine architecture dependant as it varies depending
    214  1.1  nisimura  * on where the ROM appears when you turn the MMU off.
    215  1.1  nisimura  */
    216  1.1  nisimura u_int cpu_reset_address = (u_int)0;
    217  1.1  nisimura 
    218  1.1  nisimura /* Define various stack sizes in pages */
    219  1.1  nisimura #define IRQ_STACK_SIZE	1
    220  1.1  nisimura #define ABT_STACK_SIZE	1
    221  1.1  nisimura #define UND_STACK_SIZE	1
    222  1.1  nisimura 
    223  1.1  nisimura /* Declared extern elsewhere in the kernel */
    224  1.1  nisimura BootConfig bootconfig;		/* Boot config storage */
    225  1.1  nisimura char *boot_args = NULL;
    226  1.1  nisimura //char *boot_file = NULL;
    227  1.1  nisimura 
    228  1.1  nisimura char bootinfo[BOOTINFO_MAXSIZE];
    229  1.1  nisimura struct btinfo_rootdevice 	*bi_rdev;
    230  1.1  nisimura struct btinfo_net		*bi_net;
    231  1.1  nisimura struct btinfo_bootpath		*bi_path;
    232  1.1  nisimura 
    233  1.1  nisimura vm_offset_t physical_start;
    234  1.1  nisimura vm_offset_t physical_freestart;
    235  1.1  nisimura vm_offset_t physical_freeend;
    236  1.1  nisimura vm_offset_t physical_freeend_low;
    237  1.1  nisimura vm_offset_t physical_end;
    238  1.1  nisimura u_int free_pages;
    239  1.1  nisimura vm_offset_t pagetables_start;
    240  1.1  nisimura int physmem = 0;
    241  1.1  nisimura 
    242  1.1  nisimura /*int debug_flags;*/
    243  1.1  nisimura #ifndef PMAP_STATIC_L1S
    244  1.1  nisimura int max_processes = 64;		/* Default number */
    245  1.1  nisimura #endif				/* !PMAP_STATIC_L1S */
    246  1.1  nisimura 
    247  1.1  nisimura /* Physical and virtual addresses for some global pages */
    248  1.1  nisimura pv_addr_t irqstack;
    249  1.1  nisimura pv_addr_t undstack;
    250  1.1  nisimura pv_addr_t abtstack;
    251  1.1  nisimura pv_addr_t kernelstack;
    252  1.1  nisimura 
    253  1.1  nisimura vm_offset_t msgbufphys;
    254  1.1  nisimura 
    255  1.1  nisimura extern u_int data_abort_handler_address;
    256  1.1  nisimura extern u_int prefetch_abort_handler_address;
    257  1.1  nisimura extern u_int undefined_handler_address;
    258  1.1  nisimura 
    259  1.1  nisimura #ifdef PMAP_DEBUG
    260  1.1  nisimura extern int pmap_debug_level;
    261  1.1  nisimura #endif
    262  1.1  nisimura 
    263  1.1  nisimura #define KERNEL_PT_SYS		0	/* L2 table for mapping zero page */
    264  1.1  nisimura #define KERNEL_PT_KERNEL	1	/* L2 table for mapping kernel */
    265  1.2  nisimura #define KERNEL_PT_KERNEL_NUM	3	/* L2 tables for mapping kernel VM */
    266  1.1  nisimura 
    267  1.1  nisimura #define KERNEL_PT_VMDATA	(KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
    268  1.1  nisimura 
    269  1.2  nisimura #define KERNEL_PT_VMDATA_NUM	4	/* start with 16MB of KVM */
    270  1.1  nisimura #define NUM_KERNEL_PTS		(KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
    271  1.1  nisimura 
    272  1.1  nisimura pv_addr_t kernel_pt_table[NUM_KERNEL_PTS];
    273  1.1  nisimura 
    274  1.1  nisimura struct user *proc0paddr;
    275  1.1  nisimura 
    276  1.1  nisimura /* Prototypes */
    277  1.1  nisimura 
    278  1.1  nisimura void consinit(void);
    279  1.1  nisimura void kgdb_port_init(void);
    280  1.1  nisimura static void mini2440_ksyms(struct btinfo_symtab *bi_symtab);
    281  1.1  nisimura static void *lookup_bootinfo(int type);
    282  1.1  nisimura static void mini2440_device_register(device_t dev, void *aux);
    283  1.1  nisimura 
    284  1.1  nisimura 
    285  1.1  nisimura #include "com.h"
    286  1.1  nisimura #if NCOM > 0
    287  1.1  nisimura #include <dev/ic/comreg.h>
    288  1.1  nisimura #include <dev/ic/comvar.h>
    289  1.1  nisimura #endif
    290  1.1  nisimura 
    291  1.1  nisimura #include "sscom.h"
    292  1.1  nisimura #if NSSCOM > 0
    293  1.1  nisimura #include "opt_sscom.h"
    294  1.1  nisimura #include <arm/s3c2xx0/sscom_var.h>
    295  1.1  nisimura #endif
    296  1.1  nisimura 
    297  1.1  nisimura /*
    298  1.1  nisimura  * Define the default console speed for the board.  This is generally
    299  1.1  nisimura  * what the firmware provided with the board defaults to.
    300  1.1  nisimura  */
    301  1.1  nisimura #ifndef CONSPEED
    302  1.1  nisimura #define CONSPEED B115200	/* TTYDEF_SPEED */
    303  1.1  nisimura #endif
    304  1.1  nisimura #ifndef CONMODE
    305  1.1  nisimura #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8)   /* 8N1 */
    306  1.1  nisimura #endif
    307  1.1  nisimura 
    308  1.1  nisimura int comcnspeed = CONSPEED;
    309  1.1  nisimura int comcnmode = CONMODE;
    310  1.1  nisimura 
    311  1.1  nisimura /*
    312  1.1  nisimura  * void cpu_reboot(int howto, char *bootstr)
    313  1.1  nisimura  *
    314  1.1  nisimura  * Reboots the system
    315  1.1  nisimura  *
    316  1.1  nisimura  * Deal with any syncing, unmounting, dumping and shutdown hooks,
    317  1.1  nisimura  * then reset the CPU.
    318  1.1  nisimura  */
    319  1.1  nisimura void
    320  1.1  nisimura cpu_reboot(int howto, char *bootstr)
    321  1.1  nisimura {
    322  1.1  nisimura #ifdef DIAGNOSTIC
    323  1.1  nisimura 	/* info */
    324  1.1  nisimura 	printf("boot: howto=%08x curproc=%p\n", howto, curproc);
    325  1.1  nisimura #endif
    326  1.1  nisimura 
    327  1.1  nisimura 	cpu_reset_address = vtophys((u_int)s3c2440_softreset);
    328  1.1  nisimura 
    329  1.1  nisimura 	/*
    330  1.1  nisimura 	 * If we are still cold then hit the air brakes
    331  1.1  nisimura 	 * and crash to earth fast
    332  1.1  nisimura 	 */
    333  1.1  nisimura 	if (cold) {
    334  1.1  nisimura 		doshutdownhooks();
    335  1.1  nisimura 		printf("The operating system has halted.\n");
    336  1.1  nisimura 		printf("Please press any key to reboot.\n\n");
    337  1.1  nisimura 		cngetc();
    338  1.1  nisimura 		printf("rebooting...\n");
    339  1.1  nisimura 		cpu_reset();
    340  1.1  nisimura 		/* NOTREACHED */
    341  1.1  nisimura 	}
    342  1.1  nisimura 	/* Disable console buffering */
    343  1.1  nisimura 
    344  1.1  nisimura 	/*
    345  1.1  nisimura 	 * If RB_NOSYNC was not specified sync the discs.
    346  1.1  nisimura 	 * Note: Unless cold is set to 1 here, syslogd will die during the
    347  1.1  nisimura 	 * unmount.  It looks like syslogd is getting woken up only to find
    348  1.1  nisimura 	 * that it cannot page part of the binary in as the filesystem has
    349  1.1  nisimura 	 * been unmounted.
    350  1.1  nisimura 	 */
    351  1.1  nisimura 	if (!(howto & RB_NOSYNC))
    352  1.1  nisimura 		bootsync();
    353  1.1  nisimura 
    354  1.1  nisimura 	/* Say NO to interrupts */
    355  1.1  nisimura 	splhigh();
    356  1.1  nisimura 
    357  1.1  nisimura 	/* Do a dump if requested. */
    358  1.1  nisimura 	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
    359  1.1  nisimura 		dumpsys();
    360  1.1  nisimura 
    361  1.1  nisimura 	/* Run any shutdown hooks */
    362  1.1  nisimura 	doshutdownhooks();
    363  1.1  nisimura 
    364  1.1  nisimura 	/* Make sure IRQ's are disabled */
    365  1.1  nisimura 	IRQdisable;
    366  1.1  nisimura 
    367  1.1  nisimura 	if (howto & RB_HALT) {
    368  1.1  nisimura 		printf("The operating system has halted.\n");
    369  1.1  nisimura 		printf("Please press any key to reboot.\n\n");
    370  1.1  nisimura 		cngetc();
    371  1.1  nisimura 	}
    372  1.1  nisimura 	printf("rebooting...\n");
    373  1.1  nisimura 	cpu_reset();
    374  1.1  nisimura 	/* NOTREACHED */
    375  1.1  nisimura }
    376  1.1  nisimura 
    377  1.1  nisimura /*
    378  1.1  nisimura  * Static device mappings. These peripheral registers are mapped at
    379  1.1  nisimura  * fixed virtual addresses very early in initarm() so that we can use
    380  1.1  nisimura  * them while booting the kernel , and stay at the same address
    381  1.1  nisimura  * throughout whole kernel's life time.
    382  1.1  nisimura  *
    383  1.1  nisimura  * We use this table twice; once with bootstrap page table, and once
    384  1.1  nisimura  * with kernel's page table which we build up in initarm().
    385  1.1  nisimura  *
    386  1.1  nisimura  * Since we map these registers into the bootstrap page table using
    387  1.1  nisimura  * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
    388  1.1  nisimura  * registers segment-aligned and segment-rounded in order to avoid
    389  1.1  nisimura  * using the 2nd page tables.
    390  1.1  nisimura  */
    391  1.1  nisimura 
    392  1.1  nisimura #define	_A(a)	((a) & ~L1_S_OFFSET)
    393  1.1  nisimura #define	_S(s)	(((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
    394  1.1  nisimura 
    395  1.1  nisimura #define	_V(n)	(MINI2440_IO_VBASE + (n) * L1_S_SIZE)
    396  1.1  nisimura 
    397  1.1  nisimura #define	GPIO_VBASE	_V(0)
    398  1.1  nisimura #define	INTCTL_VBASE	_V(1)
    399  1.1  nisimura #define	CLKMAN_VBASE	_V(2)
    400  1.1  nisimura #define	UART_VBASE	_V(3)
    401  1.1  nisimura 
    402  1.1  nisimura static const struct pmap_devmap mini2440_devmap[] = {
    403  1.1  nisimura 	/* GPIO registers */
    404  1.1  nisimura 	{
    405  1.1  nisimura 		GPIO_VBASE,
    406  1.1  nisimura 		_A(S3C2440_GPIO_BASE),
    407  1.1  nisimura 		_S(S3C2440_GPIO_SIZE),
    408  1.1  nisimura 		VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
    409  1.1  nisimura 	},
    410  1.1  nisimura 	{
    411  1.1  nisimura 		INTCTL_VBASE,
    412  1.1  nisimura 		_A(S3C2440_INTCTL_BASE),
    413  1.1  nisimura 		_S(S3C2440_INTCTL_SIZE),
    414  1.1  nisimura 		VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
    415  1.1  nisimura 	},
    416  1.1  nisimura 	{
    417  1.1  nisimura 		CLKMAN_VBASE,
    418  1.1  nisimura 		_A(S3C2440_CLKMAN_BASE),
    419  1.1  nisimura 		_S(S3C24X0_CLKMAN_SIZE),
    420  1.1  nisimura 		VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
    421  1.1  nisimura 	},
    422  1.1  nisimura 	{	/* UART registers for UART0, 1, 2. */
    423  1.1  nisimura 		UART_VBASE,
    424  1.1  nisimura 		_A(S3C2440_UART0_BASE),
    425  1.1  nisimura 		_S(S3C2440_UART_BASE(3) - S3C2440_UART0_BASE),
    426  1.1  nisimura 		VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
    427  1.1  nisimura 	},
    428  1.1  nisimura 
    429  1.1  nisimura 	{ 0, 0, 0, 0 }
    430  1.1  nisimura };
    431  1.1  nisimura 
    432  1.1  nisimura #undef	_A
    433  1.1  nisimura #undef	_S
    434  1.1  nisimura 
    435  1.1  nisimura static inline	pd_entry_t *
    436  1.1  nisimura read_ttb(void)
    437  1.1  nisimura {
    438  1.1  nisimura 	long ttb;
    439  1.1  nisimura 
    440  1.1  nisimura 	__asm volatile("mrc	p15, 0, %0, c2, c0, 0" : "=r"(ttb));
    441  1.1  nisimura 
    442  1.1  nisimura 
    443  1.1  nisimura 	return (pd_entry_t *)(ttb & ~((1 << 14) - 1));
    444  1.1  nisimura }
    445  1.1  nisimura 
    446  1.1  nisimura 
    447  1.1  nisimura #define	ioreg_write32(a,v)  	(*(volatile uint32_t *)(a)=(v))
    448  1.1  nisimura 
    449  1.1  nisimura /*
    450  1.1  nisimura  * u_int initarm(...)
    451  1.1  nisimura  *
    452  1.1  nisimura  * Initial entry point on startup. This gets called before main() is
    453  1.1  nisimura  * entered.
    454  1.1  nisimura  * It should be responsible for setting up everything that must be
    455  1.1  nisimura  * in place when main is called.
    456  1.1  nisimura  * This includes
    457  1.1  nisimura  *   Taking a copy of the boot configuration structure.
    458  1.1  nisimura  *   Initialising the physical console so characters can be printed.
    459  1.1  nisimura  *   Setting up page tables for the kernel
    460  1.1  nisimura  *   Relocating the kernel to the bottom of physical memory
    461  1.1  nisimura  */
    462  1.1  nisimura 
    463  1.1  nisimura u_int
    464  1.1  nisimura initarm(void *arg)
    465  1.1  nisimura {
    466  1.1  nisimura 	int loop;
    467  1.1  nisimura 	int loop1;
    468  1.1  nisimura 	u_int l1pagetable;
    469  1.1  nisimura 	extern int etext __asm("_etext");
    470  1.1  nisimura 	extern int end __asm("_end");
    471  1.1  nisimura 	uint32_t kerneldatasize;
    472  1.1  nisimura 	struct btinfo_magic *bi_magic = arg;
    473  1.1  nisimura 	struct btinfo_bootstring *bi_bootstring;
    474  1.1  nisimura 	struct btinfo_symtab *bi_symtab;
    475  1.1  nisimura 
    476  1.1  nisimura 	boothowto = 0;
    477  1.1  nisimura 
    478  1.1  nisimura 	/* Copy bootinfo from boot loader into kernel memory where it remains.
    479  1.1  nisimura 	 */
    480  1.1  nisimura 	if (bi_magic != 0x0 && bi_magic->magic == BOOTINFO_MAGIC) {
    481  1.1  nisimura 		memcpy(bootinfo, bi_magic, sizeof(bootinfo));
    482  1.1  nisimura 	} else {
    483  1.1  nisimura 		memset(bootinfo, 0, sizeof(bootinfo));
    484  1.1  nisimura 	}
    485  1.1  nisimura 
    486  1.1  nisimura 	/* Extract boot_args from bootinfo */
    487  1.1  nisimura 	bi_bootstring = lookup_bootinfo(BTINFO_BOOTSTRING);
    488  1.1  nisimura 	if (bi_bootstring ) {
    489  1.1  nisimura 		printf("Bootloader args are %s\n", bi_bootstring->bootstring);
    490  1.1  nisimura 		boot_args = bi_bootstring->bootstring;
    491  1.1  nisimura 		parse_mi_bootargs(boot_args);
    492  1.1  nisimura 	}
    493  1.1  nisimura 
    494  1.1  nisimura #define pdatb (*(volatile uint8_t *)(S3C2440_GPIO_BASE+GPIO_PBDAT))
    495  1.1  nisimura 
    496  1.1  nisimura // 0x1E0 is the mask for GPB5, GPB6, GPB7, and GPB8
    497  1.1  nisimura #define __LED(x)  (pdatb = (pdatb & ~0x1e0) | (~(1<<(x+5)) & 0x1e0))
    498  1.1  nisimura 
    499  1.1  nisimura 	__LED(0);
    500  1.1  nisimura 
    501  1.1  nisimura 	/*
    502  1.1  nisimura 	 * Heads up ... Setup the CPU / MMU / TLB functions
    503  1.1  nisimura 	 */
    504  1.1  nisimura 	if (set_cpufuncs())
    505  1.1  nisimura 		panic("cpu not recognized!");
    506  1.1  nisimura 
    507  1.1  nisimura 	/*
    508  1.1  nisimura 	 * Map I/O registers that are used in startup.  Now we are
    509  1.1  nisimura 	 * still using page table prepared by bootloader.  Later we'll
    510  1.1  nisimura 	 * map those registers at the same address in the kernel page
    511  1.1  nisimura 	 * table.
    512  1.1  nisimura 	 */
    513  1.1  nisimura 	pmap_devmap_bootstrap((vaddr_t)read_ttb(), mini2440_devmap);
    514  1.1  nisimura 
    515  1.1  nisimura #undef	pdatb
    516  1.1  nisimura #define pdatb (*(volatile uint8_t *)(GPIO_VBASE+GPIO_PBDAT))
    517  1.1  nisimura 
    518  1.1  nisimura 	/* Disable all peripheral interrupts */
    519  1.1  nisimura 	ioreg_write32(INTCTL_VBASE + INTCTL_INTMSK, ~0);
    520  1.1  nisimura 
    521  1.1  nisimura 	__LED(1);
    522  1.1  nisimura 
    523  1.1  nisimura 	/* initialize some variables so that splfoo() doesn't
    524  1.1  nisimura 	   touch illegal address.  */
    525  1.1  nisimura 	s3c2xx0_intr_bootstrap(INTCTL_VBASE);
    526  1.1  nisimura 
    527  1.1  nisimura 	__LED(2);
    528  1.1  nisimura 	consinit();
    529  1.1  nisimura 	__LED(3);
    530  1.1  nisimura 
    531  1.1  nisimura 	/* Extract information from the bootloader configuration */
    532  1.1  nisimura 	bi_rdev = lookup_bootinfo(BTINFO_ROOTDEVICE);
    533  1.1  nisimura 	bi_net = lookup_bootinfo(BTINFO_NET);
    534  1.1  nisimura 	bi_path = lookup_bootinfo(BTINFO_BOOTPATH);
    535  1.1  nisimura 
    536  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    537  1.1  nisimura 	printf("consinit done\n");
    538  1.1  nisimura #endif
    539  1.1  nisimura 
    540  1.1  nisimura #ifdef KGDB
    541  1.1  nisimura 	kgdb_port_init();
    542  1.1  nisimura #endif
    543  1.1  nisimura 
    544  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    545  1.1  nisimura 	/* Talk to the user */
    546  1.1  nisimura 	printf("\nNetBSD/evbarm (MINI2440) booting ...\n");
    547  1.1  nisimura #endif
    548  1.1  nisimura 	/*
    549  1.1  nisimura 	 * Ok we have the following memory map
    550  1.1  nisimura 	 *
    551  1.1  nisimura 	 * Physical Address Range     Description
    552  1.1  nisimura 	 * -----------------------    ----------------------------------
    553  1.1  nisimura 	 * 0x30000000 - 0x33ffffff    SDRAM (64MB)
    554  1.1  nisimura          *
    555  1.1  nisimura          * Kernel is loaded by bootloader at 0x30200000
    556  1.1  nisimura 	 *
    557  1.1  nisimura 	 * The initarm() has the responsibility for creating the kernel
    558  1.1  nisimura 	 * page tables.
    559  1.1  nisimura 	 * It must also set up various memory pointers that are used
    560  1.1  nisimura 	 * by pmap etc.
    561  1.1  nisimura 	 */
    562  1.1  nisimura 
    563  1.1  nisimura 	/* Fake bootconfig structure for the benefit of pmap.c */
    564  1.1  nisimura 	/* XXX must make the memory description h/w independent */
    565  1.1  nisimura 	bootconfig.dramblocks = 1;
    566  1.1  nisimura 	bootconfig.dram[0].address = SDRAM_START;
    567  1.1  nisimura 	bootconfig.dram[0].pages = SDRAM_SIZE / PAGE_SIZE;
    568  1.1  nisimura 
    569  1.1  nisimura 	/*
    570  1.1  nisimura 	 * Set up the variables that define the availablilty of
    571  1.1  nisimura 	 * physical memory.
    572  1.1  nisimura          * We use the 2MB between the physical start and the kernel to
    573  1.1  nisimura          * begin with. Allocating from 0x30200000 and downwards
    574  1.1  nisimura 	 * If we get too close to the bottom of SDRAM, we
    575  1.1  nisimura 	 * will panic.  We will update physical_freestart and
    576  1.1  nisimura 	 * physical_freeend later to reflect what pmap_bootstrap()
    577  1.1  nisimura 	 * wants to see.
    578  1.1  nisimura 	 *
    579  1.1  nisimura 	 * XXX pmap_bootstrap() needs an enema.
    580  1.1  nisimura 	 */
    581  1.1  nisimura 	physical_start = bootconfig.dram[0].address;
    582  1.1  nisimura 	physical_end = physical_start + (bootconfig.dram[0].pages * PAGE_SIZE);
    583  1.1  nisimura 
    584  1.1  nisimura 	physical_freestart = SDRAM_START;	/* XXX */
    585  1.1  nisimura 	physical_freeend = SDRAM_START + KERNEL_OFFSET;
    586  1.1  nisimura 
    587  1.1  nisimura 	physmem = (physical_end - physical_start) / PAGE_SIZE;
    588  1.1  nisimura 
    589  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    590  1.1  nisimura 	/* Tell the user about the memory */
    591  1.1  nisimura 	printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
    592  1.1  nisimura 	    physical_start, physical_end - 1);
    593  1.1  nisimura 	printf("phys_end: 0x%08lx\n", physical_end);
    594  1.1  nisimura #endif
    595  1.1  nisimura 
    596  1.1  nisimura 	/*
    597  1.1  nisimura 	 * XXX
    598  1.1  nisimura 	 * Okay, the kernel starts 2MB in from the bottom of physical
    599  1.1  nisimura 	 * memory.  We are going to allocate our bootstrap pages downwards
    600  1.1  nisimura 	 * from there.
    601  1.1  nisimura 	 *
    602  1.1  nisimura 	 * We need to allocate some fixed page tables to get the kernel
    603  1.1  nisimura 	 * going.  We allocate one page directory and a number of page
    604  1.1  nisimura 	 * tables and store the physical addresses in the kernel_pt_table
    605  1.1  nisimura 	 * array.
    606  1.1  nisimura 	 *
    607  1.1  nisimura 	 * The kernel page directory must be on a 16K boundary.  The page
    608  1.1  nisimura 	 * tables must be on 4K boundaries.  What we do is allocate the
    609  1.1  nisimura 	 * page directory on the first 16K boundary that we encounter, and
    610  1.1  nisimura 	 * the page tables on 4K boundaries otherwise.  Since we allocate
    611  1.1  nisimura 	 * at least 3 L2 page tables, we are guaranteed to encounter at
    612  1.1  nisimura 	 * least one 16K aligned region.
    613  1.1  nisimura 	 */
    614  1.1  nisimura 
    615  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    616  1.1  nisimura 	printf("Allocating page tables\n");
    617  1.1  nisimura #endif
    618  1.1  nisimura 
    619  1.1  nisimura 	free_pages = (physical_freeend - physical_freestart) / PAGE_SIZE;
    620  1.1  nisimura 
    621  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    622  1.1  nisimura 	printf("freestart = 0x%08lx, free_pages = %d (0x%08x), freeend = 0x%08lx\n",
    623  1.1  nisimura 	    physical_freestart, free_pages, free_pages, physical_freeend);
    624  1.1  nisimura #endif
    625  1.1  nisimura 
    626  1.1  nisimura 	/* Define a macro to simplify memory allocation */
    627  1.1  nisimura #define	valloc_pages(var, np)				\
    628  1.1  nisimura 	alloc_pages((var).pv_pa, (np));			\
    629  1.1  nisimura 	(var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
    630  1.1  nisimura 
    631  1.1  nisimura #define alloc_pages(var, np)				\
    632  1.1  nisimura 	physical_freeend -= ((np) * PAGE_SIZE);		\
    633  1.1  nisimura 	if (physical_freeend < physical_freestart)	\
    634  1.1  nisimura 		panic("initarm: out of memory");	\
    635  1.1  nisimura 	(var) = physical_freeend;			\
    636  1.1  nisimura 	free_pages -= (np);				\
    637  1.1  nisimura 	memset((char *)(var), 0, ((np) * PAGE_SIZE));
    638  1.1  nisimura 
    639  1.1  nisimura 	loop1 = 0;
    640  1.1  nisimura 	for (loop = 0; loop <= NUM_KERNEL_PTS; ++loop) {
    641  1.1  nisimura 		/* Are we 16KB aligned for an L1 ? */
    642  1.1  nisimura 		if (((physical_freeend - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) == 0
    643  1.1  nisimura 		    && kernel_l1pt.pv_pa == 0) {
    644  1.1  nisimura 			valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
    645  1.1  nisimura 		} else {
    646  1.1  nisimura 			valloc_pages(kernel_pt_table[loop1],
    647  1.1  nisimura 			    L2_TABLE_SIZE / PAGE_SIZE);
    648  1.1  nisimura 			++loop1;
    649  1.1  nisimura 		}
    650  1.1  nisimura 	}
    651  1.1  nisimura 
    652  1.1  nisimura 	/* This should never be able to happen but better confirm that. */
    653  1.1  nisimura 	if (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE - 1)) != 0)
    654  1.1  nisimura 		panic("initarm: Failed to align the kernel page directory\n");
    655  1.1  nisimura 
    656  1.1  nisimura 	/*
    657  1.1  nisimura 	 * Allocate a page for the system page mapped to V0x00000000
    658  1.1  nisimura 	 * This page will just contain the system vectors and can be
    659  1.1  nisimura 	 * shared by all processes.
    660  1.1  nisimura 	 */
    661  1.1  nisimura 	alloc_pages(systempage.pv_pa, 1);
    662  1.1  nisimura 
    663  1.1  nisimura 	/* Allocate stacks for all modes */
    664  1.1  nisimura 	valloc_pages(irqstack, IRQ_STACK_SIZE);
    665  1.1  nisimura 	valloc_pages(abtstack, ABT_STACK_SIZE);
    666  1.1  nisimura 	valloc_pages(undstack, UND_STACK_SIZE);
    667  1.1  nisimura 	valloc_pages(kernelstack, UPAGES);
    668  1.1  nisimura 
    669  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    670  1.1  nisimura 	printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack.pv_pa,
    671  1.1  nisimura 	    irqstack.pv_va);
    672  1.1  nisimura 	printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack.pv_pa,
    673  1.1  nisimura 	    abtstack.pv_va);
    674  1.1  nisimura 	printf("UND stack: p0x%08lx v0x%08lx\n", undstack.pv_pa,
    675  1.1  nisimura 	    undstack.pv_va);
    676  1.1  nisimura 	printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack.pv_pa,
    677  1.1  nisimura 	    kernelstack.pv_va);
    678  1.1  nisimura 	printf("Free memory in bootstrap region: %ld bytes\n", physical_freeend - physical_freestart);
    679  1.1  nisimura #endif
    680  1.1  nisimura 
    681  1.1  nisimura 	alloc_pages(msgbufphys, round_page(MSGBUFSIZE) / PAGE_SIZE);
    682  1.1  nisimura 
    683  1.1  nisimura 	physical_freeend_low = physical_freeend;
    684  1.1  nisimura 
    685  1.1  nisimura 	/*
    686  1.1  nisimura 	 * Ok we have allocated physical pages for the primary kernel
    687  1.1  nisimura 	 * page tables
    688  1.1  nisimura 	 */
    689  1.1  nisimura 
    690  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    691  1.1  nisimura 	printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
    692  1.1  nisimura #endif
    693  1.1  nisimura 
    694  1.1  nisimura 	/*
    695  1.1  nisimura 	 * Now we start construction of the L1 page table
    696  1.1  nisimura 	 * We start by mapping the L2 page tables into the L1.
    697  1.1  nisimura 	 * This means that we can replace L1 mappings later on if necessary
    698  1.1  nisimura 	 */
    699  1.1  nisimura 	l1pagetable = kernel_l1pt.pv_pa;
    700  1.1  nisimura 
    701  1.1  nisimura 	/* Map the L2 pages tables in the L1 page table */
    702  1.1  nisimura 	pmap_link_l2pt(l1pagetable, 0x00000000,
    703  1.1  nisimura 	    &kernel_pt_table[KERNEL_PT_SYS]);
    704  1.1  nisimura 	for (loop = 0; loop < KERNEL_PT_KERNEL_NUM; loop++)
    705  1.1  nisimura 		pmap_link_l2pt(l1pagetable, KERNEL_BASE + loop * 0x00400000,
    706  1.1  nisimura 		    &kernel_pt_table[KERNEL_PT_KERNEL + loop]);
    707  1.1  nisimura 	for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; loop++)
    708  1.1  nisimura 		pmap_link_l2pt(l1pagetable, KERNEL_VM_BASE + loop * 0x00400000,
    709  1.1  nisimura 		    &kernel_pt_table[KERNEL_PT_VMDATA + loop]);
    710  1.1  nisimura 
    711  1.1  nisimura 	/* update the top of the kernel VM */
    712  1.1  nisimura 	pmap_curmaxkvaddr =
    713  1.1  nisimura 	    KERNEL_VM_BASE + (KERNEL_PT_VMDATA_NUM * 0x00400000);
    714  1.1  nisimura 
    715  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    716  1.1  nisimura 	printf("Mapping kernel\n");
    717  1.1  nisimura #endif
    718  1.1  nisimura 
    719  1.1  nisimura 	/* Now we fill in the L2 pagetable for the kernel static code/data */
    720  1.1  nisimura 	{
    721  1.1  nisimura 		/* Total size must include symbol table, if it exists.
    722  1.1  nisimura 		   The size of the symbol table can be acquired from the ELF
    723  1.1  nisimura 		   header, to which a pointer is passed in the boot info (ssym).
    724  1.1  nisimura 		 */
    725  1.1  nisimura 		size_t textsize = (uintptr_t)&etext - KERNEL_TEXT_BASE;
    726  1.1  nisimura 		kerneldatasize = (uintptr_t)&end - KERNEL_TEXT_BASE;
    727  1.1  nisimura 		u_int logical;
    728  1.1  nisimura 
    729  1.1  nisimura 		bi_symtab = lookup_bootinfo(BTINFO_SYMTAB);
    730  1.1  nisimura 
    731  1.1  nisimura 		if (bi_symtab) {
    732  1.1  nisimura 			Elf_Ehdr *elfHeader;
    733  1.1  nisimura 			Elf_Shdr *sectionHeader;
    734  1.1  nisimura 			int nsection;
    735  1.1  nisimura 			int sz = 0;
    736  1.1  nisimura 
    737  1.1  nisimura 			elfHeader = bi_symtab->ssym;
    738  1.1  nisimura 
    739  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    740  1.1  nisimura 			printf("Symbol table information provided by bootloader\n");
    741  1.1  nisimura 			printf("ELF header is at %p\n", elfHeader);
    742  1.1  nisimura #endif
    743  1.1  nisimura 			sectionHeader = (Elf_Shdr*)((char*)(bi_symtab->ssym) +
    744  1.1  nisimura 						     (elfHeader->e_shoff));
    745  1.1  nisimura 			nsection = elfHeader->e_shnum;
    746  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    747  1.1  nisimura 			printf("Number of sections: %d\n", nsection);
    748  1.1  nisimura #endif
    749  1.1  nisimura 			for(; nsection > 0; nsection--, sectionHeader++) {
    750  1.1  nisimura 				if (sectionHeader->sh_offset > 0 &&
    751  1.1  nisimura 				    (sectionHeader->sh_offset + sectionHeader->sh_size) > sz)
    752  1.1  nisimura 					sz = sectionHeader->sh_offset + sectionHeader->sh_size;
    753  1.1  nisimura 			}
    754  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    755  1.1  nisimura 			printf("Max size of sections: %d\n", sz);
    756  1.1  nisimura #endif
    757  1.1  nisimura 			kerneldatasize += sz;
    758  1.1  nisimura 		}
    759  1.1  nisimura 
    760  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    761  1.1  nisimura 		printf("Textsize: %u, kerneldatasize: %u\n", (uint)textsize,
    762  1.1  nisimura 		       (uint)kerneldatasize);
    763  1.1  nisimura 		printf("&etext: 0x%x\n", (uint)&etext);
    764  1.1  nisimura 		printf("&end: 0x%x\n", (uint)&end);
    765  1.1  nisimura 		printf("KERNEL_TEXT_BASE: 0x%x\n", KERNEL_TEXT_BASE);
    766  1.1  nisimura #endif
    767  1.1  nisimura 
    768  1.1  nisimura 		textsize = (textsize + PGOFSET) & ~PGOFSET;
    769  1.1  nisimura 		kerneldatasize = (kerneldatasize + PGOFSET) & ~PGOFSET;
    770  1.1  nisimura 
    771  1.1  nisimura 		logical = KERNEL_OFFSET;	/* offset of kernel in RAM */
    772  1.1  nisimura 
    773  1.1  nisimura 		logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
    774  1.1  nisimura 					  physical_start + logical, textsize,
    775  1.1  nisimura 					  VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
    776  1.1  nisimura 		logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
    777  1.1  nisimura 					  physical_start + logical, kerneldatasize - textsize,
    778  1.1  nisimura 					  VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
    779  1.1  nisimura 	}
    780  1.1  nisimura 
    781  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    782  1.1  nisimura 	printf("Constructing L2 page tables\n");
    783  1.1  nisimura #endif
    784  1.1  nisimura 
    785  1.1  nisimura 	/* Map the stack pages */
    786  1.1  nisimura 	pmap_map_chunk(l1pagetable, irqstack.pv_va, irqstack.pv_pa,
    787  1.1  nisimura 	    IRQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
    788  1.1  nisimura 	    PTE_CACHE);
    789  1.1  nisimura 	pmap_map_chunk(l1pagetable, abtstack.pv_va, abtstack.pv_pa,
    790  1.1  nisimura 	    ABT_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
    791  1.1  nisimura 	    PTE_CACHE);
    792  1.1  nisimura 	pmap_map_chunk(l1pagetable, undstack.pv_va, undstack.pv_pa,
    793  1.1  nisimura 	    UND_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
    794  1.1  nisimura 	    PTE_CACHE);
    795  1.1  nisimura 	pmap_map_chunk(l1pagetable, kernelstack.pv_va, kernelstack.pv_pa,
    796  1.1  nisimura 	    UPAGES * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
    797  1.1  nisimura 
    798  1.1  nisimura 	pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
    799  1.1  nisimura 	    L1_TABLE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_PAGETABLE);
    800  1.1  nisimura 
    801  1.1  nisimura 	for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
    802  1.1  nisimura 		pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va,
    803  1.1  nisimura 		    kernel_pt_table[loop].pv_pa, L2_TABLE_SIZE,
    804  1.1  nisimura 		    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
    805  1.1  nisimura 	}
    806  1.1  nisimura 
    807  1.1  nisimura 	/* Map the vector page. */
    808  1.1  nisimura #if 0
    809  1.1  nisimura 	/* MULTI-ICE requires that page 0 is NC/NB so that it can download the
    810  1.1  nisimura 	 * cache-clean code there.  */
    811  1.1  nisimura 	pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
    812  1.1  nisimura 	    VM_PROT_READ | VM_PROT_WRITE, PTE_NOCACHE);
    813  1.1  nisimura #else
    814  1.1  nisimura 	pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
    815  1.1  nisimura 	    VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
    816  1.1  nisimura #endif
    817  1.1  nisimura 
    818  1.1  nisimura 	/*
    819  1.1  nisimura 	 * map integrated peripherals at same address in l1pagetable
    820  1.1  nisimura 	 * so that we can continue to use console.
    821  1.1  nisimura 	 */
    822  1.1  nisimura 	pmap_devmap_bootstrap(l1pagetable, mini2440_devmap);
    823  1.1  nisimura 
    824  1.1  nisimura 	/*
    825  1.1  nisimura 	 * Now we have the real page tables in place so we can switch to them.
    826  1.1  nisimura 	 * Once this is done we will be running with the REAL kernel page
    827  1.1  nisimura 	 * tables.
    828  1.1  nisimura 	 */
    829  1.1  nisimura 	/*
    830  1.1  nisimura 	 * Update the physical_freestart/physical_freeend/free_pages
    831  1.1  nisimura 	 * variables.
    832  1.1  nisimura 	 */
    833  1.1  nisimura 	physical_freestart = physical_start +
    834  1.1  nisimura 	  (KERNEL_TEXT_BASE - KERNEL_BASE) + kerneldatasize;
    835  1.1  nisimura 	physical_freeend = physical_end;
    836  1.1  nisimura 	free_pages =
    837  1.1  nisimura 	  (physical_freeend - physical_freestart) / PAGE_SIZE;
    838  1.1  nisimura 
    839  1.1  nisimura 	/* Switch tables */
    840  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    841  1.1  nisimura 	printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
    842  1.1  nisimura 	    physical_freestart, free_pages, free_pages);
    843  1.1  nisimura 	printf("switching to new L1 page table  @%#lx...", kernel_l1pt.pv_pa);
    844  1.1  nisimura #endif
    845  1.1  nisimura 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
    846  1.1  nisimura 	cpu_setttb(kernel_l1pt.pv_pa);
    847  1.1  nisimura 	cpu_tlb_flushID();
    848  1.1  nisimura 	cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
    849  1.1  nisimura 
    850  1.1  nisimura 	/*
    851  1.1  nisimura 	 * Moved from cpu_startup() as data_abort_handler() references
    852  1.1  nisimura 	 * this during uvm init
    853  1.1  nisimura 	 */
    854  1.1  nisimura 	uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
    855  1.1  nisimura 
    856  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    857  1.1  nisimura 	printf("done!\n");
    858  1.1  nisimura #endif
    859  1.1  nisimura 
    860  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    861  1.1  nisimura 	printf("bootstrap done.\n");
    862  1.1  nisimura #endif
    863  1.1  nisimura 
    864  1.1  nisimura 	arm32_vector_init(ARM_VECTORS_LOW, ARM_VEC_ALL);
    865  1.1  nisimura 
    866  1.1  nisimura 	/*
    867  1.1  nisimura 	 * Pages were allocated during the secondary bootstrap for the
    868  1.1  nisimura 	 * stacks for different CPU modes.
    869  1.1  nisimura 	 * We must now set the r13 registers in the different CPU modes to
    870  1.1  nisimura 	 * point to these stacks.
    871  1.1  nisimura 	 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
    872  1.1  nisimura 	 * of the stack memory.
    873  1.1  nisimura 	 */
    874  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    875  1.1  nisimura 	printf("init subsystems: stacks ");
    876  1.1  nisimura #endif
    877  1.1  nisimura 
    878  1.1  nisimura 	set_stackptr(PSR_IRQ32_MODE,
    879  1.1  nisimura 	    irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
    880  1.1  nisimura 	set_stackptr(PSR_ABT32_MODE,
    881  1.1  nisimura 	    abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
    882  1.1  nisimura 	set_stackptr(PSR_UND32_MODE,
    883  1.1  nisimura 	    undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
    884  1.1  nisimura 
    885  1.1  nisimura 	cpu_idcache_wbinv_all();
    886  1.1  nisimura 
    887  1.1  nisimura 	/*
    888  1.1  nisimura 	 * Well we should set a data abort handler.
    889  1.1  nisimura 	 * Once things get going this will change as we will need a proper
    890  1.1  nisimura 	 * handler.
    891  1.1  nisimura 	 * Until then we will use a handler that just panics but tells us
    892  1.1  nisimura 	 * why.
    893  1.1  nisimura 	 * Initialisation of the vectors will just panic on a data abort.
    894  1.1  nisimura 	 * This just fills in a slightly better one.
    895  1.1  nisimura 	 */
    896  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    897  1.1  nisimura 	printf("vectors ");
    898  1.1  nisimura #endif
    899  1.1  nisimura 	data_abort_handler_address = (u_int)data_abort_handler;
    900  1.1  nisimura 	prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
    901  1.1  nisimura 	undefined_handler_address = (u_int)undefinedinstruction_bounce;
    902  1.1  nisimura 
    903  1.1  nisimura 	/* Initialise the undefined instruction handlers */
    904  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    905  1.1  nisimura 	printf("undefined ");
    906  1.1  nisimura #endif
    907  1.1  nisimura 	undefined_init();
    908  1.1  nisimura 
    909  1.1  nisimura 	/* Load memory into UVM. */
    910  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    911  1.1  nisimura 	printf("page ");
    912  1.1  nisimura #endif
    913  1.1  nisimura 	uvm_setpagesize();	/* initialize PAGE_SIZE-dependent variables */
    914  1.1  nisimura 	uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
    915  1.1  nisimura 	    atop(physical_freestart), atop(physical_freeend),
    916  1.1  nisimura 	    VM_FREELIST_DEFAULT);
    917  1.1  nisimura 	uvm_page_physload(atop(SDRAM_START), atop(physical_freeend_low),
    918  1.1  nisimura 	    atop(SDRAM_START), atop(physical_freeend_low),
    919  1.1  nisimura 	    VM_FREELIST_DEFAULT);
    920  1.1  nisimura 
    921  1.1  nisimura 
    922  1.1  nisimura 	/* Boot strap pmap telling it where the kernel page table is */
    923  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    924  1.1  nisimura 	printf("pmap ");
    925  1.1  nisimura #endif
    926  1.1  nisimura 	pmap_bootstrap(KERNEL_VM_BASE, KERNEL_VM_BASE + KERNEL_VM_SIZE);
    927  1.1  nisimura 
    928  1.1  nisimura #ifdef VERBOSE_INIT_ARM
    929  1.1  nisimura 	printf("done.\n");
    930  1.1  nisimura #endif
    931  1.1  nisimura 
    932  1.1  nisimura #ifdef BOOTHOWTO
    933  1.1  nisimura 	boothowto |= BOOTHOWTO;
    934  1.1  nisimura #endif
    935  1.1  nisimura 
    936  1.1  nisimura #ifdef KGDB
    937  1.1  nisimura 	if (boothowto & RB_KDB) {
    938  1.1  nisimura 		kgdb_debug_init = 1;
    939  1.1  nisimura 		kgdb_connect(1);
    940  1.1  nisimura 	}
    941  1.1  nisimura #endif
    942  1.1  nisimura 
    943  1.1  nisimura 	mini2440_ksyms(bi_symtab);
    944  1.1  nisimura 
    945  1.1  nisimura #ifdef DDB
    946  1.1  nisimura 	/*db_machine_init();*/
    947  1.1  nisimura 	if (boothowto & RB_KDB)
    948  1.1  nisimura 		Debugger();
    949  1.1  nisimura #endif
    950  1.1  nisimura 
    951  1.1  nisimura 	evbarm_device_register = mini2440_device_register;
    952  1.1  nisimura 
    953  1.1  nisimura 	/* We return the new stack pointer address */
    954  1.1  nisimura 	return (kernelstack.pv_va + USPACE_SVC_STACK_TOP);
    955  1.1  nisimura }
    956  1.1  nisimura 
    957  1.1  nisimura void
    958  1.1  nisimura consinit(void)
    959  1.1  nisimura {
    960  1.1  nisimura 	static int consinit_done = 0;
    961  1.1  nisimura #if defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE)
    962  1.1  nisimura 	bus_space_tag_t iot = &s3c2xx0_bs_tag;
    963  1.1  nisimura #endif
    964  1.1  nisimura 	int pclk;
    965  1.1  nisimura 
    966  1.1  nisimura 	if (consinit_done != 0)
    967  1.1  nisimura 		return;
    968  1.1  nisimura 
    969  1.1  nisimura 	consinit_done = 1;
    970  1.1  nisimura 
    971  1.1  nisimura 	s3c24x0_clock_freq2(CLKMAN_VBASE, NULL, NULL, &pclk);
    972  1.1  nisimura 
    973  1.1  nisimura #if NSSCOM > 0
    974  1.1  nisimura #ifdef SSCOM0CONSOLE
    975  1.1  nisimura 	if (0 == s3c2440_sscom_cnattach(iot, 0, comcnspeed,
    976  1.1  nisimura 		pclk, comcnmode))
    977  1.1  nisimura 		return;
    978  1.1  nisimura #endif
    979  1.1  nisimura #ifdef SSCOM1CONSOLE
    980  1.1  nisimura 	if (0 == s3c2440_sscom_cnattach(iot, 1, comcnspeed,
    981  1.1  nisimura 		pclk, comcnmode))
    982  1.1  nisimura 		return;
    983  1.1  nisimura #endif
    984  1.1  nisimura #endif				/* NSSCOM */
    985  1.1  nisimura #if NCOM>0 && defined(CONCOMADDR)
    986  1.1  nisimura 	if (comcnattach(&isa_io_bs_tag, CONCOMADDR, comcnspeed,
    987  1.1  nisimura 		COM_FREQ, COM_TYPE_NORMAL, comcnmode))
    988  1.1  nisimura 		panic("can't init serial console @%x", CONCOMADDR);
    989  1.1  nisimura 	return;
    990  1.1  nisimura #endif
    991  1.1  nisimura 
    992  1.1  nisimura 	consinit_done = 0;
    993  1.1  nisimura }
    994  1.1  nisimura 
    995  1.1  nisimura 
    996  1.1  nisimura #ifdef KGDB
    997  1.1  nisimura 
    998  1.1  nisimura #if (NSSCOM > 0)
    999  1.1  nisimura 
   1000  1.1  nisimura #ifdef KGDB_DEVNAME
   1001  1.1  nisimura const char kgdb_devname[] = KGDB_DEVNAME;
   1002  1.1  nisimura #else
   1003  1.1  nisimura const char kgdb_devname[] = "";
   1004  1.1  nisimura #endif
   1005  1.1  nisimura 
   1006  1.1  nisimura #ifndef KGDB_DEVMODE
   1007  1.1  nisimura #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE|CSTOPB|PARENB))|CS8) /* 8N1 */
   1008  1.1  nisimura #endif
   1009  1.1  nisimura int kgdb_sscom_mode = KGDB_DEVMODE;
   1010  1.1  nisimura 
   1011  1.1  nisimura #endif				/* NSSCOM */
   1012  1.1  nisimura 
   1013  1.1  nisimura void
   1014  1.1  nisimura kgdb_port_init(void)
   1015  1.1  nisimura {
   1016  1.1  nisimura #if (NSSCOM > 0)
   1017  1.1  nisimura 	int unit = -1;
   1018  1.1  nisimura 	int pclk;
   1019  1.1  nisimura 
   1020  1.1  nisimura 	if (strcmp(kgdb_devname, "sscom0") == 0)
   1021  1.1  nisimura 		unit = 0;
   1022  1.1  nisimura 	else if (strcmp(kgdb_devname, "sscom1") == 0)
   1023  1.1  nisimura 		unit = 1;
   1024  1.1  nisimura 
   1025  1.1  nisimura 	if (unit >= 0) {
   1026  1.1  nisimura 		s3c24x0_clock_freq2(CLKMAN_VBASE, NULL, NULL, &pclk);
   1027  1.1  nisimura 
   1028  1.1  nisimura 		s3c2440_sscom_kgdb_attach(&s3c2xx0_bs_tag,
   1029  1.1  nisimura 		    unit, kgdb_rate, pclk, kgdb_sscom_mode);
   1030  1.1  nisimura 	}
   1031  1.1  nisimura #endif
   1032  1.1  nisimura }
   1033  1.1  nisimura #endif
   1034  1.1  nisimura 
   1035  1.1  nisimura 
   1036  1.1  nisimura static struct arm32_dma_range mini2440_dma_ranges[1];
   1037  1.1  nisimura 
   1038  1.1  nisimura bus_dma_tag_t
   1039  1.1  nisimura s3c2xx0_bus_dma_init(struct arm32_bus_dma_tag *dma_tag_template)
   1040  1.1  nisimura {
   1041  1.1  nisimura 	extern paddr_t physical_start, physical_end;
   1042  1.1  nisimura 	struct arm32_bus_dma_tag *dmat;
   1043  1.1  nisimura 
   1044  1.1  nisimura 	mini2440_dma_ranges[0].dr_sysbase = physical_start;
   1045  1.1  nisimura 	mini2440_dma_ranges[0].dr_busbase = physical_start;
   1046  1.1  nisimura 	mini2440_dma_ranges[0].dr_len = physical_end - physical_start;
   1047  1.1  nisimura 
   1048  1.1  nisimura #if 1
   1049  1.1  nisimura 	dmat = dma_tag_template;
   1050  1.1  nisimura #else
   1051  1.1  nisimura 	dmat = malloc(sizeof *dmat, M_DEVBUF, M_NOWAIT);
   1052  1.1  nisimura 	if (dmat == NULL)
   1053  1.1  nisimura 		return NULL;
   1054  1.1  nisimura 	*dmat =  *dma_tag_template;
   1055  1.1  nisimura #endif
   1056  1.1  nisimura 
   1057  1.1  nisimura 	dmat->_ranges = mini2440_dma_ranges;
   1058  1.1  nisimura 	dmat->_nranges = 1;
   1059  1.1  nisimura 
   1060  1.1  nisimura 	return dmat;
   1061  1.1  nisimura }
   1062  1.1  nisimura 
   1063  1.1  nisimura void
   1064  1.1  nisimura mini2440_ksyms(struct btinfo_symtab *bi_symtab)
   1065  1.1  nisimura {
   1066  1.1  nisimura #if NKSYMS || defined(DDB) || defined(LKM)
   1067  1.1  nisimura 	extern int end;
   1068  1.1  nisimura 
   1069  1.1  nisimura #ifdef DDB
   1070  1.1  nisimura 	db_machine_init();
   1071  1.1  nisimura #endif
   1072  1.1  nisimura 	if (bi_symtab == NULL) {
   1073  1.1  nisimura 		return;
   1074  1.1  nisimura 	}
   1075  1.1  nisimura #ifdef VERBOSE_INIT_ARM
   1076  1.1  nisimura 	printf("Got symbol table. nsym=%d, ssym=%p, esym=%p\n",
   1077  1.1  nisimura 	       bi_symtab->nsym,
   1078  1.1  nisimura 	       bi_symtab->ssym,
   1079  1.1  nisimura 	       bi_symtab->esym);
   1080  1.1  nisimura #endif
   1081  1.1  nisimura 
   1082  1.1  nisimura 	ksyms_addsyms_elf(bi_symtab->nsym,
   1083  1.1  nisimura 			  (int*)bi_symtab->ssym,
   1084  1.1  nisimura 			  (int*)bi_symtab->esym);
   1085  1.1  nisimura #endif
   1086  1.1  nisimura }
   1087  1.1  nisimura 
   1088  1.1  nisimura void *
   1089  1.1  nisimura lookup_bootinfo(int type)
   1090  1.1  nisimura {
   1091  1.1  nisimura 	struct btinfo_common *bt;
   1092  1.1  nisimura 	struct btinfo_common *help = (struct btinfo_common *)bootinfo;
   1093  1.1  nisimura 
   1094  1.1  nisimura 	if (help->next == 0)
   1095  1.1  nisimura 		return (NULL);  /* bootinfo[] was not made */
   1096  1.1  nisimura 	do {
   1097  1.1  nisimura 		bt = help;
   1098  1.1  nisimura 		if (bt->type == type)
   1099  1.1  nisimura 			return (help);
   1100  1.1  nisimura 		help = (struct btinfo_common *)((char*)help + bt->next);
   1101  1.1  nisimura 	} while (bt->next &&
   1102  1.1  nisimura 		 (size_t)help < (size_t)bootinfo + BOOTINFO_MAXSIZE);
   1103  1.1  nisimura 
   1104  1.1  nisimura 	return (NULL);
   1105  1.1  nisimura }
   1106  1.1  nisimura 
   1107  1.1  nisimura 
   1108  1.1  nisimura extern char *booted_kernel;
   1109  1.1  nisimura 
   1110  1.1  nisimura static void
   1111  1.1  nisimura mini2440_device_register(device_t dev, void *aux) {
   1112  1.1  nisimura 	if (device_class(dev) == DV_IFNET) {
   1113  1.2  nisimura #ifndef MEMORY_DISK_IS_ROOT
   1114  1.1  nisimura 		if (bi_rdev != NULL && device_is_a(dev, bi_rdev->devname) ) {
   1115  1.1  nisimura 			booted_device = dev;
   1116  1.1  nisimura 			rootfstype = MOUNT_NFS;
   1117  1.1  nisimura 			if( bi_path != NULL ) {
   1118  1.1  nisimura 				booted_kernel = bi_path->bootpath;
   1119  1.1  nisimura 			}
   1120  1.1  nisimura 		}
   1121  1.2  nisimura #endif
   1122  1.1  nisimura 		if (bi_net != NULL && device_is_a(dev, bi_net->devname)) {
   1123  1.1  nisimura 			prop_data_t pd;
   1124  1.1  nisimura 			pd = prop_data_create_data_nocopy(bi_net->mac_address, ETHER_ADDR_LEN);
   1125  1.1  nisimura 			KASSERT(pd != NULL);
   1126  1.1  nisimura 			if (prop_dictionary_set(device_properties(dev), "mac-address", pd) == false) {
   1127  1.1  nisimura 				printf("WARNING: Unable to set mac-address property for %s\n", device_xname(dev));
   1128  1.1  nisimura 			}
   1129  1.1  nisimura 			prop_object_release(pd);
   1130  1.1  nisimura 			bi_net = NULL;
   1131  1.1  nisimura 		}
   1132  1.1  nisimura 	}
   1133  1.2  nisimura #ifndef MEMORY_DISK_IS_ROOT
   1134  1.1  nisimura 	if (bi_rdev != NULL && device_class(dev) == DV_DISK
   1135  1.1  nisimura 	    && device_is_a(dev, bi_rdev->devname)
   1136  1.1  nisimura 	    && device_unit(dev) == bi_rdev->cookie) {
   1137  1.1  nisimura 		booted_device = dev;
   1138  1.1  nisimura 		booted_partition = bi_rdev->partition;
   1139  1.1  nisimura 		rootfstype = ROOT_FSTYPE_ANY;
   1140  1.1  nisimura 		if( bi_path != NULL ) {
   1141  1.1  nisimura 			booted_kernel = bi_path->bootpath;
   1142  1.1  nisimura 		}
   1143  1.1  nisimura 	}
   1144  1.2  nisimura #endif
   1145  1.1  nisimura }
   1146