Home | History | Annotate | Line # | Download | only in vr
vr.c revision 1.26
      1  1.26     enami /*	$NetBSD: vr.c,v 1.26 2001/06/11 06:11:01 enami Exp $	*/
      2   1.1  takemura 
      3   1.1  takemura /*-
      4   1.1  takemura  * Copyright (c) 1999
      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.24     lukem #include "opt_kgdb.h"
     37  1.24     lukem 
     38   1.1  takemura #include <sys/param.h>
     39   1.1  takemura #include <sys/types.h>
     40   1.1  takemura #include <sys/systm.h>
     41   1.1  takemura #include <sys/device.h>
     42   1.5  takemura #include <sys/reboot.h>
     43  1.13      shin #include <sys/kcore.h>
     44   1.1  takemura 
     45   1.1  takemura #include <machine/cpu.h>
     46   1.1  takemura #include <machine/intr.h>
     47   1.1  takemura #include <machine/reg.h>
     48   1.1  takemura #include <machine/psl.h>
     49   1.1  takemura #include <machine/locore.h>
     50   1.1  takemura #include <machine/sysconf.h>
     51   1.1  takemura #include <machine/bus.h>
     52   1.1  takemura #include <machine/autoconf.h>
     53   1.1  takemura 
     54   1.1  takemura #include <mips/mips_param.h>		/* hokey spl()s */
     55   1.1  takemura #include <mips/mips/mips_mcclock.h>	/* mcclock CPUspeed estimation */
     56   1.1  takemura 
     57  1.26     enami #include <dev/hpc/hpckbdvar.h>
     58  1.26     enami 
     59  1.22      sato #include "opt_vr41xx.h"
     60   1.1  takemura #include <hpcmips/vr/vr.h>
     61  1.11  takemura #include <hpcmips/vr/vr_asm.h>
     62  1.22      sato #include <hpcmips/vr/vrcpudef.h>
     63   1.3  takemura #include <hpcmips/vr/vripreg.h>
     64   1.1  takemura #include <hpcmips/vr/rtcreg.h>
     65  1.12      sato #include <hpcmips/hpcmips/machdep.h>	/* cpu_name */
     66   1.1  takemura #include <machine/bootinfo.h>
     67   1.1  takemura 
     68   1.8  takemura #include "vrip.h"
     69   1.8  takemura #if NVRIP > 0
     70   1.8  takemura #include <hpcmips/vr/vripvar.h>
     71   1.8  takemura #endif
     72   1.8  takemura 
     73   1.9      sato #include "vrbcu.h"
     74   1.9      sato #if NVRBCU > 0
     75   1.9      sato #include <hpcmips/vr/bcuvar.h>
     76   1.9      sato #endif
     77   1.9      sato 
     78   1.5  takemura #include "vrdsu.h"
     79   1.5  takemura #if NVRDSU > 0
     80   1.5  takemura #include <hpcmips/vr/vrdsuvar.h>
     81   1.5  takemura #endif
     82   1.5  takemura 
     83   1.1  takemura #include "com.h"
     84   1.1  takemura #if NCOM > 0
     85   1.1  takemura #include <sys/termios.h>
     86   1.1  takemura #include <sys/ttydefaults.h>
     87   1.1  takemura #include <dev/ic/comreg.h>
     88   1.1  takemura #include <dev/ic/comvar.h>
     89   1.1  takemura #include <hpcmips/vr/siureg.h>
     90   1.1  takemura #include <hpcmips/vr/com_vripvar.h>
     91   1.1  takemura #ifndef CONSPEED
     92   1.1  takemura #define CONSPEED TTYDEF_SPEED
     93   1.1  takemura #endif
     94   1.1  takemura #endif
     95   1.1  takemura 
     96  1.15  takemura #include "hpcfb.h"
     97   1.3  takemura #include "vrkiu.h"
     98  1.25     enami #if (NVRKIU > 0) || (NHPCFB > 0)
     99   1.3  takemura #include <dev/wscons/wsdisplayvar.h>
    100  1.15  takemura #include <dev/rasops/rasops.h>
    101   1.3  takemura #endif
    102   1.3  takemura 
    103  1.15  takemura #if NHPCFB > 0
    104  1.20       uch #include <dev/hpc/hpcfbvar.h>
    105   1.3  takemura #endif
    106   1.3  takemura 
    107  1.15  takemura #if NVRKIU > 0
    108  1.26     enami #include <arch/hpcmips/vr/vrkiureg.h>
    109   1.3  takemura #include <arch/hpcmips/vr/vrkiuvar.h>
    110   1.3  takemura #endif
    111   1.3  takemura 
    112   1.1  takemura void	vr_init __P((void));
    113   1.1  takemura void	vr_os_init __P((void));
    114   1.1  takemura void	vr_bus_reset __P((void));
    115  1.16       uch int	vr_intr __P((u_int32_t, u_int32_t, u_int32_t, u_int32_t));
    116   1.1  takemura void	vr_cons_init __P((void));
    117   1.1  takemura void	vr_device_register __P((struct device *, void *));
    118   1.4       uch void    vr_fb_init __P((caddr_t*));
    119  1.13      shin void    vr_mem_init __P((paddr_t));
    120  1.13      shin void	vr_find_dram __P((paddr_t, paddr_t));
    121   1.5  takemura void	vr_reboot __P((int howto, char *bootstr));
    122   1.1  takemura 
    123   1.1  takemura extern unsigned nullclkread __P((void));
    124   1.1  takemura extern unsigned (*clkread) __P((void));
    125   1.1  takemura 
    126   1.1  takemura /*
    127   1.1  takemura  * CPU interrupt dispatch table (HwInt[0:3])
    128   1.1  takemura  */
    129   1.1  takemura int null_handler __P((void*, u_int32_t, u_int32_t));
    130   1.1  takemura static int (*intr_handler[4]) __P((void*, u_int32_t, u_int32_t)) =
    131   1.1  takemura {
    132   1.1  takemura 	null_handler,
    133   1.1  takemura 	null_handler,
    134   1.1  takemura 	null_handler,
    135   1.1  takemura 	null_handler
    136   1.1  takemura };
    137   1.1  takemura static void *intr_arg[4];
    138   1.1  takemura 
    139  1.13      shin extern phys_ram_seg_t mem_clusters[];
    140  1.13      shin extern int mem_cluster_cnt;
    141  1.13      shin 
    142   1.1  takemura void
    143   1.1  takemura vr_init()
    144   1.1  takemura {
    145   1.1  takemura 	/*
    146   1.1  takemura 	 * Platform Information.
    147   1.1  takemura 	 */
    148   1.1  takemura 
    149   1.1  takemura 	/*
    150   1.1  takemura 	 * Platform Specific Function Hooks
    151   1.1  takemura 	 */
    152   1.1  takemura 	platform.os_init = vr_os_init;
    153  1.16       uch 	platform.iointr = vr_intr;
    154   1.1  takemura 	platform.bus_reset = vr_bus_reset;
    155   1.1  takemura 	platform.cons_init = vr_cons_init;
    156   1.1  takemura 	platform.device_register = vr_device_register;
    157   1.4       uch 	platform.fb_init = vr_fb_init;
    158   1.4       uch 	platform.mem_init = vr_mem_init;
    159   1.5  takemura 	platform.reboot = vr_reboot;
    160   1.1  takemura 
    161   1.9      sato #if NVRBCU > 0
    162  1.12      sato 	sprintf(cpu_name, "NEC %s rev%d.%d %d.%03dMHz",
    163   1.1  takemura 		vrbcu_vrip_getcpuname(),
    164   1.1  takemura 		vrbcu_vrip_getcpumajor(),
    165  1.10      shin 		vrbcu_vrip_getcpuminor(),
    166  1.10      shin 		vrbcu_vrip_getcpuclock() / 1000000,
    167  1.10      shin 		(vrbcu_vrip_getcpuclock() % 1000000) / 1000);
    168   1.9      sato #else
    169  1.12      sato 	sprintf(cpu_name, "NEC VR41xx");
    170   1.9      sato #endif
    171   1.4       uch }
    172   1.4       uch 
    173  1.13      shin void
    174   1.4       uch vr_mem_init(kernend)
    175  1.13      shin 	paddr_t kernend;
    176   1.4       uch {
    177  1.25     enami 
    178  1.13      shin 	mem_clusters[0].start = 0;
    179  1.13      shin 	mem_clusters[0].size = kernend;
    180  1.13      shin 	mem_cluster_cnt = 1;
    181  1.25     enami 
    182  1.13      shin 	vr_find_dram(kernend, 0x02000000);
    183  1.13      shin 	vr_find_dram(0x02000000, 0x04000000);
    184  1.13      shin 	vr_find_dram(0x04000000, 0x06000000);
    185  1.13      shin 	vr_find_dram(0x06000000, 0x08000000);
    186  1.13      shin 
    187  1.13      shin 	/* Clear currently unused D-RAM area (For reboot Windows CE clearly)*/
    188  1.13      shin 	memset((void *)(KERNBASE + 0x400), 0, KERNTEXTOFF - (KERNBASE + 0x800));
    189  1.13      shin }
    190  1.13      shin 
    191  1.13      shin void
    192  1.13      shin vr_find_dram(addr, end)
    193  1.13      shin 	paddr_t addr, end;
    194  1.13      shin {
    195  1.13      shin 	int n;
    196  1.13      shin 	caddr_t page;
    197  1.13      shin #ifdef NARLY_MEMORY_PROBE
    198  1.13      shin 	int x, i;
    199  1.13      shin #endif
    200  1.13      shin 
    201  1.25     enami #ifdef VR_FIND_DRAMLIM
    202  1.25     enami 	if (VR_FIND_DRAMLIM < end)
    203  1.25     enami 		end = VR_FIND_DRAMLIM;
    204  1.25     enami #endif
    205  1.13      shin 	n = mem_cluster_cnt;
    206  1.13      shin 	for (; addr < end; addr += NBPG) {
    207  1.13      shin 
    208  1.13      shin 		page = (void *)MIPS_PHYS_TO_KSEG1(addr);
    209  1.13      shin 		if (badaddr(page, 4))
    210  1.13      shin 			goto bad;
    211  1.14      shin 
    212  1.14      shin 		/* stop memory probing at first memory image */
    213  1.14      shin 		if (bcmp(page, (void *)MIPS_PHYS_TO_KSEG0(0), 128) == 0)
    214  1.14      shin 			return;
    215  1.13      shin 
    216  1.13      shin 		*(volatile int *)(page+0) = 0xa5a5a5a5;
    217  1.13      shin 		*(volatile int *)(page+4) = 0x5a5a5a5a;
    218  1.13      shin 		wbflush();
    219  1.13      shin 		if (*(volatile int *)(page+0) != 0xa5a5a5a5)
    220  1.13      shin 			goto bad;
    221  1.13      shin 
    222  1.13      shin 		*(volatile int *)(page+0) = 0x5a5a5a5a;
    223  1.13      shin 		*(volatile int *)(page+4) = 0xa5a5a5a5;
    224  1.13      shin 		wbflush();
    225  1.13      shin 		if (*(volatile int *)(page+0) != 0x5a5a5a5a)
    226  1.13      shin 			goto bad;
    227  1.13      shin 
    228  1.13      shin #ifdef NARLY_MEMORY_PROBE
    229  1.13      shin 		x = random();
    230  1.13      shin 		for (i = 0; i < NBPG; i += 4)
    231  1.13      shin 			*(volatile int *)(page+i) = (x ^ i);
    232   1.4       uch 		wbflush();
    233  1.13      shin 		for (i = 0; i < NBPG; i += 4)
    234  1.13      shin 			if (*(volatile int *)(page+i) != (x ^ i))
    235  1.13      shin 				goto bad;
    236  1.13      shin 
    237  1.13      shin 		x = random();
    238  1.13      shin 		for (i = 0; i < NBPG; i += 4)
    239  1.13      shin 			*(volatile int *)(page+i) = (x ^ i);
    240  1.13      shin 		wbflush();
    241  1.13      shin 		for (i = 0; i < NBPG; i += 4)
    242  1.13      shin 			if (*(volatile int *)(page+i) != (x ^ i))
    243  1.13      shin 				goto bad;
    244  1.13      shin #endif
    245  1.13      shin 
    246  1.13      shin 		if (!mem_clusters[n].size)
    247  1.13      shin 			mem_clusters[n].start = addr;
    248  1.13      shin 		mem_clusters[n].size += NBPG;
    249  1.13      shin 		continue;
    250  1.13      shin 
    251  1.13      shin 	bad:
    252  1.13      shin 		if (mem_clusters[n].size)
    253  1.13      shin 			++n;
    254  1.13      shin 		continue;
    255   1.4       uch 	}
    256  1.13      shin 	if (mem_clusters[n].size)
    257  1.13      shin 		++n;
    258  1.13      shin 	mem_cluster_cnt = n;
    259   1.4       uch }
    260   1.4       uch 
    261   1.4       uch void
    262   1.4       uch vr_fb_init(kernend)
    263   1.4       uch 	caddr_t *kernend;
    264   1.4       uch {
    265   1.4       uch 	/* Nothing to do */
    266   1.1  takemura }
    267   1.1  takemura 
    268   1.1  takemura void
    269   1.1  takemura vr_os_init()
    270   1.1  takemura {
    271   1.1  takemura 	/*
    272   1.1  takemura 	 * Set up interrupt handling and I/O addresses.
    273   1.1  takemura 	 */
    274   1.1  takemura 
    275   1.1  takemura 	splvec.splbio = MIPS_SPL0;
    276   1.1  takemura 	splvec.splnet = MIPS_SPL0;
    277   1.1  takemura 	splvec.spltty = MIPS_SPL0;
    278  1.21   thorpej 	splvec.splvm = MIPS_SPL0;
    279   1.1  takemura 	splvec.splclock = MIPS_SPL_0_1;
    280   1.1  takemura 	splvec.splstatclock = MIPS_SPL_0_1;
    281   1.1  takemura 
    282   1.1  takemura 	/* no high resolution timer circuit; possibly never called */
    283   1.1  takemura 	clkread = nullclkread;
    284   1.1  takemura 
    285   1.1  takemura #ifdef NOT_YET
    286   1.1  takemura 	mcclock_addr = (volatile struct chiptime *)
    287   1.1  takemura 		MIPS_PHYS_TO_KSEG1(Vr_SYS_CLOCK);
    288   1.1  takemura 	mc_cpuspeed(mcclock_addr, MIPS_INT_MASK_1);
    289   1.1  takemura #else
    290   1.1  takemura 	printf("%s(%d): cpuspeed estimation is notimplemented\n",
    291   1.1  takemura 	       __FILE__, __LINE__);
    292   1.1  takemura #endif
    293   1.1  takemura #ifdef HPCMIPS_L1CACHE_DISABLE
    294   1.1  takemura 	cpuspeed = 1;	/* XXX, CPU is very very slow because L1 cache is */
    295   1.1  takemura 	/* disabled. */
    296   1.1  takemura #endif /*  HPCMIPS_L1CAHCE_DISABLE */
    297   1.1  takemura }
    298   1.1  takemura 
    299   1.1  takemura 
    300   1.1  takemura /*
    301   1.1  takemura  * Initalize the memory system and I/O buses.
    302   1.1  takemura  */
    303   1.1  takemura void
    304   1.1  takemura vr_bus_reset()
    305   1.1  takemura {
    306   1.1  takemura 	printf("%s(%d): vr_bus_reset() not implemented.\n",
    307   1.1  takemura 	       __FILE__, __LINE__);
    308   1.1  takemura }
    309   1.1  takemura 
    310   1.1  takemura void
    311   1.1  takemura vr_cons_init()
    312   1.1  takemura {
    313  1.15  takemura #if NCOM > 0 || NHPCFB > 0 || NVRKIU > 0
    314   1.1  takemura 	extern bus_space_tag_t system_bus_iot;
    315   1.1  takemura 	extern bus_space_tag_t mb_bus_space_init __P((void));
    316  1.19  takemura 
    317  1.19  takemura 	/*
    318  1.19  takemura 	 * At this time, system_bus_iot is not initialized yet.
    319  1.19  takemura 	 * Just initialize it here.
    320  1.19  takemura 	 */
    321  1.19  takemura 	mb_bus_space_init();
    322   1.1  takemura #endif
    323   1.1  takemura 
    324   1.1  takemura #if NCOM > 0
    325  1.18     jeffs #ifdef KGDB
    326  1.18     jeffs 	/* if KGDB is defined, always use the serial port for KGDB */
    327  1.23     enami 	if (com_vrip_cndb_attach(system_bus_iot, VRIP_SIU_ADDR, 9600,
    328  1.23     enami 	    VRCOM_FREQ, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8, 1)) {
    329  1.18     jeffs 		printf("%s(%d): can't init kgdb's serial port",
    330  1.23     enami 		    __FILE__, __LINE__);
    331  1.18     jeffs 	}
    332  1.18     jeffs #else
    333   1.1  takemura 	if (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) {
    334   1.1  takemura 		/* Serial console */
    335  1.23     enami 		if (com_vrip_cndb_attach(system_bus_iot,
    336  1.23     enami 		    VRIP_SIU_ADDR, CONSPEED, VRCOM_FREQ,
    337  1.23     enami 		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8, 0)) {
    338  1.23     enami 			printf("%s(%d): can't init serial console",
    339  1.23     enami 			    __FILE__, __LINE__);
    340   1.1  takemura 		} else {
    341   1.1  takemura 			return;
    342   1.1  takemura 		}
    343   1.1  takemura 	}
    344  1.18     jeffs #endif
    345   1.1  takemura #endif
    346   1.1  takemura 
    347  1.15  takemura #if NHPCFB > 0
    348  1.17       uch 	if (hpcfb_cnattach(NULL)) {
    349   1.3  takemura 		printf("%s(%d): can't init fb console", __FILE__, __LINE__);
    350   1.3  takemura 	} else {
    351   1.3  takemura 		goto find_keyboard;
    352   1.3  takemura 	}
    353  1.25     enami  find_keyboard:
    354   1.3  takemura #endif
    355   1.3  takemura 
    356  1.22      sato #if NVRKIU > 0 && VRIP_KIU_ADDR != VRIP_NO_ADDR
    357   1.3  takemura 	if (vrkiu_cnattach(system_bus_iot, VRIP_KIU_ADDR)) {
    358   1.3  takemura 		printf("%s(%d): can't init vrkiu as console",
    359   1.3  takemura 		       __FILE__, __LINE__);
    360   1.3  takemura 	} else {
    361   1.3  takemura 		return;
    362   1.3  takemura 	}
    363   1.3  takemura #endif
    364   1.1  takemura }
    365   1.1  takemura 
    366   1.1  takemura void
    367   1.1  takemura vr_device_register(dev, aux)
    368   1.1  takemura 	struct device *dev;
    369   1.1  takemura 	void *aux;
    370   1.1  takemura {
    371   1.2      shin 	printf("%s(%d): vr_device_register() not implemented.\n",
    372   1.1  takemura 	       __FILE__, __LINE__);
    373   1.1  takemura 	panic("abort");
    374   1.5  takemura }
    375   1.5  takemura 
    376   1.5  takemura void
    377   1.5  takemura vr_reboot(howto, bootstr)
    378   1.5  takemura 	int howto;
    379   1.5  takemura 	char *bootstr;
    380   1.5  takemura {
    381   1.7  takemura 	/*
    382   1.7  takemura 	 * power down
    383   1.7  takemura 	 */
    384   1.7  takemura 	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
    385   1.7  takemura 		printf("fake powerdown\n");
    386   1.7  takemura 		__asm(__CONCAT(".word	",___STRING(VR_OPCODE_HIBERNATE)));
    387   1.7  takemura 		__asm("nop");
    388   1.7  takemura 		__asm("nop");
    389   1.7  takemura 		__asm("nop");
    390   1.7  takemura 		__asm("nop");
    391   1.7  takemura 		__asm("nop");
    392   1.7  takemura 		__asm(".set reorder");
    393   1.7  takemura 		/* not reach */
    394   1.7  takemura 		vr_reboot(howto&~RB_HALT, bootstr);
    395   1.7  takemura 	}
    396   1.7  takemura 	/*
    397   1.8  takemura 	 * halt
    398   1.7  takemura 	 */
    399   1.8  takemura 	if (howto & RB_HALT) {
    400   1.8  takemura #if NVRIP > 0
    401   1.8  takemura 		_spllower(~MIPS_INT_MASK_0);
    402   1.8  takemura 		vrip_intr_suspend();
    403   1.5  takemura #else
    404   1.8  takemura 		splhigh();
    405   1.5  takemura #endif
    406   1.7  takemura 		__asm(".set noreorder");
    407   1.7  takemura 		__asm(__CONCAT(".word	",___STRING(VR_OPCODE_SUSPEND)));
    408   1.6      sato 		__asm("nop");
    409   1.6      sato 		__asm("nop");
    410   1.6      sato 		__asm("nop");
    411   1.6      sato 		__asm("nop");
    412   1.6      sato 		__asm("nop");
    413   1.7  takemura 		__asm(".set reorder");
    414   1.8  takemura #if NVRIP > 0
    415   1.8  takemura 		vrip_intr_resume();
    416   1.8  takemura #endif
    417   1.6      sato 	}
    418   1.8  takemura 	/*
    419   1.8  takemura 	 * reset
    420   1.8  takemura 	 */
    421   1.8  takemura #if NVRDSU
    422   1.8  takemura 	vrdsu_reset();
    423   1.8  takemura #else
    424   1.8  takemura 	printf("%s(%d): There is no DSU.", __FILE__, __LINE__);
    425   1.8  takemura #endif
    426   1.1  takemura }
    427   1.1  takemura 
    428   1.1  takemura void *
    429   1.1  takemura vr_intr_establish(line, ih_fun, ih_arg)
    430   1.1  takemura 	int line;
    431   1.1  takemura 	int (*ih_fun) __P((void*, u_int32_t, u_int32_t));
    432   1.1  takemura 	void *ih_arg;
    433   1.1  takemura {
    434   1.1  takemura 	if (intr_handler[line] != null_handler) {
    435   1.1  takemura 		panic("vr_intr_establish: can't establish duplicated intr handler.");
    436   1.1  takemura 	}
    437   1.1  takemura 	intr_handler[line] = ih_fun;
    438   1.1  takemura 	intr_arg[line] = ih_arg;
    439   1.1  takemura 
    440   1.1  takemura 	return (void*)line;
    441   1.1  takemura }
    442   1.1  takemura 
    443   1.1  takemura 
    444   1.1  takemura void
    445   1.1  takemura vr_intr_disestablish(ih)
    446   1.1  takemura 	void *ih;
    447   1.1  takemura {
    448   1.1  takemura 	int line = (int)ih;
    449   1.1  takemura 	intr_handler[line] = null_handler;
    450   1.1  takemura 	intr_arg[line] = NULL;
    451   1.1  takemura }
    452   1.1  takemura 
    453   1.1  takemura int
    454   1.1  takemura null_handler(arg, pc, statusReg)
    455   1.1  takemura 	void *arg;
    456   1.1  takemura 	u_int32_t pc;
    457   1.1  takemura 	u_int32_t statusReg;
    458   1.1  takemura {
    459   1.1  takemura 	printf("null_handler\n");
    460   1.1  takemura 	return 0;
    461   1.1  takemura }
    462   1.1  takemura 
    463   1.1  takemura /*
    464   1.1  takemura  * Handle interrupts.
    465   1.1  takemura  */
    466   1.1  takemura int
    467  1.16       uch vr_intr(status, cause, pc, ipending)
    468  1.16       uch 	u_int32_t status, cause, pc, ipending;
    469   1.1  takemura {
    470   1.1  takemura 	int hwintr;
    471   1.1  takemura 
    472  1.16       uch 	hwintr = (ffs(ipending >> 10) -1) & 0x3;
    473   1.1  takemura 	(*intr_handler[hwintr])(intr_arg[hwintr], pc, status);
    474  1.16       uch 
    475   1.1  takemura 	return (MIPS_SR_INT_IE | (status & ~cause & MIPS_HARD_INT_MASK));
    476   1.1  takemura }
    477  1.22      sato 
    478  1.22      sato 
    479  1.22      sato /*
    480  1.22      sato int x4181 = VR4181;
    481  1.22      sato int x4101 = VR4101;
    482  1.22      sato int x4102 = VR4102;
    483  1.22      sato int x4111 = VR4111;
    484  1.22      sato int x4121 = VR4121;
    485  1.22      sato int x4122 = VR4122;
    486  1.22      sato int xo4181 = ONLY_VR4181;
    487  1.22      sato int xo4101 = ONLY_VR4101;
    488  1.22      sato int xo4102 = ONLY_VR4102;
    489  1.22      sato int xo4111_4121 = ONLY_VR4111_4121;
    490  1.22      sato int g4101=VRGROUP_4101;
    491  1.22      sato int g4102=VRGROUP_4102;
    492  1.22      sato int g4181=VRGROUP_4181;
    493  1.22      sato int g4102_4121=VRGROUP_4102_4121;
    494  1.22      sato int g4111_4121=VRGROUP_4111_4121;
    495  1.22      sato int g4102_4122=VRGROUP_4102_4122;
    496  1.22      sato int g4111_4122=VRGROUP_4111_4122;
    497  1.22      sato int single_vrip_base=SINGLE_VRIP_BASE;
    498  1.22      sato int vrip_base_addr=VRIP_BASE_ADDR;
    499  1.22      sato */
    500