Skip to content

Commit 4c465e6

Browse files
committed
Re-factor badtrap into the shared trap_subr.s. This time we pick the
sun2/sun3 implementation of this trap stub because it provides more context to the stray trap reporting routine (adjust the N copies of straytrap() to compensate as needed, sigh).
1 parent f401e76 commit 4c465e6

25 files changed

Lines changed: 95 additions & 204 deletions

File tree

sys/arch/amiga/amiga/locore.s

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.177 2026/03/18 13:56:06 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.178 2026/03/18 14:44:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -178,16 +178,6 @@ Lfptnull:
178178
* no post-trap stack adjustment.
179179
*/
180180

181-
ENTRY_NOPROFILE(badtrap)
182-
INTERRUPT_SAVEREG
183-
movw %sp@(22),%sp@- | push exception vector info
184-
clrw %sp@-
185-
movl %sp@(22),%sp@- | and PC
186-
jbsr _C_LABEL(straytrap) | report
187-
addql #8,%sp | pop args
188-
INTERRUPT_RESTOREREG | restore regs
189-
jra _ASM_LABEL(rei) | all done
190-
191181
ENTRY_NOPROFILE(trap0)
192182
clrl %sp@- | stack adjust count
193183
moveml %d0-%d7/%a0-%a7,%sp@- | save user registers

sys/arch/amiga/amiga/machdep.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: machdep.c,v 1.258 2025/12/21 07:00:26 skrll Exp $ */
1+
/* $NetBSD: machdep.c,v 1.259 2026/03/18 14:44:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -50,7 +50,7 @@
5050
#include "empm.h"
5151

5252
#include <sys/cdefs.h>
53-
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.258 2025/12/21 07:00:26 skrll Exp $");
53+
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.259 2026/03/18 14:44:09 thorpej Exp $");
5454

5555
#include <sys/param.h>
5656
#include <sys/systm.h>
@@ -122,7 +122,7 @@ void identifycpu(void);
122122
vm_offset_t reserve_dumppages(vm_offset_t);
123123
void dumpsys(void);
124124
void initcpu(void);
125-
void straytrap(int, u_short);
125+
void straytrap(struct trapframe);
126126
void intrhand(int);
127127
#if NSER > 0
128128
void ser_outintr(void);
@@ -813,10 +813,10 @@ initcpu(void)
813813
}
814814

815815
void
816-
straytrap(int pc, u_short evec)
816+
straytrap(struct trapframe tf)
817817
{
818-
printf("unexpected trap format %x (vector offset %x) from %x\n",
819-
evec>>12, evec & 0xFFF, pc);
818+
printf("unexpected trap format=%d vector=0x%x pc=0x%x\n",
819+
tf.tf_format, tf.tf_vector, tf.tf_pc);
820820
/*XXX*/ panic("straytrap");
821821
}
822822

sys/arch/atari/atari/locore.s

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.132 2026/03/18 13:56:06 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.133 2026/03/18 14:44:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -294,7 +294,6 @@ ENTRY_NOPROFILE(lev7intr)
294294
#endif /* _MILANHW_ */
295295

296296
ENTRY_NOPROFILE(lev3intr)
297-
ENTRY_NOPROFILE(badtrap)
298297
addql #1,_C_LABEL(intr_depth)
299298
INTERRUPT_SAVEREG
300299
movw %sp@(22),%sp@- | push exception vector info

sys/arch/atari/atari/machdep.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: machdep.c,v 1.194 2025/12/20 10:51:01 skrll Exp $ */
1+
/* $NetBSD: machdep.c,v 1.195 2026/03/18 14:44:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
3939
*/
4040

4141
#include <sys/cdefs.h>
42-
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.194 2025/12/20 10:51:01 skrll Exp $");
42+
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.195 2026/03/18 14:44:09 thorpej Exp $");
4343

4444
#include "opt_ddb.h"
4545
#include "opt_compat_netbsd.h"
@@ -97,7 +97,7 @@ static void bootsync(void);
9797
static void call_sicallbacks(void);
9898
static void identifycpu(void);
9999
void straymfpint(int, u_short);
100-
void straytrap(int, u_short);
100+
void straytrap(struct trapframe);
101101

