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