Home | History | Annotate | Line # | Download | only in integrator
integrator_machdep.c revision 1.80
      1  1.80     skrll /*	$NetBSD: integrator_machdep.c,v 1.80 2021/08/10 06:47:49 skrll Exp $	*/
      2   1.1  rearnsha 
      3   1.1  rearnsha /*
      4  1.23  rearnsha  * Copyright (c) 2001,2002 ARM Ltd
      5   1.1  rearnsha  * All rights reserved.
      6   1.1  rearnsha  *
      7   1.1  rearnsha  * Redistribution and use in source and binary forms, with or without
      8   1.1  rearnsha  * modification, are permitted provided that the following conditions
      9   1.1  rearnsha  * are met:
     10   1.1  rearnsha  * 1. Redistributions of source code must retain the above copyright
     11   1.1  rearnsha  *    notice, this list of conditions and the following disclaimer.
     12   1.1  rearnsha  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1  rearnsha  *    notice, this list of conditions and the following disclaimer in the
     14   1.1  rearnsha  *    documentation and/or other materials provided with the distribution.
     15   1.1  rearnsha  * 3. The name of the company may not be used to endorse or promote
     16   1.1  rearnsha  *    products derived from this software without specific prior written
     17   1.1  rearnsha  *    permission.
     18   1.1  rearnsha  *
     19  1.23  rearnsha  * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND
     20  1.23  rearnsha  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.23  rearnsha  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.23  rearnsha  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ARM LTD
     23  1.23  rearnsha  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.23  rearnsha  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.23  rearnsha  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.23  rearnsha  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.23  rearnsha  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.23  rearnsha  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.23  rearnsha  * POSSIBILITY OF SUCH DAMAGE.
     30  1.23  rearnsha  */
     31  1.23  rearnsha 
     32  1.23  rearnsha /*
     33   1.1  rearnsha  * Copyright (c) 1997,1998 Mark Brinicombe.
     34   1.1  rearnsha  * Copyright (c) 1997,1998 Causality Limited.
     35   1.1  rearnsha  * All rights reserved.
     36   1.1  rearnsha  *
     37   1.1  rearnsha  * Redistribution and use in source and binary forms, with or without
     38   1.1  rearnsha  * modification, are permitted provided that the following conditions
     39   1.1  rearnsha  * are met:
     40   1.1  rearnsha  * 1. Redistributions of source code must retain the above copyright
     41   1.1  rearnsha  *    notice, this list of conditions and the following disclaimer.
     42   1.1  rearnsha  * 2. Redistributions in binary form must reproduce the above copyright
     43   1.1  rearnsha  *    notice, this list of conditions and the following disclaimer in the
     44   1.1  rearnsha  *    documentation and/or other materials provided with the distribution.
     45   1.1  rearnsha  * 3. All advertising materials mentioning features or use of this software
     46   1.1  rearnsha  *    must display the following acknowledgement:
     47   1.1  rearnsha  *	This product includes software developed by Mark Brinicombe
     48   1.1  rearnsha  *	for the NetBSD Project.
     49   1.1  rearnsha  * 4. The name of the company nor the name of the author may be used to
     50   1.1  rearnsha  *    endorse or promote products derived from this software without specific
     51   1.1  rearnsha  *    prior written permission.
     52   1.1  rearnsha  *
     53   1.1  rearnsha  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     54   1.1  rearnsha  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     55   1.1  rearnsha  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     56   1.1  rearnsha  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     57   1.1  rearnsha  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     58   1.1  rearnsha  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     59   1.1  rearnsha  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     60   1.1  rearnsha  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     61   1.1  rearnsha  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     62   1.1  rearnsha  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     63   1.1  rearnsha  * SUCH DAMAGE.
     64   1.1  rearnsha  *
     65  1.67       wiz  * Machine dependent functions for kernel setup for integrator board
     66   1.1  rearnsha  *
     67   1.1  rearnsha  * Created      : 24/11/97
     68   1.1  rearnsha  */
     69  1.43     lukem 
     70  1.43     lukem #include <sys/cdefs.h>
     71  1.80     skrll __KERNEL_RCSID(0, "$NetBSD: integrator_machdep.c,v 1.80 2021/08/10 06:47:49 skrll Exp $");
     72   1.1  rearnsha 
     73  1.75     skrll #include "opt_arm_debug.h"
     74  1.76     skrll #include "opt_console.h"
     75   1.1  rearnsha #include "opt_ddb.h"
     76   1.1  rearnsha 
     77   1.1  rearnsha #include <sys/param.h>
     78   1.1  rearnsha #include <sys/device.h>
     79   1.1  rearnsha #include <sys/systm.h>
     80   1.1  rearnsha #include <sys/kernel.h>
     81   1.1  rearnsha #include <sys/exec.h>
     82   1.1  rearnsha #include <sys/proc.h>
     83   1.1  rearnsha #include <sys/msgbuf.h>
     84   1.1  rearnsha #include <sys/reboot.h>
     85   1.1  rearnsha #include <sys/termios.h>
     86  1.32     ragge #include <sys/ksyms.h>
     87  1.74      matt #include <sys/bus.h>
     88  1.74      matt #include <sys/cpu.h>
     89  1.74      matt #include <sys/intr.h>
     90   1.1  rearnsha 
     91  1.31   thorpej #include <uvm/uvm_extern.h>
     92  1.31   thorpej 
     93   1.1  rearnsha #include <dev/cons.h>
     94   1.1  rearnsha 
     95   1.1  rearnsha #include <machine/db_machdep.h>
     96   1.1  rearnsha #include <ddb/db_sym.h>
     97   1.1  rearnsha #include <ddb/db_extern.h>
     98   1.1  rearnsha 
     99   1.1  rearnsha #include <machine/bootconfig.h>
    100  1.74      matt #include <arm/locore.h>
    101   1.6   thorpej #include <arm/undefined.h>
    102   1.1  rearnsha 
    103  1.23  rearnsha #include <arm/arm32/machdep.h>
    104  1.23  rearnsha 
    105   1.1  rearnsha #include <evbarm/integrator/integrator_boot.h>
    106   1.1  rearnsha 
    107   1.1  rearnsha #include "pci.h"
    108  1.32     ragge #include "ksyms.h"
    109   1.1  rearnsha 
    110   1.1  rearnsha void ifpga_reset(void) __attribute__((noreturn));
    111  1.36   thorpej 
    112  1.40   thorpej /*
    113  1.40   thorpej  * The range 0xc1000000 - 0xccffffff is available for kernel VM space
    114  1.40   thorpej  * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
    115  1.40   thorpej  */
    116  1.73     skrll #define KERNEL_VM_BASE		(KERNEL_BASE + 0x01000000)
    117  1.40   thorpej #define KERNEL_VM_SIZE		0x0C000000
    118  1.36   thorpej 
    119   1.1  rearnsha BootConfig bootconfig;		/* Boot config storage */
    120   1.1  rearnsha char *boot_args = NULL;
    121   1.1  rearnsha char *boot_file = NULL;
    122   1.1  rearnsha 
    123   1.1  rearnsha /* Prototypes */
    124   1.1  rearnsha 
    125  1.23  rearnsha static void	integrator_sdram_bounds	(paddr_t *, psize_t *);
    126   1.1  rearnsha 
    127  1.23  rearnsha void	consinit(void);
    128   1.1  rearnsha 
    129   1.1  rearnsha /* A load of console goo. */
    130   1.1  rearnsha #include "vga.h"
    131  1.23  rearnsha #if NVGA > 0
    132   1.1  rearnsha #include <dev/ic/mc6845reg.h>
    133   1.1  rearnsha #include <dev/ic/pcdisplayvar.h>
    134   1.1  rearnsha #include <dev/ic/vgareg.h>
    135   1.1  rearnsha #include <dev/ic/vgavar.h>
    136   1.1  rearnsha #endif
    137   1.1  rearnsha 
    138   1.1  rearnsha #include "pckbc.h"
    139  1.23  rearnsha #if NPCKBC > 0
    140   1.1  rearnsha #include <dev/ic/i8042reg.h>
    141   1.1  rearnsha #include <dev/ic/pckbcvar.h>
    142   1.1  rearnsha #endif
    143   1.1  rearnsha 
    144   1.1  rearnsha #include "com.h"
    145  1.23  rearnsha #if NCOM > 0
    146   1.1  rearnsha #include <dev/ic/comreg.h>
    147   1.1  rearnsha #include <dev/ic/comvar.h>
    148   1.1  rearnsha #ifndef CONCOMADDR
    149   1.1  rearnsha #define CONCOMADDR 0x3f8
    150   1.1  rearnsha #endif
    151   1.1  rearnsha #endif
    152   1.1  rearnsha 
    153  1.23  rearnsha /*
    154  1.23  rearnsha  * Define the default console speed for the board.  This is generally
    155  1.23  rearnsha  * what the firmware provided with the board defaults to.
    156  1.23  rearnsha  */
    157  1.30   mycroft #ifndef CONSPEED
    158   1.1  rearnsha #define CONSPEED B115200
    159   1.1  rearnsha #endif
    160   1.1  rearnsha #ifndef CONMODE
    161   1.1  rearnsha #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    162   1.1  rearnsha #endif
    163   1.1  rearnsha 
    164   1.1  rearnsha int comcnspeed = CONSPEED;
    165   1.1  rearnsha int comcnmode = CONMODE;
    166   1.1  rearnsha 
    167   1.1  rearnsha #include "plcom.h"
    168   1.1  rearnsha #if (NPLCOM > 0)
    169   1.1  rearnsha #include <evbarm/dev/plcomreg.h>
    170   1.1  rearnsha #include <evbarm/dev/plcomvar.h>
    171   1.1  rearnsha 
    172   1.1  rearnsha #include <evbarm/ifpga/ifpgamem.h>
    173   1.1  rearnsha #include <evbarm/ifpga/ifpgareg.h>
    174   1.1  rearnsha #include <evbarm/ifpga/ifpgavar.h>
    175   1.1  rearnsha #endif
    176   1.1  rearnsha 
    177   1.1  rearnsha #ifndef CONSDEVNAME
    178   1.1  rearnsha #define CONSDEVNAME "plcom"
    179   1.1  rearnsha #endif
    180   1.1  rearnsha 
    181   1.1  rearnsha #ifndef PLCONSPEED
    182   1.1  rearnsha #define PLCONSPEED B38400
    183   1.1  rearnsha #endif
    184   1.1  rearnsha #ifndef PLCONMODE
    185   1.1  rearnsha #define PLCONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    186   1.1  rearnsha #endif
    187   1.1  rearnsha #ifndef PLCOMCNUNIT
    188   1.1  rearnsha #define PLCOMCNUNIT -1
    189   1.1  rearnsha #endif
    190   1.1  rearnsha 
    191   1.1  rearnsha int plcomcnspeed = PLCONSPEED;
    192   1.1  rearnsha int plcomcnmode = PLCONMODE;
    193   1.1  rearnsha 
    194   1.1  rearnsha #if 0
    195   1.1  rearnsha extern struct consdev kcomcons;
    196   1.1  rearnsha static void kcomcnputc(dev_t, int);
    197   1.1  rearnsha #endif
    198   1.1  rearnsha 
    199   1.1  rearnsha /*
    200   1.1  rearnsha  * void cpu_reboot(int howto, char *bootstr)
    201   1.1  rearnsha  *
    202   1.1  rearnsha  * Reboots the system
    203   1.1  rearnsha  *
    204   1.1  rearnsha  * Deal with any syncing, unmounting, dumping and shutdown hooks,
    205   1.1  rearnsha  * then reset the CPU.
    206   1.1  rearnsha  */
    207   1.1  rearnsha void
    208  1.23  rearnsha cpu_reboot(int howto, char *bootstr)
    209   1.1  rearnsha {
    210   1.1  rearnsha 
    211   1.1  rearnsha 	/*
    212   1.1  rearnsha 	 * If we are still cold then hit the air brakes
    213   1.1  rearnsha 	 * and crash to earth fast
    214   1.1  rearnsha 	 */
    215   1.1  rearnsha 	if (cold) {
    216   1.1  rearnsha 		doshutdownhooks();
    217  1.59    dyoung 		pmf_system_shutdown(boothowto);
    218   1.1  rearnsha 		printf("The operating system has halted.\n");
    219   1.1  rearnsha 		printf("Please press any key to reboot.\n\n");
    220   1.1  rearnsha 		cngetc();
    221   1.1  rearnsha 		printf("rebooting...\n");
    222   1.1  rearnsha 		ifpga_reset();
    223   1.1  rearnsha 		/*NOTREACHED*/
    224   1.1  rearnsha 	}
    225   1.1  rearnsha 
    226   1.1  rearnsha 	/* Disable console buffering */
    227   1.1  rearnsha 
    228   1.1  rearnsha 	/*
    229   1.1  rearnsha 	 * If RB_NOSYNC was not specified sync the discs.
    230  1.23  rearnsha 	 * Note: Unless cold is set to 1 here, syslogd will die during the
    231  1.23  rearnsha 	 * unmount.  It looks like syslogd is getting woken up only to find
    232  1.23  rearnsha 	 * that it cannot page part of the binary in as the filesystem has
    233  1.23  rearnsha 	 * been unmounted.
    234   1.1  rearnsha 	 */
    235   1.1  rearnsha 	if (!(howto & RB_NOSYNC))
    236   1.1  rearnsha 		bootsync();
    237   1.1  rearnsha 
    238   1.1  rearnsha 	/* Say NO to interrupts */
    239   1.1  rearnsha 	splhigh();
    240   1.1  rearnsha 
    241   1.1  rearnsha 	/* Do a dump if requested. */
    242   1.1  rearnsha 	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
    243   1.1  rearnsha 		dumpsys();
    244  1.78     skrll 
    245   1.1  rearnsha 	/* Run any shutdown hooks */
    246   1.1  rearnsha 	doshutdownhooks();
    247   1.1  rearnsha 
    248  1.59    dyoung 	pmf_system_shutdown(boothowto);
    249  1.59    dyoung 
    250   1.1  rearnsha 	/* Make sure IRQ's are disabled */
    251   1.1  rearnsha 	IRQdisable;
    252   1.1  rearnsha 
    253   1.1  rearnsha 	if (howto & RB_HALT) {
    254   1.1  rearnsha 		printf("The operating system has halted.\n");
    255   1.1  rearnsha 		printf("Please press any key to reboot.\n\n");
    256   1.1  rearnsha 		cngetc();
    257   1.1  rearnsha 	}
    258   1.1  rearnsha 
    259   1.1  rearnsha 	printf("rebooting...\n");
    260   1.1  rearnsha 	ifpga_reset();
    261   1.1  rearnsha 	/*NOTREACHED*/
    262   1.1  rearnsha }
    263   1.1  rearnsha 
    264  1.42   thorpej /* Statically mapped devices. */
    265  1.42   thorpej static const struct pmap_devmap integrator_devmap[] = {
    266   1.1  rearnsha #if NPLCOM > 0 && defined(PLCONSOLE)
    267  1.23  rearnsha 	{
    268  1.23  rearnsha 		UART0_BOOT_BASE,
    269  1.23  rearnsha 		IFPGA_IO_BASE + IFPGA_UART0,
    270  1.23  rearnsha 		1024 * 1024,
    271  1.23  rearnsha 		VM_PROT_READ|VM_PROT_WRITE,
    272  1.23  rearnsha 		PTE_NOCACHE
    273  1.23  rearnsha 	},
    274  1.23  rearnsha 
    275  1.23  rearnsha 	{
    276  1.23  rearnsha 		UART1_BOOT_BASE,
    277  1.23  rearnsha 		IFPGA_IO_BASE + IFPGA_UART1,
    278  1.23  rearnsha 		1024 * 1024,
    279  1.23  rearnsha 		VM_PROT_READ|VM_PROT_WRITE,
    280  1.23  rearnsha 		PTE_NOCACHE
    281  1.23  rearnsha 	},
    282   1.1  rearnsha #endif
    283   1.1  rearnsha #if NPCI > 0
    284  1.23  rearnsha 	{
    285  1.23  rearnsha 		IFPGA_PCI_IO_VBASE,
    286  1.23  rearnsha 		IFPGA_PCI_IO_BASE,
    287  1.23  rearnsha 		IFPGA_PCI_IO_VSIZE,
    288  1.23  rearnsha 		VM_PROT_READ|VM_PROT_WRITE,
    289  1.23  rearnsha 		PTE_NOCACHE
    290  1.23  rearnsha 	},
    291  1.23  rearnsha 
    292  1.23  rearnsha 	{
    293  1.23  rearnsha 		IFPGA_PCI_CONF_VBASE,
    294  1.23  rearnsha 		IFPGA_PCI_CONF_BASE,
    295  1.23  rearnsha 		IFPGA_PCI_CONF_VSIZE,
    296  1.23  rearnsha 		VM_PROT_READ|VM_PROT_WRITE,
    297  1.42   thorpej 		PTE_NOCACHE
    298  1.42   thorpej 	},
    299   1.1  rearnsha #endif
    300   1.1  rearnsha 
    301  1.23  rearnsha 	{
    302  1.23  rearnsha 		0,
    303  1.23  rearnsha 		0,
    304  1.23  rearnsha 		0,
    305  1.23  rearnsha 		0,
    306  1.23  rearnsha 		0
    307  1.23  rearnsha 	}
    308   1.1  rearnsha };
    309   1.1  rearnsha 
    310   1.1  rearnsha /*
    311  1.77     skrll  * vaddr_t initarm(...)
    312   1.1  rearnsha  *
    313   1.1  rearnsha  * Initial entry point on startup. This gets called before main() is
    314   1.1  rearnsha  * entered.
    315   1.1  rearnsha  * It should be responsible for setting up everything that must be
    316   1.1  rearnsha  * in place when main is called.
    317   1.1  rearnsha  * This includes
    318   1.1  rearnsha  *   Taking a copy of the boot configuration structure.
    319   1.1  rearnsha  *   Initialising the physical console so characters can be printed.
    320   1.1  rearnsha  *   Setting up page tables for the kernel
    321   1.1  rearnsha  *   Relocating the kernel to the bottom of physical memory
    322   1.1  rearnsha  */
    323   1.1  rearnsha 
    324  1.77     skrll vaddr_t
    325  1.23  rearnsha initarm(void *arg)
    326   1.1  rearnsha {
    327  1.73     skrll 	extern int KERNEL_BASE_phys[];
    328  1.23  rearnsha 	paddr_t memstart;
    329  1.23  rearnsha 	psize_t memsize;
    330  1.71      matt 
    331   1.1  rearnsha 	/*
    332   1.1  rearnsha 	 * Heads up ... Setup the CPU / MMU / TLB functions
    333   1.1  rearnsha 	 */
    334   1.1  rearnsha 	if (set_cpufuncs())
    335  1.73     skrll 		panic("cpu not recognized!");
    336   1.1  rearnsha 
    337  1.73     skrll 	/* map some peripheral registers */
    338   1.1  rearnsha 
    339  1.73     skrll 	pmap_devmap_bootstrap((vaddr_t)armreg_ttbr_read() & -L1_TABLE_SIZE,
    340  1.73     skrll 		integrator_devmap);
    341  1.69     skrll 
    342  1.73     skrll 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
    343  1.69     skrll 
    344  1.73     skrll 	consinit();
    345   1.1  rearnsha 
    346   1.1  rearnsha 	/* Talk to the user */
    347  1.73     skrll #define BDSTR(s)        _BDSTR(s)
    348  1.73     skrll #define _BDSTR(s)       #s
    349  1.73     skrll 	printf("\nNetBSD/evbarm (" BDSTR(EVBARM_BOARDTYPE) ") booting ...\n");
    350   1.1  rearnsha 
    351   1.1  rearnsha 	/*
    352  1.23  rearnsha 	 * Fetch the SDRAM start/size from the CM configuration registers.
    353   1.1  rearnsha 	 */
    354  1.23  rearnsha 	integrator_sdram_bounds(&memstart, &memsize);
    355   1.1  rearnsha 
    356  1.73     skrll #if defined(INTEGRATOR_CP)
    357  1.73     skrll 	/*
    358  1.73     skrll 	 * XXX QEMU reports SDRAM starting at 0x100000, but presents a flat
    359  1.73     skrll 	 * physical memory model. Set memstart to 0x0, so arm32_bootmem_init
    360  1.73     skrll 	 * doesn't get fooled later.
    361  1.73     skrll 	 */
    362  1.73     skrll 	memstart = 0;
    363  1.73     skrll #endif
    364  1.73     skrll 
    365  1.38   thorpej #ifdef VERBOSE_INIT_ARM
    366   1.1  rearnsha 	printf("initarm: Configuring system ...\n");
    367  1.38   thorpej #endif
    368   1.1  rearnsha 
    369  1.23  rearnsha 	/* Fake bootconfig structure for the benefit of pmap.c */
    370  1.23  rearnsha 	/* XXX must make the memory description h/w independent */
    371  1.23  rearnsha 	bootconfig.dramblocks = 1;
    372  1.23  rearnsha 	bootconfig.dram[0].address = memstart;
    373  1.31   thorpej 	bootconfig.dram[0].pages = memsize / PAGE_SIZE;
    374  1.80     skrll 	bootconfig.dram[0].flags = BOOT_DRAM_CAN_DMA;
    375  1.23  rearnsha 
    376  1.73     skrll 	arm32_bootmem_init(bootconfig.dram[0].address,
    377  1.73     skrll 		bootconfig.dram[0].pages * PAGE_SIZE, (unsigned int) KERNEL_BASE_phys);
    378   1.1  rearnsha 
    379  1.73     skrll 	arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_LOW, 0, integrator_devmap,
    380  1.73     skrll 		false);
    381   1.1  rearnsha 
    382  1.38   thorpej #ifdef VERBOSE_INIT_ARM
    383   1.1  rearnsha 	printf("done.\n");
    384  1.38   thorpej #endif
    385   1.1  rearnsha 
    386  1.73     skrll 	return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
    387   1.1  rearnsha }
    388   1.1  rearnsha 
    389   1.1  rearnsha void
    390   1.1  rearnsha consinit(void)
    391   1.1  rearnsha {
    392   1.1  rearnsha 	static int consinit_called = 0;
    393   1.1  rearnsha #if 0
    394   1.1  rearnsha 	char *console = CONSDEVNAME;
    395   1.1  rearnsha #endif
    396   1.1  rearnsha 
    397   1.1  rearnsha 	if (consinit_called != 0)
    398   1.1  rearnsha 		return;
    399   1.1  rearnsha 
    400   1.1  rearnsha 	consinit_called = 1;
    401   1.1  rearnsha 
    402   1.1  rearnsha #if NPLCOM > 0 && defined(PLCONSOLE)
    403   1.1  rearnsha 	if (PLCOMCNUNIT == 0) {
    404  1.73     skrll 		extern struct bus_space ifpga_common_bs_tag;
    405  1.69     skrll 		static struct plcom_instance ifpga_pi1 = {
    406  1.73     skrll #if defined(INTEGRATOR_CP)
    407  1.73     skrll 			.pi_type = PLCOM_TYPE_PL011,
    408  1.73     skrll #else
    409  1.69     skrll 			.pi_type = PLCOM_TYPE_PL010,
    410  1.73     skrll #endif
    411  1.73     skrll 			.pi_iot = &ifpga_common_bs_tag,
    412  1.69     skrll 			.pi_size = IFPGA_UART_SIZE,
    413  1.73     skrll 			.pi_iobase = IFPGA_UART0
    414  1.69     skrll 		};
    415  1.69     skrll 
    416  1.69     skrll 		if (plcomcnattach(&ifpga_pi1, plcomcnspeed, IFPGA_UART_CLK,
    417  1.69     skrll 		      plcomcnmode, PLCOMCNUNIT))
    418   1.1  rearnsha 			panic("can't init serial console");
    419   1.1  rearnsha 		return;
    420   1.1  rearnsha 	} else if (PLCOMCNUNIT == 1) {
    421  1.73     skrll 		extern struct bus_space ifpga_common_bs_tag;
    422  1.69     skrll 		static struct plcom_instance ifpga_pi1 = {
    423  1.73     skrll #if defined(INTEGRATOR_CP)
    424  1.73     skrll 			.pi_type = PLCOM_TYPE_PL011,
    425  1.73     skrll #else
    426  1.69     skrll 			.pi_type = PLCOM_TYPE_PL010,
    427  1.73     skrll #endif
    428  1.73     skrll 			.pi_iot = &ifpga_common_bs_tag,
    429  1.69     skrll 			.pi_size = IFPGA_UART_SIZE,
    430  1.73     skrll 			.pi_iobase = IFPGA_UART1
    431  1.69     skrll 		};
    432  1.69     skrll 
    433  1.69     skrll 		if (plcomcnattach(&ifpga_pi1, plcomcnspeed, IFPGA_UART_CLK,
    434  1.69     skrll 		      plcomcnmode, PLCOMCNUNIT))
    435   1.1  rearnsha 			panic("can't init serial console");
    436   1.1  rearnsha 		return;
    437   1.1  rearnsha 	}
    438   1.1  rearnsha #endif
    439   1.1  rearnsha #if (NCOM > 0)
    440   1.1  rearnsha 	if (comcnattach(&isa_io_bs_tag, CONCOMADDR, comcnspeed,
    441  1.41   thorpej 	    COM_FREQ, COM_TYPE_NORMAL, comcnmode))
    442   1.1  rearnsha 		panic("can't init serial console @%x", CONCOMADDR);
    443   1.1  rearnsha 	return;
    444   1.1  rearnsha #endif
    445   1.1  rearnsha 	panic("No serial console configured");
    446  1.23  rearnsha }
    447  1.23  rearnsha 
    448  1.23  rearnsha static void
    449  1.23  rearnsha integrator_sdram_bounds(paddr_t *memstart, psize_t *memsize)
    450  1.23  rearnsha {
    451  1.78     skrll 	volatile unsigned long *cm_sdram
    452  1.23  rearnsha 	    = (volatile unsigned long *)0x10000020;
    453  1.46  rearnsha 	volatile unsigned long *cm_stat
    454  1.46  rearnsha 	    = (volatile unsigned long *)0x10000010;
    455  1.23  rearnsha 
    456  1.46  rearnsha 	*memstart = *cm_stat & 0x00ff0000;
    457  1.23  rearnsha 
    458  1.46  rearnsha 	/*
    459  1.46  rearnsha 	 * Although the SSRAM overlaps the SDRAM, we can use the wrap-around
    460  1.46  rearnsha 	 * to access the entire bank.
    461  1.46  rearnsha 	 */
    462  1.23  rearnsha 	switch ((*cm_sdram >> 2) & 0x7)
    463  1.23  rearnsha 	{
    464  1.23  rearnsha 	case 0:
    465  1.23  rearnsha 		*memsize = 16 * 1024 * 1024;
    466  1.23  rearnsha 		break;
    467  1.23  rearnsha 	case 1:
    468  1.23  rearnsha 		*memsize = 32 * 1024 * 1024;
    469  1.23  rearnsha 		break;
    470  1.23  rearnsha 	case 2:
    471  1.23  rearnsha 		*memsize = 64 * 1024 * 1024;
    472  1.23  rearnsha 		break;
    473  1.23  rearnsha 	case 3:
    474  1.23  rearnsha 		*memsize = 128 * 1024 * 1024;
    475  1.23  rearnsha 		break;
    476  1.23  rearnsha 	case 4:
    477  1.46  rearnsha 		/* With 256M of memory there is no wrap-around.  */
    478  1.46  rearnsha 		*memsize = 256 * 1024 * 1024 - *memstart;
    479  1.23  rearnsha 		break;
    480  1.23  rearnsha 	default:
    481  1.23  rearnsha 		printf("CM_SDRAM retuns unknown value, using 16M\n");
    482  1.23  rearnsha 		*memsize = 16 * 1024 * 1024;
    483  1.23  rearnsha 		break;
    484  1.23  rearnsha 	}
    485   1.1  rearnsha }
    486