Home | History | Annotate | Line # | Download | only in tsarm
tsarm_machdep.c revision 1.18.2.2
      1  1.18.2.2     tls /*	$NetBSD: tsarm_machdep.c,v 1.18.2.2 2014/08/20 00:02:56 tls Exp $ */
      2       1.1    joff 
      3       1.1    joff /*
      4       1.1    joff  * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
      5       1.1    joff  * All rights reserved.
      6       1.1    joff  *
      7       1.1    joff  * Based on code written by Jason R. Thorpe and Steve C. Woodford for
      8       1.1    joff  * Wasabi Systems, Inc.
      9       1.1    joff  *
     10       1.1    joff  * Redistribution and use in source and binary forms, with or without
     11       1.1    joff  * modification, are permitted provided that the following conditions
     12       1.1    joff  * are met:
     13       1.1    joff  * 1. Redistributions of source code must retain the above copyright
     14       1.1    joff  *    notice, this list of conditions and the following disclaimer.
     15       1.1    joff  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1    joff  *    notice, this list of conditions and the following disclaimer in the
     17       1.1    joff  *    documentation and/or other materials provided with the distribution.
     18       1.1    joff  * 3. All advertising materials mentioning features or use of this software
     19       1.1    joff  *    must display the following acknowledgement:
     20       1.1    joff  *	This product includes software developed for the NetBSD Project by
     21       1.1    joff  *	Wasabi Systems, Inc.
     22       1.1    joff  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     23       1.1    joff  *    or promote products derived from this software without specific prior
     24       1.1    joff  *    written permission.
     25       1.1    joff  *
     26       1.1    joff  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     27       1.1    joff  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.1    joff  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.1    joff  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     30       1.1    joff  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.1    joff  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.1    joff  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.1    joff  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.1    joff  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.1    joff  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.1    joff  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1    joff  */
     38       1.1    joff 
     39       1.1    joff /*
     40       1.1    joff  * Copyright (c) 1997,1998 Mark Brinicombe.
     41       1.1    joff  * Copyright (c) 1997,1998 Causality Limited.
     42       1.1    joff  * All rights reserved.
     43       1.1    joff  *
     44       1.1    joff  * Redistribution and use in source and binary forms, with or without
     45       1.1    joff  * modification, are permitted provided that the following conditions
     46       1.1    joff  * are met:
     47       1.1    joff  * 1. Redistributions of source code must retain the above copyright
     48       1.1    joff  *    notice, this list of conditions and the following disclaimer.
     49       1.1    joff  * 2. Redistributions in binary form must reproduce the above copyright
     50       1.1    joff  *    notice, this list of conditions and the following disclaimer in the
     51       1.1    joff  *    documentation and/or other materials provided with the distribution.
     52       1.1    joff  * 3. All advertising materials mentioning features or use of this software
     53       1.1    joff  *    must display the following acknowledgement:
     54       1.1    joff  *	This product includes software developed by Mark Brinicombe
     55       1.1    joff  *	for the NetBSD Project.
     56       1.1    joff  * 4. The name of the company nor the name of the author may be used to
     57       1.1    joff  *    endorse or promote products derived from this software without specific
     58       1.1    joff  *    prior written permission.
     59       1.1    joff  *
     60       1.1    joff  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     61       1.1    joff  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     62       1.1    joff  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     63       1.1    joff  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     64       1.1    joff  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     65       1.1    joff  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     66       1.1    joff  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     67       1.1    joff  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     68       1.1    joff  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     69       1.1    joff  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     70       1.1    joff  * SUCH DAMAGE.
     71       1.1    joff  *
     72      1.15     wiz  * Machine dependent functions for kernel setup for Iyonix.
     73       1.1    joff  */
     74       1.1    joff 
     75       1.1    joff #include <sys/cdefs.h>
     76  1.18.2.2     tls __KERNEL_RCSID(0, "$NetBSD: tsarm_machdep.c,v 1.18.2.2 2014/08/20 00:02:56 tls Exp $");
     77       1.1    joff 
     78       1.1    joff #include "opt_ddb.h"
     79       1.1    joff #include "opt_kgdb.h"
     80       1.1    joff #include "opt_pmap_debug.h"
     81       1.1    joff 
     82       1.1    joff #include <sys/param.h>
     83       1.1    joff #include <sys/device.h>
     84       1.1    joff #include <sys/systm.h>
     85       1.1    joff #include <sys/kernel.h>
     86       1.1    joff #include <sys/exec.h>
     87       1.1    joff #include <sys/proc.h>
     88       1.1    joff #include <sys/msgbuf.h>
     89       1.1    joff #include <sys/reboot.h>
     90       1.1    joff #include <sys/termios.h>
     91       1.1    joff #include <sys/ksyms.h>
     92  1.18.2.2     tls #include <sys/bus.h>
     93  1.18.2.2     tls #include <sys/cpu.h>
     94       1.1    joff 
     95       1.1    joff #include <uvm/uvm_extern.h>
     96       1.1    joff 
     97       1.1    joff #include <dev/cons.h>
     98       1.1    joff 
     99       1.1    joff #include <machine/db_machdep.h>
    100       1.1    joff #include <ddb/db_sym.h>
    101       1.1    joff #include <ddb/db_extern.h>
    102       1.1    joff 
    103       1.1    joff #include <acorn32/include/bootconfig.h>
    104  1.18.2.2     tls #include <arm/locore.h>
    105       1.1    joff #include <arm/undefined.h>
    106       1.1    joff 
    107      1.18    matt /* Define various stack sizes in pages */
    108      1.18    matt #define IRQ_STACK_SIZE	8
    109      1.18    matt #define ABT_STACK_SIZE	8
    110      1.18    matt #define UND_STACK_SIZE	8
    111      1.18    matt 
    112       1.1    joff #include <arm/arm32/machdep.h>
    113       1.1    joff 
    114       1.1    joff #include <arm/ep93xx/ep93xxreg.h>
    115       1.1    joff #include <arm/ep93xx/ep93xxvar.h>
    116       1.1    joff 
    117       1.1    joff #include <dev/ic/comreg.h>
    118       1.1    joff #include <dev/ic/comvar.h>
    119       1.1    joff 
    120       1.1    joff #include "epcom.h"
    121       1.1    joff #if NEPCOM > 0
    122       1.1    joff #include <arm/ep93xx/epcomvar.h>
    123       1.1    joff #endif
    124       1.1    joff 
    125       1.1    joff #include "isa.h"
    126       1.1    joff #if NISA > 0
    127       1.1    joff #include <dev/isa/isareg.h>
    128       1.1    joff #include <dev/isa/isavar.h>
    129       1.1    joff #endif
    130       1.1    joff 
    131       1.1    joff #include <machine/isa_machdep.h>
    132       1.1    joff 
    133       1.1    joff #include <evbarm/tsarm/tsarmreg.h>
    134       1.1    joff 
    135       1.1    joff #include "ksyms.h"
    136       1.1    joff 
    137       1.1    joff /* Kernel text starts 2MB in from the bottom of the kernel address space. */
    138       1.1    joff #define	KERNEL_TEXT_BASE	(KERNEL_BASE + 0x00200000)
    139       1.1    joff #define	KERNEL_VM_BASE		(KERNEL_BASE + 0x01000000)
    140       1.1    joff 
    141       1.1    joff /*
    142       1.1    joff  * The range 0xc1000000 - 0xccffffff is available for kernel VM space
    143       1.1    joff  * Core-logic registers and I/O mappings occupy 0xf0000000 - 0xffffffff
    144       1.1    joff  */
    145       1.1    joff #define KERNEL_VM_SIZE		0x0C000000
    146       1.1    joff 
    147       1.1    joff struct bootconfig bootconfig;		/* Boot config storage */
    148       1.1    joff char *boot_args = NULL;
    149       1.1    joff char *boot_file = NULL;
    150       1.1    joff 
    151       1.1    joff vm_offset_t physical_start;
    152       1.1    joff vm_offset_t physical_freestart;
    153       1.1    joff vm_offset_t physical_freeend;
    154       1.1    joff vm_offset_t physical_freeend_low;
    155       1.1    joff vm_offset_t physical_end;
    156       1.1    joff u_int free_pages;
    157       1.1    joff 
    158       1.1    joff vm_offset_t msgbufphys;
    159       1.1    joff 
    160       1.1    joff static struct arm32_dma_range tsarm_dma_ranges[4];
    161       1.1    joff 
    162       1.1    joff #if NISA > 0
    163       1.1    joff extern void isa_tsarm_init(u_int, u_int);
    164       1.1    joff #endif
    165       1.1    joff 
    166       1.1    joff #ifdef PMAP_DEBUG
    167       1.1    joff extern int pmap_debug_level;
    168       1.1    joff #endif
    169       1.1    joff 
    170       1.1    joff #define KERNEL_PT_SYS		0	/* L2 table for mapping vectors page */
    171       1.1    joff 
    172       1.1    joff #define KERNEL_PT_KERNEL	1	/* L2 table for mapping kernel */
    173       1.1    joff #define	KERNEL_PT_KERNEL_NUM	4
    174       1.1    joff 					/* L2 tables for mapping kernel VM */
    175       1.1    joff #define KERNEL_PT_VMDATA	(KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
    176       1.1    joff 
    177       1.1    joff #define	KERNEL_PT_VMDATA_NUM	4	/* start with 16MB of KVM */
    178       1.1    joff #define NUM_KERNEL_PTS		(KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
    179       1.1    joff 
    180       1.1    joff pv_addr_t kernel_pt_table[NUM_KERNEL_PTS];
    181       1.1    joff 
    182       1.1    joff /* Prototypes */
    183       1.1    joff 
    184       1.1    joff void	consinit(void);
    185       1.1    joff /*
    186       1.1    joff  * Define the default console speed for the machine.
    187       1.1    joff  */
    188       1.1    joff #ifndef CONSPEED
    189       1.1    joff #define CONSPEED B115200
    190       1.1    joff #endif /* ! CONSPEED */
    191       1.1    joff 
    192       1.1    joff #ifndef CONMODE
    193       1.1    joff #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    194       1.1    joff #endif
    195       1.1    joff 
    196       1.1    joff int comcnspeed = CONSPEED;
    197       1.1    joff int comcnmode = CONMODE;
    198       1.1    joff 
    199       1.1    joff #if KGDB
    200       1.1    joff #ifndef KGDB_DEVNAME
    201       1.1    joff #error Must define KGDB_DEVNAME
    202       1.1    joff #endif
    203       1.1    joff const char kgdb_devname[] = KGDB_DEVNAME;
    204       1.1    joff 
    205       1.1    joff #ifndef KGDB_DEVADDR
    206       1.1    joff #error Must define KGDB_DEVADDR
    207       1.1    joff #endif
    208       1.1    joff unsigned long kgdb_devaddr = KGDB_DEVADDR;
    209       1.1    joff 
    210       1.1    joff #ifndef KGDB_DEVRATE
    211       1.1    joff #define KGDB_DEVRATE	CONSPEED
    212       1.1    joff #endif
    213       1.1    joff int kgdb_devrate = KGDB_DEVRATE;
    214       1.1    joff 
    215       1.1    joff #ifndef KGDB_DEVMODE
    216       1.1    joff #define KGDB_DEVMODE	CONMODE
    217       1.1    joff #endif
    218       1.1    joff int kgdb_devmode = KGDB_DEVMODE;
    219       1.1    joff #endif /* KGDB */
    220       1.1    joff 
    221       1.1    joff /*
    222       1.1    joff  * void cpu_reboot(int howto, char *bootstr)
    223       1.1    joff  *
    224       1.1    joff  * Reboots the system
    225       1.1    joff  *
    226       1.1    joff  * Deal with any syncing, unmounting, dumping and shutdown hooks,
    227       1.1    joff  * then reset the CPU.
    228       1.1    joff  */
    229       1.1    joff void
    230       1.1    joff cpu_reboot(int howto, char *bootstr)
    231       1.1    joff {
    232       1.1    joff 
    233       1.1    joff 	/*
    234       1.1    joff 	 * If we are still cold then hit the air brakes
    235       1.1    joff 	 * and crash to earth fast
    236       1.1    joff 	 */
    237       1.1    joff 	if (cold) {
    238       1.1    joff 		doshutdownhooks();
    239       1.8  dyoung 		pmf_system_shutdown(boothowto);
    240       1.1    joff 		printf("\r\n");
    241       1.1    joff 		printf("The operating system has halted.\r\n");
    242       1.1    joff 		printf("Please press any key to reboot.\r\n");
    243       1.1    joff 		cngetc();
    244       1.1    joff 		printf("\r\nrebooting...\r\n");
    245       1.1    joff 		goto reset;
    246       1.1    joff 	}
    247       1.1    joff 
    248       1.1    joff 	/* Disable console buffering */
    249       1.1    joff 
    250       1.1    joff 	/*
    251       1.1    joff 	 * If RB_NOSYNC was not specified sync the discs.
    252       1.1    joff 	 * Note: Unless cold is set to 1 here, syslogd will die during the
    253       1.1    joff 	 * unmount.  It looks like syslogd is getting woken up only to find
    254       1.1    joff 	 * that it cannot page part of the binary in as the filesystem has
    255       1.1    joff 	 * been unmounted.
    256       1.1    joff 	 */
    257       1.1    joff 	if (!(howto & RB_NOSYNC))
    258       1.1    joff 		bootsync();
    259       1.1    joff 
    260       1.1    joff 	/* Say NO to interrupts */
    261       1.1    joff 	splhigh();
    262       1.1    joff 
    263       1.1    joff 	/* Do a dump if requested. */
    264       1.1    joff 	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
    265       1.1    joff 		dumpsys();
    266       1.1    joff 
    267       1.1    joff 	/* Run any shutdown hooks */
    268       1.1    joff 	doshutdownhooks();
    269       1.1    joff 
    270       1.8  dyoung 	pmf_system_shutdown(boothowto);
    271       1.8  dyoung 
    272       1.1    joff 	/* Make sure IRQ's are disabled */
    273       1.1    joff 	IRQdisable;
    274       1.1    joff 
    275       1.1    joff 	if (howto & RB_HALT) {
    276       1.1    joff 		printf("\r\n");
    277       1.1    joff 		printf("The operating system has halted.\r\n");
    278       1.1    joff 		printf("Please press any key to reboot.\r\n");
    279       1.1    joff 		cngetc();
    280       1.1    joff 	}
    281       1.1    joff 
    282       1.1    joff 	printf("\r\nrebooting...\r\n");
    283       1.1    joff  reset:
    284       1.1    joff 	/*
    285       1.1    joff 	 * Make really really sure that all interrupts are disabled,
    286       1.1    joff 	 * and poke the Internal Bus and Peripheral Bus reset lines.
    287       1.1    joff 	 */
    288       1.1    joff 	(void) disable_interrupts(I32_bit|F32_bit);
    289       1.1    joff 
    290       1.1    joff 	{
    291  1.18.2.1     tls 		uint32_t feed, ctrl;
    292       1.1    joff 
    293       1.1    joff 		feed = TS7XXX_IO16_VBASE + TS7XXX_WDOGFEED;
    294       1.1    joff 		ctrl = TS7XXX_IO16_VBASE + TS7XXX_WDOGCTRL;
    295       1.1    joff 
    296       1.3   perry 		__asm volatile (
    297       1.1    joff 			"mov r0, #0x5\n"
    298       1.1    joff 			"mov r1, #0x1\n"
    299       1.1    joff 			"strh r0, [%0]\n"
    300       1.1    joff 			"strh r1, [%1]\n"
    301       1.1    joff 			:
    302       1.1    joff 			: "r" (feed), "r" (ctrl)
    303       1.1    joff 			: "r0", "r1"
    304       1.1    joff 		);
    305       1.1    joff 	}
    306       1.1    joff 
    307       1.1    joff 	for (;;);
    308       1.1    joff }
    309       1.1    joff 
    310       1.1    joff /* Static device mappings. */
    311       1.1    joff static const struct pmap_devmap tsarm_devmap[] = {
    312       1.1    joff     {
    313       1.1    joff 	EP93XX_AHB_VBASE,
    314       1.1    joff 	EP93XX_AHB_HWBASE,
    315       1.1    joff 	EP93XX_AHB_SIZE,
    316       1.1    joff 	VM_PROT_READ|VM_PROT_WRITE,
    317       1.1    joff 	PTE_NOCACHE,
    318       1.1    joff     },
    319       1.1    joff 
    320       1.1    joff     {
    321       1.1    joff 	EP93XX_APB_VBASE,
    322       1.1    joff 	EP93XX_APB_HWBASE,
    323       1.1    joff 	EP93XX_APB_SIZE,
    324       1.1    joff 	VM_PROT_READ|VM_PROT_WRITE,
    325       1.1    joff 	PTE_NOCACHE,
    326       1.1    joff     },
    327       1.1    joff 
    328       1.1    joff 	/*
    329       1.1    joff 	 * IO8 and IO16 space *must* be mapped contiguously with
    330       1.1    joff 	 * IO8_VA == IO16_VA - 64 Mbytes.  ISA busmap driver depends
    331       1.1    joff 	 * on that!
    332       1.1    joff 	 */
    333       1.1    joff     {
    334       1.1    joff 	TS7XXX_IO8_VBASE,
    335       1.1    joff 	TS7XXX_IO8_HWBASE,
    336       1.1    joff 	TS7XXX_IO8_SIZE,
    337       1.1    joff 	VM_PROT_READ|VM_PROT_WRITE,
    338       1.1    joff 	PTE_NOCACHE,
    339       1.1    joff     },
    340       1.1    joff 
    341       1.1    joff     {
    342       1.1    joff 	TS7XXX_IO16_VBASE,
    343       1.1    joff 	TS7XXX_IO16_HWBASE,
    344       1.1    joff 	TS7XXX_IO16_SIZE,
    345       1.1    joff 	VM_PROT_READ|VM_PROT_WRITE,
    346       1.1    joff 	PTE_NOCACHE,
    347       1.1    joff     },
    348       1.1    joff 
    349       1.1    joff    {
    350       1.1    joff 	0,
    351       1.1    joff 	0,
    352       1.1    joff 	0,
    353       1.1    joff 	0,
    354       1.1    joff 	0,
    355       1.1    joff     }
    356       1.1    joff };
    357       1.1    joff 
    358       1.1    joff /*
    359       1.1    joff  * u_int initarm(...)
    360       1.1    joff  *
    361       1.1    joff  * Initial entry point on startup. This gets called before main() is
    362       1.1    joff  * entered.
    363       1.1    joff  * It should be responsible for setting up everything that must be
    364       1.1    joff  * in place when main is called.
    365       1.1    joff  * This includes
    366       1.1    joff  *   Taking a copy of the boot configuration structure.
    367       1.1    joff  *   Initialising the physical console so characters can be printed.
    368       1.1    joff  *   Setting up page tables for the kernel
    369       1.1    joff  *   Initialising interrupt controllers to a sane default state
    370       1.1    joff  */
    371       1.1    joff u_int
    372       1.1    joff initarm(void *arg)
    373       1.1    joff {
    374       1.1    joff #ifdef FIXME
    375       1.1    joff 	struct bootconfig *passed_bootconfig = arg;
    376       1.1    joff 	extern char _end[];
    377       1.1    joff #endif
    378       1.1    joff 	int loop;
    379       1.1    joff 	int loop1;
    380       1.1    joff 	u_int l1pagetable;
    381  1.18.2.2     tls 
    382  1.18.2.2     tls #ifdef FIXME
    383       1.1    joff 	paddr_t memstart;
    384       1.1    joff 	psize_t memsize;
    385       1.1    joff 
    386       1.1    joff 	/* Calibrate the delay loop. */
    387       1.1    joff 	i80321_calibrate_delay();
    388       1.1    joff #endif
    389       1.1    joff 
    390       1.1    joff 	/*
    391       1.1    joff 	 * Since we map the on-board devices VA==PA, and the kernel
    392       1.1    joff 	 * is running VA==PA, it's possible for us to initialize
    393       1.1    joff 	 * the console now.
    394       1.1    joff 	 */
    395       1.1    joff 	consinit();
    396       1.1    joff 
    397       1.1    joff #ifdef VERBOSE_INIT_ARM
    398       1.1    joff 	/* Talk to the user */
    399       1.1    joff 	printf("\nNetBSD/tsarm booting ...\n");
    400       1.1    joff #endif
    401       1.1    joff 
    402       1.1    joff 	/*
    403       1.1    joff 	 * Heads up ... Setup the CPU / MMU / TLB functions
    404       1.1    joff 	 */
    405       1.1    joff 	if (set_cpufuncs())
    406       1.1    joff 		panic("cpu not recognized!");
    407       1.1    joff 
    408       1.1    joff 	/*
    409       1.1    joff 	 * We are currently running with the MMU enabled
    410       1.1    joff 	 */
    411       1.1    joff 
    412       1.1    joff #ifdef FIXME
    413       1.1    joff 	/*
    414       1.1    joff 	 * Fetch the SDRAM start/size from the i80321 SDRAM configuration
    415       1.1    joff 	 * registers.
    416       1.1    joff 	 */
    417       1.1    joff 	i80321_sdram_bounds(&obio_bs_tag, VERDE_PMMR_BASE + VERDE_MCU_BASE,
    418       1.1    joff 	    &memstart, &memsize);
    419  1.18.2.2     tls 
    420       1.1    joff 	memstart = 0x0;
    421       1.1    joff 	memsize = 0x2000000;
    422       1.1    joff #endif
    423       1.1    joff 
    424       1.1    joff #ifdef VERBOSE_INIT_ARM
    425       1.1    joff 	printf("initarm: Configuring system ...\n");
    426       1.1    joff #endif
    427       1.1    joff 
    428       1.1    joff 	/* Fake bootconfig structure for the benefit of pmap.c */
    429       1.5     wiz 	/* XXX must make the memory description h/w independent */
    430       1.1    joff 	bootconfig.dramblocks = 4;
    431       1.1    joff 	bootconfig.dram[0].address = 0x0UL;
    432       1.1    joff 	bootconfig.dram[0].pages = 0x800000UL / PAGE_SIZE;
    433       1.1    joff 	bootconfig.dram[1].address = 0x1000000UL;
    434       1.1    joff 	bootconfig.dram[1].pages = 0x800000UL / PAGE_SIZE;
    435       1.1    joff 	bootconfig.dram[2].address = 0x4000000UL;
    436       1.1    joff 	bootconfig.dram[2].pages = 0x800000UL / PAGE_SIZE;
    437       1.1    joff 	bootconfig.dram[3].address = 0x5000000UL;
    438       1.1    joff 	bootconfig.dram[3].pages = 0x800000UL / PAGE_SIZE;
    439       1.1    joff 
    440       1.1    joff 	/*
    441       1.1    joff 	 * Set up the variables that define the availablilty of
    442       1.1    joff 	 * physical memory.  For now, we're going to set
    443       1.1    joff 	 * physical_freestart to 0x00200000 (where the kernel
    444       1.1    joff 	 * was loaded), and allocate the memory we need downwards.
    445       1.1    joff 	 * If we get too close to the L1 table that we set up, we
    446       1.1    joff 	 * will panic.  We will update physical_freestart and
    447       1.1    joff 	 * physical_freeend later to reflect what pmap_bootstrap()
    448       1.1    joff 	 * wants to see.
    449       1.1    joff 	 *
    450       1.1    joff 	 * XXX pmap_bootstrap() needs an enema.
    451       1.1    joff 	 */
    452       1.1    joff 	physical_start = bootconfig.dram[0].address;
    453       1.1    joff 	physical_end = bootconfig.dram[0].address +
    454       1.1    joff 		(bootconfig.dram[0].pages * PAGE_SIZE);
    455       1.1    joff 
    456       1.1    joff 	physical_freestart = 0x00009000UL;
    457       1.1    joff 	physical_freeend = 0x00200000UL;
    458       1.1    joff 
    459       1.1    joff 	physmem = (physical_end - physical_start) / PAGE_SIZE;
    460       1.1    joff 
    461       1.1    joff #ifdef VERBOSE_INIT_ARM
    462       1.1    joff 	/* Tell the user about the memory */
    463       1.1    joff 	printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
    464       1.1    joff 	    physical_start, physical_end - 1);
    465       1.1    joff #endif
    466       1.1    joff 
    467       1.1    joff 	/*
    468       1.1    joff 	 * Okay, the kernel starts 2MB in from the bottom of physical
    469       1.1    joff 	 * memory.  We are going to allocate our bootstrap pages downwards
    470       1.1    joff 	 * from there.
    471       1.1    joff 	 *
    472       1.1    joff 	 * We need to allocate some fixed page tables to get the kernel
    473       1.1    joff 	 * going.  We allocate one page directory and a number of page
    474       1.1    joff 	 * tables and store the physical addresses in the kernel_pt_table
    475       1.1    joff 	 * array.
    476       1.1    joff 	 *
    477       1.1    joff 	 * The kernel page directory must be on a 16K boundary.  The page
    478       1.1    joff 	 * tables must be on 4K bounaries.  What we do is allocate the
    479       1.1    joff 	 * page directory on the first 16K boundary that we encounter, and
    480       1.1    joff 	 * the page tables on 4K boundaries otherwise.  Since we allocate
    481       1.1    joff 	 * at least 3 L2 page tables, we are guaranteed to encounter at
    482       1.1    joff 	 * least one 16K aligned region.
    483       1.1    joff 	 */
    484       1.1    joff 
    485       1.1    joff #ifdef VERBOSE_INIT_ARM
    486       1.1    joff 	printf("Allocating page tables\n");
    487       1.1    joff #endif
    488       1.1    joff 
    489       1.1    joff 	free_pages = (physical_freeend - physical_freestart) / PAGE_SIZE;
    490       1.1    joff 
    491       1.1    joff #ifdef VERBOSE_INIT_ARM
    492       1.1    joff 	printf("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
    493       1.1    joff 	       physical_freestart, free_pages, free_pages);
    494       1.1    joff #endif
    495       1.1    joff 
    496       1.1    joff 	/* Define a macro to simplify memory allocation */
    497       1.1    joff #define	valloc_pages(var, np)				\
    498       1.1    joff 	alloc_pages((var).pv_pa, (np));			\
    499       1.1    joff 	(var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
    500       1.1    joff 
    501       1.1    joff #define alloc_pages(var, np)				\
    502       1.1    joff 	physical_freeend -= ((np) * PAGE_SIZE);		\
    503       1.1    joff 	if (physical_freeend < physical_freestart)	\
    504       1.1    joff 		panic("initarm: out of memory");	\
    505       1.1    joff 	(var) = physical_freeend;			\
    506       1.1    joff 	free_pages -= (np);				\
    507       1.1    joff 	memset((char *)(var), 0, ((np) * PAGE_SIZE));
    508       1.1    joff 
    509       1.1    joff 	loop1 = 0;
    510       1.1    joff 	for (loop = 0; loop <= NUM_KERNEL_PTS; ++loop) {
    511       1.1    joff 		/* Are we 16KB aligned for an L1 ? */
    512       1.1    joff 		if (((physical_freeend - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) == 0
    513       1.1    joff 		    && kernel_l1pt.pv_pa == 0) {
    514       1.1    joff 			valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
    515       1.1    joff 		} else {
    516       1.1    joff 			valloc_pages(kernel_pt_table[loop1],
    517       1.1    joff 			    L2_TABLE_SIZE / PAGE_SIZE);
    518       1.1    joff 			++loop1;
    519       1.1    joff 		}
    520       1.1    joff 	}
    521       1.1    joff 
    522       1.1    joff 	/* This should never be able to happen but better confirm that. */
    523       1.1    joff 	if (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE-1)) != 0)
    524       1.1    joff 		panic("initarm: Failed to align the kernel page directory");
    525       1.1    joff 
    526       1.1    joff 	/*
    527       1.1    joff 	 * Allocate a page for the system vectors page
    528       1.1    joff 	 */
    529       1.1    joff 	alloc_pages(systempage.pv_pa, 1);
    530       1.1    joff 
    531       1.1    joff 	/* Allocate stacks for all modes */
    532       1.1    joff 	valloc_pages(irqstack, IRQ_STACK_SIZE);
    533       1.1    joff 	valloc_pages(abtstack, ABT_STACK_SIZE);
    534       1.1    joff 	valloc_pages(undstack, UND_STACK_SIZE);
    535       1.1    joff 	valloc_pages(kernelstack, UPAGES);
    536       1.1    joff 
    537       1.1    joff #ifdef VERBOSE_INIT_ARM
    538       1.1    joff 	printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack.pv_pa,
    539       1.1    joff 	    irqstack.pv_va);
    540       1.1    joff 	printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack.pv_pa,
    541       1.1    joff 	    abtstack.pv_va);
    542       1.1    joff 	printf("UND stack: p0x%08lx v0x%08lx\n", undstack.pv_pa,
    543       1.1    joff 	    undstack.pv_va);
    544       1.1    joff 	printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack.pv_pa,
    545       1.1    joff 	    kernelstack.pv_va);
    546       1.1    joff #endif
    547       1.1    joff 
    548       1.1    joff 	alloc_pages(msgbufphys, round_page(MSGBUFSIZE) / PAGE_SIZE);
    549       1.1    joff 
    550       1.1    joff 	/*
    551       1.1    joff 	 * Ok we have allocated physical pages for the primary kernel
    552       1.1    joff 	 * page tables.  Save physical_freeend for when we give whats left
    553       1.1    joff 	 * of memory below 2Mbyte to UVM.
    554       1.1    joff 	 */
    555       1.1    joff 
    556       1.1    joff 	physical_freeend_low = physical_freeend;
    557       1.1    joff 
    558       1.1    joff #ifdef VERBOSE_INIT_ARM
    559       1.1    joff 	printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
    560       1.1    joff #endif
    561       1.1    joff 
    562       1.1    joff 	/*
    563       1.1    joff 	 * Now we start construction of the L1 page table
    564       1.1    joff 	 * We start by mapping the L2 page tables into the L1.
    565       1.1    joff 	 * This means that we can replace L1 mappings later on if necessary
    566       1.1    joff 	 */
    567       1.1    joff 	l1pagetable = kernel_l1pt.pv_pa;
    568       1.1    joff 
    569       1.1    joff 	/* Map the L2 pages tables in the L1 page table */
    570       1.1    joff 	pmap_link_l2pt(l1pagetable, ARM_VECTORS_HIGH & ~(0x00400000 - 1),
    571       1.1    joff 	    &kernel_pt_table[KERNEL_PT_SYS]);
    572       1.1    joff 	for (loop = 0; loop < KERNEL_PT_KERNEL_NUM; loop++)
    573       1.1    joff 		pmap_link_l2pt(l1pagetable, KERNEL_BASE + loop * 0x00400000,
    574       1.1    joff 		    &kernel_pt_table[KERNEL_PT_KERNEL + loop]);
    575       1.1    joff 	for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; loop++)
    576       1.1    joff 		pmap_link_l2pt(l1pagetable, KERNEL_VM_BASE + loop * 0x00400000,
    577       1.1    joff 		    &kernel_pt_table[KERNEL_PT_VMDATA + loop]);
    578       1.1    joff 
    579       1.1    joff 	/* update the top of the kernel VM */
    580       1.1    joff 	pmap_curmaxkvaddr =
    581       1.1    joff 	    KERNEL_VM_BASE + (KERNEL_PT_VMDATA_NUM * 0x00400000);
    582       1.1    joff 
    583       1.1    joff #ifdef VERBOSE_INIT_ARM
    584       1.1    joff 	printf("Mapping kernel\n");
    585       1.1    joff #endif
    586       1.1    joff 
    587       1.1    joff 	/* Now we fill in the L2 pagetable for the kernel static code/data */
    588       1.1    joff 	{
    589       1.1    joff 		extern char etext[], _end[];
    590       1.1    joff 		size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE;
    591       1.1    joff 		size_t totalsize = (uintptr_t) _end - KERNEL_TEXT_BASE;
    592       1.1    joff 		u_int logical;
    593       1.1    joff 
    594       1.1    joff 		textsize = (textsize + PGOFSET) & ~PGOFSET;
    595       1.1    joff 		totalsize = (totalsize + PGOFSET) & ~PGOFSET;
    596       1.1    joff 
    597       1.1    joff 		logical = 0x00200000;	/* offset of kernel in RAM */
    598       1.1    joff 		logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
    599       1.1    joff 		    physical_start + logical, textsize,
    600       1.1    joff 		    VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
    601       1.1    joff 		logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
    602       1.1    joff 		    physical_start + logical, totalsize - textsize,
    603       1.1    joff 		    VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
    604       1.1    joff 	}
    605       1.1    joff 
    606       1.1    joff #ifdef VERBOSE_INIT_ARM
    607       1.1    joff 	printf("Constructing L2 page tables\n");
    608       1.1    joff #endif
    609       1.1    joff 
    610       1.1    joff 	/* Map the stack pages */
    611       1.1    joff 	pmap_map_chunk(l1pagetable, irqstack.pv_va, irqstack.pv_pa,
    612       1.1    joff 	    IRQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
    613       1.1    joff 	pmap_map_chunk(l1pagetable, abtstack.pv_va, abtstack.pv_pa,
    614       1.1    joff 	    ABT_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
    615       1.1    joff 	pmap_map_chunk(l1pagetable, undstack.pv_va, undstack.pv_pa,
    616       1.1    joff 	    UND_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
    617       1.1    joff 	pmap_map_chunk(l1pagetable, kernelstack.pv_va, kernelstack.pv_pa,
    618       1.1    joff 	    UPAGES * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
    619       1.1    joff 
    620       1.1    joff 	pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
    621       1.1    joff 	    L1_TABLE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
    622       1.1    joff 
    623       1.1    joff 	for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
    624       1.1    joff 		pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va,
    625       1.1    joff 		    kernel_pt_table[loop].pv_pa, L2_TABLE_SIZE,
    626       1.1    joff 		    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
    627       1.1    joff 	}
    628       1.1    joff 
    629       1.1    joff 	/* Map the vector page. */
    630       1.1    joff 	pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
    631       1.1    joff 	    VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
    632       1.1    joff 
    633       1.1    joff 	/* Map the statically mapped devices. */
    634       1.1    joff 	pmap_devmap_bootstrap(l1pagetable, tsarm_devmap);
    635       1.1    joff 
    636       1.1    joff 	/*
    637       1.1    joff 	 * Update the physical_freestart/physical_freeend/free_pages
    638       1.1    joff 	 * variables.
    639       1.1    joff 	 */
    640       1.1    joff 	{
    641       1.1    joff 		extern char _end[];
    642       1.1    joff 
    643       1.1    joff 		physical_freestart = physical_start +
    644       1.1    joff 		    (((((uintptr_t) _end) + PGOFSET) & ~PGOFSET) -
    645       1.1    joff 		     KERNEL_BASE);
    646       1.1    joff 		physical_freeend = physical_end;
    647       1.1    joff 		free_pages =
    648       1.1    joff 		    (physical_freeend - physical_freestart) / PAGE_SIZE;
    649       1.1    joff 	}
    650       1.1    joff 
    651       1.1    joff 	/*
    652       1.1    joff 	 * Now we have the real page tables in place so we can switch to them.
    653       1.1    joff 	 * Once this is done we will be running with the REAL kernel page
    654       1.1    joff 	 * tables.
    655       1.1    joff 	 */
    656       1.1    joff 
    657       1.1    joff 	/* Switch tables */
    658       1.1    joff #ifdef VERBOSE_INIT_ARM
    659       1.1    joff 	printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
    660       1.1    joff 	       physical_freestart, free_pages, free_pages);
    661       1.1    joff 	printf("switching to new L1 page table  @%#lx...", kernel_l1pt.pv_pa);
    662       1.1    joff #endif
    663       1.1    joff 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
    664  1.18.2.1     tls 	cpu_setttb(kernel_l1pt.pv_pa, true);
    665       1.1    joff 	cpu_tlb_flushID();
    666       1.1    joff 	cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
    667       1.1    joff 
    668       1.1    joff 	/*
    669       1.1    joff 	 * Moved from cpu_startup() as data_abort_handler() references
    670       1.1    joff 	 * this during uvm init
    671       1.1    joff 	 */
    672      1.13   rmind 	uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
    673       1.1    joff 
    674       1.1    joff #ifdef VERBOSE_INIT_ARM
    675       1.1    joff 	printf("done!\n");
    676       1.1    joff #endif
    677       1.1    joff 
    678       1.1    joff #ifdef VERBOSE_INIT_ARM
    679       1.1    joff 	printf("bootstrap done.\n");
    680       1.1    joff #endif
    681       1.1    joff 
    682       1.1    joff 	arm32_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL);
    683       1.1    joff 
    684       1.1    joff 	/*
    685       1.1    joff 	 * Pages were allocated during the secondary bootstrap for the
    686       1.1    joff 	 * stacks for different CPU modes.
    687       1.1    joff 	 * We must now set the r13 registers in the different CPU modes to
    688       1.1    joff 	 * point to these stacks.
    689       1.1    joff 	 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
    690       1.1    joff 	 * of the stack memory.
    691       1.1    joff 	 */
    692       1.1    joff #ifdef VERBOSE_INIT_ARM
    693       1.1    joff 	printf("init subsystems: stacks ");
    694       1.1    joff #endif
    695       1.1    joff 
    696       1.1    joff 	set_stackptr(PSR_IRQ32_MODE,
    697       1.1    joff 	    irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
    698       1.1    joff 	set_stackptr(PSR_ABT32_MODE,
    699       1.1    joff 	    abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
    700       1.1    joff 	set_stackptr(PSR_UND32_MODE,
    701       1.1    joff 	    undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
    702       1.1    joff 
    703       1.1    joff 	/*
    704       1.1    joff 	 * Well we should set a data abort handler.
    705       1.1    joff 	 * Once things get going this will change as we will need a proper
    706       1.1    joff 	 * handler.
    707       1.1    joff 	 * Until then we will use a handler that just panics but tells us
    708       1.1    joff 	 * why.
    709       1.1    joff 	 * Initialisation of the vectors will just panic on a data abort.
    710       1.1    joff 	 * This just fills in a slightly better one.
    711       1.1    joff 	 */
    712       1.1    joff #ifdef VERBOSE_INIT_ARM
    713       1.1    joff 	printf("vectors ");
    714       1.1    joff #endif
    715       1.1    joff 	data_abort_handler_address = (u_int)data_abort_handler;
    716       1.1    joff 	prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
    717       1.1    joff 	undefined_handler_address = (u_int)undefinedinstruction_bounce;
    718       1.1    joff 
    719       1.1    joff 	/* Initialise the undefined instruction handlers */
    720       1.1    joff #ifdef VERBOSE_INIT_ARM
    721       1.1    joff 	printf("undefined ");
    722       1.1    joff #endif
    723       1.1    joff 	undefined_init();
    724       1.1    joff 
    725       1.1    joff 	/* Load memory into UVM. */
    726       1.1    joff #ifdef VERBOSE_INIT_ARM
    727       1.1    joff 	printf("page ");
    728       1.1    joff #endif
    729       1.1    joff 	uvm_setpagesize();	/* initialize PAGE_SIZE-dependent variables */
    730       1.1    joff 	uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
    731       1.1    joff 	    atop(physical_freestart), atop(physical_freeend),
    732       1.1    joff 	    VM_FREELIST_DEFAULT);
    733       1.1    joff 	uvm_page_physload(0, atop(physical_freeend_low),
    734       1.1    joff 	    0, atop(physical_freeend_low),
    735       1.1    joff 	    VM_FREELIST_DEFAULT);
    736       1.1    joff 	/*
    737       1.1    joff 	 * There is 32 Mb of memory on the TS-7200 in 4 8Mb chunks, so far
    738       1.1    joff 	 * we've only been working with the first one mapped at 0x0.  Tell
    739       1.1    joff 	 * UVM about the others.
    740       1.1    joff 	 */
    741       1.1    joff 	uvm_page_physload(atop(0x1000000), atop(0x1800000),
    742       1.1    joff 	    atop(0x1000000), atop(0x1800000),
    743       1.1    joff 	    VM_FREELIST_DEFAULT);
    744       1.1    joff 	uvm_page_physload(atop(0x4000000), atop(0x4800000),
    745       1.1    joff 	    atop(0x4000000), atop(0x4800000),
    746       1.1    joff 	    VM_FREELIST_DEFAULT);
    747       1.1    joff 	uvm_page_physload(atop(0x5000000), atop(0x5800000),
    748       1.1    joff 	    atop(0x5000000), atop(0x5800000),
    749       1.1    joff 	    VM_FREELIST_DEFAULT);
    750       1.1    joff 
    751       1.1    joff 	physmem = 0x2000000 / PAGE_SIZE;
    752       1.1    joff 
    753       1.1    joff 
    754       1.1    joff 	/* Boot strap pmap telling it where the kernel page table is */
    755       1.1    joff #ifdef VERBOSE_INIT_ARM
    756       1.1    joff 	printf("pmap ");
    757       1.1    joff #endif
    758       1.7    matt 	pmap_bootstrap(KERNEL_VM_BASE, KERNEL_VM_BASE + KERNEL_VM_SIZE);
    759       1.1    joff 
    760       1.1    joff 	/* Setup the IRQ system */
    761       1.1    joff #ifdef VERBOSE_INIT_ARM
    762       1.1    joff 	printf("irq ");
    763       1.1    joff #endif
    764       1.1    joff 	ep93xx_intr_init();
    765       1.1    joff #if NISA > 0
    766       1.1    joff 	isa_intr_init();
    767       1.1    joff 
    768       1.1    joff #ifdef VERBOSE_INIT_ARM
    769       1.1    joff 	printf("isa ");
    770       1.1    joff #endif
    771       1.1    joff 	isa_tsarm_init(TS7XXX_IO16_VBASE + TS7XXX_ISAIO,
    772       1.1    joff 		TS7XXX_IO16_VBASE + TS7XXX_ISAMEM);
    773       1.1    joff #endif
    774       1.1    joff 
    775       1.1    joff #ifdef VERBOSE_INIT_ARM
    776       1.1    joff 	printf("done.\n");
    777       1.1    joff #endif
    778       1.1    joff 
    779       1.1    joff #ifdef BOOTHOWTO
    780       1.1    joff 	boothowto = BOOTHOWTO;
    781       1.1    joff #endif
    782       1.1    joff 
    783       1.1    joff #ifdef DDB
    784       1.1    joff 	db_machine_init();
    785       1.1    joff 	if (boothowto & RB_KDB)
    786       1.1    joff 		Debugger();
    787       1.1    joff #endif
    788       1.1    joff 
    789       1.1    joff 	/* We return the new stack pointer address */
    790       1.1    joff 	return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
    791       1.1    joff }
    792       1.1    joff 
    793       1.1    joff void
    794       1.1    joff consinit(void)
    795       1.1    joff {
    796       1.1    joff 	static int consinit_called;
    797       1.1    joff 	bus_space_handle_t ioh;
    798       1.1    joff 
    799       1.1    joff 	if (consinit_called != 0)
    800       1.1    joff 		return;
    801       1.1    joff 
    802       1.1    joff 	consinit_called = 1;
    803       1.1    joff 
    804       1.1    joff 	/*
    805       1.1    joff 	 * Console devices are already mapped in VA.  Our devmap reflects
    806       1.1    joff 	 * this, so register it now so drivers can map the console
    807       1.1    joff 	 * device.
    808       1.1    joff 	 */
    809       1.1    joff 	pmap_devmap_register(tsarm_devmap);
    810       1.1    joff #if 0
    811       1.1    joff 	isa_tsarm_init(TS7XXX_IO16_VBASE + TS7XXX_ISAIO,
    812       1.1    joff 		TS7XXX_IO16_VBASE + TS7XXX_ISAMEM);
    813       1.1    joff 
    814       1.1    joff         if (comcnattach(&isa_io_bs_tag, 0x3e8, comcnspeed,
    815       1.1    joff             COM_FREQ, COM_TYPE_NORMAL, comcnmode))
    816       1.1    joff         {
    817       1.1    joff                 panic("can't init serial console");
    818       1.1    joff         }
    819       1.1    joff #endif
    820       1.1    joff 
    821       1.1    joff #if NEPCOM > 0
    822       1.1    joff 	bus_space_map(&ep93xx_bs_tag, EP93XX_APB_HWBASE + EP93XX_APB_UART1,
    823       1.1    joff 		EP93XX_APB_UART_SIZE, 0, &ioh);
    824       1.1    joff         if (epcomcnattach(&ep93xx_bs_tag, EP93XX_APB_HWBASE + EP93XX_APB_UART1,
    825       1.1    joff 		ioh, comcnspeed, comcnmode))
    826       1.1    joff 	{
    827       1.1    joff 		panic("can't init serial console");
    828       1.1    joff 	}
    829       1.1    joff #else
    830       1.1    joff 	panic("serial console not configured");
    831       1.1    joff #endif
    832       1.1    joff #if KGDB
    833       1.1    joff #if NEPCOM > 0
    834       1.1    joff 	if (strcmp(kgdb_devname, "epcom") == 0) {
    835       1.1    joff 		com_kgdb_attach(&ep93xx_bs_tag, kgdb_devaddr, kgdb_devrate,
    836       1.1    joff 			kgdb_devmode);
    837       1.1    joff 	}
    838       1.1    joff #endif	/* NEPCOM > 0 */
    839       1.1    joff #endif	/* KGDB */
    840       1.1    joff }
    841       1.1    joff 
    842       1.1    joff 
    843       1.1    joff bus_dma_tag_t
    844       1.1    joff ep93xx_bus_dma_init(struct arm32_bus_dma_tag *dma_tag_template)
    845       1.1    joff {
    846       1.1    joff 	int i;
    847       1.1    joff 	struct arm32_bus_dma_tag *dmat;
    848       1.1    joff 
    849       1.1    joff 	for (i = 0; i < bootconfig.dramblocks; i++) {
    850       1.1    joff 		tsarm_dma_ranges[i].dr_sysbase = bootconfig.dram[i].address;
    851       1.1    joff 		tsarm_dma_ranges[i].dr_busbase = bootconfig.dram[i].address;
    852       1.1    joff 		tsarm_dma_ranges[i].dr_len = bootconfig.dram[i].pages *
    853       1.1    joff 			PAGE_SIZE;
    854       1.1    joff 	}
    855       1.1    joff 
    856       1.1    joff 	dmat = dma_tag_template;
    857       1.1    joff 
    858       1.1    joff 	dmat->_ranges = tsarm_dma_ranges;
    859       1.1    joff 	dmat->_nranges = bootconfig.dramblocks;
    860       1.1    joff 
    861       1.1    joff 	return dmat;
    862       1.1    joff }
    863