102102
#ifdef _MILANHW_
103103
void nmihandler(void);
@@ -519,18 +519,18 @@ dumpsys(void)
519519
}
520520

521521
void
522-
straytrap(int pc, u_short evec)
522+
straytrap(struct trapframe tf)
523523
{
524524
static int prev_evec;
525525

526-
printf("unexpected trap (vector offset 0x%x) from 0x%x\n",
527-
evec & 0xFFF, pc);
526+
printf("unexpected trap format=%d vector=0x%x pc=0x%x\n",
527+
tf.tf_format, tf.tf_vector, tf.tf_pc);
528528

529-
if (prev_evec == evec) {
529+
if (prev_evec == tf.tf_vector) {
530530
delay(1000000);
531531
prev_evec = 0;
532532
} else
533-
prev_evec = evec;
533+
prev_evec = tf.tf_vector;
534534
}
535535

536536
void

sys/arch/cesfic/cesfic/locore.s

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.56 2026/03/18 13:56:06 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.57 2026/03/18 14:44:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1980, 1990, 1993
@@ -449,16 +449,6 @@ Lfptnull:
449449
jra _ASM_LABEL(faultstkadj) | call trap and deal with stack cleanup
450450

451451

452-
ENTRY_NOPROFILE(badtrap)
453-
moveml #0xC0C0,%sp@- | save scratch regs
454-
movw %sp@(22),%sp@- | push exception vector info
455-
clrw %sp@-
456-
movl %sp@(22),%sp@- | and PC
457-
jbsr _C_LABEL(straytrap) | report
458-
addql #8,%sp | pop args
459-
moveml %sp@+,#0x0303 | restore regs
460-
jra _ASM_LABEL(rei) | all done
461-
462452
ENTRY_NOPROFILE(trap0)
463453
clrl %sp@- | stack adjust count
464454
moveml #0xFFFF,%sp@- | save user registers

sys/arch/cesfic/cesfic/machdep.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: machdep.c,v 1.77 2025/12/21 07:00:26 skrll Exp $ */
1+
/* $NetBSD: machdep.c,v 1.78 2026/03/18 14:44:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
3939
*/
4040

4141
#include <sys/cdefs.h>
42-
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.77 2025/12/21 07:00:26 skrll Exp $");
42+
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.78 2026/03/18 14:44:09 thorpej Exp $");
4343

4444
#include "opt_bufcache.h"
4545
#include "opt_ddb.h"
@@ -116,7 +116,7 @@ char *hexstr(int, int);
116116

117117
/* functions called from locore.s */
118118
void dumpsys(void);
119-
void straytrap(int, u_short);
119+
void straytrap(struct trapframe);
120120
void nmihand(struct frame);
121121

122122
int delay_divisor; /* delay constant */
@@ -471,10 +471,10 @@ dumpsys(void)
471471
}
472472

473473
void
474-
straytrap(int pc, u_short evec)
474+
straytrap(struct trapframe tf)
475475
{
476-
printf("unexpected trap (vector offset %x) from %x\n",
477-
evec & 0xFFF, pc);
476+
printf("unexpected trap format=%d vector=0x%x pc=0x%x\n",
477+
tf.tf_format, tf.tf_vector, tf.tf_pc);
478478
}
479479

480480
/* XXX should change the interface, and make one badaddr() function */

sys/arch/hp300/hp300/locore.s

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.203 2026/03/18 13:56:06 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.204 2026/03/18 14:44:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1980, 1990, 1993
@@ -621,16 +621,6 @@ Lfptnull:
621621
* no post-trap stack adjustment.
622622
*/
623623

624-
ENTRY_NOPROFILE(badtrap)
625-
moveml #0xC0C0,%sp@- | save scratch regs
626-
movw %sp@(22),%sp@- | push exception vector info
627-
clrw %sp@-
628-
movl %sp@(22),%sp@- | and PC
629-
jbsr _C_LABEL(straytrap) | report
630-
addql #8,%sp | pop args
631-
moveml %sp@+,#0x0303 | restore regs
632-
jra _ASM_LABEL(rei) | all done
633-
634624
ENTRY_NOPROFILE(trap0)
635625
clrl %sp@- | stack adjust count
636626
moveml #0xFFFF,%sp@- | save user registers

