1 /* $NetBSD: ka730.c,v 1.6 2017/05/22 16:46:15 ragge Exp $ */
2 /*
3 * Copyright (c) 1982, 1986, 1988 The Regents of the University of California.
4 * 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 * @(#)ka730.c 7.4 (Berkeley) 5/9/91
31 * @(#)autoconf.c 7.20 (Berkeley) 5/9/91
32 */
33
34 /*
35 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
36 * All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * @(#)ka730.c 7.4 (Berkeley) 5/9/91
60 * @(#)autoconf.c 7.20 (Berkeley) 5/9/91
61 */
62
63 #include <sys/cdefs.h>
64 __KERNEL_RCSID(0, "$NetBSD: ka730.c,v 1.6 2017/05/22 16:46:15 ragge Exp $");
65
66 #include <sys/param.h>
67 #include <sys/systm.h>
68 #include <sys/bus.h>
69 #include <sys/cpu.h>
70 #include <sys/device.h>
71
72 #include <machine/ka730.h>
73 #include <machine/clock.h>
74 #include <machine/sid.h>
75
76 #include <vax/vax/gencons.h>
77
78 #include "locators.h"
79
80 void ctuattach(void);
81 static void ka730_clrf(void);
82 static void ka730_conf(void);
83 static void ka730_memerr(void);
84 static int ka730_mchk(void *t);
85 static void ka730_attach_cpu(device_t);
86
87 static const char * const ka730_devs[] = { "cpu", "ubi", NULL };
88
89 struct cpu_dep ka730_calls = {
90 .cpu_mchk = ka730_mchk,
91 .cpu_memerr = ka730_memerr,
92 .cpu_conf = ka730_conf,
93 .cpu_gettime = generic_gettime,
94 .cpu_settime = generic_settime,
95 .cpu_vups = 1, /* ~VUPS */
96 .cpu_scbsz = 4, /* SCB pages */
97 .cpu_clrf = ka730_clrf,
98 .cpu_devs = ka730_devs,
99 .cpu_attach_cpu = ka730_attach_cpu,
100
101 };
102
103 void
ka730_conf(void)104 ka730_conf(void)
105 {
106 /* Call ctuattach() here so it can setup its vectors. */
107 ctuattach();
108 }
109
110 void
ka730_attach_cpu(device_t self)111 ka730_attach_cpu(device_t self)
112 {
113 aprint_normal(": KA730, ucode rev %d\n", V730UCODE(vax_cpudata));
114 }
115
116 static void ka730_memenable(device_t, device_t, void *);
117 static int ka730_memmatch(device_t, cfdata_t, void *);
118
119 CFATTACH_DECL_NEW(mem_ubi, 0,
120 ka730_memmatch, ka730_memenable, NULL, NULL);
121
122 int
ka730_memmatch(device_t parent,cfdata_t cf,void * aux)123 ka730_memmatch(device_t parent, cfdata_t cf, void *aux)
124 {
125 struct sbi_attach_args *sa = aux;
126
127 if (cf->cf_loc[UBICF_TR] != sa->sa_nexnum &&
128 cf->cf_loc[UBICF_TR] > UBICF_TR_DEFAULT)
129 return 0;
130
131 if (sa->sa_type != NEX_MEM16)
132 return 0;
133
134 return 1;
135 }
136
137 struct mcr730 {
138 int mc_addr; /* address and syndrome */
139 int mc_err; /* error bits */
140 };
141
142 /* enable crd interrupts */
143 void
ka730_memenable(device_t parent,device_t self,void * aux)144 ka730_memenable(device_t parent, device_t self, void *aux)
145 {
146 }
147
148 /* log crd errors */
149 void
ka730_memerr(void)150 ka730_memerr(void)
151 {
152 }
153
154 #define NMC730 12
155 const char *mc730[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13",
156 "14","15"};
157
158 struct mc730frame {
159 int mc3_bcnt; /* byte count == 0xc */
160 int mc3_summary; /* summary parameter (as above) */
161 int mc3_parm[2]; /* parameters */
162 int mc3_pc; /* trapped pc */
163 int mc3_psl; /* trapped psl */
164 };
165
166 int
ka730_mchk(void * cmcf)167 ka730_mchk(void *cmcf)
168 {
169 register struct mc730frame *mcf = (struct mc730frame *)cmcf;
170 register int type = mcf->mc3_summary;
171
172 printf("machine check %x: %s\n",
173 type, type < NMC730 ? mc730[type] : "???");
174 printf("\tparams %x %x pc %x psl %x mcesr %x\n",
175 mcf->mc3_parm[0], mcf->mc3_parm[1],
176 mcf->mc3_pc, mcf->mc3_psl, mfpr(PR_MCESR));
177 mtpr(0xf, PR_MCESR);
178 return (MCHK_PANIC);
179 }
180
181 void
ka730_clrf(void)182 ka730_clrf(void)
183 {
184 int s = splhigh();
185
186 #define WAIT while ((mfpr(PR_TXCS) & GC_RDY) == 0) ;
187
188 WAIT;
189
190 mtpr(GC_CWFL|GC_CONS, PR_TXDB);
191
192 WAIT;
193 mtpr(GC_CCFL|GC_CONS, PR_TXDB);
194
195 WAIT;
196 splx(s);
197 }
198