| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cpu.h,v 1.85 2008/03/11 05:34:02 matt Exp $ */ | | 1 | /* $NetBSD: cpu.h,v 1.85.14.1 2012/08/22 20:59:47 bouyer Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1994 Ludd, University of Lule}, Sweden | | 4 | * Copyright (c) 1994 Ludd, University of Lule}, Sweden |
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. |
| @@ -155,27 +155,38 @@ struct cpu_info { | | | @@ -155,27 +155,38 @@ struct cpu_info { |
155 | extern int cpu_printfataltraps; | | 155 | extern int cpu_printfataltraps; |
156 | | | 156 | |
157 | #define curcpu() (curlwp->l_cpu + 0) | | 157 | #define curcpu() (curlwp->l_cpu + 0) |
158 | #define curlwp ((struct lwp *)mfpr(PR_SSP)) | | 158 | #define curlwp ((struct lwp *)mfpr(PR_SSP)) |
159 | #define cpu_number() (curcpu()->ci_cpuid) | | 159 | #define cpu_number() (curcpu()->ci_cpuid) |
160 | #define cpu_need_resched(ci, flags) \ | | 160 | #define cpu_need_resched(ci, flags) \ |
161 | do { \ | | 161 | do { \ |
162 | (ci)->ci_want_resched = 1; \ | | 162 | (ci)->ci_want_resched = 1; \ |
163 | mtpr(AST_OK,PR_ASTLVL); \ | | 163 | mtpr(AST_OK,PR_ASTLVL); \ |
164 | } while (/*CONSTCOND*/ 0) | | 164 | } while (/*CONSTCOND*/ 0) |
165 | #define cpu_proc_fork(x, y) do { } while (/*CONSCOND*/0) | | 165 | #define cpu_proc_fork(x, y) do { } while (/*CONSCOND*/0) |
166 | #define cpu_lwp_free(l, f) do { } while (/*CONSCOND*/0) | | 166 | #define cpu_lwp_free(l, f) do { } while (/*CONSCOND*/0) |
167 | #define cpu_lwp_free2(l) do { } while (/*CONSCOND*/0) | | 167 | #define cpu_lwp_free2(l) do { } while (/*CONSCOND*/0) |
168 | #define cpu_idle() do { } while (/*CONSCOND*/0) | | 168 | |
| | | 169 | /* |
| | | 170 | * This allows SIMH to recognize the kernel wants to sleep. |
| | | 171 | */ |
| | | 172 | static inline void |
| | | 173 | cpu_idle(void) |
| | | 174 | { |
| | | 175 | int ipl = mfpr(PR_IPL); |
| | | 176 | mtpr(1, PR_IPL); |
| | | 177 | mtpr(ipl, PR_IPL); |
| | | 178 | } |
| | | 179 | |
169 | static inline bool | | 180 | static inline bool |
170 | cpu_intr_p(void) | | 181 | cpu_intr_p(void) |
171 | { | | 182 | { |
172 | register_t psl; | | 183 | register_t psl; |
173 | __asm("movpsl %0" : "=g"(psl)); | | 184 | __asm("movpsl %0" : "=g"(psl)); |
174 | return (psl & PSL_IS) != 0; | | 185 | return (psl & PSL_IS) != 0; |
175 | } | | 186 | } |
176 | #if defined(MULTIPROCESSOR) | | 187 | #if defined(MULTIPROCESSOR) |
177 | #define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CI_MASTERCPU) | | 188 | #define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CI_MASTERCPU) |
178 | | | 189 | |
179 | #define CPU_INFO_ITERATOR int | | 190 | #define CPU_INFO_ITERATOR int |
180 | #define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = SIMPLEQ_FIRST(&cpus); \ | | 191 | #define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = SIMPLEQ_FIRST(&cpus); \ |
181 | ci != NULL; \ | | 192 | ci != NULL; \ |