cpu.h revision 1.20 1 1.20 thorpej /* $NetBSD: cpu.h,v 1.20 2024/01/18 14:39:06 thorpej Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.14 rmind * Copyright (c) 1988 University of Utah.
5 1.1 thorpej * Copyright (c) 1982, 1990, 1993
6 1.1 thorpej * The Regents of the University of California. All rights reserved.
7 1.10 agc *
8 1.10 agc * This code is derived from software contributed to Berkeley by
9 1.10 agc * the Systems Programming Group of the University of Utah Computer
10 1.10 agc * Science Department.
11 1.10 agc *
12 1.10 agc * Redistribution and use in source and binary forms, with or without
13 1.10 agc * modification, are permitted provided that the following conditions
14 1.10 agc * are met:
15 1.10 agc * 1. Redistributions of source code must retain the above copyright
16 1.10 agc * notice, this list of conditions and the following disclaimer.
17 1.10 agc * 2. Redistributions in binary form must reproduce the above copyright
18 1.10 agc * notice, this list of conditions and the following disclaimer in the
19 1.10 agc * documentation and/or other materials provided with the distribution.
20 1.10 agc * 3. Neither the name of the University nor the names of its contributors
21 1.10 agc * may be used to endorse or promote products derived from this software
22 1.10 agc * without specific prior written permission.
23 1.10 agc *
24 1.10 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.10 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.10 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.10 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.10 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.10 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.10 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.10 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.10 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.10 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.10 agc * SUCH DAMAGE.
35 1.10 agc *
36 1.10 agc * from: Utah $Hdr: cpu.h 1.16 91/03/25$
37 1.10 agc *
38 1.10 agc * @(#)cpu.h 8.4 (Berkeley) 1/5/94
39 1.10 agc */
40 1.1 thorpej
41 1.1 thorpej #ifndef _M68K_CPU_H_
42 1.1 thorpej #define _M68K_CPU_H_
43 1.1 thorpej
44 1.20 thorpej #if defined(_KERNEL_OPT)
45 1.20 thorpej #include "opt_m68k_arch.h" /* XXX Should not do this here. */
46 1.20 thorpej #endif
47 1.20 thorpej
48 1.1 thorpej /*
49 1.1 thorpej * Exported definitions common to Motorola m68k-based ports.
50 1.1 thorpej *
51 1.1 thorpej * Note that are some port-specific definitions here, such as
52 1.1 thorpej * HP and Sun MMU types. These facilitate adding very small
53 1.1 thorpej * amounts of port-specific code to what would otherwise be
54 1.1 thorpej * identical. The is especially true in the case of the HP
55 1.1 thorpej * and other m68k pmaps.
56 1.1 thorpej *
57 1.1 thorpej * Individual ports are expected to define the following CPP symbols
58 1.1 thorpej * in <machine/cpu.h> to enable conditional code:
59 1.1 thorpej *
60 1.1 thorpej * M68K_MMU_MOTOROLA Machine has a Motorola MMU (incl.
61 1.1 thorpej * 68851, 68030, 68040, 68060)
62 1.1 thorpej *
63 1.1 thorpej * M68K_MMU_HP Machine has an HP MMU.
64 1.1 thorpej *
65 1.1 thorpej * Note also that while m68k-generic code conditionalizes on the
66 1.8 wiz * M68K_MMU_HP CPP symbol, none of the HP MMU definitions are in this
67 1.1 thorpej * file (since none are used in otherwise sharable code).
68 1.1 thorpej */
69 1.1 thorpej
70 1.1 thorpej /*
71 1.5 gwr * XXX The remaining contents of this file should be split out
72 1.5 gwr * XXX into separate files (like m68k.h) and then this file
73 1.5 gwr * XXX should go away. Furthermore, most of the stuff defined
74 1.5 gwr * XXX here does NOT belong in <machine/cpu.h>, and the ports
75 1.5 gwr * XXX using this file should remove <m68k/cpu.h> from there.
76 1.1 thorpej */
77 1.1 thorpej
78 1.5 gwr #include <m68k/m68k.h>
79 1.5 gwr
80 1.5 gwr /* XXX - Move this stuff into <m68k/cacr.h> maybe? */
81 1.5 gwr
82 1.1 thorpej /* fields in the 68020 cache control register */
83 1.1 thorpej #define IC_ENABLE 0x0001 /* enable instruction cache */
84 1.1 thorpej #define IC_FREEZE 0x0002 /* freeze instruction cache */
85 1.1 thorpej #define IC_CE 0x0004 /* clear instruction cache entry */
86 1.1 thorpej #define IC_CLR 0x0008 /* clear entire instruction cache */
87 1.1 thorpej
88 1.1 thorpej /* additional fields in the 68030 cache control register */
89 1.1 thorpej #define IC_BE 0x0010 /* instruction burst enable */
90 1.1 thorpej #define DC_ENABLE 0x0100 /* data cache enable */
91 1.1 thorpej #define DC_FREEZE 0x0200 /* data cache freeze */
92 1.1 thorpej #define DC_CE 0x0400 /* clear data cache entry */
93 1.1 thorpej #define DC_CLR 0x0800 /* clear entire data cache */
94 1.1 thorpej #define DC_BE 0x1000 /* data burst enable */
95 1.1 thorpej #define DC_WA 0x2000 /* write allocate */
96 1.1 thorpej
97 1.1 thorpej /* fields in the 68040 cache control register */
98 1.1 thorpej #define IC40_ENABLE 0x00008000 /* instruction cache enable bit */
99 1.1 thorpej #define DC40_ENABLE 0x80000000 /* data cache enable bit */
100 1.1 thorpej
101 1.1 thorpej /* additional fields in the 68060 cache control register */
102 1.1 thorpej #define DC60_NAD 0x40000000 /* no allocate mode, data cache */
103 1.1 thorpej #define DC60_ESB 0x20000000 /* enable store buffer */
104 1.1 thorpej #define DC60_DPI 0x10000000 /* disable CPUSH invalidation */
105 1.1 thorpej #define DC60_FOC 0x08000000 /* four kB data cache mode (else 8) */
106 1.1 thorpej
107 1.1 thorpej #define IC60_EBC 0x00800000 /* enable branch cache */
108 1.1 thorpej #define IC60_CABC 0x00400000 /* clear all branch cache entries */
109 1.1 thorpej #define IC60_CUBC 0x00200000 /* clear user branch cache entries */
110 1.1 thorpej
111 1.1 thorpej #define IC60_NAI 0x00004000 /* no allocate mode, instr. cache */
112 1.1 thorpej #define IC60_FIC 0x00002000 /* four kB instr. cache (else 8) */
113 1.1 thorpej
114 1.1 thorpej #define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE)
115 1.1 thorpej #define CACHE_OFF (DC_CLR|IC_CLR)
116 1.1 thorpej #define CACHE_CLR (CACHE_ON)
117 1.1 thorpej #define IC_CLEAR (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE)
118 1.1 thorpej #define DC_CLEAR (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE)
119 1.1 thorpej
120 1.1 thorpej #define CACHE40_ON (IC40_ENABLE|DC40_ENABLE)
121 1.1 thorpej #define CACHE40_OFF (0x00000000)
122 1.1 thorpej
123 1.1 thorpej #define CACHE60_ON (CACHE40_ON|IC60_CABC|IC60_EBC|DC60_ESB)
124 1.1 thorpej #define CACHE60_OFF (CACHE40_OFF|IC60_CABC)
125 1.6 scw
126 1.15 rkujawa #define CACHELINE_SIZE 16
127 1.15 rkujawa #define CACHELINE_MASK (CACHELINE_SIZE - 1)
128 1.15 rkujawa
129 1.16 msaitoh /* CTL_MACHDEP definitions. (Common to all m68k ports.) */
130 1.16 msaitoh #define CPU_CONSDEV 1 /* dev_t: console terminal device */
131 1.16 msaitoh #define CPU_ROOT_DEVICE 2 /* string: root device name */
132 1.16 msaitoh #define CPU_BOOTED_KERNEL 3 /* string: booted kernel name */
133 1.16 msaitoh
134 1.13 he #if defined(_KERNEL) || defined(_KMEMUSER)
135 1.12 matt #include <sys/cpu_data.h>
136 1.12 matt
137 1.12 matt struct cpu_info {
138 1.12 matt struct cpu_data ci_data; /* MI per-cpu data */
139 1.12 matt cpuid_t ci_cpuid;
140 1.12 matt int ci_mtx_count;
141 1.12 matt int ci_mtx_oldspl;
142 1.12 matt volatile int ci_want_resched;
143 1.12 matt volatile int ci_idepth;
144 1.17 ad struct lwp *ci_onproc; /* current user LWP / kthread */
145 1.12 matt };
146 1.12 matt #endif /* _KERNEL || _KMEMUSER */
147 1.12 matt
148 1.6 scw #ifdef _KERNEL
149 1.12 matt extern struct cpu_info cpu_info_store;
150 1.12 matt
151 1.12 matt struct proc;
152 1.12 matt void cpu_proc_fork(struct proc *, struct proc *);
153 1.12 matt
154 1.12 matt #define curcpu() (&cpu_info_store)
155 1.12 matt
156 1.6 scw /*
157 1.12 matt * definitions of cpu-dependent requirements
158 1.12 matt * referenced in generic code
159 1.6 scw */
160 1.12 matt #define cpu_number() 0
161 1.9 thorpej
162 1.9 thorpej #define LWP_PC(l) (((struct trapframe *)((l)->l_md.md_regs))->tf_pc)
163 1.6 scw #endif /* _KERNEL */
164 1.1 thorpej
165 1.1 thorpej #endif /* _M68K_CPU_H_ */
166