1*6c825a13Sjoerg /* $NetBSD: cpuconf.h,v 1.5 2016/10/08 20:30:54 joerg Exp $ */ 2efdd83f4Sthorpej 3efdd83f4Sthorpej /* 4efdd83f4Sthorpej * Copyright (c) 1992, 1993 5efdd83f4Sthorpej * The Regents of the University of California. All rights reserved. 6efdd83f4Sthorpej * 7efdd83f4Sthorpej * This software was developed by the Computer Systems Engineering group 8efdd83f4Sthorpej * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 9efdd83f4Sthorpej * contributed to Berkeley. 10efdd83f4Sthorpej * 11efdd83f4Sthorpej * All advertising materials mentioning features or use of this software 12efdd83f4Sthorpej * must display the following acknowledgement: 13efdd83f4Sthorpej * This product includes software developed by the University of 14efdd83f4Sthorpej * California, Lawrence Berkeley Laboratory. 15efdd83f4Sthorpej * 16efdd83f4Sthorpej * Redistribution and use in source and binary forms, with or without 17efdd83f4Sthorpej * modification, are permitted provided that the following conditions 18efdd83f4Sthorpej * are met: 19efdd83f4Sthorpej * 1. Redistributions of source code must retain the above copyright 20efdd83f4Sthorpej * notice, this list of conditions and the following disclaimer. 21efdd83f4Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 22efdd83f4Sthorpej * notice, this list of conditions and the following disclaimer in the 23efdd83f4Sthorpej * documentation and/or other materials provided with the distribution. 24aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 25efdd83f4Sthorpej * may be used to endorse or promote products derived from this software 26efdd83f4Sthorpej * without specific prior written permission. 27efdd83f4Sthorpej * 28efdd83f4Sthorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29efdd83f4Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30efdd83f4Sthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31efdd83f4Sthorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32efdd83f4Sthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33efdd83f4Sthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34efdd83f4Sthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35efdd83f4Sthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36efdd83f4Sthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37efdd83f4Sthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38efdd83f4Sthorpej * SUCH DAMAGE. 39efdd83f4Sthorpej * 40efdd83f4Sthorpej * @(#)param.h 8.1 (Berkeley) 6/11/93 41efdd83f4Sthorpej */ 42efdd83f4Sthorpej /* 43efdd83f4Sthorpej * Sun4M support by Aaron Brown, Harvard University. 44efdd83f4Sthorpej * Changes Copyright (c) 1995 The President and Fellows of Harvard College. 45efdd83f4Sthorpej * All rights reserved. 46efdd83f4Sthorpej */ 47efdd83f4Sthorpej 48efdd83f4Sthorpej #ifndef _SPARC_CPUCONF_H_ 49efdd83f4Sthorpej #define _SPARC_CPUCONF_H_ 50efdd83f4Sthorpej 51efdd83f4Sthorpej /* 52efdd83f4Sthorpej * Values for the cputyp variable. 53efdd83f4Sthorpej */ 54efdd83f4Sthorpej #define CPU_SUN4 0 55efdd83f4Sthorpej #define CPU_SUN4C 1 56efdd83f4Sthorpej #define CPU_SUN4M 2 57efdd83f4Sthorpej #define CPU_SUN4U 3 58efdd83f4Sthorpej #define CPU_SUN4D 4 59efdd83f4Sthorpej 60efdd83f4Sthorpej #if defined(_KERNEL) || defined(_STANDALONE) 61efdd83f4Sthorpej 62efdd83f4Sthorpej #if defined(_KERNEL_OPT) 63efdd83f4Sthorpej #include "opt_sparc_arch.h" 64efdd83f4Sthorpej #endif /* _KERNEL_OPT */ 65efdd83f4Sthorpej 66efdd83f4Sthorpej #ifndef _LOCORE 67efdd83f4Sthorpej extern int cputyp; 68efdd83f4Sthorpej #endif 69efdd83f4Sthorpej 70efdd83f4Sthorpej /* 71efdd83f4Sthorpej * Shorthand CPU-type macros. Let the compiler optimize away code 72efdd83f4Sthorpej * conditional on constants. 73efdd83f4Sthorpej */ 74efdd83f4Sthorpej 75efdd83f4Sthorpej /* 76efdd83f4Sthorpej * Step 1: Count the number of CPU types configured into the kernel. 77efdd83f4Sthorpej */ 78efdd83f4Sthorpej #if defined(_KERNEL_OPT) 79*6c825a13Sjoerg #ifdef SUN4 80*6c825a13Sjoerg #define _CPU_NTYPES_SUN4 1 81*6c825a13Sjoerg #else 82*6c825a13Sjoerg #define _CPU_NTYPES_SUN4 0 83*6c825a13Sjoerg #endif 84*6c825a13Sjoerg #ifdef SUN4C 85*6c825a13Sjoerg #define _CPU_NTYPES_SUN4C 1 86*6c825a13Sjoerg #else 87*6c825a13Sjoerg #define _CPU_NTYPES_SUN4C 0 88*6c825a13Sjoerg #endif 89*6c825a13Sjoerg #ifdef SUN4M 90*6c825a13Sjoerg #define _CPU_NTYPES_SUN4M 1 91*6c825a13Sjoerg #else 92*6c825a13Sjoerg #define _CPU_NTYPES_SUN4M 0 93*6c825a13Sjoerg #endif 94*6c825a13Sjoerg #ifdef SUN4D 95*6c825a13Sjoerg #define _CPU_NTYPES_SUN4D 1 96*6c825a13Sjoerg #else 97*6c825a13Sjoerg #define _CPU_NTYPES_SUN4D 0 98*6c825a13Sjoerg #endif 99*6c825a13Sjoerg #define CPU_NTYPES (_CPU_NTYPES_SUN4 + _CPU_NTYPES_SUN4C + \ 100*6c825a13Sjoerg _CPU_NTYPES_SUN4M + _CPU_NTYPES_SUN4D) 101efdd83f4Sthorpej #else 102efdd83f4Sthorpej #define CPU_NTYPES 0 103efdd83f4Sthorpej #endif 104efdd83f4Sthorpej 105efdd83f4Sthorpej /* 106efdd83f4Sthorpej * Step 2: Define the CPU type predicates. Rules: 107efdd83f4Sthorpej * 108efdd83f4Sthorpej * * If multiple CPU types are configured in, and the CPU type 109efdd83f4Sthorpej * is not one of them, then the test is always false. 110efdd83f4Sthorpej * 111efdd83f4Sthorpej * * If exactly one CPU type is configured in, and it's this 112efdd83f4Sthorpej * one, then the test is always true. 113efdd83f4Sthorpej * 114efdd83f4Sthorpej * * Otherwise, we have to reference the cputyp variable. 115efdd83f4Sthorpej */ 116efdd83f4Sthorpej #if CPU_NTYPES != 0 && !defined(SUN4) 117efdd83f4Sthorpej # define CPU_ISSUN4 (0) 118efdd83f4Sthorpej #elif CPU_NTYPES == 1 && defined(SUN4) 119efdd83f4Sthorpej # define CPU_ISSUN4 (1) 120efdd83f4Sthorpej #else 121efdd83f4Sthorpej # define CPU_ISSUN4 (cputyp == CPU_SUN4) 122efdd83f4Sthorpej #endif 123efdd83f4Sthorpej 124efdd83f4Sthorpej #if CPU_NTYPES != 0 && !defined(SUN4C) 125efdd83f4Sthorpej # define CPU_ISSUN4C (0) 126efdd83f4Sthorpej #elif CPU_NTYPES == 1 && defined(SUN4C) 127efdd83f4Sthorpej # define CPU_ISSUN4C (1) 128efdd83f4Sthorpej #else 129efdd83f4Sthorpej # define CPU_ISSUN4C (cputyp == CPU_SUN4C) 130efdd83f4Sthorpej #endif 131efdd83f4Sthorpej 132efdd83f4Sthorpej #if CPU_NTYPES != 0 && !defined(SUN4M) 133efdd83f4Sthorpej # define CPU_ISSUN4M (0) 134efdd83f4Sthorpej #elif CPU_NTYPES == 1 && defined(SUN4M) 135efdd83f4Sthorpej # define CPU_ISSUN4M (1) 136efdd83f4Sthorpej #else 137efdd83f4Sthorpej # define CPU_ISSUN4M (cputyp == CPU_SUN4M) 138efdd83f4Sthorpej #endif 139efdd83f4Sthorpej 140efdd83f4Sthorpej #if CPU_NTYPES != 0 && !defined(SUN4D) 141efdd83f4Sthorpej # define CPU_ISSUN4D (0) 142efdd83f4Sthorpej #elif CPU_NTYPES == 1 && defined(SUN4D) 143efdd83f4Sthorpej # define CPU_ISSUN4D (1) 144efdd83f4Sthorpej #else 145efdd83f4Sthorpej # define CPU_ISSUN4D (cputyp == CPU_SUN4D) 146efdd83f4Sthorpej #endif 147efdd83f4Sthorpej 148efdd83f4Sthorpej #define CPU_ISSUN4U (0) 149efdd83f4Sthorpej 150efdd83f4Sthorpej /* 1510b7dee4bSchs * Step 3: Define some short-hand for the different MMUs. 152efdd83f4Sthorpej */ 153efdd83f4Sthorpej #define CPU_HAS_SRMMU (CPU_ISSUN4M || CPU_ISSUN4D) 1540b7dee4bSchs #define CPU_HAS_SUNMMU (CPU_ISSUN4 || CPU_ISSUN4C) 155efdd83f4Sthorpej 156efdd83f4Sthorpej #endif /* _KERNEL || _STANDALONE */ 157efdd83f4Sthorpej 158efdd83f4Sthorpej #endif /* _SPARC_CPUCONF_H_ */ 159