locore.h revision 1.78.36.1.2.7 1 1.78.36.1.2.7 matt /* $NetBSD: locore.h,v 1.78.36.1.2.7 2009/12/30 04:51:26 matt Exp $ */
2 1.1 jonathan
3 1.1 jonathan /*
4 1.1 jonathan * Copyright 1996 The Board of Trustees of The Leland Stanford
5 1.1 jonathan * Junior University. All Rights Reserved.
6 1.1 jonathan *
7 1.1 jonathan * Permission to use, copy, modify, and distribute this
8 1.1 jonathan * software and its documentation for any purpose and without
9 1.1 jonathan * fee is hereby granted, provided that the above copyright
10 1.1 jonathan * notice appear in all copies. Stanford University
11 1.1 jonathan * makes no representations about the suitability of this
12 1.1 jonathan * software for any purpose. It is provided "as is" without
13 1.1 jonathan * express or implied warranty.
14 1.1 jonathan */
15 1.1 jonathan
16 1.1 jonathan /*
17 1.68 wiz * Jump table for MIPS CPU locore functions that are implemented
18 1.1 jonathan * differently on different generations, or instruction-level
19 1.1 jonathan * archtecture (ISA) level, the Mips family.
20 1.1 jonathan *
21 1.33 soren * We currently provide support for MIPS I and MIPS III.
22 1.1 jonathan */
23 1.1 jonathan
24 1.1 jonathan #ifndef _MIPS_LOCORE_H
25 1.70 tsutsui #define _MIPS_LOCORE_H
26 1.2 jonathan
27 1.17 castor #ifndef _LKM
28 1.32 soren #include "opt_cputype.h"
29 1.17 castor #endif
30 1.16 castor
31 1.59 simonb #include <mips/cpuregs.h>
32 1.59 simonb
33 1.38 cgd struct tlb;
34 1.38 cgd
35 1.59 simonb uint32_t mips_cp0_cause_read(void);
36 1.59 simonb void mips_cp0_cause_write(uint32_t);
37 1.59 simonb uint32_t mips_cp0_status_read(void);
38 1.59 simonb void mips_cp0_status_write(uint32_t);
39 1.29 simonb
40 1.77 tsutsui int _splraise(int);
41 1.77 tsutsui int _spllower(int);
42 1.77 tsutsui int _splset(int);
43 1.77 tsutsui int _splget(void);
44 1.77 tsutsui void _splnone(void);
45 1.77 tsutsui void _setsoftintr(int);
46 1.77 tsutsui void _clrsoftintr(int);
47 1.77 tsutsui
48 1.59 simonb #ifdef MIPS1
49 1.54 simonb void mips1_SetPID(int);
50 1.38 cgd void mips1_TBIA(int);
51 1.38 cgd void mips1_TBIAP(int);
52 1.38 cgd void mips1_TBIS(vaddr_t);
53 1.78.36.1.2.6 matt int mips1_TLBUpdate(vaddr_t, uint32_t);
54 1.38 cgd void mips1_wbflush(void);
55 1.76 yamt void mips1_lwp_trampoline(void);
56 1.78.36.1 snj void mips1_setfunc_trampoline(void);
57 1.38 cgd void mips1_cpu_switch_resume(void);
58 1.38 cgd
59 1.58 thorpej uint32_t tx3900_cp0_config_read(void);
60 1.59 simonb #endif
61 1.38 cgd
62 1.59 simonb #if defined(MIPS3) || defined(MIPS4)
63 1.54 simonb void mips3_SetPID(int);
64 1.38 cgd void mips3_TBIA(int);
65 1.38 cgd void mips3_TBIAP(int);
66 1.38 cgd void mips3_TBIS(vaddr_t);
67 1.78.36.1.2.6 matt int mips3_TLBUpdate(vaddr_t, uint32_t);
68 1.38 cgd void mips3_TLBRead(int, struct tlb *);
69 1.71 tsutsui void mips3_TLBWriteIndexedVPS(int, struct tlb *);
70 1.38 cgd void mips3_wbflush(void);
71 1.76 yamt void mips3_lwp_trampoline(void);
72 1.78.36.1 snj void mips3_setfunc_trampoline(void);
73 1.38 cgd void mips3_cpu_switch_resume(void);
74 1.75 christos void mips3_pagezero(void *dst);
75 1.38 cgd
76 1.59 simonb #ifdef MIPS3_5900
77 1.59 simonb void mips5900_SetPID(int);
78 1.59 simonb void mips5900_TBIA(int);
79 1.59 simonb void mips5900_TBIAP(int);
80 1.59 simonb void mips5900_TBIS(vaddr_t);
81 1.78.36.1.2.6 matt int mips5900_TLBUpdate(vaddr_t, uint32_t);
82 1.59 simonb void mips5900_TLBRead(int, struct tlb *);
83 1.71 tsutsui void mips5900_TLBWriteIndexedVPS(int, struct tlb *);
84 1.59 simonb void mips5900_wbflush(void);
85 1.76 yamt void mips5900_lwp_trampoline(void);
86 1.78.36.1 snj void mips5900_setfunc_trampoline(void);
87 1.59 simonb void mips5900_cpu_switch_resume(void);
88 1.75 christos void mips5900_pagezero(void *dst);
89 1.59 simonb #endif
90 1.59 simonb #endif
91 1.49 cgd
92 1.59 simonb #ifdef MIPS32
93 1.59 simonb void mips32_SetPID(int);
94 1.59 simonb void mips32_TBIA(int);
95 1.59 simonb void mips32_TBIAP(int);
96 1.59 simonb void mips32_TBIS(vaddr_t);
97 1.78.36.1.2.6 matt int mips32_TLBUpdate(vaddr_t, uint32_t);
98 1.59 simonb void mips32_TLBRead(int, struct tlb *);
99 1.71 tsutsui void mips32_TLBWriteIndexedVPS(int, struct tlb *);
100 1.59 simonb void mips32_wbflush(void);
101 1.76 yamt void mips32_lwp_trampoline(void);
102 1.78.36.1 snj void mips32_setfunc_trampoline(void);
103 1.59 simonb void mips32_cpu_switch_resume(void);
104 1.59 simonb #endif
105 1.59 simonb
106 1.59 simonb #ifdef MIPS64
107 1.59 simonb void mips64_SetPID(int);
108 1.59 simonb void mips64_TBIA(int);
109 1.59 simonb void mips64_TBIAP(int);
110 1.59 simonb void mips64_TBIS(vaddr_t);
111 1.78.36.1.2.6 matt int mips64_TLBUpdate(vaddr_t, uint32_t);
112 1.59 simonb void mips64_TLBRead(int, struct tlb *);
113 1.71 tsutsui void mips64_TLBWriteIndexedVPS(int, struct tlb *);
114 1.59 simonb void mips64_wbflush(void);
115 1.76 yamt void mips64_lwp_trampoline(void);
116 1.78.36.1 snj void mips64_setfunc_trampoline(void);
117 1.59 simonb void mips64_cpu_switch_resume(void);
118 1.75 christos void mips64_pagezero(void *dst);
119 1.59 simonb #endif
120 1.49 cgd
121 1.63 simonb #if defined(MIPS3) || defined(MIPS4) || defined(MIPS32) || defined(MIPS64)
122 1.59 simonb uint32_t mips3_cp0_compare_read(void);
123 1.59 simonb void mips3_cp0_compare_write(uint32_t);
124 1.49 cgd
125 1.59 simonb uint32_t mips3_cp0_config_read(void);
126 1.59 simonb void mips3_cp0_config_write(uint32_t);
127 1.63 simonb #if defined(MIPS32) || defined(MIPS64)
128 1.59 simonb uint32_t mipsNN_cp0_config1_read(void);
129 1.59 simonb void mipsNN_cp0_config1_write(uint32_t);
130 1.63 simonb uint32_t mipsNN_cp0_config2_read(void);
131 1.63 simonb uint32_t mipsNN_cp0_config3_read(void);
132 1.63 simonb #endif
133 1.59 simonb
134 1.59 simonb uint32_t mips3_cp0_count_read(void);
135 1.59 simonb void mips3_cp0_count_write(uint32_t);
136 1.59 simonb
137 1.59 simonb uint32_t mips3_cp0_wired_read(void);
138 1.59 simonb void mips3_cp0_wired_write(uint32_t);
139 1.69 tsutsui void mips3_cp0_pg_mask_write(uint32_t);
140 1.59 simonb
141 1.78.36.1.2.1 matt #if defined(__GNUC__) && !defined(__mips_o32)
142 1.78.36.1.2.1 matt static inline uint64_t
143 1.78.36.1.2.5 matt mips3_ld(const volatile uint64_t *va)
144 1.78.36.1.2.1 matt {
145 1.78.36.1.2.1 matt uint64_t rv;
146 1.78.36.1.2.1 matt #if defined(__mips_o32)
147 1.78.36.1.2.1 matt uint32_t sr;
148 1.78.36.1.2.1 matt
149 1.78.36.1.2.1 matt sr = mips_cp0_status_read();
150 1.78.36.1.2.1 matt mips_cp0_status_write(sr & ~MIPS_SR_INT_IE);
151 1.78.36.1.2.1 matt
152 1.78.36.1.2.1 matt __asm volatile(
153 1.78.36.1.2.1 matt ".set push \n\t"
154 1.78.36.1.2.1 matt ".set mips3 \n\t"
155 1.78.36.1.2.1 matt ".set noreorder \n\t"
156 1.78.36.1.2.1 matt ".set noat \n\t"
157 1.78.36.1.2.1 matt "ld %M0,0(%1) \n\t"
158 1.78.36.1.2.1 matt "dsll32 %L0,%M0,0 \n\t"
159 1.78.36.1.2.1 matt "dsra32 %M0,%M0,0 \n\t" /* high word */
160 1.78.36.1.2.1 matt "dsra32 %L0,%L0,0 \n\t" /* low word */
161 1.78.36.1.2.1 matt "ld %0,0(%1) \n\t"
162 1.78.36.1.2.1 matt ".set pop"
163 1.78.36.1.2.1 matt : "=d"(rv)
164 1.78.36.1.2.1 matt : "r"(va));
165 1.78.36.1.2.1 matt
166 1.78.36.1.2.1 matt mips_cp0_status_write(sr);
167 1.78.36.1.2.1 matt #elif defined(_LP64)
168 1.78.36.1.2.1 matt rv = *va;
169 1.78.36.1.2.1 matt #else
170 1.78.36.1.2.1 matt __asm volatile("ld %0,0(%1)" : "=d"(rv) : "r"(va));
171 1.78.36.1.2.1 matt #endif
172 1.78.36.1.2.1 matt
173 1.78.36.1.2.1 matt return rv;
174 1.78.36.1.2.1 matt }
175 1.78.36.1.2.1 matt static inline void
176 1.78.36.1.2.5 matt mips3_sd(volatile uint64_t *va, uint64_t v)
177 1.78.36.1.2.1 matt {
178 1.78.36.1.2.1 matt #if defined(__mips_o32)
179 1.78.36.1.2.1 matt uint32_t sr;
180 1.78.36.1.2.1 matt
181 1.78.36.1.2.1 matt sr = mips_cp0_status_read();
182 1.78.36.1.2.1 matt mips_cp0_status_write(sr & ~MIPS_SR_INT_IE);
183 1.78.36.1.2.1 matt
184 1.78.36.1.2.1 matt __asm volatile(
185 1.78.36.1.2.1 matt ".set push \n\t"
186 1.78.36.1.2.1 matt ".set mips3 \n\t"
187 1.78.36.1.2.1 matt ".set noreorder \n\t"
188 1.78.36.1.2.1 matt ".set noat \n\t"
189 1.78.36.1.2.1 matt "dsll32 %M0,%M0,0 \n\t"
190 1.78.36.1.2.1 matt "dsll32 %L0,%L0,0 \n\t"
191 1.78.36.1.2.1 matt "dsrl32 %L0,%L0,0 \n\t"
192 1.78.36.1.2.1 matt "or %0,%L0,%M0 \n\t"
193 1.78.36.1.2.1 matt "sd %0,0(%1) \n\t"
194 1.78.36.1.2.1 matt ".set pop"
195 1.78.36.1.2.1 matt : "=d"(v) : "0"(v), "r"(va));
196 1.78.36.1.2.1 matt
197 1.78.36.1.2.1 matt mips_cp0_status_write(sr);
198 1.78.36.1.2.1 matt #elif defined(_LP64)
199 1.78.36.1.2.1 matt *va = v;
200 1.78.36.1.2.1 matt #else
201 1.78.36.1.2.1 matt __asm volatile("sd %0,0(%1)" :: "r"(v), "r"(va));
202 1.78.36.1.2.1 matt #endif
203 1.78.36.1.2.1 matt }
204 1.78.36.1.2.1 matt #else
205 1.78.36.1.2.5 matt uint64_t mips3_ld(volatile uint64_t *va);
206 1.78.36.1.2.5 matt void mips3_sd(volatile uint64_t *, uint64_t);
207 1.78.36.1.2.1 matt #endif /* __GNUC__ */
208 1.63 simonb #endif /* MIPS3 || MIPS4 || MIPS32 || MIPS64 */
209 1.59 simonb
210 1.63 simonb #if defined(MIPS3) || defined(MIPS4) || defined(MIPS64)
211 1.74 perry static __inline uint32_t mips3_lw_a64(uint64_t addr)
212 1.59 simonb __attribute__((__unused__));
213 1.74 perry static __inline void mips3_sw_a64(uint64_t addr, uint32_t val)
214 1.59 simonb __attribute__ ((__unused__));
215 1.59 simonb
216 1.74 perry static __inline uint32_t
217 1.59 simonb mips3_lw_a64(uint64_t addr)
218 1.59 simonb {
219 1.59 simonb uint32_t rv;
220 1.78.36.1.2.1 matt #if defined(__mips_o32)
221 1.59 simonb uint32_t sr;
222 1.59 simonb
223 1.59 simonb sr = mips_cp0_status_read();
224 1.78.36.1.2.1 matt mips_cp0_status_write((sr & ~MIPS_SR_INT_IE) | MIPS3_SR_KX);
225 1.59 simonb
226 1.78.36.1.2.1 matt __asm volatile (
227 1.78.36.1.2.1 matt ".set push \n\t"
228 1.78.36.1.2.1 matt ".set mips3 \n\t"
229 1.78.36.1.2.1 matt ".set noreorder \n\t"
230 1.78.36.1.2.1 matt ".set noat \n\t"
231 1.78.36.1.2.1 matt "dsll32 %M1,%M1,0 \n\t"
232 1.78.36.1.2.1 matt "dsll32 %L1,%L1,0 \n\t"
233 1.78.36.1.2.1 matt "dsrl32 $L1,%L1,0 \n\t"
234 1.78.36.1.2.1 matt "or %1,%M1,%L1 \n\t"
235 1.78.36.1.2.1 matt "lw %0, 0(%1) \n\t"
236 1.78.36.1.2.1 matt ".set pop"
237 1.78.36.1.2.1 matt : "=r"(rv), "=d"(addr)
238 1.78.36.1.2.1 matt : "1"(addr)
239 1.78.36.1.2.1 matt );
240 1.59 simonb
241 1.59 simonb mips_cp0_status_write(sr);
242 1.78.36.1.2.1 matt #elif defined(_LP64)
243 1.78.36.1.2.1 matt rv = *(const uint32_t *)addr;
244 1.78.36.1.2.1 matt #else
245 1.78.36.1.2.1 matt __asm volatile("lw %0, 0(%1)" : "=r"(rv) : "d"(addr));
246 1.78.36.1.2.1 matt #endif
247 1.59 simonb return (rv);
248 1.59 simonb }
249 1.59 simonb
250 1.74 perry static __inline void
251 1.59 simonb mips3_sw_a64(uint64_t addr, uint32_t val)
252 1.59 simonb {
253 1.78.36.1.2.1 matt #if defined(__mips_o32)
254 1.59 simonb uint32_t sr;
255 1.59 simonb
256 1.59 simonb sr = mips_cp0_status_read();
257 1.78.36.1.2.1 matt mips_cp0_status_write((sr & ~MIPS_SR_INT_IE) | MIPS3_SR_KX);
258 1.59 simonb
259 1.78.36.1.2.1 matt __asm volatile (
260 1.78.36.1.2.1 matt ".set push \n\t"
261 1.78.36.1.2.1 matt ".set mips3 \n\t"
262 1.78.36.1.2.1 matt ".set noreorder \n\t"
263 1.78.36.1.2.1 matt ".set noat \n\t"
264 1.78.36.1.2.1 matt "dsll32 %M0,%M0,0 \n\t"
265 1.78.36.1.2.1 matt "dsll32 %L0,%L0,0 \n\t"
266 1.78.36.1.2.1 matt "dsrl32 $L0,%L0,0 \n\t"
267 1.78.36.1.2.1 matt "or %0,%M0,%L0 \n\t"
268 1.78.36.1.2.1 matt "sw %1, 0(%0) \n\t"
269 1.78.36.1.2.1 matt ".set pop"
270 1.78.36.1.2.1 matt : "=d"(addr): "r"(val), "0"(addr)
271 1.78.36.1.2.1 matt );
272 1.44 cgd
273 1.59 simonb mips_cp0_status_write(sr);
274 1.78.36.1.2.1 matt #elif defined(_LP64)
275 1.78.36.1.2.1 matt *(uint32_t *)addr = val;
276 1.78.36.1.2.1 matt #else
277 1.78.36.1.2.1 matt __asm volatile("sw %1, 0(%0)" :: "d"(addr), "r"(val));
278 1.78.36.1.2.1 matt #endif
279 1.59 simonb }
280 1.63 simonb #endif /* MIPS3 || MIPS4 || MIPS64 */
281 1.7 jonathan
282 1.1 jonathan /*
283 1.58 thorpej * A vector with an entry for each mips-ISA-level dependent
284 1.1 jonathan * locore function, and macros which jump through it.
285 1.58 thorpej *
286 1.1 jonathan * XXX the macro names are chosen to be compatible with the old
287 1.58 thorpej * XXX Sprite coding-convention names used in 4.4bsd/pmax.
288 1.1 jonathan */
289 1.1 jonathan typedef struct {
290 1.38 cgd void (*setTLBpid)(int pid);
291 1.38 cgd void (*TBIAP)(int);
292 1.38 cgd void (*TBIS)(vaddr_t);
293 1.78.36.1.2.6 matt int (*tlbUpdate)(vaddr_t, uint32_t);
294 1.38 cgd void (*wbflush)(void);
295 1.1 jonathan } mips_locore_jumpvec_t;
296 1.13 jonathan
297 1.38 cgd void mips_set_wbflush(void (*)(void));
298 1.62 simonb void mips_wait_idle(void);
299 1.1 jonathan
300 1.38 cgd void stacktrace(void);
301 1.38 cgd void logstacktrace(void);
302 1.1 jonathan
303 1.78.36.1.2.2 matt struct locoresw {
304 1.78.36.1.2.2 matt uintptr_t lsw_cpu_switch_resume;
305 1.78.36.1.2.2 matt uintptr_t lsw_lwp_trampoline;
306 1.78.36.1.2.2 matt void (*lsw_cpu_idle)(void);
307 1.78.36.1.2.2 matt uintptr_t lsw_setfunc_trampoline;
308 1.78.36.1.2.2 matt };
309 1.78.36.1.2.2 matt
310 1.78.36.1.2.7 matt struct mips_vmfreelist {
311 1.78.36.1.2.7 matt paddr_t fl_start;
312 1.78.36.1.2.7 matt paddr_t fl_end;
313 1.78.36.1.2.7 matt int fl_freelist;
314 1.78.36.1.2.7 matt };
315 1.78.36.1.2.7 matt
316 1.1 jonathan /*
317 1.1 jonathan * The "active" locore-fuction vector, and
318 1.1 jonathan */
319 1.1 jonathan extern mips_locore_jumpvec_t mips_locore_jumpvec;
320 1.78.36.1.2.2 matt extern struct locoresw mips_locoresw;
321 1.1 jonathan
322 1.59 simonb #if defined(MIPS1) && !defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64)
323 1.11 jonathan #define MachSetPID mips1_SetPID
324 1.30 nisimura #define MIPS_TBIAP() mips1_TBIAP(mips_num_tlb_entries)
325 1.30 nisimura #define MIPS_TBIS mips1_TBIS
326 1.11 jonathan #define MachTLBUpdate mips1_TLBUpdate
327 1.22 nisimura #define wbflush() mips1_wbflush()
328 1.76 yamt #define lwp_trampoline mips1_lwp_trampoline
329 1.78.36.1 snj #define setfunc_trampoline mips1_setfunc_trampoline
330 1.60 uch #elif !defined(MIPS1) && defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64) && !defined(MIPS3_5900)
331 1.59 simonb #define MachSetPID mips3_SetPID
332 1.59 simonb #define MIPS_TBIAP() mips3_TBIAP(mips_num_tlb_entries)
333 1.59 simonb #define MIPS_TBIS mips3_TBIS
334 1.59 simonb #define MachTLBUpdate mips3_TLBUpdate
335 1.71 tsutsui #define MachTLBWriteIndexedVPS mips3_TLBWriteIndexedVPS
336 1.76 yamt #define lwp_trampoline mips3_lwp_trampoline
337 1.78.36.1 snj #define setfunc_trampoline mips3_setfunc_trampoline
338 1.59 simonb #define wbflush() mips3_wbflush()
339 1.59 simonb #elif !defined(MIPS1) && !defined(MIPS3) && defined(MIPS32) && !defined(MIPS64)
340 1.70 tsutsui #define MachSetPID mips32_SetPID
341 1.70 tsutsui #define MIPS_TBIAP() mips32_TBIAP(mips_num_tlb_entries)
342 1.70 tsutsui #define MIPS_TBIS mips32_TBIS
343 1.70 tsutsui #define MachTLBUpdate mips32_TLBUpdate
344 1.71 tsutsui #define MachTLBWriteIndexedVPS mips32_TLBWriteIndexedVPS
345 1.76 yamt #define lwp_trampoline mips32_lwp_trampoline
346 1.78.36.1 snj #define setfunc_trampoline mips32_setfunc_trampoline
347 1.59 simonb #define wbflush() mips32_wbflush()
348 1.59 simonb #elif !defined(MIPS1) && !defined(MIPS3) && !defined(MIPS32) && defined(MIPS64)
349 1.59 simonb /* all common with mips3 */
350 1.59 simonb #define MachSetPID mips64_SetPID
351 1.59 simonb #define MIPS_TBIAP() mips64_TBIAP(mips_num_tlb_entries)
352 1.59 simonb #define MIPS_TBIS mips64_TBIS
353 1.59 simonb #define MachTLBUpdate mips64_TLBUpdate
354 1.71 tsutsui #define MachTLBWriteIndexedVPS mips64_TLBWriteIndexedVPS
355 1.76 yamt #define lwp_trampoline mips64_lwp_trampoline
356 1.78.36.1 snj #define setfunc_trampoline mips64_setfunc_trampoline
357 1.59 simonb #define wbflush() mips64_wbflush()
358 1.60 uch #elif !defined(MIPS1) && defined(MIPS3) && !defined(MIPS32) && !defined(MIPS64) && defined(MIPS3_5900)
359 1.60 uch #define MachSetPID mips5900_SetPID
360 1.60 uch #define MIPS_TBIAP() mips5900_TBIAP(mips_num_tlb_entries)
361 1.60 uch #define MIPS_TBIS mips5900_TBIS
362 1.60 uch #define MachTLBUpdate mips5900_TLBUpdate
363 1.71 tsutsui #define MachTLBWriteIndexedVPS mips5900_TLBWriteIndexedVPS
364 1.76 yamt #define lwp_trampoline mips5900_lwp_trampoline
365 1.78.36.1 snj #define setfunc_trampoline mips5900_setfunc_trampoline
366 1.60 uch #define wbflush() mips5900_wbflush()
367 1.59 simonb #else
368 1.1 jonathan #define MachSetPID (*(mips_locore_jumpvec.setTLBpid))
369 1.31 nisimura #define MIPS_TBIAP() (*(mips_locore_jumpvec.TBIAP))(mips_num_tlb_entries)
370 1.31 nisimura #define MIPS_TBIS (*(mips_locore_jumpvec.TBIS))
371 1.1 jonathan #define MachTLBUpdate (*(mips_locore_jumpvec.tlbUpdate))
372 1.22 nisimura #define wbflush() (*(mips_locore_jumpvec.wbflush))()
373 1.78.36.1.2.2 matt #define lwp_trampoline mips_locoresw.lsw_lwp_trampoline
374 1.78.36.1.2.2 matt #define setfunc_trampoline mips_locoresw.lsw_setfunc_trampoline
375 1.11 jonathan #endif
376 1.31 nisimura
377 1.78.36.1.2.2 matt #define CPU_IDLE mips_locoresw.lsw_cpu_idle
378 1.11 jonathan
379 1.16 castor /* cpu_switch_resume is called inside locore.S */
380 1.7 jonathan
381 1.7 jonathan /*
382 1.7 jonathan * CPU identification, from PRID register.
383 1.7 jonathan */
384 1.40 cgd typedef int mips_prid_t;
385 1.40 cgd
386 1.70 tsutsui #define MIPS_PRID_REV(x) (((x) >> 0) & 0x00ff)
387 1.70 tsutsui #define MIPS_PRID_IMPL(x) (((x) >> 8) & 0x00ff)
388 1.45 cgd
389 1.59 simonb /* pre-MIPS32/64 */
390 1.70 tsutsui #define MIPS_PRID_RSVD(x) (((x) >> 16) & 0xffff)
391 1.70 tsutsui #define MIPS_PRID_REV_MIN(x) ((MIPS_PRID_REV(x) >> 0) & 0x0f)
392 1.70 tsutsui #define MIPS_PRID_REV_MAJ(x) ((MIPS_PRID_REV(x) >> 4) & 0x0f)
393 1.45 cgd
394 1.59 simonb /* MIPS32/64 */
395 1.70 tsutsui #define MIPS_PRID_CID(x) (((x) >> 16) & 0x00ff) /* Company ID */
396 1.70 tsutsui #define MIPS_PRID_CID_PREHISTORIC 0x00 /* Not MIPS32/64 */
397 1.70 tsutsui #define MIPS_PRID_CID_MTI 0x01 /* MIPS Technologies, Inc. */
398 1.70 tsutsui #define MIPS_PRID_CID_BROADCOM 0x02 /* Broadcom */
399 1.70 tsutsui #define MIPS_PRID_CID_ALCHEMY 0x03 /* Alchemy Semiconductor */
400 1.70 tsutsui #define MIPS_PRID_CID_SIBYTE 0x04 /* SiByte */
401 1.70 tsutsui #define MIPS_PRID_CID_SANDCRAFT 0x05 /* SandCraft */
402 1.70 tsutsui #define MIPS_PRID_CID_PHILIPS 0x06 /* Philips */
403 1.70 tsutsui #define MIPS_PRID_CID_TOSHIBA 0x07 /* Toshiba */
404 1.70 tsutsui #define MIPS_PRID_CID_LSI 0x08 /* LSI */
405 1.67 simonb /* 0x09 unannounced */
406 1.67 simonb /* 0x0a unannounced */
407 1.70 tsutsui #define MIPS_PRID_CID_LEXRA 0x0b /* Lexra */
408 1.78.36.1.2.3 matt #define MIPS_PRID_CID_RMI 0x0c /* RMI / NetLogic */
409 1.70 tsutsui #define MIPS_PRID_COPTS(x) (((x) >> 24) & 0x00ff) /* Company Options */
410 1.6 jonathan
411 1.6 jonathan #ifdef _KERNEL
412 1.6 jonathan /*
413 1.6 jonathan * Global variables used to communicate CPU type, and parameters
414 1.6 jonathan * such as cache size, from locore to higher-level code (e.g., pmap).
415 1.6 jonathan */
416 1.40 cgd
417 1.40 cgd extern mips_prid_t cpu_id;
418 1.40 cgd extern mips_prid_t fpu_id;
419 1.14 jonathan extern int mips_num_tlb_entries;
420 1.52 jeffs
421 1.75 christos void mips_pagecopy(void *dst, void *src);
422 1.75 christos void mips_pagezero(void *dst);
423 1.19 jonathan
424 1.59 simonb #ifdef __HAVE_MIPS_MACHDEP_CACHE_CONFIG
425 1.59 simonb void mips_machdep_cache_config(void);
426 1.59 simonb #endif
427 1.59 simonb
428 1.19 jonathan /*
429 1.20 simonb * trapframe argument passed to trap()
430 1.19 jonathan */
431 1.64 thorpej
432 1.70 tsutsui #define TF_AST 0
433 1.70 tsutsui #define TF_V0 1
434 1.70 tsutsui #define TF_V1 2
435 1.70 tsutsui #define TF_A0 3
436 1.70 tsutsui #define TF_A1 4
437 1.70 tsutsui #define TF_A2 5
438 1.70 tsutsui #define TF_A3 6
439 1.70 tsutsui #define TF_T0 7
440 1.70 tsutsui #define TF_T1 8
441 1.70 tsutsui #define TF_T2 9
442 1.70 tsutsui #define TF_T3 10
443 1.64 thorpej
444 1.64 thorpej #if defined(__mips_n32) || defined(__mips_n64)
445 1.70 tsutsui #define TF_A4 11
446 1.70 tsutsui #define TF_A5 12
447 1.70 tsutsui #define TF_A6 13
448 1.70 tsutsui #define TF_A7 14
449 1.64 thorpej #else
450 1.70 tsutsui #define TF_T4 11
451 1.70 tsutsui #define TF_T5 12
452 1.70 tsutsui #define TF_T6 13
453 1.70 tsutsui #define TF_T7 14
454 1.64 thorpej #endif /* __mips_n32 || __mips_n64 */
455 1.64 thorpej
456 1.70 tsutsui #define TF_TA0 11
457 1.70 tsutsui #define TF_TA1 12
458 1.70 tsutsui #define TF_TA2 13
459 1.70 tsutsui #define TF_TA3 14
460 1.70 tsutsui
461 1.70 tsutsui #define TF_T8 15
462 1.70 tsutsui #define TF_T9 16
463 1.70 tsutsui
464 1.70 tsutsui #define TF_RA 17
465 1.70 tsutsui #define TF_SR 18
466 1.70 tsutsui #define TF_MULLO 19
467 1.70 tsutsui #define TF_MULHI 20
468 1.70 tsutsui #define TF_EPC 21 /* may be changed by trap() call */
469 1.65 thorpej
470 1.70 tsutsui #define TF_NREGS 22
471 1.64 thorpej
472 1.19 jonathan struct trapframe {
473 1.64 thorpej mips_reg_t tf_regs[TF_NREGS];
474 1.78.36.1.2.2 matt uint32_t tf_ppl; /* previous priority level */
475 1.78.36.1.2.2 matt mips_reg_t tf_pad; /* for 8 byte aligned */
476 1.19 jonathan };
477 1.19 jonathan
478 1.19 jonathan /*
479 1.19 jonathan * Stack frame for kernel traps. four args passed in registers.
480 1.19 jonathan * A trapframe is pointed to by the 5th arg, and a dummy sixth argument
481 1.19 jonathan * is used to avoid alignment problems
482 1.19 jonathan */
483 1.19 jonathan
484 1.19 jonathan struct kernframe {
485 1.78.36.1.2.1 matt #if defined(__mips_o32) || defined(__mips_o64)
486 1.19 jonathan register_t cf_args[4 + 1];
487 1.78.36.1.2.1 matt #if defined(__mips_o32)
488 1.19 jonathan register_t cf_pad; /* (for 8 word alignment) */
489 1.78.36.1.2.1 matt #endif
490 1.78.36.1.2.1 matt #endif
491 1.78.36.1.2.1 matt #if defined(__mips_n32) || defined(__mips_n64)
492 1.78.36.1.2.4 matt register_t cf_pad[2]; /* for 16 byte alignment */
493 1.78.36.1.2.1 matt #endif
494 1.19 jonathan register_t cf_sp;
495 1.19 jonathan register_t cf_ra;
496 1.19 jonathan struct trapframe cf_frame;
497 1.19 jonathan };
498 1.61 simonb #endif /* _KERNEL */
499 1.1 jonathan #endif /* _MIPS_LOCORE_H */
500