Wed Mar 31 12:56:14 2010 UTC ()
Make cpl, ipending, and intr_depth per CPU values.


(skrll)
diff -r1.22 -r1.23 src/sys/arch/hp700/hp700/genassym.cf
diff -r1.23 -r1.24 src/sys/arch/hp700/hp700/intr.c
diff -r1.44 -r1.45 src/sys/arch/hp700/hp700/locore.S
diff -r1.41 -r1.42 src/sys/arch/hp700/include/cpu.h
diff -r1.15 -r1.16 src/sys/arch/hp700/include/intr.h
diff -r1.12 -r1.13 src/sys/arch/hppa/hppa/machdep.h
diff -r1.84 -r1.85 src/sys/arch/hppa/hppa/trap.c

cvs diff -r1.22 -r1.23 src/sys/arch/hp700/hp700/Attic/genassym.cf (expand / switch to unified diff)

--- src/sys/arch/hp700/hp700/Attic/genassym.cf 2010/03/30 19:38:52 1.22
+++ src/sys/arch/hp700/hp700/Attic/genassym.cf 2010/03/31 12:56:14 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: genassym.cf,v 1.22 2010/03/30 19:38:52 skrll Exp $ 1# $NetBSD: genassym.cf,v 1.23 2010/03/31 12:56:14 skrll Exp $
2 2
3# $OpenBSD: genassym.cf,v 1.18 2001/09/20 18:31:14 mickey Exp $ 3# $OpenBSD: genassym.cf,v 1.18 2001/09/20 18:31:14 mickey Exp $
4 4
5# 5#
6# Copyright (c) 1982, 1990, 1993 6# Copyright (c) 1982, 1990, 1993
7# The Regents of the University of California. All rights reserved. 7# The Regents of the University of California. 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
@@ -75,27 +75,28 @@ export HPPA_LDCW_ALIGN @@ -75,27 +75,28 @@ export HPPA_LDCW_ALIGN
75 75
76# `break' entry points 76# `break' entry points
77export HPPA_BREAK_KERNEL 77export HPPA_BREAK_KERNEL
78export HPPA_BREAK_GET_PSW 78export HPPA_BREAK_GET_PSW
79export HPPA_BREAK_SET_PSW 79export HPPA_BREAK_SET_PSW
80 80
81# hp700_int_reg fields 81# hp700_int_reg fields
82struct hp700_int_reg 82struct hp700_int_reg
83member INT_REG_REQ int_reg_req 83member INT_REG_REQ int_reg_req
84member INT_REG_BITS_MAP int_reg_bits_map 84member INT_REG_BITS_MAP int_reg_bits_map
85export INT_REG_BIT_REG 85export INT_REG_BIT_REG
86 86
87# struct cpu_info fields 87# struct cpu_info fields
88#define CI_CPL offsetof(struct cpu_info, ci_cpl) 88define CI_CPL offsetof(struct cpu_info, ci_cpl)
 89define CI_IPENDING offsetof(struct cpu_info, ci_ipending)
89#define CI_INTR_DEPTH offsetof(struct cpu_info, ci_intr_depth) 90#define CI_INTR_DEPTH offsetof(struct cpu_info, ci_intr_depth)
90#define CI_SOFTLWPS offsetof(struct cpu_info, ci_softlwps) 91#define CI_SOFTLWPS offsetof(struct cpu_info, ci_softlwps)
91define CI_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count) 92define CI_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count)
92#define CI_CURLWP offsetof(struct cpu_info, ci_curlwp) 93#define CI_CURLWP offsetof(struct cpu_info, ci_curlwp)
93 94
94define MTX_IPL offsetof(struct kmutex, mtx_ipl) 95define MTX_IPL offsetof(struct kmutex, mtx_ipl)
95define MTX_LOCK offsetof(struct kmutex, mtx_lock) 96define MTX_LOCK offsetof(struct kmutex, mtx_lock)
96define MTX_OWNER offsetof(struct kmutex, mtx_owner) 97define MTX_OWNER offsetof(struct kmutex, mtx_owner)
97define MTX_WAITERS offsetof(struct kmutex, mtx_waiters) 98define MTX_WAITERS offsetof(struct kmutex, mtx_waiters)
98 99
99define RW_OWNER offsetof(struct krwlock, rw_owner) 100define RW_OWNER offsetof(struct krwlock, rw_owner)
100define RW_WRITE_LOCKED RW_WRITE_LOCKED 101define RW_WRITE_LOCKED RW_WRITE_LOCKED
101define RW_WRITE_WANTED RW_WRITE_WANTED 102define RW_WRITE_WANTED RW_WRITE_WANTED

cvs diff -r1.23 -r1.24 src/sys/arch/hp700/hp700/Attic/intr.c (expand / switch to unified diff)

--- src/sys/arch/hp700/hp700/Attic/intr.c 2010/03/24 12:38:55 1.23
+++ src/sys/arch/hp700/hp700/Attic/intr.c 2010/03/31 12:56:14 1.24
@@ -1,14 +1,16 @@ @@ -1,14 +1,16 @@
1/* $NetBSD: intr.c,v 1.23 2010/03/24 12:38:55 skrll Exp $ */ 1/* $NetBSD: intr.c,v 1.24 2010/03/31 12:56:14 skrll Exp $ */
 2/* $NetBSD: intr.c,v 1.24 2010/03/31 12:56:14 skrll Exp $ */
 3/* $OpenBSD: intr.c,v 1.27 2009/12/31 12:52:35 jsing Exp $ */
