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