cpu.h revision 1.32 1 1.32 thorpej /* $NetBSD: cpu.h,v 1.32 1999/08/10 21:08:08 thorpej Exp $ */
2 1.8 cgd
3 1.1 deraadt /*-
4 1.5 glass * Copyright (c) 1992, 1993
5 1.5 glass * The Regents of the University of California. All rights reserved.
6 1.1 deraadt *
7 1.1 deraadt * This code is derived from software contributed to Berkeley by
8 1.1 deraadt * Ralph Campbell and Rick Macklem.
9 1.1 deraadt *
10 1.1 deraadt * Redistribution and use in source and binary forms, with or without
11 1.1 deraadt * modification, are permitted provided that the following conditions
12 1.1 deraadt * are met:
13 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
14 1.1 deraadt * notice, this list of conditions and the following disclaimer.
15 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
17 1.1 deraadt * documentation and/or other materials provided with the distribution.
18 1.1 deraadt * 3. All advertising materials mentioning features or use of this software
19 1.1 deraadt * must display the following acknowledgement:
20 1.1 deraadt * This product includes software developed by the University of
21 1.1 deraadt * California, Berkeley and its contributors.
22 1.1 deraadt * 4. Neither the name of the University nor the names of its contributors
23 1.1 deraadt * may be used to endorse or promote products derived from this software
24 1.1 deraadt * without specific prior written permission.
25 1.1 deraadt *
26 1.1 deraadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.1 deraadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.1 deraadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.1 deraadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.1 deraadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.1 deraadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.1 deraadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 deraadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 deraadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 deraadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 deraadt * SUCH DAMAGE.
37 1.1 deraadt *
38 1.8 cgd * @(#)cpu.h 8.4 (Berkeley) 1/4/94
39 1.1 deraadt */
40 1.1 deraadt
41 1.1 deraadt #ifndef _CPU_H_
42 1.1 deraadt #define _CPU_H_
43 1.1 deraadt
44 1.1 deraadt /*
45 1.13 jonathan * Exported definitions unique to NetBSD/mips cpu support.
46 1.1 deraadt */
47 1.1 deraadt
48 1.1 deraadt /*
49 1.21 jonathan * Macros to find the CPU architecture we're on at run-time,
50 1.21 jonathan * or if possible, at compile-time.
51 1.21 jonathan */
52 1.21 jonathan
53 1.21 jonathan #if (MIPS1 + MIPS3) == 1
54 1.21 jonathan #ifdef MIPS1
55 1.21 jonathan # define CPUISMIPS3 0
56 1.21 jonathan #endif /* mips1 */
57 1.21 jonathan
58 1.21 jonathan #ifdef MIPS3
59 1.21 jonathan # define CPUISMIPS3 1
60 1.21 jonathan #endif /* mips1 */
61 1.21 jonathan
62 1.21 jonathan #else /* run-time test */
63 1.21 jonathan extern int cpu_arch;
64 1.21 jonathan #define CPUISMIPS3 (cpu_arch == 3)
65 1.21 jonathan #endif /* run-time test */
66 1.21 jonathan
67 1.21 jonathan /*
68 1.1 deraadt * definitions of cpu-dependent requirements
69 1.1 deraadt * referenced in generic code
70 1.1 deraadt */
71 1.11 cgd #define cpu_wait(p) /* nothing */
72 1.11 cgd #define cpu_swapout(p) panic("cpu_swapout: can't get here");
73 1.32 thorpej #define cpu_number() 0
74 1.1 deraadt
75 1.1 deraadt /*
76 1.1 deraadt * Arguments to hardclock and gatherstats encapsulate the previous
77 1.1 deraadt * machine state in an opaque clockframe.
78 1.1 deraadt */
79 1.5 glass struct clockframe {
80 1.1 deraadt int pc; /* program counter at time of interrupt */
81 1.1 deraadt int sr; /* status register at time of interrupt */
82 1.5 glass };
83 1.1 deraadt
84 1.14 jonathan /*
85 1.14 jonathan * A port must provde CLKF_USERMODE() and CLKF_BASEPRI() for use
86 1.14 jonathan * in machine-independent code. These differ on r4000 and r3000 systems;
87 1.14 jonathan * provide them in the port-dependent file that includes this one, using
88 1.14 jonathan * the macros below.
89 1.14 jonathan */
90 1.14 jonathan
91 1.21 jonathan /* mips1 versions */
92 1.22 jonathan #define MIPS1_CLKF_USERMODE(framep) ((framep)->sr & MIPS_SR_KU_PREV)
93 1.21 jonathan #define MIPS1_CLKF_BASEPRI(framep) \
94 1.22 jonathan ((~(framep)->sr & (MIPS_INT_MASK | MIPS_SR_INT_ENA_PREV)) == 0)
95 1.14 jonathan
96 1.21 jonathan /* mips3 versions */
97 1.22 jonathan #define MIPS3_CLKF_USERMODE(framep) ((framep)->sr & MIPS_SR_KSU_USER)
98 1.21 jonathan #define MIPS3_CLKF_BASEPRI(framep) \
99 1.22 jonathan ((~(framep)->sr & (MIPS_INT_MASK | MIPS_SR_INT_ENAB)) == 0)
100 1.14 jonathan
101 1.1 deraadt #define CLKF_PC(framep) ((framep)->pc)
102 1.1 deraadt #define CLKF_INTR(framep) (0)
103 1.18 jonathan
104 1.21 jonathan #if defined(MIPS3) && !defined(MIPS1)
105 1.21 jonathan #define CLKF_USERMODE(framep) MIPS3_CLKF_USERMODE(framep)
106 1.21 jonathan #define CLKF_BASEPRI(framep) MIPS3_CLKF_BASEPRI(framep)
107 1.21 jonathan #endif
108 1.21 jonathan
109 1.21 jonathan #if !defined(MIPS3) && defined(MIPS1)
110 1.21 jonathan #define CLKF_USERMODE(framep) MIPS1_CLKF_USERMODE(framep)
111 1.21 jonathan #define CLKF_BASEPRI(framep) MIPS1_CLKF_BASEPRI(framep)
112 1.21 jonathan #endif
113 1.21 jonathan
114 1.21 jonathan
115 1.21 jonathan #if defined(MIPS3) && defined(MIPS1)
116 1.21 jonathan #define CLKF_USERMODE(framep) \
117 1.21 jonathan ((CPUISMIPS3) ? MIPS3_CLKF_USERMODE(framep): MIPS1_CLKF_USERMODE(framep))
118 1.21 jonathan #define CLKF_BASEPRI(framep) \
119 1.21 jonathan ((CPUISMIPS3) ? MIPS3_CLKF_BASEPRI(framep): MIPS1_CLKF_BASEPRI(framep))
120 1.18 jonathan #endif
121 1.18 jonathan
122 1.1 deraadt
123 1.21 jonathan
124 1.1 deraadt /*
125 1.1 deraadt * Preempt the current process if in interrupt from user mode,
126 1.1 deraadt * or after the current trap/syscall if in system mode.
127 1.1 deraadt */
128 1.1 deraadt #define need_resched() { want_resched = 1; aston(); }
129 1.1 deraadt
130 1.1 deraadt /*
131 1.1 deraadt * Give a profiling tick to the current process when the user profiling
132 1.13 jonathan * buffer pages are invalid. On the MIPS, request an ast to send us
133 1.1 deraadt * through trap, marking the proc as needing a profiling tick.
134 1.1 deraadt */
135 1.5 glass #define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
136 1.1 deraadt
137 1.1 deraadt /*
138 1.1 deraadt * Notify the current process (p) that it has a signal pending,
139 1.1 deraadt * process as soon as possible.
140 1.1 deraadt */
141 1.1 deraadt #define signotify(p) aston()
142 1.1 deraadt
143 1.1 deraadt #define aston() (astpending = 1)
144 1.1 deraadt
145 1.25 jonathan extern int astpending; /* need to trap before returning to user mode */
146 1.25 jonathan extern int want_resched; /* resched() was called */
147 1.25 jonathan #ifdef MIPS3
148 1.25 jonathan extern u_int mips_L2CacheSize;
149 1.25 jonathan extern int mips_L2CacheIsSnooping; /* L2 cache snoops uncached writes ? */
150 1.25 jonathan extern int mips_L2CacheMixed;
151 1.25 jonathan
152 1.25 jonathan #ifdef MIPS3_INTERNAL_TIMER_INTERRUPT
153 1.25 jonathan extern u_int32_t mips3_intr_cycle_count;
154 1.25 jonathan extern u_int32_t mips3_timer_delta;
155 1.25 jonathan #endif
156 1.25 jonathan #endif
157 1.5 glass
158 1.5 glass /*
159 1.5 glass * CTL_MACHDEP definitions.
160 1.5 glass */
161 1.5 glass #define CPU_CONSDEV 1 /* dev_t: console terminal device */
162 1.29 simonb #define CPU_BOOTED_KERNEL 2 /* string: booted kernel name */
163 1.29 simonb #define CPU_MAXID 3 /* number of valid machdep ids */
164 1.5 glass
165 1.5 glass #define CTL_MACHDEP_NAMES { \
166 1.5 glass { 0, 0 }, \
167 1.5 glass { "console_device", CTLTYPE_STRUCT }, \
168 1.29 simonb { "booted_kernel", CTLTYPE_STRING }, \
169 1.5 glass }
170 1.1 deraadt
171 1.28 castor #ifdef _KERNEL
172 1.28 castor
173 1.23 thorpej /*
174 1.23 thorpej * Misc prototypes.
175 1.23 thorpej */
176 1.28 castor struct proc;
177 1.28 castor struct user;
178 1.25 jonathan
179 1.28 castor /* trap.c */
180 1.28 castor void child_return __P((void *));
181 1.28 castor int kdbpeek __P((vaddr_t));
182 1.23 thorpej
183 1.28 castor /* mips_machdep.c */
184 1.23 thorpej void dumpsys __P((void));
185 1.23 thorpej int savectx __P((struct user *));
186 1.24 thorpej void mips_init_msgbuf __P((void));
187 1.13 jonathan
188 1.25 jonathan /* locore.S */
189 1.28 castor void savefpregs __P((struct proc *));
190 1.28 castor void switchfpregs __P((struct proc *, struct proc *));
191 1.28 castor int badaddr __P((void *, size_t));
192 1.25 jonathan
193 1.25 jonathan /* mips_machdep.c */
194 1.28 castor void cpu_identify __P((void));
195 1.28 castor void mips_vector_init __P((void));
196 1.27 thorpej
197 1.28 castor #endif /* _KERNEL */
198 1.1 deraadt
199 1.1 deraadt #endif /* _CPU_H_ */
200