2 4
3/* 5/*
4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 6 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 7 * All rights reserved.
6 * 8 *
7 * This code is derived from software contributed to The NetBSD Foundation 9 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matthew Fredette. 10 * by Matthew Fredette.
9 * 11 *
10 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
12 * are met: 14 * are met:
13 * 1. Redistributions of source code must retain the above copyright 15 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 16 * notice, this list of conditions and the following disclaimer.
@@ -24,61 +26,52 @@ @@ -24,61 +26,52 @@
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 31 * POSSIBILITY OF SUCH DAMAGE.
30 */ 32 */
31 33
32/* 34/*
33 * Interrupt handling for NetBSD/hp700. 35 * Interrupt handling for NetBSD/hp700.
34 */ 36 */
35 37
36#include <sys/cdefs.h> 38#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.23 2010/03/24 12:38:55 skrll Exp $"); 39__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.24 2010/03/31 12:56:14 skrll Exp $");
38 40
39#define __MUTEX_PRIVATE 41#define __MUTEX_PRIVATE
40 42
41#include <sys/param.h> 43#include <sys/param.h>
42#include <sys/malloc.h> 44#include <sys/malloc.h>
43#include <sys/cpu.h> 45#include <sys/cpu.h>
44 46
45#include <machine/autoconf.h> 47#include <machine/autoconf.h>
46#include <machine/cpufunc.h> 48#include <machine/cpufunc.h>
47#include <machine/intr.h> 49#include <machine/intr.h>
48#include <machine/reg.h> 50#include <machine/reg.h>
49 51
50#include <hp700/hp700/intr.h> 52#include <hp700/hp700/intr.h>
51#include <hp700/hp700/machdep.h> 53#include <hp700/hp700/machdep.h>
52 54
53#include <uvm/uvm_extern.h> 55#include <uvm/uvm_extern.h>
54 56
55#include <machine/mutex.h> 57#include <machine/mutex.h>
56 58
57/* The priority level masks. */ 59/* The priority level masks. */
58int imask[NIPL]; 60int imask[NIPL];
59 61
60/* The current priority level. */ 
61volatile int cpl; 
62 
63/* The pending interrupts. */ 
64volatile int ipending; 
65 
66/* Shared interrupts */ 62/* Shared interrupts */
67int ishared; 63int ishared;
68 64
69/* Nonzero iff we are running an interrupt. */ 
70u_int hppa_intr_depth; 
71 
72/* The list of all interrupt registers. */ 65/* The list of all interrupt registers. */
73struct hp700_int_reg *hp700_int_regs[HP700_INT_BITS]; 66struct hp700_int_reg *hp700_int_regs[HP700_INT_BITS];
74 67
75/* 68/*
76 * The array of interrupt handler structures, one per bit. 69 * The array of interrupt handler structures, one per bit.
77 */ 70 */
78static struct hp700_int_bit { 71static struct hp700_int_bit {
79 72
80 /* The interrupt register this bit is in. */ 73 /* The interrupt register this bit is in. */
81 struct hp700_int_reg *int_bit_reg; 74 struct hp700_int_reg *int_bit_reg;
82 75
83 /* 76 /*
84 * The priority level associated with this bit, e.g, IPL_BIO, IPL_NET, 77 * The priority level associated with this bit, e.g, IPL_BIO, IPL_NET,
@@ -127,40 +120,41 @@ hp700_intr_reg_establish(struct hp700_in @@ -127,40 +120,41 @@ hp700_intr_reg_establish(struct hp700_in
127 if (hp700_int_regs[idx] == NULL) 120 if (hp700_int_regs[idx] == NULL)
128 break; 121 break;
129 if (idx == HP700_INT_BITS) 122 if (idx == HP700_INT_BITS)
130 panic("hp700_intr_reg_establish: too many regs"); 123 panic("hp700_intr_reg_establish: too many regs");
131 hp700_int_regs[idx] = int_reg; 124 hp700_int_regs[idx] = int_reg;
132} 125}
133 126
134/* 127/*
135 * This bootstraps interrupts. 128 * This bootstraps interrupts.
136 */ 129 */
137void 130void
138hp700_intr_bootstrap(void) 131hp700_intr_bootstrap(void)
139{ 132{
 133 struct cpu_info *ci = curcpu();
140 int i; 134 int i;
141 135
142 /* Initialize all prority level masks to mask everything. */ 136 /* Initialize all prority level masks to mask everything. */
143 for (i = 0; i < NIPL; i++) 137 for (i = 0; i < NIPL; i++)
144 imask[i] = -1; 138 imask[i] = -1;
145 139
146 /* We are now at the highest priority level. */ 140 /* We are now at the highest priority level. */
147 cpl = -1; 141 ci->ci_cpl = -1;
148 142
149 /* There are no pending interrupts. */ 143 /* There are no pending interrupts. */
150 ipending = 0; 144 ci->ci_ipending = 0;
151 145
152 /* We are not running an interrupt. */ 146 /* We are not running an interrupt. */
153 hppa_intr_depth = 0; 147 ci->ci_intr_depth = 0;
154 148
155 /* There are no interrupt handlers. */ 149 /* There are no interrupt handlers. */
156 memset(hp700_int_bits, 0, sizeof(hp700_int_bits)); 150 memset(hp700_int_bits, 0, sizeof(hp700_int_bits));
157 151
158 /* There are no interrupt registers. */ 152 /* There are no interrupt registers. */
159 memset(hp700_int_regs, 0, sizeof(hp700_int_regs)); 153 memset(hp700_int_regs, 0, sizeof(hp700_int_regs));
160 154
161 /* Initialize the CPU interrupt register description. */ 155 /* Initialize the CPU interrupt register description. */
162 hp700_intr_reg_establish(&int_reg_cpu); 156 hp700_intr_reg_establish(&int_reg_cpu);
163 int_reg_cpu.int_reg_dev = "cpu0"; /* XXX */ 157 int_reg_cpu.int_reg_dev = "cpu0"; /* XXX */
164} 158}
165 159
166/* 160/*
@@ -267,30 +261,31 @@ _hp700_intr_ipl_next(void) @@ -267,30 +261,31 @@ _hp700_intr_ipl_next(void)
267 */ 261 */
268int 262int
269_hp700_intr_spl_mask(void *_int_bit) 263_hp700_intr_spl_mask(void *_int_bit)
270{ 264{
271 return ((struct hp700_int_bit *) _int_bit)->int_bit_spl; 265 return ((struct hp700_int_bit *) _int_bit)->int_bit_spl;
272} 266}
273 267
274/* 268/*
275 * This finally initializes interrupts. 269 * This finally initializes interrupts.
276 */ 270 */
277void 271void
278hp700_intr_init(void) 272hp700_intr_init(void)
279{ 273{
280 int idx, bit_pos; 
281 struct hp700_int_bit *int_bit; 274 struct hp700_int_bit *int_bit;
282 int mask; 
283 struct hp700_int_reg *int_reg; 275 struct hp700_int_reg *int_reg;
 276 struct cpu_info *ci = curcpu();
 277 int idx, bit_pos;
 278 int mask;
284 int eiem; 279 int eiem;
285 280
286 /* 281 /*
287 * Put together the initial imask for each level. 282 * Put together the initial imask for each level.
288 */ 283 */
289 memset(imask, 0, sizeof(imask)); 284 memset(imask, 0, sizeof(imask));
290 for (bit_pos = 0; bit_pos < HP700_INT_BITS; bit_pos++) { 285 for (bit_pos = 0; bit_pos < HP700_INT_BITS; bit_pos++) {
291 int_bit = hp700_int_bits + bit_pos; 286 int_bit = hp700_int_bits + bit_pos;
292 if (int_bit->int_bit_reg == NULL) 287 if (int_bit->int_bit_reg == NULL)
293 continue; 288 continue;
294 imask[int_bit->int_bit_ipl] |= int_bit->int_bit_spl; 289 imask[int_bit->int_bit_ipl] |= int_bit->int_bit_spl;
295 } 290 }
296  291
@@ -329,28 +324,28 @@ hp700_intr_init(void) @@ -329,28 +324,28 @@ hp700_intr_init(void)
329 for (bit_pos = 0; bit_pos < NIPL; bit_pos++) 324 for (bit_pos = 0; bit_pos < NIPL; bit_pos++)
330 printf("imask[%d] == %08x\n", bit_pos, imask[bit_pos]); 325 printf("imask[%d] == %08x\n", bit_pos, imask[bit_pos]);
331#endif 326#endif
332 327
333 /* 328 /*
334 * Load all mask registers, loading %eiem last. This will finally 329 * Load all mask registers, loading %eiem last. This will finally
335 * enable interrupts, but since cpl and ipending should be -1 and 0, 330 * enable interrupts, but since cpl and ipending should be -1 and 0,
336 * respectively, no interrupts will get dispatched until the priority 331 * respectively, no interrupts will get dispatched until the priority
337 * level is lowered. 332 * level is lowered.
338 * 333 *
339 * Because we're paranoid, we force these values for cpl and ipending, 334 * Because we're paranoid, we force these values for cpl and ipending,
340 * even though they should be unchanged since hp700_intr_bootstrap(). 335 * even though they should be unchanged since hp700_intr_bootstrap().
341 */ 336 */
342 cpl = -1; 337 ci->ci_cpl = -1;
343 ipending = 0; 338 ci->ci_ipending = 0;
344 eiem = 0; 339 eiem = 0;
345 for (idx = 0; idx < HP700_INT_BITS; idx++) { 340 for (idx = 0; idx < HP700_INT_BITS; idx++) {
346 int_reg = hp700_int_regs[idx]; 341 int_reg = hp700_int_regs[idx];
347 if (int_reg == NULL) 342 if (int_reg == NULL)
348 continue; 343 continue;
349 mask = 0; 344 mask = 0;
350 for (bit_pos = 0; bit_pos < HP700_INT_BITS; bit_pos++) { 345 for (bit_pos = 0; bit_pos < HP700_INT_BITS; bit_pos++) {
351 if (int_reg->int_reg_bits_map[31 ^ bit_pos] != 346 if (int_reg->int_reg_bits_map[31 ^ bit_pos] !=
352 INT_REG_BIT_UNUSED) 347 INT_REG_BIT_UNUSED)
353 mask |= (1 << bit_pos); 348 mask |= (1 << bit_pos);
354 } 349 }
355 if (int_reg == &int_reg_cpu) 350 if (int_reg == &int_reg_cpu)
356 eiem = mask; 351 eiem = mask;
@@ -364,26 +359,27 @@ hp700_intr_init(void) @@ -364,26 +359,27 @@ hp700_intr_init(void)
364 * Service interrupts. This doesn't necessarily dispatch them. This is called 359 * Service interrupts. This doesn't necessarily dispatch them. This is called
365 * with %eiem loaded with zero. It's named hppa_intr instead of hp700_intr 360 * with %eiem loaded with zero. It's named hppa_intr instead of hp700_intr
366 * because trap.c calls it. 361 * because trap.c calls it.
367 */ 362 */
368void 363void
369hppa_intr(struct trapframe *frame) 364hppa_intr(struct trapframe *frame)
370{ 365{
371 int eirr; 366 int eirr;
372 int ipending_new; 367 int ipending_new;
373 int pending; 368 int pending;
374 int i; 369 int i;
375 struct hp700_int_reg *int_reg; 370 struct hp700_int_reg *int_reg;
376 int hp700_intr_ipending_new(struct hp700_int_reg *, int); 371 int hp700_intr_ipending_new(struct hp700_int_reg *, int);
 372 struct cpu_info *ci = curcpu();
377 373
378 extern char ucas_ras_start[]; 374 extern char ucas_ras_start[];
379 extern char ucas_ras_end[]; 375 extern char ucas_ras_end[];
380 376
381#ifndef LOCKDEBUG 377#ifndef LOCKDEBUG
382 extern char mutex_enter_crit_start[]; 378 extern char mutex_enter_crit_start[];
383 extern char mutex_enter_crit_end[]; 379 extern char mutex_enter_crit_end[];
384 380
385 extern char _lock_cas_ras_start[]; 381 extern char _lock_cas_ras_start[];
386 extern char _lock_cas_ras_end[]; 382 extern char _lock_cas_ras_end[];
387 383
388 if (frame->tf_iisq_head == HPPA_SID_KERNEL && 384 if (frame->tf_iisq_head == HPPA_SID_KERNEL &&
389 frame->tf_iioq_head >= (u_int)_lock_cas_ras_start && 385 frame->tf_iioq_head >= (u_int)_lock_cas_ras_start &&
@@ -408,81 +404,83 @@ hppa_intr(struct trapframe *frame) @@ -408,81 +404,83 @@ hppa_intr(struct trapframe *frame)
408 frame->tf_iioq_head >= (u_int)ucas_ras_start && 404 frame->tf_iioq_head >= (u_int)ucas_ras_start &&
409 frame->tf_iioq_head <= (u_int)ucas_ras_end) { 405 frame->tf_iioq_head <= (u_int)ucas_ras_end) {
410 frame->tf_iioq_head = (u_int)ucas_ras_start; 406 frame->tf_iioq_head = (u_int)ucas_ras_start;
411 frame->tf_iioq_tail = (u_int)ucas_ras_start + 4; 407 frame->tf_iioq_tail = (u_int)ucas_ras_start + 4;
412 } 408 }
413 409
414 /* 410 /*
415 * Read the CPU interrupt register and acknowledge all interrupts. 411 * Read the CPU interrupt register and acknowledge all interrupts.
416 * Starting with this value, get our set of new pending interrupts and 412 * Starting with this value, get our set of new pending interrupts and
417 * add these new bits to ipending. 413 * add these new bits to ipending.
418 */ 414 */
419 mfctl(CR_EIRR, eirr); 415 mfctl(CR_EIRR, eirr);
420 mtctl(eirr, CR_EIRR); 416 mtctl(eirr, CR_EIRR);
421 ipending |= hp700_intr_ipending_new(&int_reg_cpu, eirr); 417
 418 ci->ci_ipending |= hp700_intr_ipending_new(&int_reg_cpu, eirr);
422 419
423 /* If we have interrupts to dispatch, do so. */ 420 /* If we have interrupts to dispatch, do so. */
424 if (ipending & ~cpl) 421 if (ci->ci_ipending & ~ci->ci_cpl)
425 hp700_intr_dispatch(cpl, frame->tf_eiem, frame); 422 hp700_intr_dispatch(ci->ci_cpl, frame->tf_eiem, frame);
426 423
427 /* We are done if there are no shared interrupts. */ 424 /* We are done if there are no shared interrupts. */
428 if (ishared == 0) 425 if (ishared == 0)
429 return; 426 return;
430 427
431 for (i = 0; i < HP700_INT_BITS; i++) { 428 for (i = 0; i < HP700_INT_BITS; i++) {
432 int_reg = hp700_int_regs[i]; 429 int_reg = hp700_int_regs[i];
433 if (int_reg == NULL || int_reg->int_reg_level == NULL) 430 if (int_reg == NULL || int_reg->int_reg_level == NULL)
434 continue; 431 continue;
435 /* 432 /*
436 * For shared interrupts look if the interrupt line is still 433 * For shared interrupts look if the interrupt line is still
437 * asserted. If it is, reschedule the corresponding interrupt. 434 * asserted. If it is, reschedule the corresponding interrupt.
438 */ 435 */
439 ipending_new = *int_reg->int_reg_level; 436 ipending_new = *int_reg->int_reg_level;
440 while (ipending_new != 0) { 437 while (ipending_new != 0) {
441 pending = ffs(ipending_new) - 1; 438 pending = ffs(ipending_new) - 1;
442 ipending |= int_reg->int_reg_bits_map[31 ^ pending] 439 ci->ci_ipending |=
443 & ishared; 440 int_reg->int_reg_bits_map[31 ^ pending] & ishared;
444 ipending_new &= ~(1 << pending); 441 ipending_new &= ~(1 << pending);
445 } 442 }
446 } 443 }
447 444
448 /* If we still have interrupts to dispatch, do so. */ 445 /* If we still have interrupts to dispatch, do so. */
449 if (ipending & ~cpl) 446 if (ci->ci_ipending & ~ci->ci_cpl)
450 hp700_intr_dispatch(cpl, frame->tf_eiem, frame); 447 hp700_intr_dispatch(ci->ci_cpl, frame->tf_eiem, frame);
451} 448}
452  449
453/* 450/*
454 * Dispatch interrupts. This dispatches at least one interrupt. 451 * Dispatch interrupts. This dispatches at least one interrupt.
455 * This is called with %eiem loaded with zero. 452 * This is called with %eiem loaded with zero.
456 */ 453 */
457void 454void
458hp700_intr_dispatch(int ncpl, int eiem, struct trapframe *frame) 455hp700_intr_dispatch(int ncpl, int eiem, struct trapframe *frame)
459{ 456{
 457 struct cpu_info *ci = curcpu();
460 int ipending_run; 458 int ipending_run;
461 u_int old_hppa_intr_depth; 459 u_int old_hppa_intr_depth;
462 int bit_pos; 460 int bit_pos;
463 struct hp700_int_bit *int_bit; 461 struct hp700_int_bit *int_bit;
464 void *arg; 462 void *arg;
465 struct clockframe clkframe; 463 struct clockframe clkframe;
466 int handled; 464 int handled;
467 465
468 /* Increment our depth, grabbing the previous value. */ 466 /* Increment our depth, grabbing the previous value. */
469 old_hppa_intr_depth = hppa_intr_depth++; 467 old_hppa_intr_depth = ci->ci_intr_depth++;
470 468
471 /* Loop while we have interrupts to dispatch. */ 469 /* Loop while we have interrupts to dispatch. */
472 for (;;) { 470 for (;;) {
473 471
474 /* Read ipending and mask it with ncpl. */ 472 /* Read ipending and mask it with ncpl. */
475 ipending_run = (ipending & ~ncpl); 473 ipending_run = (ci->ci_ipending & ~ncpl);
476 if (ipending_run == 0) 474 if (ipending_run == 0)
477 break; 475 break;
478 476
479 /* Choose one of the resulting bits to dispatch. */ 477 /* Choose one of the resulting bits to dispatch. */
480 bit_pos = ffs(ipending_run) - 1; 478 bit_pos = ffs(ipending_run) - 1;
481 479
482 /* 480 /*
483 * If this interrupt handler takes the clockframe 481 * If this interrupt handler takes the clockframe
484 * as an argument, conjure one up. 482 * as an argument, conjure one up.
485 */ 483 */
486 int_bit = hp700_int_bits + bit_pos; 484 int_bit = hp700_int_bits + bit_pos;
487 int_bit->int_bit_evcnt.ev_count++; 485 int_bit->int_bit_evcnt.ev_count++;
488 arg = int_bit->int_bit_arg; 486 arg = int_bit->int_bit_arg;
@@ -492,45 +490,46 @@ hp700_intr_dispatch(int ncpl, int eiem,  @@ -492,45 +490,46 @@ hp700_intr_dispatch(int ncpl, int eiem,
492 clkframe.cf_spl = ncpl; 490 clkframe.cf_spl = ncpl;
493 if (frame != NULL) { 491 if (frame != NULL) {
494 clkframe.cf_flags |= frame->tf_flags; 492 clkframe.cf_flags |= frame->tf_flags;
495 clkframe.cf_pc = frame->tf_iioq_head; 493 clkframe.cf_pc = frame->tf_iioq_head;
496 } 494 }
497 arg = &clkframe; 495 arg = &clkframe;
498 } 496 }
499  497
500 /* 498 /*
501 * Remove this bit from ipending, raise spl to 499 * Remove this bit from ipending, raise spl to
502 * the level required to run this interrupt, 500 * the level required to run this interrupt,
503 * and reenable interrupts. 501 * and reenable interrupts.
504 */ 502 */
505 ipending &= ~(1 << bit_pos); 503 ci->ci_ipending &= ~(1 << bit_pos);
506 cpl = ncpl | int_bit->int_bit_spl; 504 ci->ci_cpl = ncpl | int_bit->int_bit_spl;
507 mtctl(eiem, CR_EIEM); 505 mtctl(eiem, CR_EIEM);
508 506
509 /* Count and dispatch the interrupt. */ 507 /* Count and dispatch the interrupt. */
510 uvmexp.intrs++; 508 uvmexp.intrs++;
511 handled = (*int_bit->int_bit_handler)(arg); 509 handled = (*int_bit->int_bit_handler)(arg);
512#if 0 510#if 0
513 if (!handled) 511 if (!handled)
514 printf("%s: can't handle interrupt\n", 512 printf("%s: can't handle interrupt\n",
515 int_bit->int_bit_evcnt.ev_name); 513 int_bit->int_bit_evcnt.ev_name);
516#endif 514#endif
517 515
518 /* Disable interrupts and loop. */ 516 /* Disable interrupts and loop. */
519 mtctl(0, CR_EIEM); 517 mtctl(0, CR_EIEM);
520 } 518 }
521 519
522 /* Interrupts are disabled again, restore cpl and the depth. */ 520 /* Interrupts are disabled again, restore cpl and the depth. */
523 cpl = ncpl; 521 ci->ci_cpl = ncpl;
524 hppa_intr_depth = old_hppa_intr_depth; 522 ci->ci_intr_depth = old_hppa_intr_depth;
525} 523}
526 524
527bool 525bool
528cpu_intr_p(void) 526cpu_intr_p(void)
529{ 527{
 528 struct cpu_info *ci = curcpu();
530 529
531#ifdef __HAVE_FAST_SOFTINTS 530#ifdef __HAVE_FAST_SOFTINTS
532#error this should not count fast soft interrupts 531#error this should not count fast soft interrupts
533#else 532#else
534 return hppa_intr_depth != 0; 533 return ci->ci_intr_depth != 0;
535#endif 534#endif
536} 535}

cvs diff -r1.44 -r1.45 src/sys/arch/hp700/hp700/Attic/locore.S (expand / switch to unified diff)

--- src/sys/arch/hp700/hp700/Attic/locore.S 2010/03/16 16:20:19 1.44
+++ src/sys/arch/hp700/hp700/Attic/locore.S 2010/03/31 12:56:14 1.45
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore.S,v 1.44 2010/03/16 16:20:19 skrll Exp $ */ 1/* $NetBSD: locore.S,v 1.45 2010/03/31 12:56:14 skrll Exp $ */
2/* $OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $ */ 2/* $OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1998-2004 Michael Shalayeff 5 * Copyright (c) 1998-2004 Michael Shalayeff
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -524,49 +524,61 @@ pdc_call_unmapped2: @@ -524,49 +524,61 @@ pdc_call_unmapped2:
524 ldw HPPA_FRAME_ARG(23)(%sp), %arg0 524 ldw HPPA_FRAME_ARG(23)(%sp), %arg0
525 break HPPA_BREAK_KERNEL, HPPA_BREAK_SET_PSW 525 break HPPA_BREAK_KERNEL, HPPA_BREAK_SET_PSW
526 nop 526 nop
527 copy %t3, %ret0 527 copy %t3, %ret0
528 528
529pdc_call_unmapped3: 529pdc_call_unmapped3:
530 ldw HPPA_FRAME_PSP(%sp), %sp 530 ldw HPPA_FRAME_PSP(%sp), %sp
531 ldw HPPA_FRAME_CRP(%sp), %rp 531 ldw HPPA_FRAME_CRP(%sp), %rp
532 bv %r0(%rp) 532 bv %r0(%rp)
533 mtctl %t2, %eiem 533 mtctl %t2, %eiem
534EXIT(pdc_call) 534EXIT(pdc_call)
535 535
536/* 536/*
 537 * int splraise(int ncpl);
 538 */
 539LEAF_ENTRY(splraise)
 540 mfctl CR_CURLWP, %t1
 541 ldw L_CPU(%t1),%t1
 542 ldw CI_CPL(%t1), %ret0
 543 or %ret0, %arg0, %arg0
 544 bv %r0(%rp)
 545 stw %arg0, CI_CPL(%t1)
 546EXIT(splraise)
 547
 548/*
537 * int spllower(int ncpl); 549 * int spllower(int ncpl);
538 */ 550 */
539ENTRY(spllower,64) 551ENTRY(spllower,HPPA_FRAME_SIZE)
540 ldil L%ipending, %r1 552 mfctl CR_CURLWP, %t1
541 ldw R%ipending(%r1), %r1 ; load ipending 553 ldw L_CPU(%t1),%t1
542 ldil L%cpl, %t1 554
 555 ldw CI_IPENDING(%t1), %r1 ; load ipending
543 andcm,<> %r1, %arg0, %r1 ; and with complement of new cpl 556 andcm,<> %r1, %arg0, %r1 ; and with complement of new cpl
544 bv %r0(%rp) 557 bv %r0(%rp)
545 stw %arg0, R%cpl(%t1) ; store new cpl 558 stw %arg0, CI_CPL(%t1) ; store new cpl
546 559
547 /* 560 /*
548 * Dispatch interrupts. There's a chance 561 * Dispatch interrupts. There's a chance
549 * that we may end up not dispatching anything; 562 * that we may end up not dispatching anything;
550 * in between our load of ipending and this 563 * in between our load of ipending and this
551 * disabling of interrupts, something else may 564 * disabling of interrupts, something else may
552 * have come in and dispatched some or all 565 * have come in and dispatched some or all
553 * of what we previously saw in ipending. 566 * of what we previously saw in ipending.
554 */ 567 */
555 mfctl %eiem, %arg1 568 mfctl %eiem, %arg1
556 mtctl %r0, %eiem ; disable interrupts 569 mtctl %r0, %eiem ; disable interrupts
557 570
558 ldil L%ipending, %r1 571 ldw CI_IPENDING(%t1), %r1 ; load ipending
559 ldw R%ipending(%r1), %r1 ; load ipending 
560 andcm,<> %r1, %arg0, %r1 ; and with complement of new cpl 572 andcm,<> %r1, %arg0, %r1 ; and with complement of new cpl
561 b,n spllower_out ; branch if we got beaten 573 b,n spllower_out ; branch if we got beaten
562  574
563spllower_dispatch: 575spllower_dispatch:
564 /* start stack calling convention */ 576 /* start stack calling convention */
565 stw %rp, HPPA_FRAME_CRP(%sp) 577 stw %rp, HPPA_FRAME_CRP(%sp)
566 copy %r3, %r1 578 copy %r3, %r1
567 copy %sp, %r3 579 copy %sp, %r3
568 stw,ma %r1, HPPA_FRAME_SIZE(%sp) 580 stw,ma %r1, HPPA_FRAME_SIZE(%sp)
569 581
570 /* save ncpl and %eiem */ 582 /* save ncpl and %eiem */
571 stw %arg0, HPPA_FRAME_ARG(0)(%r3) 583 stw %arg0, HPPA_FRAME_ARG(0)(%r3)
572 stw %arg1, HPPA_FRAME_ARG(1)(%r3) 584 stw %arg1, HPPA_FRAME_ARG(1)(%r3)
@@ -593,34 +605,34 @@ spllower_out: @@ -593,34 +605,34 @@ spllower_out:
593 * (hp700_intr_dispatch leaves it zero). I think 605 * (hp700_intr_dispatch leaves it zero). I think
594 * doing this in the delay slot is important to 606 * doing this in the delay slot is important to
595 * prevent recursion, but I might be being too 607 * prevent recursion, but I might be being too
596 * paranoid. 608 * paranoid.
597 */ 609 */
598 bv %r0(%rp) 610 bv %r0(%rp)
599 mtctl %arg1, %eiem 611 mtctl %arg1, %eiem
600EXIT(spllower) 612EXIT(spllower)
601 613
602/* 614/*
603 * void hp700_intr_schedule(int mask); 615 * void hp700_intr_schedule(int mask);
604 */ 616 */
605ENTRY(hp700_intr_schedule,0) 617ENTRY(hp700_intr_schedule,0)
606 ldil L%ipending, %t1 618 mfctl CR_CURLWP, %t1
607 ldil L%cpl, %t2 619 ldw L_CPU(%t1),%t2
608 mfctl %eiem, %arg1 620 mfctl %eiem, %arg1
609 mtctl %r0, %eiem ; disable interrupts 621 mtctl %r0, %eiem ; disable interrupts
610 ldw R%ipending(%t1), %r1 ; load ipending 622 ldw CI_IPENDING(%t1), %r1 ; load ipending
611 or %r1, %arg0, %r1 ; or in mask 623 or %r1, %arg0, %r1 ; or in mask
612 stw %r1, R%ipending(%t1) ; store ipending 624 stw %r1, CI_IPENDING(%t1) ; store ipending
613 ldw R%cpl(%t2), %arg0 ; load cpl 625 ldw CI_CPL(%t2), %arg0 ; load cpl
614 andcm,= %r1, %arg0, %r1 ; and ipending with ~cpl 626 andcm,= %r1, %arg0, %r1 ; and ipending with ~cpl
615 b,n spllower_dispatch ; dispatch if we can 627 b,n spllower_dispatch ; dispatch if we can
616 bv %r0(%rp) 628 bv %r0(%rp)
617 mtctl %arg1, %eiem 629 mtctl %arg1, %eiem
618EXIT(hp700_intr_schedule) 630EXIT(hp700_intr_schedule)
619 631
620/* 632/*
621 * 633 *
622 * int hp700_intr_ipending_new(struct hp700_int_reg *int_reg, int int_req); 634 * int hp700_intr_ipending_new(struct hp700_int_reg *int_reg, int int_req);
623 * 635 *
624 * This assembles the mask of new pending interrupts. 636 * This assembles the mask of new pending interrupts.
625 * 637 *
626 */ 638 */

cvs diff -r1.41 -r1.42 src/sys/arch/hp700/include/Attic/cpu.h (expand / switch to unified diff)

--- src/sys/arch/hp700/include/Attic/cpu.h 2010/03/31 06:35:12 1.41
+++ src/sys/arch/hp700/include/Attic/cpu.h 2010/03/31 12:56:14 1.42
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu.h,v 1.41 2010/03/31 06:35:12 skrll Exp $ */ 1/* $NetBSD: cpu.h,v 1.42 2010/03/31 12:56:14 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
@@ -218,29 +218,31 @@ struct clockframe { @@ -218,29 +218,31 @@ struct clockframe {
218 218
219#define cpu_signotify(l) (setsoftast()) 219#define cpu_signotify(l) (setsoftast())
220#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, setsoftast()) 220#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, setsoftast())
221 221
222#include <sys/cpu_data.h> 222#include <sys/cpu_data.h>
223struct cpu_info { 223struct cpu_info {
224 struct cpu_data ci_data; /* MI per-cpu data */ 224 struct cpu_data ci_data; /* MI per-cpu data */
225 225
226 struct lwp *ci_curlwp; /* CPU owner */ 226 struct lwp *ci_curlwp; /* CPU owner */
227 int ci_cpuid; /* CPU index (see cpus[] array) */ 227 int ci_cpuid; /* CPU index (see cpus[] array) */
228 int ci_mtx_count; 228 int ci_mtx_count;
229 int ci_mtx_oldspl; 229 int ci_mtx_oldspl;
230 int ci_want_resched; 230 int ci_want_resched;
231}; 
232 231
233#include <machine/intr.h> 232 volatile int ci_cpl;
 233 volatile int ci_ipending; /* The pending interrupts. */
 234 u_int ci_intr_depth; /* Nonzero iff running an interrupt. */
 235};
234 236
235extern struct cpu_info cpu_info_store; 237extern struct cpu_info cpu_info_store;
236 238
237/* 239/*
238 * definitions of cpu-dependent requirements 240 * definitions of cpu-dependent requirements
239 * referenced in generic code 241 * referenced in generic code
240 */ 242 */
241 243
242#define curcpu() (&cpu_info_store) 244#define curcpu() (&cpu_info_store)
243#define cpu_number() 0 245#define cpu_number() 0
244 246
245#define cpu_proc_fork(p1, p2) 247#define cpu_proc_fork(p1, p2)
246 248

cvs diff -r1.15 -r1.16 src/sys/arch/hp700/include/Attic/intr.h (expand / switch to unified diff)

--- src/sys/arch/hp700/include/Attic/intr.h 2009/05/08 09:33:58 1.15
+++ src/sys/arch/hp700/include/Attic/intr.h 2010/03/31 12:56:14 1.16
@@ -1,14 +1,15 @@ @@ -1,14 +1,15 @@
1/* $NetBSD: intr.h,v 1.15 2009/05/08 09:33:58 skrll Exp $ */ 1/* $NetBSD: intr.h,v 1.16 2010/03/31 12:56:14 skrll Exp $ */
 2/* $OpenBSD: intr.h,v 1.26 2009/12/29 13:11:40 jsing Exp $ */
2 3
3/*- 4/*-
4 * Copyright (c) 1998, 2001, 2002 The NetBSD Foundation, Inc. 5 * Copyright (c) 1998, 2001, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 6 * All rights reserved.
6 * 7 *
7 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum, and by Jason R. Thorpe, and by Matthew Fredette. 9 * by Charles M. Hannum, and by Jason R. Thorpe, and by Matthew Fredette.
9 * 10 *
10 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
12 * are met: 13 * are met:
13 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 15 * notice, this list of conditions and the following disclaimer.
@@ -46,50 +47,31 @@ @@ -46,50 +47,31 @@
46#define NIPL 8 47#define NIPL 8
47 48
48/* Interrupt sharing types. */ 49/* Interrupt sharing types. */
49#define IST_NONE 0 /* none */ 50#define IST_NONE 0 /* none */
50#define IST_PULSE 1 /* pulsed */ 51#define IST_PULSE 1 /* pulsed */
51#define IST_EDGE 2 /* edge-triggered */ 52#define IST_EDGE 2 /* edge-triggered */
52#define IST_LEVEL 3 /* level-triggered */ 53#define IST_LEVEL 3 /* level-triggered */
53 54
54#ifndef _LOCORE 55#ifndef _LOCORE
55 56
56/* The priority level masks. */ 57/* The priority level masks. */
57extern int imask[NIPL]; 58extern int imask[NIPL];
58 59
59/* The current priority level. */ 
60extern volatile int cpl; 
61 
62/* The asynchronous system trap flag. */ 60/* The asynchronous system trap flag. */
63extern volatile int astpending; 61extern volatile int astpending;
64 62
65/* The softnet mask. */ 63/* splraise()/spllower() are in locore.S */
66extern int softnetmask; 64int splraise(int);
67 
68/* 
69 * Add a mask to cpl, and return the old value of cpl. 
70 */ 
71static __inline int 
72splraise(register int ncpl) 
73{ 
74 register int ocpl = cpl; 
75 
76 cpl = ocpl | ncpl; 
77 __insn_barrier(); 
78 
79 return (ocpl); 
80} 
81 
82/* spllower() is in locore.S */ 
83void spllower(int); 65void spllower(int);
84 66
85/* 67/*
86 * Miscellaneous 68 * Miscellaneous
87 */ 69 */
88#define spl0() spllower(0) 70#define spl0() spllower(0)
89#define splx(x) spllower(x) 71#define splx(x) spllower(x)
90 72
91typedef int ipl_t; 73typedef int ipl_t;
92typedef struct { 74typedef struct {
93 ipl_t _ipl; 75 ipl_t _ipl;
94} ipl_cookie_t; 76} ipl_cookie_t;
95 77

cvs diff -r1.12 -r1.13 src/sys/arch/hppa/hppa/machdep.h (expand / switch to unified diff)

--- src/sys/arch/hppa/hppa/machdep.h 2009/08/11 17:04:18 1.12
+++ src/sys/arch/hppa/hppa/machdep.h 2010/03/31 12:56:14 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: machdep.h,v 1.12 2009/08/11 17:04:18 matt Exp $ */ 1/* $NetBSD: machdep.h,v 1.13 2010/03/31 12:56:14 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matthew Fredette. 8 * by Matthew Fredette.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -66,27 +66,26 @@ extern int resvmem; @@ -66,27 +66,26 @@ extern int resvmem;
66extern u_int hppa_btlb_size_min; 66extern u_int hppa_btlb_size_min;
67extern u_int hppa_btlb_size_max; 67extern u_int hppa_btlb_size_max;
68 68
69/* FPU variables and functions. */ 69/* FPU variables and functions. */
70extern int fpu_present; 70extern int fpu_present;
71extern u_int fpu_version; 71extern u_int fpu_version;
72extern u_int fpu_csw; 72extern u_int fpu_csw;
73extern paddr_t fpu_cur_uspace; 73extern paddr_t fpu_cur_uspace;
74void hppa_fpu_bootstrap(u_int); 74void hppa_fpu_bootstrap(u_int);
75void hppa_fpu_flush(struct lwp *); 75void hppa_fpu_flush(struct lwp *);
76void hppa_fpu_emulate(struct trapframe *, struct lwp *, u_int); 76void hppa_fpu_emulate(struct trapframe *, struct lwp *, u_int);
77 77
78/* Interrupt dispatching. */ 78/* Interrupt dispatching. */
79extern u_int hppa_intr_depth; 
80void hppa_intr(struct trapframe *); 79void hppa_intr(struct trapframe *);
81 80
82/* Special pmap functions. */ 81/* Special pmap functions. */
83void pmap_redzone(vaddr_t, vaddr_t, int); 82void pmap_redzone(vaddr_t, vaddr_t, int);
84 83
85/* Functions to write low memory and the kernel text. */ 84/* Functions to write low memory and the kernel text. */
86void hppa_ktext_stw(vaddr_t, int); 85void hppa_ktext_stw(vaddr_t, int);
87void hppa_ktext_stb(vaddr_t, char); 86void hppa_ktext_stb(vaddr_t, char);
88 87
89/* Machine check handling. */ 88/* Machine check handling. */
90extern u_int os_hpmc; 89extern u_int os_hpmc;
91extern u_int os_hpmc_cont; 90extern u_int os_hpmc_cont;
92extern u_int os_hpmc_cont_end; 91extern u_int os_hpmc_cont_end;

cvs diff -r1.84 -r1.85 src/sys/arch/hppa/hppa/trap.c (expand / switch to unified diff)

--- src/sys/arch/hppa/hppa/trap.c 2010/03/24 12:56:30 1.84
+++ src/sys/arch/hppa/hppa/trap.c 2010/03/31 12:56:14 1.85
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: trap.c,v 1.84 2010/03/24 12:56:30 skrll Exp $ */ 1/* $NetBSD: trap.c,v 1.85 2010/03/31 12:56:14 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matthew Fredette. 8 * by Matthew Fredette.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -48,27 +48,27 @@ @@ -48,27 +48,27 @@
48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 50 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
51 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 51 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 52 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 55 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
56 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 56 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
57 * THE POSSIBILITY OF SUCH DAMAGE. 57 * THE POSSIBILITY OF SUCH DAMAGE.
58 */ 58 */
59 59
60#include <sys/cdefs.h> 60#include <sys/cdefs.h>
61__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.84 2010/03/24 12:56:30 skrll Exp $"); 61__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.85 2010/03/31 12:56:14 skrll Exp $");
62 62
63/* #define INTRDEBUG */ 63/* #define INTRDEBUG */
64/* #define TRAPDEBUG */ 64/* #define TRAPDEBUG */
65/* #define USERTRACE */ 65/* #define USERTRACE */
66 66
67#include "opt_kgdb.h" 67#include "opt_kgdb.h"
68#include "opt_ptrace.h" 68#include "opt_ptrace.h"
69#include "opt_sa.h" 69#include "opt_sa.h"
70 70
71#include <sys/param.h> 71#include <sys/param.h>
72#include <sys/systm.h> 72#include <sys/systm.h>
73#include <sys/kernel.h> 73#include <sys/kernel.h>
74#include <sys/syscall.h> 74#include <sys/syscall.h>
@@ -483,27 +483,28 @@ trap(int type, struct trapframe *frame) @@ -483,27 +483,28 @@ trap(int type, struct trapframe *frame)
483 struct pcb *pcb; 483 struct pcb *pcb;
484 vaddr_t va; 484 vaddr_t va;
485 struct vm_map *map; 485 struct vm_map *map;
486 struct vmspace *vm; 486 struct vmspace *vm;
487 vm_prot_t vftype; 487 vm_prot_t vftype;
488 pa_space_t space; 488 pa_space_t space;
489 ksiginfo_t ksi; 489 ksiginfo_t ksi;
490 u_int opcode, onfault; 490 u_int opcode, onfault;
491 int ret; 491 int ret;
492 const char *tts = "reserved"; 492 const char *tts = "reserved";
493 int trapnum; 493 int trapnum;
494#ifdef DIAGNOSTIC 494#ifdef DIAGNOSTIC
495 extern int emergency_stack_start, emergency_stack_end; 495 extern int emergency_stack_start, emergency_stack_end;
496 int oldcpl = cpl; 496 struct cpu_info *ci = curcpu();
 497 int oldcpl = ci->ci_cpl;
497#endif 498#endif
498 499
499 trapnum = type & ~T_USER; 500 trapnum = type & ~T_USER;
500 opcode = frame->tf_iir; 501 opcode = frame->tf_iir;
501 502
502 if (trapnum <= T_EXCEPTION || trapnum == T_HIGHERPL || 503 if (trapnum <= T_EXCEPTION || trapnum == T_HIGHERPL ||
503 trapnum == T_LOWERPL || trapnum == T_TAKENBR || 504 trapnum == T_LOWERPL || trapnum == T_TAKENBR ||
504 trapnum == T_IDEBUG || trapnum == T_PERFMON) { 505 trapnum == T_IDEBUG || trapnum == T_PERFMON) {
505 va = frame->tf_iioq_head; 506 va = frame->tf_iioq_head;
506 space = frame->tf_iisq_head; 507 space = frame->tf_iisq_head;
507 vftype = VM_PROT_EXECUTE; 508 vftype = VM_PROT_EXECUTE;
508 } else { 509 } else {
509 va = frame->tf_ior; 510 va = frame->tf_ior;
@@ -857,27 +858,27 @@ do_onfault: @@ -857,27 +858,27 @@ do_onfault:
857 858
858 va = trunc_page(va); 859 va = trunc_page(va);
859 860
860 if (map->pmap->pm_space != space) { 861 if (map->pmap->pm_space != space) {
861#ifdef TRAPDEBUG 862#ifdef TRAPDEBUG
862 printf("trap: space mismatch %d != %d\n", 863 printf("trap: space mismatch %d != %d\n",
863 space, map->pmap->pm_space); 864 space, map->pmap->pm_space);
864#endif 865#endif
865 /* actually dump the user, crap the kernel */ 866 /* actually dump the user, crap the kernel */
866 goto dead_end; 867 goto dead_end;
867 } 868 }
868 869
869 /* Never call uvm_fault in interrupt context. */ 870 /* Never call uvm_fault in interrupt context. */
870 KASSERT(hppa_intr_depth == 0); 871 KASSERT(curcpu()->ci_cpl == 0);
871 872
872 onfault = pcb->pcb_onfault; 873 onfault = pcb->pcb_onfault;
873 pcb->pcb_onfault = 0; 874 pcb->pcb_onfault = 0;
874 ret = uvm_fault(map, va, vftype); 875 ret = uvm_fault(map, va, vftype);
875 pcb->pcb_onfault = onfault; 876 pcb->pcb_onfault = onfault;
876 877
877#ifdef TRAPDEBUG 878#ifdef TRAPDEBUG
878 printf("uvm_fault(%p, %x, %d)=%d\n", 879 printf("uvm_fault(%p, %x, %d)=%d\n",
879 map, (u_int)va, vftype, ret); 880 map, (u_int)va, vftype, ret);
880#endif 881#endif
881 882
882 if (map != kernel_map) 883 if (map != kernel_map)
883 l->l_pflag &= ~LP_SA_PAGEFAULT; 884 l->l_pflag &= ~LP_SA_PAGEFAULT;
@@ -947,29 +948,29 @@ do_onfault: @@ -947,29 +948,29 @@ do_onfault:
947 case T_POWERFAIL: 948 case T_POWERFAIL:
948 case T_LPMC: 949 case T_LPMC:
949 case T_PAGEREF: 950 case T_PAGEREF:
950 case T_DATAPID: case T_DATAPID | T_USER: 951 case T_DATAPID: case T_DATAPID | T_USER:
951 if (0 /* T-chip */) { 952 if (0 /* T-chip */) {
952 break; 953 break;
953 } 954 }
954 /* FALLTHROUGH to unimplemented */ 955 /* FALLTHROUGH to unimplemented */
955 default: 956 default:
956 panic ("trap: unimplemented \'%s\' (%d)", tts, type); 957 panic ("trap: unimplemented \'%s\' (%d)", tts, type);
957 } 958 }
958 959
959#ifdef DIAGNOSTIC 960#ifdef DIAGNOSTIC
960 if (cpl != oldcpl) 961 if (ci->ci_cpl != oldcpl)
961 printf("WARNING: SPL (%d) NOT LOWERED ON TRAP (%d) EXIT\n", 962 printf("WARNING: SPL (%d) NOT LOWERED ON TRAP (%d) EXIT\n",
962 cpl, trapnum); 963 ci->ci_cpl, trapnum);
963#endif 964#endif
964 965
965 if (type & T_USER) 966 if (type & T_USER)
966 userret(l, l->l_md.md_regs->tf_iioq_head, 0); 967 userret(l, l->l_md.md_regs->tf_iioq_head, 0);
967 968
968#ifdef DEBUG 969#ifdef DEBUG
969 frame_sanity_check(__func__, __LINE__, type, frame, l); 970 frame_sanity_check(__func__, __LINE__, type, frame, l);
970 if (frame->tf_flags & TFF_LAST && (curlwp->l_flag & LW_IDLE) == 0) 971 if (frame->tf_flags & TFF_LAST && (curlwp->l_flag & LW_IDLE) == 0)
971 frame_sanity_check(__func__, __LINE__, type, 972 frame_sanity_check(__func__, __LINE__, type,
972 curlwp->l_md.md_regs, curlwp); 973 curlwp->l_md.md_regs, curlwp);
973#endif /* DEBUG */ 974#endif /* DEBUG */
974} 975}
975 976
@@ -1095,27 +1096,28 @@ process_sstep(struct lwp *l, int sstep) @@ -1095,27 +1096,28 @@ process_sstep(struct lwp *l, int sstep)
1095 * - register args are copied onto stack too 1096 * - register args are copied onto stack too
1096 */ 1097 */
1097void 1098void
1098syscall(struct trapframe *frame, int *args) 1099syscall(struct trapframe *frame, int *args)
1099{ 1100{
1100 struct lwp *l; 1101 struct lwp *l;
1101 struct proc *p; 1102 struct proc *p;
1102 const struct sysent *callp; 1103 const struct sysent *callp;
1103 size_t nargs64; 1104 size_t nargs64;
1104 int nsys, code, error; 1105 int nsys, code, error;
1105 int tmp; 1106 int tmp;
1106 int rval[2]; 1107 int rval[2];
1107#ifdef DIAGNOSTIC 1108#ifdef DIAGNOSTIC
1108 int oldcpl = cpl; 1109 struct cpu_info *ci = curcpu();
 1110 int oldcpl = ci->ci_cpl;
1109#endif 1111#endif
1110 1112
1111 uvmexp.syscalls++; 1113 uvmexp.syscalls++;
1112 1114
1113#ifdef DEBUG 1115#ifdef DEBUG
1114 frame_sanity_check(__func__, __LINE__, 0, frame, curlwp); 1116 frame_sanity_check(__func__, __LINE__, 0, frame, curlwp);
1115#endif /* DEBUG */ 1117#endif /* DEBUG */
1116 1118
1117 if (!USERMODE(frame->tf_iioq_head)) 1119 if (!USERMODE(frame->tf_iioq_head))
1118 panic("syscall"); 1120 panic("syscall");
1119 1121
1120 KASSERT(curlwp != NULL); 1122 KASSERT(curlwp != NULL);
1121 l = curlwp; 1123 l = curlwp;
@@ -1264,31 +1266,31 @@ out: @@ -1264,31 +1266,31 @@ out:
1264 default: 1266 default:
1265 if (p->p_emul->e_errno) 1267 if (p->p_emul->e_errno)
1266 error = p->p_emul->e_errno[error]; 1268 error = p->p_emul->e_errno[error];
1267 frame->tf_t1 = error; 1269 frame->tf_t1 = error;
1268 break; 1270 break;
1269 } 1271 }
1270 1272
1271 if (__predict_false(p->p_trace_enabled)) 1273 if (__predict_false(p->p_trace_enabled))
1272 trace_exit(code, rval, error); 1274 trace_exit(code, rval, error);
1273 1275
1274 userret(l, frame->tf_iioq_head, 0); 1276 userret(l, frame->tf_iioq_head, 0);
1275 1277
1276#ifdef DIAGNOSTIC 1278#ifdef DIAGNOSTIC
1277 if (cpl != oldcpl) { 1279 if (ci->ci_cpl != oldcpl) {
1278 printf("WARNING: SPL (0x%x) NOT LOWERED ON " 1280 printf("WARNING: SPL (0x%x) NOT LOWERED ON "
1279 "syscall(0x%x, 0x%x, 0x%x, 0x%x...) EXIT, PID %d\n", 1281 "syscall(0x%x, 0x%x, 0x%x, 0x%x...) EXIT, PID %d\n",
1280 cpl, code, args[0], args[1], args[2], p->p_pid); 1282 ci->ci_cpl, code, args[0], args[1], args[2], p->p_pid);
1281 cpl = oldcpl; 1283 ci->ci_cpl = oldcpl;
1282 } 1284 }
1283#endif 1285#endif
1284 1286
1285#ifdef DEBUG 1287#ifdef DEBUG
1286 frame_sanity_check(__func__, __LINE__, 0, frame, l); 1288 frame_sanity_check(__func__, __LINE__, 0, frame, l);
1287#endif /* DEBUG */ 1289#endif /* DEBUG */
1288} 1290}
1289 1291
1290/*  1292/*
1291 * Start a new LWP 1293 * Start a new LWP
1292 */ 1294 */
1293void 1295void
1294startlwp(void *arg) 1296startlwp(void *arg)