master
1/* $NetBSD: cpuconf.h,v 1.5 2016/10/08 20:30:54 joerg 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
67extern 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#ifdef SUN4
80#define _CPU_NTYPES_SUN4 1
81#else
82#define _CPU_NTYPES_SUN4 0
83#endif
84#ifdef SUN4C
85#define _CPU_NTYPES_SUN4C 1
86#else
87#define _CPU_NTYPES_SUN4C 0
88#endif
89#ifdef SUN4M
90#define _CPU_NTYPES_SUN4M 1
91#else
92#define _CPU_NTYPES_SUN4M 0
93#endif
94#ifdef SUN4D
95#define _CPU_NTYPES_SUN4D 1
96#else
97#define _CPU_NTYPES_SUN4D 0
98#endif
99#define CPU_NTYPES (_CPU_NTYPES_SUN4 + _CPU_NTYPES_SUN4C + \
100 _CPU_NTYPES_SUN4M + _CPU_NTYPES_SUN4D)
101#else
102#define CPU_NTYPES 0
103#endif
104
105/*
106 * Step 2: Define the CPU type predicates. Rules:
107 *
108 * * If multiple CPU types are configured in, and the CPU type
109 * is not one of them, then the test is always false.
110 *
111 * * If exactly one CPU type is configured in, and it's this
112 * one, then the test is always true.
113 *
114 * * Otherwise, we have to reference the cputyp variable.
115 */
116#if CPU_NTYPES != 0 && !defined(SUN4)
117# define CPU_ISSUN4 (0)
118#elif CPU_NTYPES == 1 && defined(SUN4)
119# define CPU_ISSUN4 (1)
120#else
121# define CPU_ISSUN4 (cputyp == CPU_SUN4)
122#endif
123
124#if CPU_NTYPES != 0 && !defined(SUN4C)
125# define CPU_ISSUN4C (0)
126#elif CPU_NTYPES == 1 && defined(SUN4C)
127# define CPU_ISSUN4C (1)
128#else
129# define CPU_ISSUN4C (cputyp == CPU_SUN4C)
130#endif
131
132#if CPU_NTYPES != 0 && !defined(SUN4M)
133# define CPU_ISSUN4M (0)
134#elif CPU_NTYPES == 1 && defined(SUN4M)
135# define CPU_ISSUN4M (1)
136#else
137# define CPU_ISSUN4M (cputyp == CPU_SUN4M)
138#endif
139
140#if CPU_NTYPES != 0 && !defined(SUN4D)
141# define CPU_ISSUN4D (0)
142#elif CPU_NTYPES == 1 && defined(SUN4D)
143# define CPU_ISSUN4D (1)
144#else
145# define CPU_ISSUN4D (cputyp == CPU_SUN4D)
146#endif
147
148#define CPU_ISSUN4U (0)
149
150/*
151 * Step 3: Define some short-hand for the different MMUs.
152 */
153#define CPU_HAS_SRMMU (CPU_ISSUN4M || CPU_ISSUN4D)
154#define CPU_HAS_SUNMMU (CPU_ISSUN4 || CPU_ISSUN4C)
155
156#endif /* _KERNEL || _STANDALONE */
157
158#endif /* _SPARC_CPUCONF_H_ */