Fix cur{lwp,cpu} and other bits for MODULESdiff -r1.30 -r1.31 src/sys/arch/hppa/hppa/hppa_machdep.c
(skrll)
--- src/sys/arch/hppa/hppa/hppa_machdep.c 2019/11/23 19:40:35 1.30
+++ src/sys/arch/hppa/hppa/hppa_machdep.c 2020/04/16 09:28:52 1.31
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: hppa_machdep.c,v 1.30 2019/11/23 19:40:35 ad Exp $ */ | 1 | /* $NetBSD: hppa_machdep.c,v 1.31 2020/04/16 09:28:52 skrll Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.30 2019/11/23 19:40:35 ad Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.31 2020/04/16 09:28:52 skrll Exp $"); | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/systm.h> | 33 | #include <sys/systm.h> | |
34 | #include <sys/lwp.h> | 34 | #include <sys/lwp.h> | |
35 | #include <sys/proc.h> | 35 | #include <sys/proc.h> | |
36 | #include <sys/ras.h> | 36 | #include <sys/ras.h> | |
37 | #include <sys/cpu.h> | 37 | #include <sys/cpu.h> | |
38 | 38 | |||
39 | #include <sys/kernel.h> | 39 | #include <sys/kernel.h> | |
40 | 40 | |||
41 | #include <uvm/uvm_extern.h> | 41 | #include <uvm/uvm_extern.h> | |
42 | 42 | |||
43 | #include <machine/cpufunc.h> | 43 | #include <machine/cpufunc.h> | |
@@ -293,13 +293,28 @@ hppa_ras(struct lwp *l) | @@ -293,13 +293,28 @@ hppa_ras(struct lwp *l) | |||
293 | */ | 293 | */ | |
294 | void | 294 | void | |
295 | cpu_need_resched(struct cpu_info *ci, struct lwp *l, int flags) | 295 | cpu_need_resched(struct cpu_info *ci, struct lwp *l, int flags) | |
296 | { | 296 | { | |
297 | 297 | |||
298 | if ((flags & RESCHED_REMOTE) != 0) { | 298 | if ((flags & RESCHED_REMOTE) != 0) { | |
299 | #ifdef MULTIPROCESSOR | 299 | #ifdef MULTIPROCESSOR | |
300 | /* XXX send IPI */ | 300 | /* XXX send IPI */ | |
301 | #endif | 301 | #endif | |
302 | } else { | 302 | } else { | |
303 | setsoftast(l); | 303 | setsoftast(l); | |
304 | } | 304 | } | |
305 | } | 305 | } | |
306 | ||||
307 | #ifdef MODULAR | |||
308 | struct lwp * | |||
309 | hppa_curlwp(void) | |||
310 | { | |||
311 | return curlwp; | |||
312 | } | |||
313 | ||||
314 | struct cpu_info * | |||
315 | hppa_curcpu(void) | |||
316 | { | |||
317 | return curcpu(); | |||
318 | } | |||
319 | #endif | |||
320 |
--- src/sys/arch/hppa/include/cpu.h 2019/12/05 08:00:05 1.9
+++ src/sys/arch/hppa/include/cpu.h 2020/04/16 09:28:52 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpu.h,v 1.9 2019/12/05 08:00:05 skrll Exp $ */ | 1 | /* $NetBSD: cpu.h,v 1.10 2020/04/16 09:28:52 skrll Exp $ */ | |
2 | 2 | |||
3 | /* $OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $ */ | 3 | /* $OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $ */ | |
4 | 4 | |||
5 | /* | 5 | /* | |
6 | * Copyright (c) 2000-2004 Michael Shalayeff | 6 | * Copyright (c) 2000-2004 Michael Shalayeff | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -306,69 +306,79 @@ struct cpu_info { | @@ -306,69 +306,79 @@ struct cpu_info { | |||
306 | 306 | |||
307 | #endif /* _KERNEL || _KMEMUSER */ | 307 | #endif /* _KERNEL || _KMEMUSER */ | |
308 | #endif /* __ASSEMBLER__ */ | 308 | #endif /* __ASSEMBLER__ */ | |
309 | 309 | |||
310 | #if defined(_KERNEL) | 310 | #if defined(_KERNEL) | |
311 | 311 | |||
312 | /* | 312 | /* | |
313 | * definitions of cpu-dependent requirements | 313 | * definitions of cpu-dependent requirements | |
314 | * referenced in generic code | 314 | * referenced in generic code | |
315 | */ | 315 | */ | |
316 | 316 | |||
317 | void cpu_proc_fork(struct proc *, struct proc *); | 317 | void cpu_proc_fork(struct proc *, struct proc *); | |
318 | 318 | |||
319 | #ifdef MULTIPROCESSOR | 319 | struct lwp *hppa_curlwp(void); | |
320 | struct cpu_info *hppa_curcpu(void); | |||
321 | ||||
322 | #if defined(_MODULE) | |||
323 | #define curcpu() hppa_curcpu() | |||
324 | #define curlwp hppa_curlwp() | |||
325 | #endif | |||
320 | 326 | |||
327 | #if defined(MULTIPROCESSOR) || defined(_MODULE) | |||
321 | /* Number of CPUs in the system */ | 328 | /* Number of CPUs in the system */ | |
322 | extern int hppa_ncpu; | 329 | extern int hppa_ncpu; | |
323 | 330 | |||
324 | #define HPPA_MAXCPUS 4 | 331 | #define HPPA_MAXCPUS 4 | |
332 | ||||
325 | #define cpu_number() (curcpu()->ci_cpuid) | 333 | #define cpu_number() (curcpu()->ci_cpuid) | |
326 | 334 | |||
327 | #define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0) | 335 | #define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0) | |
328 | #define CPU_INFO_ITERATOR int | 336 | #define CPU_INFO_ITERATOR int | |
329 | #define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = &cpus[0]; cii < hppa_ncpu; cii++, ci++ | 337 | #define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = &cpus[0]; cii < hppa_ncpu; cii++, ci++ | |
330 | 338 | |||
331 | void cpu_boot_secondary_processors(void); | 339 | void cpu_boot_secondary_processors(void); | |
332 | 340 | |||
341 | #if !defined(_MODULE) | |||
333 | static __inline struct cpu_info * | 342 | static __inline struct cpu_info * | |
334 | hppa_curcpu(void) | 343 | _hppa_curcpu(void) | |
335 | { | 344 | { | |
336 | struct cpu_info *ci; | 345 | struct cpu_info *ci; | |
337 | 346 | |||
338 | __asm volatile("mfctl %1, %0" : "=r" (ci): "i" (CR_CURCPU)); | 347 | __asm volatile("mfctl %1, %0" : "=r" (ci): "i" (CR_CURCPU)); | |
339 | 348 | |||
340 | return ci; | 349 | return ci; | |
341 | } | 350 | } | |
342 | 351 | |||
343 | #define curcpu() hppa_curcpu() | 352 | #define curcpu() _hppa_curcpu() | |
353 | #endif | |||
344 | 354 | |||
345 | #else /* MULTIPROCESSOR */ | 355 | #else /* MULTIPROCESSOR */ | |
346 | 356 | |||
347 | #define HPPA_MAXCPUS 1 | 357 | #define HPPA_MAXCPUS 1 | |
348 | #define curcpu() (&cpus[0]) | 358 | #define curcpu() (&cpus[0]) | |
349 | #define cpu_number() 0 | 359 | #define cpu_number() 0 | |
350 | 360 | |||
351 | static __inline struct lwp * | 361 | static __inline struct lwp * | |
352 | hppa_curlwp(void) | 362 | _hppa_curlwp(void) | |
353 | { | 363 | { | |
354 | struct lwp *l; | 364 | struct lwp *l; | |
355 | 365 | |||
356 | __asm volatile("mfctl %1, %0" : "=r" (l): "i" (CR_CURLWP)); | 366 | __asm volatile("mfctl %1, %0" : "=r" (l): "i" (CR_CURLWP)); | |
357 | 367 | |||
358 | return l; | 368 | return l; | |
359 | } | 369 | } | |
360 | 370 | |||
361 | #define curlwp hppa_curlwp() | 371 | #define curlwp _hppa_curlwp() | |
362 | 372 | |||
363 | #endif /* MULTIPROCESSOR */ | 373 | #endif /* MULTIPROCESSOR */ | |
364 | 374 | |||
365 | extern struct cpu_info cpus[HPPA_MAXCPUS]; | 375 | extern struct cpu_info cpus[HPPA_MAXCPUS]; | |
366 | 376 | |||
367 | #define DELAY(x) delay(x) | 377 | #define DELAY(x) delay(x) | |
368 | 378 | |||
369 | static __inline paddr_t | 379 | static __inline paddr_t | |
370 | kvtop(const void *va) | 380 | kvtop(const void *va) | |
371 | { | 381 | { | |
372 | paddr_t pa; | 382 | paddr_t pa; | |
373 | 383 | |||
374 | __asm volatile ("lpa %%r0(%1), %0" : "=r" (pa) : "r" (va)); | 384 | __asm volatile ("lpa %%r0(%1), %0" : "=r" (pa) : "r" (va)); |