Home | History | Annotate | Line # | Download | only in pmppc
machdep.c revision 1.4
      1  1.4   dyoung /*	$NetBSD: machdep.c,v 1.4 2008/11/11 06:46:42 dyoung Exp $	*/
      2  1.2  garbled 
      3  1.2  garbled /*
      4  1.2  garbled  * Copyright (c) 2002 The NetBSD Foundation, Inc.
      5  1.2  garbled  * All rights reserved.
      6  1.2  garbled  *
      7  1.2  garbled  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2  garbled  * by Lennart Augustsson (lennart (at) augustsson.net) at Sandburst Corp.
      9  1.2  garbled  *
     10  1.2  garbled  * Redistribution and use in source and binary forms, with or without
     11  1.2  garbled  * modification, are permitted provided that the following conditions
     12  1.2  garbled  * are met:
     13  1.2  garbled  * 1. Redistributions of source code must retain the above copyright
     14  1.2  garbled  *    notice, this list of conditions and the following disclaimer.
     15  1.2  garbled  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.2  garbled  *    notice, this list of conditions and the following disclaimer in the
     17  1.2  garbled  *    documentation and/or other materials provided with the distribution.
     18  1.2  garbled  *
     19  1.2  garbled  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.2  garbled  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.2  garbled  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.2  garbled  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.2  garbled  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.2  garbled  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.2  garbled  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.2  garbled  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.2  garbled  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.2  garbled  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.2  garbled  * POSSIBILITY OF SUCH DAMAGE.
     30  1.2  garbled  */
     31  1.2  garbled 
     32  1.2  garbled /*
     33  1.2  garbled  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
     34  1.2  garbled  * Copyright (C) 1995, 1996 TooLs GmbH.
     35  1.2  garbled  * All rights reserved.
     36  1.2  garbled  *
     37  1.2  garbled  * Redistribution and use in source and binary forms, with or without
     38  1.2  garbled  * modification, are permitted provided that the following conditions
     39  1.2  garbled  * are met:
     40  1.2  garbled  * 1. Redistributions of source code must retain the above copyright
     41  1.2  garbled  *    notice, this list of conditions and the following disclaimer.
     42  1.2  garbled  * 2. Redistributions in binary form must reproduce the above copyright
     43  1.2  garbled  *    notice, this list of conditions and the following disclaimer in the
     44  1.2  garbled  *    documentation and/or other materials provided with the distribution.
     45  1.2  garbled  * 3. All advertising materials mentioning features or use of this software
     46  1.2  garbled  *    must display the following acknowledgement:
     47  1.2  garbled  *	This product includes software developed by TooLs GmbH.
     48  1.2  garbled  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     49  1.2  garbled  *    derived from this software without specific prior written permission.
     50  1.2  garbled  *
     51  1.2  garbled  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     52  1.2  garbled  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     53  1.2  garbled  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     54  1.2  garbled  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     55  1.2  garbled  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     56  1.2  garbled  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     57  1.2  garbled  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     58  1.2  garbled  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     59  1.2  garbled  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     60  1.2  garbled  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     61  1.2  garbled  */
     62  1.2  garbled 
     63  1.2  garbled #include <sys/cdefs.h>
     64  1.4   dyoung __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.4 2008/11/11 06:46:42 dyoung Exp $");
     65  1.2  garbled 
     66  1.2  garbled #include "opt_compat_netbsd.h"
     67  1.2  garbled #include "opt_ddb.h"
     68  1.2  garbled #include "opt_ddbparam.h"
     69  1.2  garbled #include "opt_inet.h"
     70  1.2  garbled #include "opt_ccitt.h"
     71  1.2  garbled #include "opt_iso.h"
     72  1.2  garbled #include "opt_ns.h"
     73  1.2  garbled #include "opt_ipkdb.h"
     74  1.2  garbled 
     75  1.2  garbled #include <sys/param.h>
     76  1.2  garbled #include <sys/buf.h>
     77  1.2  garbled #include <sys/conf.h>
     78  1.2  garbled #include <sys/device.h>
     79  1.2  garbled #include <sys/exec.h>
     80  1.2  garbled #include <sys/extent.h>
     81  1.2  garbled #include <sys/kernel.h>
     82  1.2  garbled #include <sys/kgdb.h>
     83  1.2  garbled #include <sys/malloc.h>
     84  1.2  garbled #include <sys/mbuf.h>
     85  1.2  garbled #include <sys/mount.h>
     86  1.2  garbled #include <sys/msgbuf.h>
     87  1.2  garbled #include <sys/proc.h>
     88  1.2  garbled #include <sys/reboot.h>
     89  1.2  garbled #include <sys/syscallargs.h>
     90  1.2  garbled #include <sys/syslog.h>
     91  1.2  garbled #include <sys/sysctl.h>
     92  1.2  garbled #include <sys/systm.h>
     93  1.2  garbled #include <sys/user.h>
     94  1.2  garbled #include <sys/ksyms.h>
     95  1.2  garbled 
     96  1.2  garbled #include <uvm/uvm.h>
     97  1.2  garbled #include <uvm/uvm_extern.h>
     98  1.2  garbled 
     99  1.2  garbled #include <net/netisr.h>
    100  1.2  garbled 
    101  1.2  garbled #include <machine/bus.h>
    102  1.2  garbled #include <machine/db_machdep.h>
    103  1.2  garbled #include <machine/intr.h>
    104  1.2  garbled #include <machine/pio.h>
    105  1.2  garbled #include <machine/pmap.h>
    106  1.2  garbled #include <machine/powerpc.h>
    107  1.2  garbled #include <machine/trap.h>
    108  1.2  garbled #include <machine/pmppc.h>
    109  1.2  garbled 
    110  1.2  garbled #include <powerpc/oea/bat.h>
    111  1.2  garbled #include <arch/powerpc/pic/picvar.h>
    112  1.2  garbled 
    113  1.2  garbled #include <ddb/db_extern.h>
    114  1.2  garbled 
    115  1.2  garbled #include <dev/cons.h>
    116  1.2  garbled 
    117  1.2  garbled #include <dev/ic/cpc700reg.h>
    118  1.2  garbled #include <dev/ic/cpc700uic.h>
    119  1.2  garbled 
    120  1.2  garbled #include "com.h"
    121  1.2  garbled #if (NCOM > 0)
    122  1.2  garbled #include <sys/termios.h>
    123  1.2  garbled #include <dev/ic/comreg.h>
    124  1.2  garbled #include <dev/ic/comvar.h>
    125  1.2  garbled #endif
    126  1.2  garbled 
    127  1.2  garbled #include "ksyms.h"
    128  1.2  garbled 
    129  1.2  garbled struct powerpc_bus_space pmppc_mem_tag = {
    130  1.2  garbled 	_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
    131  1.2  garbled 	0, 0, 0xffffffff,
    132  1.2  garbled 	NULL,
    133  1.2  garbled };
    134  1.2  garbled struct powerpc_bus_space pmppc_pci_io_tag = {
    135  1.2  garbled 	_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
    136  1.2  garbled 	0, CPC_PCI_IO_BASE, 0xffffffff,
    137  1.2  garbled 	NULL,
    138  1.2  garbled };
    139  1.2  garbled 
    140  1.2  garbled static char ex_storage[1][EXTENT_FIXED_STORAGE_SIZE(8)]
    141  1.2  garbled     __attribute__((aligned(8)));
    142  1.2  garbled 
    143  1.2  garbled 
    144  1.2  garbled #ifdef KGDB
    145  1.2  garbled char kgdb_devname[] = KGDB_DEVNAME;
    146  1.2  garbled int comkgdbaddr = KGDB_DEVADDR;
    147  1.2  garbled int comkgdbrate = KGDB_DEVRATE;
    148  1.2  garbled 
    149  1.2  garbled #ifndef KGDB_DEVMODE
    150  1.2  garbled #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    151  1.2  garbled #endif
    152  1.2  garbled int comkgdbmode = KGDB_DEVMODE;
    153  1.2  garbled 
    154  1.2  garbled void kgdb_port_init(void);
    155  1.2  garbled #endif /* KGDB */
    156  1.2  garbled 
    157  1.2  garbled /*
    158  1.2  garbled  * Global variables used here and there
    159  1.2  garbled  */
    160  1.2  garbled struct mem_region physmemr[2], availmemr[2];
    161  1.2  garbled 
    162  1.2  garbled struct a_config a_config;
    163  1.2  garbled 
    164  1.2  garbled void initppc(u_int, u_int, u_int, void *); /* Called from locore */
    165  1.2  garbled void pmppc_setup(void);
    166  1.2  garbled void setleds(int leds);
    167  1.2  garbled 
    168  1.2  garbled /*
    169  1.2  garbled  * Force cpu_info to be in the data segment to avoid the
    170  1.2  garbled  * memset() blowing away the data set up by locore.S.
    171  1.2  garbled  */
    172  1.2  garbled #if 0
    173  1.2  garbled  /* this is defined in powerpc/oea/cpu_subr.c, I don't understand the above
    174  1.2  garbled   * comment however.
    175  1.2  garbled   */
    176  1.2  garbled struct cpu_info cpu_info[1] = { { .ci_curlwp = &lwp0, }, };
    177  1.2  garbled #endif
    178  1.2  garbled 
    179  1.2  garbled void
    180  1.2  garbled initppc(u_int startkernel, u_int endkernel, u_int args, void *btinfo)
    181  1.2  garbled {
    182  1.2  garbled 	extern void consinit(void);
    183  1.2  garbled 	extern u_long ticks_per_sec;
    184  1.2  garbled 	extern unsigned char edata[], end[];
    185  1.2  garbled 
    186  1.2  garbled 	memset(&edata, 0, end - edata); /* clear BSS */
    187  1.2  garbled 
    188  1.2  garbled 	pmppc_setup();
    189  1.2  garbled 
    190  1.2  garbled 	physmemr[0].start = 0;
    191  1.2  garbled 	physmemr[0].size = a_config.a_mem_size;
    192  1.2  garbled 	physmemr[1].size = 0;
    193  1.2  garbled 	availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET;
    194  1.2  garbled 	availmemr[0].size = a_config.a_mem_size - availmemr[0].start;
    195  1.2  garbled 	availmemr[1].size = 0;
    196  1.2  garbled 
    197  1.2  garbled #ifdef BOOTHOWTO
    198  1.2  garbled 	/*
    199  1.2  garbled 	 * boothowto
    200  1.2  garbled 	 */
    201  1.2  garbled 	boothowto = BOOTHOWTO;
    202  1.2  garbled #endif
    203  1.2  garbled 
    204  1.2  garbled 	if (bus_space_init(&pmppc_mem_tag, "iomem",
    205  1.2  garbled 			   ex_storage[0], sizeof(ex_storage[0])))
    206  1.2  garbled 		panic("bus_space_init failed");
    207  1.2  garbled 
    208  1.2  garbled 	/*
    209  1.2  garbled 	 * Get CPU clock
    210  1.2  garbled 	 */
    211  1.2  garbled 	ticks_per_sec = a_config.a_bus_freq;
    212  1.2  garbled 	ticks_per_sec /= 4;	/* 4 cycles per DEC tick */
    213  1.2  garbled 	cpu_timebase = ticks_per_sec;
    214  1.2  garbled 	cpu_initclocks();
    215  1.2  garbled 
    216  1.2  garbled 	/*
    217  1.2  garbled 	 * Initialize the BAT registers
    218  1.2  garbled 	 */
    219  1.2  garbled 	oea_batinit(
    220  1.2  garbled 	    PMPPC_FLASH_BASE, BAT_BL_256M, /* flash (etc) memory 256M area */
    221  1.2  garbled 	    CPC_PCI_MEM_BASE, BAT_BL_256M, /* PCI memory 256M area */
    222  1.2  garbled 	    CPC_PCI_IO_BASE,  BAT_BL_128M, /* PCI I/O 128M area */
    223  1.2  garbled 	    0);
    224  1.2  garbled 
    225  1.2  garbled 	/*
    226  1.2  garbled 	 * Set up trap vectors
    227  1.2  garbled 	 */
    228  1.2  garbled 	oea_init(NULL);
    229  1.2  garbled 
    230  1.2  garbled 	/*
    231  1.2  garbled 	 * Set up console.
    232  1.2  garbled 	 */
    233  1.2  garbled 	consinit();		/* XXX should not be here */
    234  1.2  garbled 
    235  1.2  garbled 	printf("console set up\n");
    236  1.2  garbled 
    237  1.2  garbled         /*
    238  1.2  garbled 	 * Set the page size.
    239  1.2  garbled 	 */
    240  1.2  garbled 	uvm_setpagesize();
    241  1.2  garbled 
    242  1.2  garbled 	/*
    243  1.2  garbled 	 * Initialize pmap module.
    244  1.2  garbled 	 */
    245  1.2  garbled 	pmap_bootstrap(startkernel, endkernel);
    246  1.2  garbled 
    247  1.2  garbled #if NKSYMS || defined(DDB) || defined(LKM)
    248  1.2  garbled #ifdef SYMTAB_SPACE
    249  1.2  garbled 	ksyms_init(0, NULL, NULL);
    250  1.2  garbled #else
    251  1.2  garbled 	#error "No SYMTAB_SPACE"
    252  1.2  garbled #endif
    253  1.2  garbled #endif
    254  1.2  garbled #ifdef IPKDB
    255  1.2  garbled 	/*
    256  1.2  garbled 	 * Now trap to IPKDB
    257  1.2  garbled 	 */
    258  1.2  garbled 	ipkdb_init();
    259  1.2  garbled 	if (boothowto & RB_KDB)
    260  1.2  garbled 		ipkdb_connect(0);
    261  1.2  garbled #endif
    262  1.2  garbled #ifdef KGDB
    263  1.2  garbled 	kgdb_port_init();
    264  1.2  garbled 	if (boothowto & RB_KDB) {
    265  1.2  garbled 		kgdb_debug_init = 1;
    266  1.2  garbled 		kgdb_connect(1);
    267  1.2  garbled 	}
    268  1.2  garbled #endif
    269  1.2  garbled }
    270  1.2  garbled 
    271  1.2  garbled void
    272  1.2  garbled mem_regions(struct mem_region **mem, struct mem_region **avail)
    273  1.2  garbled {
    274  1.2  garbled 	*mem = physmemr;
    275  1.2  garbled 	*avail = availmemr;
    276  1.2  garbled }
    277  1.2  garbled 
    278  1.2  garbled /*
    279  1.2  garbled  * Machine dependent startup code.
    280  1.2  garbled  */
    281  1.2  garbled void
    282  1.2  garbled cpu_startup()
    283  1.2  garbled {
    284  1.2  garbled 
    285  1.2  garbled 	oea_startup(NULL);
    286  1.2  garbled 
    287  1.2  garbled 	/*
    288  1.2  garbled 	 * Now that we have VM, malloc()s are OK in bus_space.
    289  1.2  garbled 	 */
    290  1.2  garbled 	bus_space_mallocok();
    291  1.2  garbled 
    292  1.2  garbled 	/* Set up the PCI bus tag. */
    293  1.2  garbled 	if (bus_space_init(&pmppc_pci_io_tag, "pcimem", NULL, 0))
    294  1.2  garbled 		panic("bus_space_init pci failed");
    295  1.2  garbled 
    296  1.2  garbled 	/* Set up interrupt controller */
    297  1.2  garbled 	cpc700_init_intr(&pmppc_mem_tag, CPC_UIC_BASE,
    298  1.2  garbled 	    CPC_INTR_MASK(PMPPC_I_ETH_INT), 0);
    299  1.2  garbled 
    300  1.2  garbled 	pic_init();
    301  1.2  garbled 	(void)setup_cpc700();
    302  1.2  garbled 	oea_install_extint(pic_ext_intr);
    303  1.2  garbled 
    304  1.2  garbled #if 0
    305  1.2  garbled /* XXX doesn't seem to be needed anymore */
    306  1.2  garbled 	/*
    307  1.2  garbled 	 * Now allow hardware interrupts.
    308  1.2  garbled 	 */
    309  1.2  garbled 	__asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
    310  1.2  garbled 	    : "=r"(msr) : "K"(PSL_EE));
    311  1.2  garbled #endif
    312  1.2  garbled }
    313  1.2  garbled 
    314  1.2  garbled /*
    315  1.2  garbled  * consinit
    316  1.2  garbled  * Initialize system console.
    317  1.2  garbled  */
    318  1.2  garbled void
    319  1.2  garbled consinit(void)
    320  1.2  garbled {
    321  1.2  garbled 	static int initted;
    322  1.2  garbled #if (NCOM > 0)
    323  1.2  garbled 	bus_space_tag_t tag;
    324  1.2  garbled #endif
    325  1.2  garbled 
    326  1.2  garbled 	if (initted)
    327  1.2  garbled 		return;
    328  1.2  garbled 	initted = 1;
    329  1.2  garbled 
    330  1.2  garbled #if (NCOM > 0)
    331  1.2  garbled 	tag = &pmppc_mem_tag;
    332  1.2  garbled 
    333  1.2  garbled 	if(comcnattach(tag, CPC_COM0, 9600, CPC_COM_SPEED(a_config.a_bus_freq),
    334  1.2  garbled 	    COM_TYPE_NORMAL,
    335  1.2  garbled             ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8)))
    336  1.2  garbled 		panic("can't init serial console");
    337  1.2  garbled 	else
    338  1.2  garbled 		return;
    339  1.2  garbled #endif
    340  1.2  garbled 
    341  1.2  garbled 	panic("console device missing -- serial console not in kernel");
    342  1.2  garbled 	/* Of course, this is moot if there is no console... */
    343  1.2  garbled }
    344  1.2  garbled 
    345  1.2  garbled #ifdef KGDB
    346  1.2  garbled void
    347  1.2  garbled kgdb_port_init(void)
    348  1.2  garbled {
    349  1.2  garbled #if (NCOM > 0)
    350  1.2  garbled 	if(!strcmp(kgdb_devname, "com")) {
    351  1.2  garbled 		bus_space_tag_t tag = &pmppc_mem_tag;
    352  1.2  garbled 		com_kgdb_attach(tag, comkgdbaddr, comkgdbrate,
    353  1.2  garbled 				CPC_COM_SPEED(a_config.a_bus_freq),
    354  1.2  garbled 				COM_TYPE_NORMAL, comkgdbmode);
    355  1.2  garbled 	}
    356  1.2  garbled #endif
    357  1.2  garbled }
    358  1.2  garbled #endif
    359  1.2  garbled 
    360  1.2  garbled /*
    361  1.2  garbled  * Halt or reboot the machine after syncing/dumping according to howto.
    362  1.2  garbled  */
    363  1.2  garbled void
    364  1.2  garbled cpu_reboot(int howto, char *what)
    365  1.2  garbled {
    366  1.2  garbled 	static int syncing;
    367  1.2  garbled 	static char str[256];
    368  1.2  garbled 	char *ap = str, *ap1 = ap;
    369  1.2  garbled 	extern void disable_intr(void);
    370  1.2  garbled 
    371  1.2  garbled 	boothowto = howto;
    372  1.2  garbled 	if (!cold && !(howto & RB_NOSYNC) && !syncing) {
    373  1.2  garbled 		syncing = 1;
    374  1.2  garbled 		vfs_shutdown();		/* sync */
    375  1.2  garbled 		resettodr();		/* set wall clock */
    376  1.2  garbled 	}
    377  1.2  garbled 	splhigh();
    378  1.2  garbled 	if (howto & RB_HALT) {
    379  1.2  garbled 		doshutdownhooks();
    380  1.4   dyoung 		pmf_system_shutdown(boothowto);
    381  1.2  garbled 		printf("halted\n\n");
    382  1.2  garbled 		while(1);
    383  1.2  garbled 	}
    384  1.2  garbled 	if (!cold && (howto & RB_DUMP))
    385  1.2  garbled 		oea_dumpsys();
    386  1.2  garbled 	doshutdownhooks();
    387  1.4   dyoung 
    388  1.4   dyoung 	pmf_system_shutdown(boothowto);
    389  1.2  garbled 	printf("rebooting\n\n");
    390  1.2  garbled 	if (what && *what) {
    391  1.2  garbled 		if (strlen(what) > sizeof str - 5)
    392  1.2  garbled 			printf("boot string too large, ignored\n");
    393  1.2  garbled 		else {
    394  1.2  garbled 			strcpy(str, what);
    395  1.2  garbled 			ap1 = ap = str + strlen(str);
    396  1.2  garbled 			*ap++ = ' ';
    397  1.2  garbled 		}
    398  1.2  garbled 	}
    399  1.2  garbled 	*ap++ = '-';
    400  1.2  garbled 	if (howto & RB_SINGLE)
    401  1.2  garbled 		*ap++ = 's';
    402  1.2  garbled 	if (howto & RB_KDB)
    403  1.2  garbled 		*ap++ = 'd';
    404  1.2  garbled 	*ap++ = 0;
    405  1.2  garbled 	if (ap[-2] == '-')
    406  1.2  garbled 		*ap1 = 0;
    407  1.2  garbled 
    408  1.2  garbled 	disable_intr();
    409  1.2  garbled 
    410  1.2  garbled         /* Write the two byte reset sequence to the reset register. */
    411  1.2  garbled 	out8(PMPPC_RESET, PMPPC_RESET_SEQ_STEP1);
    412  1.2  garbled 	out8(PMPPC_RESET, PMPPC_RESET_SEQ_STEP2);
    413  1.2  garbled 
    414  1.2  garbled 	while (1);
    415  1.2  garbled }
    416  1.2  garbled 
    417  1.2  garbled void
    418  1.2  garbled setleds(int leds)
    419  1.2  garbled {
    420  1.2  garbled 	out8(PMPPC_LEDS, leds);
    421  1.2  garbled }
    422  1.2  garbled 
    423  1.2  garbled void
    424  1.2  garbled pmppc_setup(void)
    425  1.2  garbled {
    426  1.2  garbled 	uint config0, config1;
    427  1.2  garbled 
    428  1.2  garbled 	config0 = in8(PMPPC_CONFIG0);
    429  1.2  garbled 	config1 = in8(PMPPC_CONFIG1);
    430  1.2  garbled 
    431  1.2  garbled 	/* from page 2-8 in the Artesyn User's manual */
    432  1.2  garbled 	a_config.a_boot_device = config1 & 0x80 ? A_BOOT_FLASH : A_BOOT_ROM;
    433  1.2  garbled 	a_config.a_has_ecc = (config1 & 0x40) != 0;
    434  1.2  garbled 	switch (config1 & 0x30) {
    435  1.2  garbled 	case 0x00: a_config.a_mem_size = 32 * 1024 * 1024; break;
    436  1.2  garbled 	case 0x10: a_config.a_mem_size = 64 * 1024 * 1024; break;
    437  1.2  garbled 	case 0x20: a_config.a_mem_size = 128 * 1024 * 1024; break;
    438  1.2  garbled 	case 0x30: a_config.a_mem_size = 256 * 1024 * 1024; break;
    439  1.2  garbled 	}
    440  1.2  garbled 	a_config.a_l2_cache = (config1 >> 2) & 3;
    441  1.2  garbled 	switch (config1 & 0x03) {
    442  1.2  garbled 	case 0x00: a_config.a_bus_freq = 66666666; break;
    443  1.2  garbled 	case 0x01: a_config.a_bus_freq = 83333333; break;
    444  1.2  garbled 	case 0x02: a_config.a_bus_freq = 100000000; break;
    445  1.2  garbled 	case 0x03: a_config.a_bus_freq = 0; break; /* XXX */
    446  1.2  garbled 	}
    447  1.2  garbled 	a_config.a_is_monarch = (config0 & 0x80) == 0;
    448  1.2  garbled 	a_config.a_has_eth = (config0 & 0x20) != 0;
    449  1.2  garbled 	a_config.a_has_rtc = (config0 & 0x10) == 0;
    450  1.2  garbled 	switch (config0 & 0x0c) {
    451  1.2  garbled 	case 0x00: a_config.a_flash_size = 256 * 1024 * 1024; break;
    452  1.2  garbled 	case 0x04: a_config.a_flash_size = 128 * 1024 * 1024; break;
    453  1.2  garbled 	case 0x08: a_config.a_flash_size = 64 * 1024 * 1024; break;
    454  1.2  garbled 	case 0x0c: a_config.a_flash_size = 32 * 1024 * 1024; break;
    455  1.2  garbled 	}
    456  1.2  garbled 	switch (config0 & 0x03) {
    457  1.2  garbled 	case 0x00: a_config.a_flash_width = 64; break;
    458  1.2  garbled 	case 0x01: a_config.a_flash_width = 32; break;
    459  1.2  garbled 	case 0x02: a_config.a_flash_width = 16; break;
    460  1.2  garbled 	case 0x03: a_config.a_flash_width = 0; break;
    461  1.2  garbled 	}
    462  1.2  garbled }
    463