xref: /netbsd-src/sys/arch/vax/vax/ka630.c (revision 081736733661053bbfceabb885b5bba50b76ce85)
1 /*	$NetBSD: ka630.c,v 1.30 2010/12/14 23:44:49 matt Exp $	*/
2 /*-
3  * Copyright (c) 1982, 1988, 1990, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the University nor the names of its contributors
15  *    may be used to endorse or promote products derived from this software
16  *    without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *	@(#)ka630.c	7.8 (Berkeley) 5/9/91
31  */
32 
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: ka630.c,v 1.30 2010/12/14 23:44:49 matt Exp $");
35 
36 #include "opt_cputype.h"
37 
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/cpu.h>
41 #include <sys/device.h>
42 #include <sys/kernel.h>
43 #include <sys/time.h>
44 
45 #include <machine/ka630.h>
46 #include <machine/clock.h>
47 #include <machine/vsbus.h>
48 
49 static struct uvaxIIcpu *uvaxIIcpu_ptr;
50 
51 static void ka630_conf(void);
52 static void ka630_memerr(void);
53 static int ka630_mchk(void *);
54 static void ka630_halt(void);
55 static void ka630_reboot(int);
56 static void ka630_clrf(void);
57 
58 static const char * const ka630_devs[] = { "cpu", "uba", NULL };
59 
60 const struct cpu_dep ka630_calls = {
61 	.cpu_mchk	= ka630_mchk,
62 	.cpu_memerr	= ka630_memerr,
63 	.cpu_conf	= ka630_conf,
64 	.cpu_gettime	= chip_gettime,
65 	.cpu_settime	= chip_settime,
66 	.cpu_vups	= 1,      /* ~VUPS */
67 	.cpu_scbsz	= 2,	/* SCB pages */
68 	.cpu_halt	= ka630_halt,
69 	.cpu_reboot	= ka630_reboot,
70 	.cpu_clrf	= ka630_clrf,
71 	.cpu_devs	= ka630_devs
72 };
73 
74 /*
75  * uvaxII_conf() is called by cpu_startup to do the cpu_specific setup.
76  */
77 void
ka630_conf(void)78 ka630_conf(void)
79 {
80 	curcpu()->ci_cpustr = "KA630, UV2";
81 
82 	clk_adrshift = 0;	/* Addressed at short's... */
83 	clk_tweak = 0;		/* ...and no shifting */
84 	clk_page = (short *)vax_map_physmem((paddr_t)KA630CLK, 1);
85 
86 	uvaxIIcpu_ptr = (void *)vax_map_physmem(VS_REGS, 1);
87 
88 	/*
89 	 * Enable memory parity error detection and clear error bits.
90 	 */
91 	uvaxIIcpu_ptr->uvaxII_mser = (UVAXIIMSER_PEN | UVAXIIMSER_MERR |
92 	    UVAXIIMSER_LEB);
93 }
94 
95 /* log crd errors */
96 void
ka630_memerr(void)97 ka630_memerr(void)
98 {
99 	printf("memory err!\n");
100 }
101 
102 #define NMC78032 10
103 const char * const mc78032[] = {
104 	0,		"immcr (fsd)",	"immcr (ssd)",	"fpu err 0",
105 	"fpu err 7",	"mmu st(tb)",	"mmu st(m=0)",	"pte in p0",
106 	"pte in p1",	"un intr id",
107 };
108 
109 struct mc78032frame {
110 	int	mc63_bcnt;		/* byte count == 0xc */
111 	int	mc63_summary;		/* summary parameter */
112 	int	mc63_mrvaddr;		/* most recent vad */
113 	int	mc63_istate;		/* internal state */
114 	int	mc63_pc;		/* trapped pc */
115 	int	mc63_psl;		/* trapped psl */
116 };
117 
118 int
ka630_mchk(void * cmcf)119 ka630_mchk(void *cmcf)
120 {
121 	struct mc78032frame * const mcf = (struct mc78032frame *)cmcf;
122 	u_int type = mcf->mc63_summary;
123 
124 	printf("machine check %x", type);
125 	if (type < NMC78032 && mc78032[type])
126 		printf(": %s", mc78032[type]);
127 	printf("\n\tvap %x istate %x pc %x psl %x\n",
128 	    mcf->mc63_mrvaddr, mcf->mc63_istate,
129 	    mcf->mc63_pc, mcf->mc63_psl);
130 	if (uvaxIIcpu_ptr && uvaxIIcpu_ptr->uvaxII_mser & UVAXIIMSER_MERR) {
131 		printf("\tmser=0x%lx ", uvaxIIcpu_ptr->uvaxII_mser);
132 		if (uvaxIIcpu_ptr->uvaxII_mser & UVAXIIMSER_CPUE)
133 			printf("page=%ld", uvaxIIcpu_ptr->uvaxII_cear);
134 		if (uvaxIIcpu_ptr->uvaxII_mser & UVAXIIMSER_DQPE)
135 			printf("page=%ld", uvaxIIcpu_ptr->uvaxII_dear);
136 		printf("\n");
137 	}
138 	return (-1);
139 }
140 
141 void
ka630_halt(void)142 ka630_halt(void)
143 {
144 	((volatile struct ka630clock *)clk_page)->cpmbx = KA630CLK_DOTHIS|KA630CLK_HALT;
145 	__asm("halt");
146 }
147 
148 void
ka630_reboot(int arg)149 ka630_reboot(int arg)
150 {
151 	((volatile struct ka630clock *)clk_page)->cpmbx =
152 	    KA630CLK_DOTHIS | KA630CLK_REBOOT;
153 }
154 
155 /*
156  * Clear restart and boot in progress flags in the CPMBX.
157  */
158 void
ka630_clrf(void)159 ka630_clrf(void)
160 {
161 	short i = ((volatile struct ka630clock *)clk_page)->cpmbx;
162 
163 	((volatile struct ka630clock *)clk_page)->cpmbx = i & KA630CLK_LANG;
164 }
165