Home | History | Annotate | Line # | Download | only in vr
vr.c revision 1.35
      1  1.35  takemura /*	$NetBSD: vr.c,v 1.35 2002/01/04 14:11:52 takemura 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.29       uch #include "opt_vr41xx.h"
     38  1.31       uch #include "opt_tx39xx.h"
     39  1.24     lukem #include "opt_kgdb.h"
     40  1.24     lukem 
     41   1.1  takemura #include <sys/param.h>
     42   1.1  takemura #include <sys/systm.h>
     43   1.5  takemura #include <sys/reboot.h>
     44   1.1  takemura 
     45  1.31       uch #include <uvm/uvm_extern.h>
     46  1.31       uch 
     47   1.1  takemura #include <machine/sysconf.h>
     48  1.32  takemura #include <machine/bootinfo.h>
     49   1.1  takemura #include <machine/bus.h>
     50  1.32  takemura #include <machine/bus_space_hpcmips.h>
     51  1.35  takemura #include <machine/platid.h>
     52  1.35  takemura #include <machine/platid_mask.h>
     53   1.1  takemura 
     54  1.26     enami #include <dev/hpc/hpckbdvar.h>
     55  1.26     enami 
     56  1.30       uch #include <hpcmips/hpcmips/machdep.h>	/* cpu_name, mem_cluster */
     57  1.30       uch 
     58   1.1  takemura #include <hpcmips/vr/vr.h>
     59  1.11  takemura #include <hpcmips/vr/vr_asm.h>
     60  1.22      sato #include <hpcmips/vr/vrcpudef.h>
     61   1.3  takemura #include <hpcmips/vr/vripreg.h>
     62   1.1  takemura #include <hpcmips/vr/rtcreg.h>
     63   1.1  takemura 
     64   1.8  takemura #include "vrip.h"
     65   1.8  takemura #if NVRIP > 0
     66   1.8  takemura #include <hpcmips/vr/vripvar.h>
     67   1.8  takemura #endif
     68   1.8  takemura 
     69   1.9      sato #include "vrbcu.h"
     70   1.9      sato #if NVRBCU > 0
     71   1.9      sato #include <hpcmips/vr/bcuvar.h>
     72   1.9      sato #endif
     73   1.9      sato 
     74   1.5  takemura #include "vrdsu.h"
     75   1.5  takemura #if NVRDSU > 0
     76   1.5  takemura #include <hpcmips/vr/vrdsuvar.h>
     77   1.5  takemura #endif
     78   1.5  takemura 
     79   1.1  takemura #include "com.h"
     80  1.35  takemura #include "com_vrip.h"
     81  1.35  takemura #include "com_hpcio.h"
     82  1.35  takemura #if NCOM > 0
     83   1.1  takemura #include <sys/termios.h>
     84   1.1  takemura #include <sys/ttydefaults.h>
     85   1.1  takemura #include <dev/ic/comreg.h>
     86   1.1  takemura #include <dev/ic/comvar.h>
     87  1.35  takemura #if NCOM_VRIP > 0
     88   1.1  takemura #include <hpcmips/vr/siureg.h>
     89   1.1  takemura #include <hpcmips/vr/com_vripvar.h>
     90  1.33  takemura #endif
     91  1.35  takemura #if NCOM_HPCIO > 0
     92  1.35  takemura #include <hpcmips/dev/com_hpciovar.h>
     93  1.33  takemura #endif
     94   1.1  takemura #ifndef CONSPEED
     95   1.1  takemura #define CONSPEED TTYDEF_SPEED
     96   1.1  takemura #endif
     97   1.1  takemura #endif
     98   1.1  takemura 
     99  1.15  takemura #include "hpcfb.h"
    100   1.3  takemura #include "vrkiu.h"
    101  1.25     enami #if (NVRKIU > 0) || (NHPCFB > 0)
    102   1.3  takemura #include <dev/wscons/wsdisplayvar.h>
    103  1.15  takemura #include <dev/rasops/rasops.h>
    104   1.3  takemura #endif
    105   1.3  takemura 
    106  1.15  takemura #if NHPCFB > 0
    107  1.20       uch #include <dev/hpc/hpcfbvar.h>
    108   1.3  takemura #endif
    109   1.3  takemura 
    110  1.15  takemura #if NVRKIU > 0
    111  1.26     enami #include <arch/hpcmips/vr/vrkiureg.h>
    112   1.3  takemura #include <arch/hpcmips/vr/vrkiuvar.h>
    113   1.3  takemura #endif
    114   1.3  takemura 
    115  1.31       uch #ifdef DEBUG
    116  1.31       uch #define STATIC
    117  1.31       uch #else
    118  1.31       uch #define STATIC	static
    119  1.31       uch #endif
    120  1.31       uch 
    121  1.31       uch /*
    122  1.31       uch  * This is a mask of bits to clear in the SR when we go to a
    123  1.31       uch  * given interrupt priority level.
    124  1.31       uch  */
    125  1.31       uch const u_int32_t __ipl_sr_bits_vr[_IPL_N] = {
    126  1.31       uch 	0,					/* IPL_NONE */
    127  1.31       uch 
    128  1.31       uch 	MIPS_SOFT_INT_MASK_0,			/* IPL_SOFT */
    129  1.31       uch 
    130  1.31       uch 	MIPS_SOFT_INT_MASK_0,			/* IPL_SOFTCLOCK */
    131  1.31       uch 
    132  1.31       uch 	MIPS_SOFT_INT_MASK_0|
    133  1.31       uch 		MIPS_SOFT_INT_MASK_1,		/* IPL_SOFTNET */
    134  1.31       uch 
    135  1.31       uch 	MIPS_SOFT_INT_MASK_0|
    136  1.31       uch 		MIPS_SOFT_INT_MASK_1,		/* IPL_SOFTSERIAL */
    137  1.31       uch 
    138  1.31       uch 	MIPS_SOFT_INT_MASK_0|
    139  1.31       uch 		MIPS_SOFT_INT_MASK_1|
    140  1.31       uch 		MIPS_INT_MASK_0,		/* IPL_BIO */
    141  1.31       uch 
    142  1.31       uch 	MIPS_SOFT_INT_MASK_0|
    143  1.31       uch 		MIPS_SOFT_INT_MASK_1|
    144  1.31       uch 		MIPS_INT_MASK_0,		/* IPL_NET */
    145  1.31       uch 
    146  1.31       uch 	MIPS_SOFT_INT_MASK_0|
    147  1.31       uch 		MIPS_SOFT_INT_MASK_1|
    148  1.31       uch 		MIPS_INT_MASK_0,		/* IPL_{TTY,SERIAL} */
    149  1.31       uch 
    150  1.31       uch 	MIPS_SOFT_INT_MASK_0|
    151  1.31       uch 		MIPS_SOFT_INT_MASK_1|
    152  1.31       uch 		MIPS_INT_MASK_0|
    153  1.31       uch 		MIPS_INT_MASK_1,		/* IPL_{CLOCK,HIGH} */
    154  1.31       uch };
    155  1.31       uch 
    156  1.31       uch #if defined(VR41XX) && defined(TX39XX)
    157  1.31       uch #define	VR_INTR	vr_intr
    158  1.31       uch #else
    159  1.31       uch #define	VR_INTR	cpu_intr	/* locore_mips3 directly call this */
    160  1.31       uch #endif
    161  1.31       uch 
    162  1.31       uch void vr_init(void);
    163  1.31       uch void VR_INTR(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
    164  1.31       uch extern void vr_idle(void);
    165  1.31       uch STATIC void vr_cons_init(void);
    166  1.31       uch STATIC void vr_fb_init(caddr_t *);
    167  1.31       uch STATIC void vr_mem_init(paddr_t);
    168  1.31       uch STATIC void vr_find_dram(paddr_t, paddr_t);
    169  1.31       uch STATIC void vr_reboot(int, char *);
    170   1.1  takemura 
    171   1.1  takemura /*
    172   1.1  takemura  * CPU interrupt dispatch table (HwInt[0:3])
    173   1.1  takemura  */
    174  1.31       uch STATIC int vr_null_handler(void *, u_int32_t, u_int32_t);
    175  1.31       uch STATIC int (*vr_intr_handler[4])(void *, u_int32_t, u_int32_t) =
    176   1.1  takemura {
    177  1.31       uch 	vr_null_handler,
    178  1.31       uch 	vr_null_handler,
    179  1.31       uch 	vr_null_handler,
    180  1.31       uch 	vr_null_handler
    181   1.1  takemura };
    182  1.31       uch STATIC void *vr_intr_arg[4];
    183   1.1  takemura 
    184  1.35  takemura #if NCOM > 0
    185  1.35  takemura /*
    186  1.35  takemura  * machine dependent serial console info
    187  1.35  takemura  */
    188  1.35  takemura static struct vr_com_platdep {
    189  1.35  takemura 	platid_mask_t *platidmask;
    190  1.35  takemura 	int (*attach)(bus_space_tag_t, int, int, int, tcflag_t, int);
    191  1.35  takemura 	int addr;
    192  1.35  takemura 	int freq;
    193  1.35  takemura } platdep_com_table[] = {
    194  1.35  takemura #if NCOM_HPCIO > 0
    195  1.35  takemura 	{
    196  1.35  takemura 		&platid_mask_MACH_NEC_MCR_SIGMARION2,
    197  1.35  takemura 		com_hpcio_cndb_attach,	/* attach proc */
    198  1.35  takemura 		0x0b600000,		/* base address */
    199  1.35  takemura 		COM_FREQ,		/* frequency */
    200  1.35  takemura 	},
    201  1.35  takemura #endif
    202  1.35  takemura #if NCOM_VRIP > 0
    203  1.35  takemura 	{
    204  1.35  takemura 		&platid_wild,
    205  1.35  takemura 		com_vrip_cndb_attach,	/* attach proc */
    206  1.35  takemura 		VRIP_SIU_ADDR,		/* base address */
    207  1.35  takemura 		VRCOM_FREQ,		/* frequency */
    208  1.35  takemura 	},
    209  1.35  takemura #else
    210  1.35  takemura 	/* dummy */
    211  1.35  takemura 	{
    212  1.35  takemura 		&platid_wild,
    213  1.35  takemura 		NULL,			/* attach proc */
    214  1.35  takemura 		0,			/* base address */
    215  1.35  takemura 		0,			/* frequency */
    216  1.35  takemura 	},
    217  1.35  takemura #endif
    218  1.35  takemura };
    219  1.35  takemura #endif /* NCOM > 0 */
    220  1.35  takemura 
    221   1.1  takemura void
    222   1.1  takemura vr_init()
    223   1.1  takemura {
    224   1.1  takemura 	/*
    225   1.1  takemura 	 * Platform Specific Function Hooks
    226   1.1  takemura 	 */
    227  1.29       uch 	platform.cpu_idle	= vr_idle;
    228  1.31       uch 	platform.cpu_intr	= VR_INTR;
    229  1.29       uch 	platform.cons_init	= vr_cons_init;
    230  1.29       uch 	platform.fb_init	= vr_fb_init;
    231  1.29       uch 	platform.mem_init	= vr_mem_init;
    232  1.29       uch 	platform.reboot		= vr_reboot;
    233   1.1  takemura 
    234   1.9      sato #if NVRBCU > 0
    235  1.12      sato 	sprintf(cpu_name, "NEC %s rev%d.%d %d.%03dMHz",
    236   1.1  takemura 		vrbcu_vrip_getcpuname(),
    237   1.1  takemura 		vrbcu_vrip_getcpumajor(),
    238  1.10      shin 		vrbcu_vrip_getcpuminor(),
    239  1.10      shin 		vrbcu_vrip_getcpuclock() / 1000000,
    240  1.10      shin 		(vrbcu_vrip_getcpuclock() % 1000000) / 1000);
    241   1.9      sato #else
    242  1.12      sato 	sprintf(cpu_name, "NEC VR41xx");
    243   1.9      sato #endif
    244   1.4       uch }
    245   1.4       uch 
    246  1.13      shin void
    247  1.28       uch vr_mem_init(paddr_t kernend)
    248   1.4       uch {
    249  1.25     enami 
    250  1.13      shin 	mem_clusters[0].start = 0;
    251  1.13      shin 	mem_clusters[0].size = kernend;
    252  1.13      shin 	mem_cluster_cnt = 1;
    253  1.25     enami 
    254  1.13      shin 	vr_find_dram(kernend, 0x02000000);
    255  1.13      shin 	vr_find_dram(0x02000000, 0x04000000);
    256  1.13      shin 	vr_find_dram(0x04000000, 0x06000000);
    257  1.13      shin 	vr_find_dram(0x06000000, 0x08000000);
    258  1.13      shin }
    259  1.13      shin 
    260  1.13      shin void
    261  1.28       uch vr_find_dram(paddr_t addr, paddr_t end)
    262  1.13      shin {
    263  1.13      shin 	int n;
    264  1.13      shin 	caddr_t page;
    265  1.13      shin #ifdef NARLY_MEMORY_PROBE
    266  1.13      shin 	int x, i;
    267  1.13      shin #endif
    268  1.13      shin 
    269  1.25     enami #ifdef VR_FIND_DRAMLIM
    270  1.25     enami 	if (VR_FIND_DRAMLIM < end)
    271  1.25     enami 		end = VR_FIND_DRAMLIM;
    272  1.31       uch #endif /* VR_FIND_DRAMLIM */
    273  1.13      shin 	n = mem_cluster_cnt;
    274  1.13      shin 	for (; addr < end; addr += NBPG) {
    275  1.13      shin 
    276  1.13      shin 		page = (void *)MIPS_PHYS_TO_KSEG1(addr);
    277  1.13      shin 		if (badaddr(page, 4))
    278  1.13      shin 			goto bad;
    279  1.14      shin 
    280  1.14      shin 		/* stop memory probing at first memory image */
    281  1.14      shin 		if (bcmp(page, (void *)MIPS_PHYS_TO_KSEG0(0), 128) == 0)
    282  1.14      shin 			return;
    283  1.13      shin 
    284  1.13      shin 		*(volatile int *)(page+0) = 0xa5a5a5a5;
    285  1.13      shin 		*(volatile int *)(page+4) = 0x5a5a5a5a;
    286  1.13      shin 		wbflush();
    287  1.13      shin 		if (*(volatile int *)(page+0) != 0xa5a5a5a5)
    288  1.13      shin 			goto bad;
    289  1.13      shin 
    290  1.13      shin 		*(volatile int *)(page+0) = 0x5a5a5a5a;
    291  1.13      shin 		*(volatile int *)(page+4) = 0xa5a5a5a5;
    292  1.13      shin 		wbflush();
    293  1.13      shin 		if (*(volatile int *)(page+0) != 0x5a5a5a5a)
    294  1.13      shin 			goto bad;
    295  1.13      shin 
    296  1.13      shin #ifdef NARLY_MEMORY_PROBE
    297  1.13      shin 		x = random();
    298  1.13      shin 		for (i = 0; i < NBPG; i += 4)
    299  1.13      shin 			*(volatile int *)(page+i) = (x ^ i);
    300   1.4       uch 		wbflush();
    301  1.13      shin 		for (i = 0; i < NBPG; i += 4)
    302  1.13      shin 			if (*(volatile int *)(page+i) != (x ^ i))
    303  1.13      shin 				goto bad;
    304  1.13      shin 
    305  1.13      shin 		x = random();
    306  1.13      shin 		for (i = 0; i < NBPG; i += 4)
    307  1.13      shin 			*(volatile int *)(page+i) = (x ^ i);
    308  1.13      shin 		wbflush();
    309  1.13      shin 		for (i = 0; i < NBPG; i += 4)
    310  1.13      shin 			if (*(volatile int *)(page+i) != (x ^ i))
    311  1.13      shin 				goto bad;
    312  1.31       uch #endif /* NARLY_MEMORY_PROBE */
    313  1.13      shin 
    314  1.13      shin 		if (!mem_clusters[n].size)
    315  1.13      shin 			mem_clusters[n].start = addr;
    316  1.13      shin 		mem_clusters[n].size += NBPG;
    317  1.13      shin 		continue;
    318  1.13      shin 
    319  1.13      shin 	bad:
    320  1.13      shin 		if (mem_clusters[n].size)
    321  1.13      shin 			++n;
    322  1.13      shin 		continue;
    323   1.4       uch 	}
    324  1.13      shin 	if (mem_clusters[n].size)
    325  1.13      shin 		++n;
    326  1.13      shin 	mem_cluster_cnt = n;
    327   1.4       uch }
    328   1.4       uch 
    329   1.4       uch void
    330  1.28       uch vr_fb_init(caddr_t *kernend)
    331   1.4       uch {
    332   1.4       uch 	/* Nothing to do */
    333   1.1  takemura }
    334   1.1  takemura 
    335   1.1  takemura void
    336   1.1  takemura vr_cons_init()
    337   1.1  takemura {
    338  1.35  takemura #if NCOM > 0 || NHPCFB > 0 || NVRKIU > 0
    339  1.30       uch 	bus_space_tag_t iot = hpcmips_system_bus_space();
    340   1.1  takemura #endif
    341  1.35  takemura #if NCOM > 0
    342  1.35  takemura 	static struct vr_com_platdep *com_info;
    343  1.35  takemura #endif
    344   1.1  takemura 
    345   1.1  takemura #if NCOM > 0
    346  1.35  takemura 	com_info = platid_search(&platid, platdep_com_table,
    347  1.35  takemura 	    sizeof(platdep_com_table)/sizeof(*platdep_com_table),
    348  1.35  takemura 	    sizeof(*platdep_com_table));
    349  1.18     jeffs #ifdef KGDB
    350  1.35  takemura 	if (com_info->attach != NULL) {
    351  1.35  takemura 		/* if KGDB is defined, always use the serial port for KGDB */
    352  1.35  takemura 		if ((*com_info->attach)(iot, com_info->addr, 9600,
    353  1.35  takemura 		    com_info->freq,
    354  1.35  takemura 		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8, 1)) {
    355  1.35  takemura 			printf("%s(%d): can't init kgdb's serial port",
    356  1.23     enami 			    __FILE__, __LINE__);
    357   1.1  takemura 		}
    358  1.33  takemura #else /* KGDB */
    359  1.35  takemura 	if (com_info->attach != NULL && (bootinfo->bi_cnuse&BI_CNUSE_SERIAL)) {
    360  1.33  takemura 		/* Serial console */
    361  1.35  takemura 		if ((*com_info->attach)(iot, com_info->addr, CONSPEED,
    362  1.35  takemura 		    com_info->freq,
    363  1.35  takemura 		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8, 0)) {
    364  1.33  takemura 			printf("%s(%d): can't init serial console",
    365  1.33  takemura 			    __FILE__, __LINE__);
    366  1.33  takemura 		} else {
    367  1.33  takemura 			return;
    368  1.33  takemura 		}
    369  1.33  takemura 	}
    370  1.33  takemura #endif /* KGDB */
    371  1.35  takemura #endif /* NCOM > 0 */
    372   1.1  takemura 
    373  1.15  takemura #if NHPCFB > 0
    374  1.17       uch 	if (hpcfb_cnattach(NULL)) {
    375   1.3  takemura 		printf("%s(%d): can't init fb console", __FILE__, __LINE__);
    376   1.3  takemura 	} else {
    377   1.3  takemura 		goto find_keyboard;
    378   1.3  takemura 	}
    379  1.25     enami  find_keyboard:
    380  1.30       uch #endif /* NHPCFB > 0 */
    381   1.3  takemura 
    382  1.22      sato #if NVRKIU > 0 && VRIP_KIU_ADDR != VRIP_NO_ADDR
    383  1.30       uch 	if (vrkiu_cnattach(iot, VRIP_KIU_ADDR)) {
    384   1.3  takemura 		printf("%s(%d): can't init vrkiu as console",
    385   1.3  takemura 		       __FILE__, __LINE__);
    386   1.3  takemura 	} else {
    387   1.3  takemura 		return;
    388   1.3  takemura 	}
    389  1.30       uch #endif /* NVRKIU > 0 && VRIP_KIU_ADDR != VRIP_NO_ADDR */
    390   1.5  takemura }
    391   1.5  takemura 
    392   1.5  takemura void
    393  1.28       uch vr_reboot(int howto, char *bootstr)
    394   1.5  takemura {
    395   1.7  takemura 	/*
    396   1.7  takemura 	 * power down
    397   1.7  takemura 	 */
    398   1.7  takemura 	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
    399   1.7  takemura 		printf("fake powerdown\n");
    400   1.7  takemura 		__asm(__CONCAT(".word	",___STRING(VR_OPCODE_HIBERNATE)));
    401   1.7  takemura 		__asm("nop");
    402   1.7  takemura 		__asm("nop");
    403   1.7  takemura 		__asm("nop");
    404   1.7  takemura 		__asm("nop");
    405   1.7  takemura 		__asm("nop");
    406   1.7  takemura 		__asm(".set reorder");
    407   1.7  takemura 		/* not reach */
    408   1.7  takemura 		vr_reboot(howto&~RB_HALT, bootstr);
    409   1.7  takemura 	}
    410   1.7  takemura 	/*
    411   1.8  takemura 	 * halt
    412   1.7  takemura 	 */
    413   1.8  takemura 	if (howto & RB_HALT) {
    414   1.8  takemura #if NVRIP > 0
    415   1.8  takemura 		_spllower(~MIPS_INT_MASK_0);
    416   1.8  takemura 		vrip_intr_suspend();
    417   1.5  takemura #else
    418   1.8  takemura 		splhigh();
    419   1.5  takemura #endif
    420   1.7  takemura 		__asm(".set noreorder");
    421   1.7  takemura 		__asm(__CONCAT(".word	",___STRING(VR_OPCODE_SUSPEND)));
    422   1.6      sato 		__asm("nop");
    423   1.6      sato 		__asm("nop");
    424   1.6      sato 		__asm("nop");
    425   1.6      sato 		__asm("nop");
    426   1.6      sato 		__asm("nop");
    427   1.7  takemura 		__asm(".set reorder");
    428   1.8  takemura #if NVRIP > 0
    429   1.8  takemura 		vrip_intr_resume();
    430   1.8  takemura #endif
    431   1.6      sato 	}
    432   1.8  takemura 	/*
    433   1.8  takemura 	 * reset
    434   1.8  takemura 	 */
    435   1.8  takemura #if NVRDSU
    436   1.8  takemura 	vrdsu_reset();
    437   1.8  takemura #else
    438   1.8  takemura 	printf("%s(%d): There is no DSU.", __FILE__, __LINE__);
    439   1.8  takemura #endif
    440   1.1  takemura }
    441   1.1  takemura 
    442  1.30       uch /*
    443  1.30       uch  * Handle interrupts.
    444  1.30       uch  */
    445  1.31       uch void
    446  1.31       uch VR_INTR(u_int32_t status, u_int32_t cause, u_int32_t pc, u_int32_t ipending)
    447  1.30       uch {
    448  1.31       uch 	uvmexp.intrs++;
    449  1.31       uch 
    450  1.31       uch 	if (ipending & MIPS_INT_MASK_5) {
    451  1.31       uch 		/*
    452  1.31       uch 		 * spl* uses MIPS_INT_MASK not MIPS3_INT_MASK. it causes
    453  1.31       uch 		 * INT5 interrupt.
    454  1.31       uch 		 */
    455  1.31       uch 		mips3_cp0_compare_write(mips3_cp0_count_read());
    456  1.31       uch 	}
    457  1.31       uch 
    458  1.31       uch 	/* for spllowersoftclock */
    459  1.31       uch 	_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
    460  1.31       uch 
    461  1.31       uch 	if (ipending & MIPS_INT_MASK_1) {
    462  1.31       uch 		(*vr_intr_handler[1])(vr_intr_arg[1], pc, status);
    463  1.30       uch 
    464  1.31       uch 		cause &= ~MIPS_INT_MASK_1;
    465  1.31       uch 		_splset(((status & ~cause) & MIPS_HARD_INT_MASK)
    466  1.31       uch 		    | MIPS_SR_INT_IE);
    467  1.31       uch 	}
    468  1.31       uch 
    469  1.31       uch 	if (ipending & MIPS_INT_MASK_0) {
    470  1.31       uch 		(*vr_intr_handler[0])(vr_intr_arg[0], pc, status);
    471  1.31       uch 
    472  1.31       uch 		cause &= ~MIPS_INT_MASK_0;
    473  1.31       uch 	}
    474  1.31       uch 	_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
    475  1.31       uch 
    476  1.31       uch 	softintr(ipending);
    477  1.30       uch }
    478  1.30       uch 
    479   1.1  takemura void *
    480  1.30       uch vr_intr_establish(int line, int (*ih_fun)(void *, u_int32_t, u_int32_t),
    481  1.28       uch     void *ih_arg)
    482   1.1  takemura {
    483  1.28       uch 
    484  1.31       uch 	KDASSERT(vr_intr_handler[line] == vr_null_handler);
    485  1.31       uch 
    486  1.31       uch 	vr_intr_handler[line] = ih_fun;
    487  1.31       uch 	vr_intr_arg[line] = ih_arg;
    488   1.1  takemura 
    489  1.31       uch 	return ((void *)line);
    490   1.1  takemura }
    491   1.1  takemura 
    492   1.1  takemura void
    493  1.28       uch vr_intr_disestablish(void *ih)
    494   1.1  takemura {
    495   1.1  takemura 	int line = (int)ih;
    496  1.28       uch 
    497  1.31       uch 	vr_intr_handler[line] = vr_null_handler;
    498  1.31       uch 	vr_intr_arg[line] = NULL;
    499   1.1  takemura }
    500   1.1  takemura 
    501   1.1  takemura int
    502  1.31       uch vr_null_handler(void *arg, u_int32_t pc, u_int32_t status)
    503   1.1  takemura {
    504  1.31       uch 
    505  1.31       uch 	printf("vr_null_handler\n");
    506  1.28       uch 
    507  1.28       uch 	return (0);
    508   1.1  takemura }
    509  1.22      sato 
    510  1.22      sato /*
    511  1.22      sato int x4181 = VR4181;
    512  1.22      sato int x4101 = VR4101;
    513  1.22      sato int x4102 = VR4102;
    514  1.22      sato int x4111 = VR4111;
    515  1.22      sato int x4121 = VR4121;
    516  1.22      sato int x4122 = VR4122;
    517  1.22      sato int xo4181 = ONLY_VR4181;
    518  1.22      sato int xo4101 = ONLY_VR4101;
    519  1.22      sato int xo4102 = ONLY_VR4102;
    520  1.22      sato int xo4111_4121 = ONLY_VR4111_4121;
    521  1.22      sato int g4101=VRGROUP_4101;
    522  1.22      sato int g4102=VRGROUP_4102;
    523  1.22      sato int g4181=VRGROUP_4181;
    524  1.22      sato int g4102_4121=VRGROUP_4102_4121;
    525  1.22      sato int g4111_4121=VRGROUP_4111_4121;
    526  1.22      sato int g4102_4122=VRGROUP_4102_4122;
    527  1.22      sato int g4111_4122=VRGROUP_4111_4122;
    528  1.22      sato int single_vrip_base=SINGLE_VRIP_BASE;
    529  1.22      sato int vrip_base_addr=VRIP_BASE_ADDR;
    530  1.22      sato */
    531