sys/arch/hp300/hp300/machdep.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: machdep.c,v 1.252 2025/12/20 10:51:03 skrll Exp $ */
1+
/* $NetBSD: machdep.c,v 1.253 2026/03/18 14:44:10 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
3939
*/
4040

4141
#include <sys/cdefs.h>
42-
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.252 2025/12/20 10:51:03 skrll Exp $");
42+
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.253 2026/03/18 14:44:10 thorpej Exp $");
4343

4444
#include "opt_ddb.h"
4545
#include "opt_compat_netbsd.h"
@@ -147,7 +147,7 @@ static void cpu_init_kcore_hdr(void);
147147
/* functions called from locore.s */
148148
void dumpsys(void);
149149
void machine_init(paddr_t);
150-
void straytrap(int, u_short);
150+
void straytrap(struct trapframe);
151151
void nmihand(struct frame);
152152

153153
/*
@@ -900,10 +900,10 @@ initcpu(void)
900900
}
901901

902902
void
903-
straytrap(int pc, u_short evec)
903+
straytrap(struct trapframe tf)
904904
{
905-
printf("unexpected trap (vector offset %x) from %x\n",
906-
evec & 0xFFF, pc);
905+
printf("unexpected trap format=%d vector=0x%x pc=0x%x\n",
906+
tf.tf_format, tf.tf_vector, tf.tf_pc);
907907
}
908908

909909
/* XXX should change the interface, and make one badaddr() function */

sys/arch/luna68k/luna68k/locore.s

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.99 2026/03/18 13:56:07 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.100 2026/03/18 14:44:10 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -366,16 +366,6 @@ Lfptnull:
366366
* no post-trap stack adjustment.
367367
*/
368368

369-
ENTRY_NOPROFILE(badtrap)
370-
moveml #0xC0C0,%sp@- | save scratch regs
371-
movw %sp@(22),%sp@- | push exception vector info
372-
clrw %sp@-
373-
movl %sp@(22),%sp@- | and PC
374-
jbsr _C_LABEL(straytrap) | report
375-
addql #8,%sp | pop args
376-
moveml %sp@+,#0x0303 | restore regs
377-
jra _ASM_LABEL(rei) | all done
378-
379369
ENTRY_NOPROFILE(trap0)
380370
clrl %sp@- | stack adjust count
381371
moveml #0xFFFF,%sp@- | save user registers

sys/arch/luna68k/luna68k/machdep.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: machdep.c,v 1.118 2025/12/20 10:51:03 skrll Exp $ */
1+
/* $NetBSD: machdep.c,v 1.119 2026/03/18 14:44:10 thorpej Exp $ */
22

33
/*-
44
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
3131

3232
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
3333

34-
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.118 2025/12/20 10:51:03 skrll Exp $");
34+
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.119 2026/03/18 14:44:10 thorpej Exp $");
3535

3636
#include "opt_ddb.h"
3737
#include "opt_kgdb.h"
@@ -114,7 +114,7 @@ void machine_init(paddr_t);
114114
void identifycpu(void);
115115
void dumpsys(void);
116116

117-
void straytrap(int, u_short);
117+
void straytrap(struct trapframe);
118118
void nmihand(struct frame);
119119

120120
int cpu_dumpsize(void);
@@ -691,11 +691,10 @@ dumpsys(void)
691691
}
692692

693693
void
694-
straytrap(int pc, u_short evec)
694+
straytrap(struct trapframe tf)
695695
{
696-
697-
printf("unexpected trap (vector offset %x) from %x\n",
698-
evec & 0xFFF, pc);
696+
printf("unexpected trap format=%d vector=0x%x pc=0x%x\n",
697+
tf.tf_format, tf.tf_vector, tf.tf_pc);
699698
}
700699

701700
int *nofault;

0 commit comments

Comments
 (0)