1 /* $NetBSD: findcpu.c,v 1.20 2017/05/22 16:39:41 ragge Exp $ */ 2 /* 3 * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. 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 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #include <sys/cdefs.h> 28 __KERNEL_RCSID(0, "$NetBSD: findcpu.c,v 1.20 2017/05/22 16:39:41 ragge Exp $"); 29 30 #include <sys/param.h> 31 #ifdef _KERNEL 32 #include <sys/device.h> 33 #endif 34 35 #include <machine/sid.h> 36 #include <machine/nexus.h> 37 #include <machine/mtpr.h> 38 #include <machine/cpu.h> 39 40 /* 41 * We set up some information about the machine we're 42 * running on and thus initializes/uses vax_cputype and vax_boardtype. 43 * There should be no need to change/reinitialize these variables 44 * outside of this routine, they should be read only! 45 */ 46 int vax_cputype; /* highest byte of SID register */ 47 int vax_bustype; /* holds/defines all busses on this machine */ 48 int vax_boardtype; /* machine dependent, combination of SID and SIE */ 49 50 int vax_cpudata; /* contents of the SID register */ 51 int vax_siedata; /* contents of the SIE register */ 52 int vax_confdata; /* machine dependent, configuration/setup data */ 53 54 /* 55 * Try to figure out which type of system this is. 56 */ 57 void 58 findcpu(void) 59 { 60 vax_cpudata = mfpr(PR_SID); 61 vax_cputype = vax_cpudata >> 24; 62 vax_boardtype = vax_cputype << 24; 63 64 switch (vax_cputype) { 65 case VAX_TYP_730: 66 vax_bustype = VAX_UNIBUS; 67 break; 68 case VAX_TYP_780: 69 vax_bustype = VAX_SBIBUS; 70 break; 71 case VAX_TYP_750: 72 vax_bustype = VAX_CMIBUS; 73 break; 74 case VAX_TYP_790: 75 vax_bustype = VAX_ABUS; 76 break; 77 78 case VAX_TYP_UV1: 79 vax_bustype = VAX_IBUS; 80 break; 81 82 case VAX_TYP_UV2: 83 case VAX_TYP_CVAX: 84 case VAX_TYP_RIGEL: 85 case VAX_TYP_MARIAH: 86 case VAX_TYP_NVAX: 87 case VAX_TYP_SOC: 88 vax_siedata = *(int *)(0x20040004); /* SIE address */ 89 vax_boardtype |= vax_siedata >> 24; 90 91 switch (vax_boardtype) { 92 case VAX_BTYP_420: /* They are very similar */ 93 case VAX_BTYP_410: 94 case VAX_BTYP_43: 95 case VAX_BTYP_46: 96 case VAX_BTYP_48: 97 case VAX_BTYP_IS1: 98 vax_confdata = *(int *)(0x20020000); 99 vax_bustype = VAX_VSBUS; 100 break; 101 case VAX_BTYP_49: 102 vax_confdata = *(int *)(0x25800000); 103 vax_bustype = VAX_VSBUS; 104 break; 105 106 case VAX_BTYP_9CC: 107 case VAX_BTYP_9RR: 108 case VAX_BTYP_1202: 109 case VAX_BTYP_1302: 110 vax_bustype = VAX_XMIBUS; 111 break; 112 113 case VAX_BTYP_670: 114 case VAX_BTYP_660: 115 case VAX_BTYP_60: 116 case VAX_BTYP_680: 117 case VAX_BTYP_681: 118 case VAX_BTYP_630: 119 case VAX_BTYP_650: 120 case VAX_BTYP_53: 121 vax_bustype = VAX_IBUS; 122 break; 123 124 } 125 break; 126 127 case VAX_TYP_8SS: 128 vax_boardtype = VAX_BTYP_8000; 129 vax_bustype = VAX_BIBUS; 130 break; 131 132 case VAX_TYP_8NN: 133 vax_boardtype = VAX_BTYP_8800; /* subversion later */ 134 vax_bustype = VAX_NMIBUS; 135 break; 136 137 case VAX_TYP_8PS: 138 vax_boardtype = VAX_BTYP_8PS; 139 vax_bustype = VAX_NMIBUS; 140 break; 141 142 default: 143 /* CPU not supported, just give up */ 144 __asm("halt"); 145 } 146 } 147