Annotation of sys/arch/vax/vax/ka46.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: ka46.c,v 1.7 2002/07/21 19:28:50 hugh Exp $ */
2: /* $NetBSD: ka46.c,v 1.12 2000/03/04 07:27:49 matt Exp $ */
3: /*
4: * Copyright (c) 1998 Ludd, University of Lule}, Sweden.
5: * All rights reserved.
6: *
7: * This code is derived from software contributed to Ludd by Bertram Barth.
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
12: * 1. Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: * 2. Redistributions in binary form must reproduce the above copyright
15: * notice, this list of conditions and the following disclaimer in the
16: * documentation and/or other materials provided with the distribution.
17: * 3. All advertising materials mentioning features or use of this software
18: * must display the following acknowledgement:
19: * This product includes software developed at Ludd, University of
20: * Lule}, Sweden and its contributors.
21: * 4. The name of the author may not be used to endorse or promote products
22: * derived from this software without specific prior written permission
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34: */
35:
36: #include <sys/param.h>
37: #include <sys/types.h>
38: #include <sys/device.h>
39: #include <sys/kernel.h>
40: #include <sys/systm.h>
41:
42: #include <uvm/uvm_extern.h>
43:
44: #include <machine/pte.h>
45: #include <machine/cpu.h>
46: #include <machine/mtpr.h>
47: #include <machine/sid.h>
48: #include <machine/pmap.h>
49: #include <machine/nexus.h>
50: #include <machine/uvax.h>
51: #include <machine/ka410.h>
52: #include <machine/ka420.h>
53: #include <machine/ka46.h>
54: #include <machine/clock.h>
55: #include <machine/vsbus.h>
56:
57: static void ka46_conf(void);
58: static void ka46_steal_pages(void);
59: static void ka46_memerr(void);
60: static int ka46_mchk(caddr_t);
61: static void ka46_halt(void);
62: static void ka46_reboot(int);
63: static void ka46_cache_enable(void);
64:
65: struct vs_cpu *ka46_cpu;
66:
67: /*
68: * Declaration of 46-specific calls.
69: */
70: struct cpu_dep ka46_calls = {
71: ka46_steal_pages,
72: ka46_mchk,
73: ka46_memerr,
74: ka46_conf,
75: chip_clkread,
76: chip_clkwrite,
77: 12, /* ~VUPS */
78: 2, /* SCB pages */
79: ka46_halt,
80: ka46_reboot,
81: };
82:
83:
84: void
85: ka46_conf()
86: {
87: switch(vax_siedata & 0xFF) {
88: case VAX_VTYP_47:
89: printf("cpu: KA47\n");
90: break;
91: case VAX_VTYP_46:
92: printf("cpu: KA46\n");
93: break;
94: default:
95: printf("cpu: Unknown Mariah\n");
96: }
97:
98: ka46_cpu = (void *)vax_map_physmem(VS_REGS, 1);
99: printf("cpu: turning on floating point chip\n");
100: mtpr(2, PR_ACCS); /* Enable floating points */
101: /*
102: * Setup parameters necessary to read time from clock chip.
103: */
104: clk_adrshift = 1; /* Addressed at long's... */
105: clk_tweak = 2; /* ...and shift two */
106: clk_page = (short *)vax_map_physmem(VS_CLOCK, 1);
107: }
108:
109: void
110: ka46_cache_enable()
111: {
112: int i, *tmp;
113:
114: /* Disable caches */
115: *(int *)KA46_CCR &= ~CCR_SPECIO;/* secondary */
116: mtpr(PCSTS_FLUSH, PR_PCSTS); /* primary */
117: *(int *)KA46_BWF0 &= ~BWF0_FEN; /* invalidate filter */
118:
119: /* Clear caches */
120: tmp = (void *)KA46_INVFLT; /* inv filter */
121: for (i = 0; i < 32768; i++)
122: tmp[i] = 0;
123:
124: /* Write valid parity to all primary cache entries */
125: for (i = 0; i < 256; i++) {
126: mtpr(i << 3, PR_PCIDX);
127: mtpr(PCTAG_PARITY, PR_PCTAG);
128: }
129:
130: /* Secondary cache */
131: tmp = (void *)KA46_TAGST;
132: for (i = 0; i < KA46_TAGSZ*2; i+=2)
133: tmp[i] = 0;
134:
135: /* Enable cache */
136: *(int *)KA46_BWF0 |= BWF0_FEN; /* invalidate filter */
137: mtpr(PCSTS_ENABLE, PR_PCSTS);
138: *(int *)KA46_CCR = CCR_SPECIO | CCR_CENA;
139: }
140:
141: void
142: ka46_memerr()
143: {
144: printf("Memory err!\n");
145: }
146:
147: int
148: ka46_mchk(addr)
149: caddr_t addr;
150: {
151: panic("Machine check");
152: return 0;
153: }
154:
155: void
156: ka46_steal_pages()
157: {
158:
159: /* Turn on caches (to speed up execution a bit) */
160: ka46_cache_enable();
161: }
162:
163: #define KA46_CPMBX 0x38
164: #define KA46_HLT_HALT 0xcf
165: #define KA46_HLT_BOOT 0x8b
166:
167: static void
168: ka46_halt()
169: {
170: if (((u_int8_t *) clk_page)[KA46_CPMBX] != KA46_HLT_HALT)
171: ((u_int8_t *) clk_page)[KA46_CPMBX] = KA46_HLT_HALT;
172: asm("halt");
173: }
174:
175: static void
176: ka46_reboot(arg)
177: int arg;
178: {
179: if (((u_int8_t *) clk_page)[KA46_CPMBX] != KA46_HLT_BOOT)
180: ((u_int8_t *) clk_page)[KA46_CPMBX] = KA46_HLT_BOOT;
181: asm("halt");
182: }
CVSweb