1 /* 2 * Copyright (c) 1998 Ludd, University of Lule}, Sweden. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Ludd by Bertram Barth. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed at Ludd, University of 18 * Lule}, Sweden and its contributors. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 /*** needs to be completed MK-990306 ***/ 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/ka48.h> 54 #include <machine/clock.h> 55 #include <machine/vsbus.h> 56 57 static void ka48_conf __P((void)); 58 static void ka48_steal_pages __P((void)); 59 static void ka48_memerr __P((void)); 60 static int ka48_mchk __P((caddr_t)); 61 static void ka48_halt __P((void)); 62 static void ka48_reboot __P((int)); 63 static void ka48_cache_enable __P((void)); 64 65 struct vs_cpu *ka48_cpu; 66 67 /* 68 * Declaration of 48-specific calls. 69 */ 70 struct cpu_dep ka48_calls = { 71 ka48_steal_pages, 72 ka48_mchk, 73 ka48_memerr, 74 ka48_conf, 75 chip_clkread, 76 chip_clkwrite, 77 6, /* ~VUPS */ 78 2, /* SCB pages */ 79 ka48_halt, 80 ka48_reboot, 81 NULL, 82 NULL, 83 CPU_RAISEIPL, 84 }; 85 86 87 void 88 ka48_conf() 89 { 90 printf("cpu: KA48\n"); 91 ka48_cpu = (void *)vax_map_physmem(VS_REGS, 1); 92 printf("cpu: turning on floating point chip\n"); 93 mtpr(2, PR_ACCS); /* Enable floating points */ 94 /* 95 * Setup parameters necessary to read time from clock chip. 96 */ 97 clk_adrshift = 1; /* Addressed at long's... */ 98 clk_tweak = 2; /* ...and shift two */ 99 clk_page = (short *)vax_map_physmem(VS_CLOCK, 1); 100 } 101 102 void 103 ka48_cache_enable() 104 { 105 int i, *tmp; 106 long *par_ctl = (long *)KA48_PARCTL; 107 108 /* Disable cache */ 109 mtpr(0, PR_CADR); /* disable */ 110 *par_ctl &= ~KA48_PARCTL_INVENA; /* clear ? invalid enable */ 111 mtpr(2, PR_CADR); /* flush */ 112 113 /* Clear caches */ 114 tmp = (void *)KA48_INVFLT; /* inv filter */ 115 for (i = 0; i < KA48_INVFLTSZ / sizeof(int); i++) 116 tmp[i] = 0; 117 *par_ctl |= KA48_PARCTL_INVENA; /* Enable ???? */ 118 mtpr(4, PR_CADR); /* enable cache */ 119 *par_ctl |= (KA48_PARCTL_AGS | /* AGS? */ 120 KA48_PARCTL_NPEN | /* N? Parity Enable */ 121 KA48_PARCTL_CPEN); /* Cpu parity enable */ 122 } 123 124 void 125 ka48_memerr() 126 { 127 printf("Memory err!\n"); 128 } 129 130 int 131 ka48_mchk(addr) 132 caddr_t addr; 133 { 134 panic("Machine check"); 135 return 0; 136 } 137 138 void 139 ka48_steal_pages() 140 { 141 /* Turn on caches (to speed up execution a bit) */ 142 ka48_cache_enable(); 143 } 144 145 #define KA48_CPMBX 0x38 146 #define KA48_HLT_HALT 0xcf /* 11001111 */ 147 #define KA48_HLT_BOOT 0x8b /* 10001011 */ 148 149 static void 150 ka48_halt() 151 { 152 ((u_int8_t *) clk_page)[KA48_CPMBX] = KA48_HLT_HALT; 153 asm("halt"); 154 } 155 156 static void 157 ka48_reboot(arg) 158 int arg; 159 { 160 ((u_int8_t *) clk_page)[KA48_CPMBX] = KA48_HLT_BOOT; 161 asm("halt"); 162 } 163