Home | History | Annotate | Line # | Download | only in vr
vr.c revision 1.41.2.4
      1  1.41.2.4     skrll /*	$NetBSD: vr.c,v 1.41.2.4 2005/01/17 19:29:28 skrll Exp $	*/
      2       1.1  takemura 
      3       1.1  takemura /*-
      4      1.35  takemura  * Copyright (c) 1999-2002
      5       1.1  takemura  *         Shin Takemura and PocketBSD Project. All rights reserved.
      6       1.1  takemura  *
      7       1.1  takemura  * Redistribution and use in source and binary forms, with or without
      8       1.1  takemura  * modification, are permitted provided that the following conditions
      9       1.1  takemura  * are met:
     10       1.1  takemura  * 1. Redistributions of source code must retain the above copyright
     11       1.1  takemura  *    notice, this list of conditions and the following disclaimer.
     12       1.1  takemura  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1  takemura  *    notice, this list of conditions and the following disclaimer in the
     14       1.1  takemura  *    documentation and/or other materials provided with the distribution.
     15       1.1  takemura  * 3. All advertising materials mentioning features or use of this software
     16       1.1  takemura  *    must display the following acknowledgement:
     17       1.1  takemura  *	This product includes software developed by the PocketBSD project
     18       1.1  takemura  *	and its contributors.
     19       1.1  takemura  * 4. Neither the name of the project nor the names of its contributors
     20       1.1  takemura  *    may be used to endorse or promote products derived from this software
     21       1.1  takemura  *    without specific prior written permission.
     22       1.1  takemura  *
     23       1.1  takemura  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24       1.1  takemura  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25       1.1  takemura  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26       1.1  takemura  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27       1.1  takemura  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28       1.1  takemura  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29       1.1  takemura  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30       1.1  takemura  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31       1.1  takemura  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32       1.1  takemura  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33       1.1  takemura  * SUCH DAMAGE.
     34       1.1  takemura  *
     35       1.1  takemura  */
     36      1.29       uch 
     37  1.41.2.1     skrll #include <sys/cdefs.h>
     38  1.41.2.4     skrll __KERNEL_RCSID(0, "$NetBSD: vr.c,v 1.41.2.4 2005/01/17 19:29:28 skrll Exp $");
     39  1.41.2.1     skrll 
     40      1.29       uch #include "opt_vr41xx.h"
     41      1.31       uch #include "opt_tx39xx.h"
     42      1.24     lukem #include "opt_kgdb.h"
     43      1.24     lukem 
     44       1.1  takemura #include <sys/param.h>
     45       1.1  takemura #include <sys/systm.h>
     46       1.5  takemura #include <sys/reboot.h>
     47       1.1  takemura 
     48      1.31       uch #include <uvm/uvm_extern.h>
     49      1.31       uch 
     50       1.1  takemura #include <machine/sysconf.h>
     51      1.32  takemura #include <machine/bootinfo.h>
     52       1.1  takemura #include <machine/bus.h>
     53      1.32  takemura #include <machine/bus_space_hpcmips.h>
     54      1.35  takemura #include <machine/platid.h>
     55      1.35  takemura #include <machine/platid_mask.h>
     56       1.1  takemura 
     57      1.26     enami #include <dev/hpc/hpckbdvar.h>
     58      1.30       uch 
     59       1.1  takemura #include <hpcmips/vr/vr.h>
     60      1.11  takemura #include <hpcmips/vr/vr_asm.h>
     61      1.22      sato #include <hpcmips/vr/vrcpudef.h>
     62       1.3  takemura #include <hpcmips/vr/vripreg.h>
     63       1.1  takemura #include <hpcmips/vr/rtcreg.h>
     64       1.1  takemura 
     65      1.40      shin #include <mips/cache.h>
     66      1.40      shin 
     67      1.38  takemura #include "vrip_common.h"
     68      1.38  takemura #if NVRIP_COMMON > 0
     69       1.8  takemura #include <hpcmips/vr/vripvar.h>
     70       1.8  takemura #endif
     71       1.8  takemura 
     72       1.9      sato #include "vrbcu.h"
     73       1.9      sato #if NVRBCU > 0
     74       1.9      sato #include <hpcmips/vr/bcuvar.h>
     75       1.9      sato #endif
     76       1.9      sato 
     77       1.5  takemura #include "vrdsu.h"
     78       1.5  takemura #if NVRDSU > 0
     79       1.5  takemura #include <hpcmips/vr/vrdsuvar.h>
     80       1.5  takemura #endif
     81       1.5  takemura 
     82       1.1  takemura #include "com.h"
     83      1.35  takemura #include "com_vrip.h"
     84      1.35  takemura #include "com_hpcio.h"
     85      1.35  takemura #if NCOM > 0
     86       1.1  takemura #include <sys/termios.h>
     87       1.1  takemura #include <sys/ttydefaults.h>
     88       1.1  takemura #include <dev/ic/comreg.h>
     89       1.1  takemura #include <dev/ic/comvar.h>
     90      1.35  takemura #if NCOM_VRIP > 0
     91       1.1  takemura #include <hpcmips/vr/siureg.h>
     92       1.1  takemura #include <hpcmips/vr/com_vripvar.h>
     93      1.33  takemura #endif
     94      1.35  takemura #if NCOM_HPCIO > 0
     95      1.35  takemura #include <hpcmips/dev/com_hpciovar.h>
     96      1.33  takemura #endif
     97       1.1  takemura #ifndef CONSPEED
     98       1.1  takemura #define CONSPEED TTYDEF_SPEED
     99       1.1  takemura #endif
    100       1.1  takemura #endif
    101       1.1  takemura 
    102      1.15  takemura #include "hpcfb.h"
    103       1.3  takemura #include "vrkiu.h"
    104      1.25     enami #if (NVRKIU > 0) || (NHPCFB > 0)
    105       1.3  takemura #include <dev/wscons/wsdisplayvar.h>
    106      1.15  takemura #include <dev/rasops/rasops.h>
    107       1.3  takemura #endif
    108       1.3  takemura 
    109      1.15  takemura #if NHPCFB > 0
    110      1.20       uch #include <dev/hpc/hpcfbvar.h>
    111       1.3  takemura #endif
    112       1.3  takemura 
    113      1.15  takemura #if NVRKIU > 0
    114      1.26     enami #include <arch/hpcmips/vr/vrkiureg.h>
    115       1.3  takemura #include <arch/hpcmips/vr/vrkiuvar.h>
    116       1.3  takemura #endif
    117       1.3  takemura 
    118      1.31       uch #ifdef DEBUG
    119      1.31       uch #define STATIC
    120      1.31       uch #else
    121      1.31       uch #define STATIC	static
    122      1.31       uch #endif
    123      1.31       uch 
    124      1.31       uch /*
    125      1.31       uch  * This is a mask of bits to clear in the SR when we go to a
    126      1.31       uch  * given interrupt priority level.
    127      1.31       uch  */
    128      1.31       uch const u_int32_t __ipl_sr_bits_vr[_IPL_N] = {
    129      1.31       uch 	0,					/* IPL_NONE */
    130      1.31       uch 
    131      1.31       uch 	MIPS_SOFT_INT_MASK_0,			/* IPL_SOFT */
    132      1.31       uch 
    133      1.31       uch 	MIPS_SOFT_INT_MASK_0,			/* IPL_SOFTCLOCK */
    134      1.31       uch 
    135      1.31       uch 	MIPS_SOFT_INT_MASK_0|
    136      1.31       uch 		MIPS_SOFT_INT_MASK_1,		/* IPL_SOFTNET */
    137      1.31       uch 
    138      1.31       uch 	MIPS_SOFT_INT_MASK_0|
    139      1.31       uch 		MIPS_SOFT_INT_MASK_1,		/* IPL_SOFTSERIAL */
    140      1.31       uch 
    141      1.31       uch 	MIPS_SOFT_INT_MASK_0|
    142      1.31       uch 		MIPS_SOFT_INT_MASK_1|
    143      1.31       uch 		MIPS_INT_MASK_0,		/* IPL_BIO */
    144      1.31       uch 
    145      1.31       uch 	MIPS_SOFT_INT_MASK_0|
    146      1.31       uch 		MIPS_SOFT_INT_MASK_1|
    147      1.31       uch 		MIPS_INT_MASK_0,		/* IPL_NET */
    148      1.31       uch 
    149      1.31       uch 	MIPS_SOFT_INT_MASK_0|
    150      1.31       uch 		MIPS_SOFT_INT_MASK_1|
    151      1.31       uch 		MIPS_INT_MASK_0,		/* IPL_{TTY,SERIAL} */
    152      1.31       uch 
    153      1.31       uch 	MIPS_SOFT_INT_MASK_0|
    154      1.31       uch 		MIPS_SOFT_INT_MASK_1|
    155      1.31       uch 		MIPS_INT_MASK_0|
    156      1.31       uch 		MIPS_INT_MASK_1,		/* IPL_{CLOCK,HIGH} */
    157      1.31       uch };
    158      1.31       uch 
    159      1.31       uch #if defined(VR41XX) && defined(TX39XX)
    160      1.31       uch #define	VR_INTR	vr_intr
    161      1.31       uch #else
    162      1.31       uch #define	VR_INTR	cpu_intr	/* locore_mips3 directly call this */
    163      1.31       uch #endif
    164      1.31       uch 
    165      1.31       uch void vr_init(void);
    166      1.31       uch void VR_INTR(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
    167      1.31       uch extern void vr_idle(void);
    168      1.31       uch STATIC void vr_cons_init(void);
    169      1.31       uch STATIC void vr_fb_init(caddr_t *);
    170      1.31       uch STATIC void vr_mem_init(paddr_t);
    171      1.31       uch STATIC void vr_find_dram(paddr_t, paddr_t);
    172      1.31       uch STATIC void vr_reboot(int, char *);
    173       1.1  takemura 
    174       1.1  takemura /*
    175       1.1  takemura  * CPU interrupt dispatch table (HwInt[0:3])
    176       1.1  takemura  */
    177      1.31       uch STATIC int vr_null_handler(void *, u_int32_t, u_int32_t);
    178      1.31       uch STATIC int (*vr_intr_handler[4])(void *, u_int32_t, u_int32_t) =
    179       1.1  takemura {
    180      1.31       uch 	vr_null_handler,
    181      1.31       uch 	vr_null_handler,
    182      1.31       uch 	vr_null_handler,
    183      1.31       uch 	vr_null_handler
    184       1.1  takemura };
    185      1.31       uch STATIC void *vr_intr_arg[4];
    186       1.1  takemura 
    187      1.35  takemura #if NCOM > 0
    188      1.35  takemura /*
    189      1.35  takemura  * machine dependent serial console info
    190      1.35  takemura  */
    191      1.35  takemura static struct vr_com_platdep {
    192      1.35  takemura 	platid_mask_t *platidmask;
    193      1.35  takemura 	int (*attach)(bus_space_tag_t, int, int, int, tcflag_t, int);
    194      1.35  takemura 	int addr;
    195      1.35  takemura 	int freq;
    196      1.35  takemura } platdep_com_table[] = {
    197      1.35  takemura #if NCOM_HPCIO > 0
    198      1.35  takemura 	{
    199      1.35  takemura 		&platid_mask_MACH_NEC_MCR_SIGMARION2,
    200      1.35  takemura 		com_hpcio_cndb_attach,	/* attach proc */
    201      1.35  takemura 		0x0b600000,		/* base address */
    202      1.35  takemura 		COM_FREQ,		/* frequency */
    203      1.35  takemura 	},
    204      1.35  takemura #endif
    205      1.35  takemura #if NCOM_VRIP > 0
    206      1.37  takemura #ifdef VR4102
    207      1.37  takemura 	{
    208      1.37  takemura 		&platid_mask_CPU_MIPS_VR_4102,
    209      1.37  takemura 		com_vrip_cndb_attach,	/* attach proc */
    210      1.37  takemura 		VR4102_SIU_ADDR,	/* base address */
    211      1.37  takemura 		VRCOM_FREQ,		/* frequency */
    212      1.37  takemura 	},
    213      1.37  takemura #endif /* VR4102 */
    214      1.37  takemura #ifdef VR4111
    215      1.37  takemura 	{
    216      1.37  takemura 		&platid_mask_CPU_MIPS_VR_4111,
    217      1.37  takemura 		com_vrip_cndb_attach,	/* attach proc */
    218      1.37  takemura 		VR4102_SIU_ADDR,	/* base address */
    219      1.37  takemura 		VRCOM_FREQ,		/* frequency */
    220      1.37  takemura 	},
    221      1.37  takemura #endif /* VR4111 */
    222      1.37  takemura #ifdef VR4121
    223      1.37  takemura 	{
    224      1.37  takemura 		&platid_mask_CPU_MIPS_VR_4121,
    225      1.37  takemura 		com_vrip_cndb_attach,	/* attach proc */
    226      1.37  takemura 		VR4102_SIU_ADDR,	/* base address */
    227      1.37  takemura 		VRCOM_FREQ,		/* frequency */
    228      1.37  takemura 	},
    229      1.37  takemura #endif /* VR4121 */
    230      1.37  takemura #ifdef VR4122
    231      1.37  takemura 	{
    232      1.37  takemura 		&platid_mask_CPU_MIPS_VR_4122,
    233      1.37  takemura 		com_vrip_cndb_attach,	/* attach proc */
    234      1.37  takemura 		VR4122_SIU_ADDR,	/* base address */
    235      1.37  takemura 		VRCOM_FREQ,		/* frequency */
    236      1.37  takemura 	},
    237      1.37  takemura #endif /* VR4122 */
    238      1.37  takemura #ifdef VR4131
    239      1.37  takemura 	{
    240      1.37  takemura 		&platid_mask_CPU_MIPS_VR_4122,
    241      1.37  takemura 		com_vrip_cndb_attach,	/* attach proc */
    242      1.37  takemura 		VR4122_SIU_ADDR,	/* base address */
    243      1.37  takemura 		VRCOM_FREQ,		/* frequency */
    244      1.37  takemura 	},
    245      1.37  takemura #endif /* VR4131 */
    246      1.37  takemura #ifdef SINGLE_VRIP_BASE
    247      1.35  takemura 	{
    248      1.35  takemura 		&platid_wild,
    249      1.35  takemura 		com_vrip_cndb_attach,	/* attach proc */
    250      1.35  takemura 		VRIP_SIU_ADDR,		/* base address */
    251      1.35  takemura 		VRCOM_FREQ,		/* frequency */
    252      1.35  takemura 	},
    253      1.37  takemura #endif /* SINGLE_VRIP_BASE */
    254      1.37  takemura #else /* NCOM_VRIP > 0 */
    255      1.35  takemura 	/* dummy */
    256      1.35  takemura 	{
    257      1.35  takemura 		&platid_wild,
    258      1.35  takemura 		NULL,			/* attach proc */
    259      1.35  takemura 		0,			/* base address */
    260      1.35  takemura 		0,			/* frequency */
    261      1.35  takemura 	},
    262      1.37  takemura #endif /* NCOM_VRIP > 0 */
    263      1.35  takemura };
    264      1.35  takemura #endif /* NCOM > 0 */
    265      1.35  takemura 
    266      1.39  takemura #if NVRKIU > 0
    267      1.39  takemura /*
    268      1.39  takemura  * machine dependent keyboard info
    269      1.39  takemura  */
    270      1.39  takemura static struct vr_kiu_platdep {
    271      1.39  takemura 	platid_mask_t *platidmask;
    272      1.39  takemura 	int addr;
    273      1.39  takemura } platdep_kiu_table[] = {
    274      1.39  takemura #ifdef VR4102
    275      1.39  takemura 	{
    276      1.39  takemura 		&platid_mask_CPU_MIPS_VR_4102,
    277      1.39  takemura 		VR4102_KIU_ADDR,	/* base address */
    278      1.39  takemura 	},
    279      1.39  takemura #endif /* VR4102 */
    280      1.39  takemura #ifdef VR4111
    281      1.39  takemura 	{
    282      1.39  takemura 		&platid_mask_CPU_MIPS_VR_4111,
    283      1.39  takemura 		VR4102_KIU_ADDR,	/* base address */
    284      1.39  takemura 	},
    285      1.39  takemura #endif /* VR4111 */
    286      1.39  takemura #ifdef VR4121
    287      1.39  takemura 	{
    288      1.39  takemura 		&platid_mask_CPU_MIPS_VR_4121,
    289      1.39  takemura 		VR4102_KIU_ADDR,	/* base address */
    290      1.39  takemura 	},
    291      1.39  takemura #endif /* VR4121 */
    292      1.39  takemura 	{
    293      1.39  takemura 		&platid_wild,
    294      1.39  takemura #ifdef SINGLE_VRIP_BASE
    295      1.39  takemura 		VRIP_KIU_ADDR,		/* base address */
    296      1.39  takemura #else
    297      1.39  takemura 		VRIP_NO_ADDR,		/* base address */
    298      1.39  takemura #endif /* SINGLE_VRIP_BASE */
    299      1.39  takemura 	},
    300      1.39  takemura };
    301      1.39  takemura #endif /* NVRKIU > 0 */
    302      1.39  takemura 
    303       1.1  takemura void
    304       1.1  takemura vr_init()
    305       1.1  takemura {
    306       1.1  takemura 	/*
    307       1.1  takemura 	 * Platform Specific Function Hooks
    308       1.1  takemura 	 */
    309      1.29       uch 	platform.cpu_idle	= vr_idle;
    310      1.31       uch 	platform.cpu_intr	= VR_INTR;
    311      1.29       uch 	platform.cons_init	= vr_cons_init;
    312      1.29       uch 	platform.fb_init	= vr_fb_init;
    313      1.29       uch 	platform.mem_init	= vr_mem_init;
    314      1.29       uch 	platform.reboot		= vr_reboot;
    315       1.1  takemura 
    316       1.9      sato #if NVRBCU > 0
    317      1.12      sato 	sprintf(cpu_name, "NEC %s rev%d.%d %d.%03dMHz",
    318       1.1  takemura 		vrbcu_vrip_getcpuname(),
    319       1.1  takemura 		vrbcu_vrip_getcpumajor(),
    320      1.10      shin 		vrbcu_vrip_getcpuminor(),
    321      1.10      shin 		vrbcu_vrip_getcpuclock() / 1000000,
    322      1.10      shin 		(vrbcu_vrip_getcpuclock() % 1000000) / 1000);
    323       1.9      sato #else
    324      1.12      sato 	sprintf(cpu_name, "NEC VR41xx");
    325       1.9      sato #endif
    326       1.4       uch }
    327       1.4       uch 
    328      1.13      shin void
    329      1.28       uch vr_mem_init(paddr_t kernend)
    330       1.4       uch {
    331      1.25     enami 
    332      1.13      shin 	mem_clusters[0].start = 0;
    333      1.13      shin 	mem_clusters[0].size = kernend;
    334      1.13      shin 	mem_cluster_cnt = 1;
    335      1.25     enami 
    336      1.13      shin 	vr_find_dram(kernend, 0x02000000);
    337      1.13      shin 	vr_find_dram(0x02000000, 0x04000000);
    338      1.13      shin 	vr_find_dram(0x04000000, 0x06000000);
    339      1.13      shin 	vr_find_dram(0x06000000, 0x08000000);
    340      1.13      shin }
    341      1.13      shin 
    342      1.13      shin void
    343      1.28       uch vr_find_dram(paddr_t addr, paddr_t end)
    344      1.13      shin {
    345      1.13      shin 	int n;
    346      1.13      shin 	caddr_t page;
    347      1.13      shin #ifdef NARLY_MEMORY_PROBE
    348      1.13      shin 	int x, i;
    349      1.13      shin #endif
    350      1.13      shin 
    351      1.25     enami #ifdef VR_FIND_DRAMLIM
    352      1.25     enami 	if (VR_FIND_DRAMLIM < end)
    353      1.25     enami 		end = VR_FIND_DRAMLIM;
    354      1.31       uch #endif /* VR_FIND_DRAMLIM */
    355      1.13      shin 	n = mem_cluster_cnt;
    356      1.41   thorpej 	for (; addr < end; addr += PAGE_SIZE) {
    357      1.13      shin 
    358      1.13      shin 		page = (void *)MIPS_PHYS_TO_KSEG1(addr);
    359      1.13      shin 		if (badaddr(page, 4))
    360      1.13      shin 			goto bad;
    361      1.14      shin 
    362      1.14      shin 		/* stop memory probing at first memory image */
    363      1.14      shin 		if (bcmp(page, (void *)MIPS_PHYS_TO_KSEG0(0), 128) == 0)
    364      1.14      shin 			return;
    365      1.13      shin 
    366      1.13      shin 		*(volatile int *)(page+0) = 0xa5a5a5a5;
    367      1.13      shin 		*(volatile int *)(page+4) = 0x5a5a5a5a;
    368      1.13      shin 		wbflush();
    369      1.13      shin 		if (*(volatile int *)(page+0) != 0xa5a5a5a5)
    370      1.13      shin 			goto bad;
    371      1.13      shin 
    372      1.13      shin 		*(volatile int *)(page+0) = 0x5a5a5a5a;
    373      1.13      shin 		*(volatile int *)(page+4) = 0xa5a5a5a5;
    374      1.13      shin 		wbflush();
    375      1.13      shin 		if (*(volatile int *)(page+0) != 0x5a5a5a5a)
    376      1.13      shin 			goto bad;
    377      1.13      shin 
    378      1.13      shin #ifdef NARLY_MEMORY_PROBE
    379      1.13      shin 		x = random();
    380      1.41   thorpej 		for (i = 0; i < PAGE_SIZE; i += 4)
    381      1.13      shin 			*(volatile int *)(page+i) = (x ^ i);
    382       1.4       uch 		wbflush();
    383      1.41   thorpej 		for (i = 0; i < PAGE_SIZE; i += 4)
    384      1.13      shin 			if (*(volatile int *)(page+i) != (x ^ i))
    385      1.13      shin 				goto bad;
    386      1.13      shin 
    387      1.13      shin 		x = random();
    388      1.41   thorpej 		for (i = 0; i < PAGE_SIZE; i += 4)
    389      1.13      shin 			*(volatile int *)(page+i) = (x ^ i);
    390      1.13      shin 		wbflush();
    391      1.41   thorpej 		for (i = 0; i < PAGE_SIZE; i += 4)
    392      1.13      shin 			if (*(volatile int *)(page+i) != (x ^ i))
    393      1.13      shin 				goto bad;
    394      1.31       uch #endif /* NARLY_MEMORY_PROBE */
    395      1.13      shin 
    396      1.13      shin 		if (!mem_clusters[n].size)
    397      1.13      shin 			mem_clusters[n].start = addr;
    398      1.41   thorpej 		mem_clusters[n].size += PAGE_SIZE;
    399      1.13      shin 		continue;
    400      1.13      shin 
    401      1.13      shin 	bad:
    402      1.13      shin 		if (mem_clusters[n].size)
    403      1.13      shin 			++n;
    404      1.13      shin 		continue;
    405       1.4       uch 	}
    406      1.13      shin 	if (mem_clusters[n].size)
    407      1.13      shin 		++n;
    408      1.13      shin 	mem_cluster_cnt = n;
    409       1.4       uch }
    410       1.4       uch 
    411       1.4       uch void
    412      1.28       uch vr_fb_init(caddr_t *kernend)
    413       1.4       uch {
    414       1.4       uch 	/* Nothing to do */
    415       1.1  takemura }
    416       1.1  takemura 
    417       1.1  takemura void
    418       1.1  takemura vr_cons_init()
    419       1.1  takemura {
    420      1.35  takemura #if NCOM > 0 || NHPCFB > 0 || NVRKIU > 0
    421      1.30       uch 	bus_space_tag_t iot = hpcmips_system_bus_space();
    422       1.1  takemura #endif
    423      1.35  takemura #if NCOM > 0
    424      1.35  takemura 	static struct vr_com_platdep *com_info;
    425      1.35  takemura #endif
    426      1.39  takemura #if NVRKIU > 0
    427      1.39  takemura 	static struct vr_kiu_platdep *kiu_info;
    428      1.39  takemura #endif
    429       1.1  takemura 
    430       1.1  takemura #if NCOM > 0
    431      1.35  takemura 	com_info = platid_search(&platid, platdep_com_table,
    432      1.35  takemura 	    sizeof(platdep_com_table)/sizeof(*platdep_com_table),
    433      1.35  takemura 	    sizeof(*platdep_com_table));
    434      1.18     jeffs #ifdef KGDB
    435      1.35  takemura 	if (com_info->attach != NULL) {
    436      1.35  takemura 		/* if KGDB is defined, always use the serial port for KGDB */
    437      1.35  takemura 		if ((*com_info->attach)(iot, com_info->addr, 9600,
    438      1.35  takemura 		    com_info->freq,
    439      1.35  takemura 		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8, 1)) {
    440      1.35  takemura 			printf("%s(%d): can't init kgdb's serial port",
    441      1.23     enami 			    __FILE__, __LINE__);
    442       1.1  takemura 		}
    443      1.33  takemura #else /* KGDB */
    444      1.35  takemura 	if (com_info->attach != NULL && (bootinfo->bi_cnuse&BI_CNUSE_SERIAL)) {
    445      1.33  takemura 		/* Serial console */
    446      1.35  takemura 		if ((*com_info->attach)(iot, com_info->addr, CONSPEED,
    447      1.35  takemura 		    com_info->freq,
    448      1.35  takemura 		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8, 0)) {
    449      1.33  takemura 			printf("%s(%d): can't init serial console",
    450      1.33  takemura 			    __FILE__, __LINE__);
    451      1.33  takemura 		} else {
    452      1.33  takemura 			return;
    453      1.33  takemura 		}
    454      1.33  takemura 	}
    455      1.33  takemura #endif /* KGDB */
    456      1.35  takemura #endif /* NCOM > 0 */
    457       1.1  takemura 
    458      1.15  takemura #if NHPCFB > 0
    459      1.17       uch 	if (hpcfb_cnattach(NULL)) {
    460       1.3  takemura 		printf("%s(%d): can't init fb console", __FILE__, __LINE__);
    461       1.3  takemura 	} else {
    462       1.3  takemura 		goto find_keyboard;
    463       1.3  takemura 	}
    464      1.25     enami  find_keyboard:
    465      1.30       uch #endif /* NHPCFB > 0 */
    466       1.3  takemura 
    467      1.39  takemura #if NVRKIU > 0
    468      1.39  takemura 	kiu_info = platid_search(&platid, platdep_kiu_table,
    469      1.39  takemura 	    sizeof(platdep_kiu_table)/sizeof(*platdep_kiu_table),
    470      1.39  takemura 	    sizeof(*platdep_kiu_table));
    471      1.39  takemura 	if (kiu_info->addr != VRIP_NO_ADDR) {
    472      1.39  takemura 		if (vrkiu_cnattach(iot, kiu_info->addr)) {
    473      1.39  takemura 			printf("%s(%d): can't init vrkiu as console",
    474      1.39  takemura 			    __FILE__, __LINE__);
    475      1.39  takemura 		} else {
    476      1.39  takemura 			return;
    477      1.39  takemura 		}
    478       1.3  takemura 	}
    479      1.39  takemura #endif /* NVRKIU > 0 */
    480       1.5  takemura }
    481       1.5  takemura 
    482      1.40      shin extern char vr_hibernate[];
    483      1.40      shin extern char evr_hibernate[];
    484      1.40      shin 
    485       1.5  takemura void
    486      1.28       uch vr_reboot(int howto, char *bootstr)
    487       1.5  takemura {
    488       1.7  takemura 	/*
    489       1.7  takemura 	 * power down
    490       1.7  takemura 	 */
    491       1.7  takemura 	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
    492       1.7  takemura 		printf("fake powerdown\n");
    493      1.40      shin 		/*
    494      1.40      shin 		 * copy vr_hibernate() to top of physical memory.
    495      1.40      shin 		 */
    496      1.40      shin 		memcpy((void *)MIPS_KSEG0_START, vr_hibernate,
    497      1.40      shin 		   evr_hibernate - (char *)vr_hibernate);
    498      1.40      shin 		/* sync I&D cache */
    499      1.40      shin 		mips_dcache_wbinv_all();
    500      1.40      shin 		mips_icache_sync_all();
    501      1.40      shin 		/*
    502      1.40      shin 		 * call vr_hibernate() at MIPS_KSEG0_START.
    503      1.40      shin 		 */
    504      1.40      shin 		((void (*)(void *,int))MIPS_KSEG0_START)(
    505      1.40      shin 		    (void *)MIPS_KSEG0_START, ptoa(physmem));
    506       1.7  takemura 		/* not reach */
    507       1.7  takemura 		vr_reboot(howto&~RB_HALT, bootstr);
    508       1.7  takemura 	}
    509       1.7  takemura 	/*
    510       1.8  takemura 	 * halt
    511       1.7  takemura 	 */
    512       1.8  takemura 	if (howto & RB_HALT) {
    513      1.38  takemura #if NVRIP_COMMON > 0
    514       1.8  takemura 		_spllower(~MIPS_INT_MASK_0);
    515       1.8  takemura 		vrip_intr_suspend();
    516       1.5  takemura #else
    517       1.8  takemura 		splhigh();
    518       1.5  takemura #endif
    519       1.7  takemura 		__asm(".set noreorder");
    520  1.41.2.1     skrll 		__asm(".word	" ___STRING(VR_OPCODE_SUSPEND));
    521       1.6      sato 		__asm("nop");
    522       1.6      sato 		__asm("nop");
    523       1.6      sato 		__asm("nop");
    524       1.6      sato 		__asm("nop");
    525       1.6      sato 		__asm("nop");
    526       1.7  takemura 		__asm(".set reorder");
    527      1.38  takemura #if NVRIP_COMMON > 0
    528       1.8  takemura 		vrip_intr_resume();
    529       1.8  takemura #endif
    530       1.6      sato 	}
    531       1.8  takemura 	/*
    532       1.8  takemura 	 * reset
    533       1.8  takemura 	 */
    534       1.8  takemura #if NVRDSU
    535       1.8  takemura 	vrdsu_reset();
    536       1.8  takemura #else
    537       1.8  takemura 	printf("%s(%d): There is no DSU.", __FILE__, __LINE__);
    538       1.8  takemura #endif
    539       1.1  takemura }
    540       1.1  takemura 
    541      1.30       uch /*
    542      1.30       uch  * Handle interrupts.
    543      1.30       uch  */
    544      1.31       uch void
    545      1.31       uch VR_INTR(u_int32_t status, u_int32_t cause, u_int32_t pc, u_int32_t ipending)
    546      1.30       uch {
    547      1.31       uch 	uvmexp.intrs++;
    548      1.31       uch 
    549  1.41.2.4     skrll 	/* Deal with unneded compare interrupts occasionally so that we can
    550  1.41.2.4     skrll 	 * keep spllowersoftclock. */
    551      1.31       uch 	if (ipending & MIPS_INT_MASK_5) {
    552  1.41.2.4     skrll 		mips3_cp0_compare_write(0);
    553      1.31       uch 	}
    554      1.31       uch 
    555      1.31       uch 	if (ipending & MIPS_INT_MASK_1) {
    556  1.41.2.4     skrll 		_splset(MIPS_SR_INT_IE); /* for spllowersoftclock */
    557  1.41.2.4     skrll 		/* Remove the lower priority pending bits from status so that
    558  1.41.2.4     skrll 		 * spllowersoftclock will not happen if other interrupts are
    559  1.41.2.4     skrll 		 * pending. */
    560  1.41.2.4     skrll 		(*vr_intr_handler[1])(vr_intr_arg[1], pc, status & ~(ipending
    561  1.41.2.4     skrll 		& (MIPS_INT_MASK_0|MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)));
    562      1.31       uch 	}
    563      1.31       uch 
    564      1.31       uch 	if (ipending & MIPS_INT_MASK_0) {
    565  1.41.2.4     skrll 		_splset(MIPS_INT_MASK_1|MIPS_SR_INT_IE);
    566      1.31       uch 		(*vr_intr_handler[0])(vr_intr_arg[0], pc, status);
    567  1.41.2.4     skrll 	}
    568      1.31       uch 
    569  1.41.2.4     skrll 	if (ipending & MIPS_SOFT_INT_MASK_1) {
    570  1.41.2.4     skrll 		_splset(MIPS_INT_MASK_1|MIPS_INT_MASK_0|MIPS_SR_INT_IE);
    571  1.41.2.4     skrll 		softintr(MIPS_SOFT_INT_MASK_1);
    572      1.31       uch 	}
    573      1.31       uch 
    574  1.41.2.4     skrll 	if (ipending & MIPS_SOFT_INT_MASK_0) {
    575  1.41.2.4     skrll 		_splset(MIPS_SOFT_INT_MASK_1|MIPS_INT_MASK_1|MIPS_INT_MASK_0|
    576  1.41.2.4     skrll 		    MIPS_SR_INT_IE);
    577  1.41.2.4     skrll 		softintr(MIPS_SOFT_INT_MASK_0);
    578  1.41.2.4     skrll 	}
    579      1.30       uch }
    580      1.30       uch 
    581       1.1  takemura void *
    582      1.30       uch vr_intr_establish(int line, int (*ih_fun)(void *, u_int32_t, u_int32_t),
    583      1.28       uch     void *ih_arg)
    584       1.1  takemura {
    585      1.28       uch 
    586      1.31       uch 	KDASSERT(vr_intr_handler[line] == vr_null_handler);
    587      1.31       uch 
    588      1.31       uch 	vr_intr_handler[line] = ih_fun;
    589      1.31       uch 	vr_intr_arg[line] = ih_arg;
    590       1.1  takemura 
    591      1.31       uch 	return ((void *)line);
    592       1.1  takemura }
    593       1.1  takemura 
    594       1.1  takemura void
    595      1.28       uch vr_intr_disestablish(void *ih)
    596       1.1  takemura {
    597       1.1  takemura 	int line = (int)ih;
    598      1.28       uch 
    599      1.31       uch 	vr_intr_handler[line] = vr_null_handler;
    600      1.31       uch 	vr_intr_arg[line] = NULL;
    601       1.1  takemura }
    602       1.1  takemura 
    603       1.1  takemura int
    604      1.31       uch vr_null_handler(void *arg, u_int32_t pc, u_int32_t status)
    605       1.1  takemura {
    606      1.31       uch 
    607      1.31       uch 	printf("vr_null_handler\n");
    608      1.28       uch 
    609      1.28       uch 	return (0);
    610       1.1  takemura }
    611      1.22      sato 
    612      1.22      sato /*
    613      1.22      sato int x4181 = VR4181;
    614      1.22      sato int x4101 = VR4101;
    615      1.22      sato int x4102 = VR4102;
    616      1.22      sato int x4111 = VR4111;
    617      1.22      sato int x4121 = VR4121;
    618      1.22      sato int x4122 = VR4122;
    619      1.22      sato int xo4181 = ONLY_VR4181;
    620      1.22      sato int xo4101 = ONLY_VR4101;
    621      1.22      sato int xo4102 = ONLY_VR4102;
    622      1.22      sato int xo4111_4121 = ONLY_VR4111_4121;
    623      1.22      sato int g4101=VRGROUP_4101;
    624      1.22      sato int g4102=VRGROUP_4102;
    625      1.22      sato int g4181=VRGROUP_4181;
    626      1.22      sato int g4102_4121=VRGROUP_4102_4121;
    627      1.22      sato int g4111_4121=VRGROUP_4111_4121;
    628      1.22      sato int g4102_4122=VRGROUP_4102_4122;
    629      1.22      sato int g4111_4122=VRGROUP_4111_4122;
    630      1.22      sato int single_vrip_base=SINGLE_VRIP_BASE;
    631      1.22      sato int vrip_base_addr=VRIP_BASE_ADDR;
    632      1.22      sato */
    633