Skip to content

Commit c7ffc3e

Browse files
committed
Remove the last vestigal remains of the simulated software interrupt
register, or "ssir". The NetBSD kernel long ago adopted a software interrupt thread model along with a "fast software interrupts" mechanism that m68k platforms do not (yet) implement, but a few m68k platforms were still consuling an "ssir" variable in the return from every exception that nothing ever set. This cleanup paves the way for futher consolidation of m68k trap handling code in future commits.
1 parent e35524c commit c7ffc3e

7 files changed

Lines changed: 28 additions & 205 deletions

File tree

sys/arch/atari/atari/intr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: intr.c,v 1.34 2026/03/13 21:13:45 andvar Exp $ */
1+
/* $NetBSD: intr.c,v 1.35 2026/03/18 04:08:38 thorpej Exp $ */
22

33
/*-
44
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
3030
*/
3131

3232
#include <sys/cdefs.h>
33-
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.34 2026/03/13 21:13:45 andvar Exp $");
33+
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.35 2026/03/18 04:08:38 thorpej Exp $");
3434

3535
#include <sys/param.h>
3636
#include <sys/systm.h>
@@ -54,7 +54,6 @@ typedef LIST_HEAD(, intrhand) ih_list_t;
5454
static ih_list_t autovec_list[AVEC_MAX - AVEC_MIN + 1];
5555
static ih_list_t uservec_list[UVEC_MAX - UVEC_MIN + 1];
5656
volatile unsigned int intr_depth;
57-
volatile int ssir;
5857

5958
void
6059
intr_init(void)

sys/arch/atari/atari/locore.s

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.129 2026/03/14 21:03:39 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.130 2026/03/18 04:08:38 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -619,10 +619,10 @@ ASENTRY_NOPROFILE(rei)
619619
jne Ldorte | yes, do not make matters worse
620620
#endif
621621
tstl _C_LABEL(astpending) | AST pending?
622-
jeq Lchksir | no, go check for SIR
622+
jeq Ldorte | Nope. Just return.
623623
Lrei1:
624624
btst #5,%sp@ | yes, are we returning to user mode?
625-
jne Lchksir | no, go check for SIR
625+
jne Ldorte | Nope. Just return.
626626
movw #PSL_LOWIPL,%sr | lower SPL
627627
clrl %sp@- | stack adjust
628628
moveml #0xFFFF,%sp@- | save all registers
@@ -651,38 +651,8 @@ Laststkadj:
651651
movl %a0,%sp@(FR_SP) | new SSP
652652
moveml %sp@+,#0x7FFF | restore user registers
653653
movl %sp@,%sp | and our SP
654-
rte | and do real RTE
655-
Lchksir:
656-
tstb _C_LABEL(ssir) | SIR pending?
657-
jeq Ldorte | no, all done
658-
movl %d0,%sp@- | need a scratch register
659-
movw %sp@(4),%d0 | get SR
660-
andw #PSL_IPL7,%d0 | mask all but IPL
661-
jne Lnosir | came from interrupt, no can do
662-
movl %sp@+,%d0 | restore scratch register
663-
Lgotsir:
664-
movw #SPL1,%sr | prevent others from servicing int
665-
tstb _C_LABEL(ssir) | too late?
666-
jeq Ldorte | yes, oh well...
667-
clrl %sp@- | stack adjust
668-
moveml #0xFFFF,%sp@- | save all registers
669-
movl %usp,%a1 | including
670-
movl %a1,%sp@(FR_SP) | the users SP
671-
clrl %sp@- | VA == none
672-
clrl %sp@- | code == none
673-
movl #T_SSIR,%sp@- | type == software interrupt
674-
pea %sp@(12) | fp == address of trap frame
675-
jbsr _C_LABEL(trap) | go handle it
676-
lea %sp@(16),%sp | pop value args
677-
movl %sp@(FR_SP),%a0 | restore
678-
movl %a0,%usp | user SP
679-
moveml %sp@+,#0x7FFF | and all remaining registers
680-
addql #8,%sp | pop SP and stack adjust
681-
rte
682-
Lnosir:
683-
movl %sp@+,%d0 | restore scratch register
684654
Ldorte:
685-
rte | real return
655+
rte | and do real RTE
686656

687657
/*
688658
* Initialization
@@ -941,26 +911,6 @@ ENTRY(probeva)
941911
.word 0x4e7a,0x0805 | movec MMUSR,d0
942912
rts
943913

944-
/*
945-
* Set processor priority level calls. Most are implemented with
946-
* inline asm expansions. However, spl0 requires special handling
947-
* as we need to check for our emulated software interrupts.
948-
*/
949-
950-
ENTRY(spl0)
951-
moveq #0,%d0
952-
movw %sr,%d0 | get old SR for return
953-
movw #PSL_LOWIPL,%sr | restore new SR
954-
tstb _C_LABEL(ssir) | software interrupt pending?
955-
jeq Lspldone | no, all done
956-
subql #4,%sp | make room for RTE frame
957-
movl %sp@(4),%sp@(2) | position return address
958-
clrw %sp@(6) | set frame type 0
959-
movw #PSL_LOWIPL,%sp@ | and new SR
960-
jra Lgotsir | go handle it
961-
Lspldone:
962-
rts
963-
964914
/*
965915
* Handle the nitty-gritty of rebooting the machine.
966916
*

sys/arch/atari/include/intr.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: intr.h,v 1.25 2024/01/19 20:55:42 thorpej Exp $ */
1+
/* $NetBSD: intr.h,v 1.26 2026/03/18 04:08:38 thorpej Exp $ */
22

33
/*-
44
* Copyright (c) 1996, 1997, 2007 The NetBSD Foundation, Inc.
@@ -59,20 +59,17 @@ typedef struct {
5959
*/
6060
#include <machine/psl.h>
6161

62-
/* spl0 requires checking for software interrupts */
63-
6462
#define splsoftclock() splraise1()
6563
#define splsoftbio() splraise1()
6664
#define splsoftnet() splraise1()
6765
#define splsoftserial() splraise1()
6866
#define splvm() splraise4()
6967
#define splsched() splraise6()
7068
#define splhigh() spl7()
71-
#define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0())
69+
#define spl0() _spl0()
70+
#define splx(s) _splx(s)
7271

7372
#ifdef _KERNEL
74-
int spl0(void);
75-
7673
extern const uint16_t ipl2psl_table[NIPL];
7774
extern volatile unsigned int intr_depth;
7875

sys/arch/cesfic/cesfic/locore.s

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.53 2026/03/14 21:03:39 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.54 2026/03/18 04:08:38 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1980, 1990, 1993
@@ -371,7 +371,7 @@ Lmainreturned:
371371

372372
/*
373373
* Trap/interrupt vector routines
374-
*/
374+
*/
375375
#include <m68k/m68k/trap_subr.s>
376376

377377
/*
@@ -467,21 +467,15 @@ ENTRY_NOPROFILE(badtrap)
467467
ENTRY_NOPROFILE(trap0)
468468
clrl %sp@- | stack adjust count
469469
moveml #0xFFFF,%sp@- | save user registers
470-
movl %usp,%a0 | save the user SP
470+
movl %usp,%a0 | save the user SP
471471
movl %a0,%sp@(FR_SP) | in the savearea
472-
movl %d0,%sp@- | push syscall number
472+
movl %d0,%sp@- | push syscall number
473473
jbsr _C_LABEL(syscall) | handle it
474474
addql #4,%sp | pop syscall arg
475475
tstl _C_LABEL(astpending)
476476
jne Lrei2
477-
tstb _C_LABEL(ssir)
478-
jeq Ltrap1
479-
movw #SPL1,%sr
480-
tstb _C_LABEL(ssir)
481-
jne Lsir1
482-
Ltrap1:
483477
movl %sp@(FR_SP),%a0 | grab and restore
484-
movl %a0,%usp | user SP
478+
movl %a0,%usp | user SP
485479
moveml %sp@+,#0x7FFF | restore most registers
486480
addql #8,%sp | pop SP and stack adjust
487481
rte
@@ -635,18 +629,16 @@ ENTRY_NOPROFILE(lev7intr) /* level 7: parity errors, reset key */
635629
* This code is complicated by the fact that sendsig may have been called
636630
* necessitating a stack cleanup.
637631
*/
638-
BSS(ssir,1)
639-
640632
ASENTRY_NOPROFILE(rei)
641633
tstl _C_LABEL(astpending) | AST pending?
642-
jeq Lchksir | no, go check for SIR
634+
jeq Ldorte | Nope. Just return.
643635
Lrei1:
644-
btst #5,%sp@ | yes, are we returning to user mode?
645-
jne Lchksir | no, go check for SIR
636+
btst #5,%sp@ | Are we returning to user mode?
637+
jne Ldorte | Nope. Just return.
646638
movw #PSL_LOWIPL,%sr | lower SPL
647639
clrl %sp@- | stack adjust
648640
moveml #0xFFFF,%sp@- | save all registers
649-
movl %usp,%a1 | including
641+
movl %usp,%a1 | including
650642
movl %a1,%sp@(FR_SP) | the users SP
651643
Lrei2:
652644
clrl %sp@- | VA == none
@@ -672,39 +664,8 @@ Laststkadj:
672664
movl %a0,%sp@(FR_SP) | new SSP
673665
moveml %sp@+,#0x7FFF | restore user registers
674666
movl %sp@,%sp | and our SP
675-
rte | and do real RTE
676-
Lchksir:
677-
tstb _C_LABEL(ssir) | SIR pending?
678-
jeq Ldorte | no, all done
679-
movl %d0,%sp@- | need a scratch register
680-
movw %sp@(4),%d0 | get SR
681-
andw #PSL_IPL7,%d0 | mask all but IPL
682-
jne Lnosir | came from interrupt, no can do
683-
movl %sp@+,%d0 | restore scratch register
684-
Lgotsir:
685-
movw #SPL1,%sr | prevent others from servicing int
686-
tstb _C_LABEL(ssir) | too late?
687-
jeq Ldorte | yes, oh well...
688-
clrl %sp@- | stack adjust
689-
moveml #0xFFFF,%sp@- | save all registers
690-
movl %usp,%a1 | including
691-
movl %a1,%sp@(FR_SP) | the users SP
692-
Lsir1:
693-
clrl %sp@- | VA == none
694-
clrl %sp@- | code == none
695-
movl #T_SSIR,%sp@- | type == software interrupt
696-
pea %sp@(12) | fp == address of trap frame
697-
jbsr _C_LABEL(trap) | go handle it
698-
lea %sp@(16),%sp | pop value args
699-
movl %sp@(FR_SP),%a0 | restore
700-
movl %a0,%usp | user SP
701-
moveml %sp@+,#0x7FFF | and all remaining registers
702-
addql #8,%sp | pop SP and stack adjust
703-
rte
704-
Lnosir:
705-
movl %sp@+,%d0 | restore scratch register
706667
Ldorte:
707-
rte | real return
668+
rte | and do real RTE
708669

709670
/*
710671
* Primitives
@@ -745,26 +706,6 @@ Lsldone:
745706
rts
746707
#endif
747708

748-
/*
749-
* Set processor priority level calls. Most are implemented with
750-
* inline asm expansions. However, spl0 requires special handling
751-
* as we need to check for our emulated software interrupts.
752-
*/
753-
754-
ENTRY(spl0)
755-
moveq #0,%d0
756-
movw %sr,%d0 | get old SR for return
757-
movw #PSL_LOWIPL,%sr | restore new SR
758-
tstb _C_LABEL(ssir) | software interrupt pending?
759-
jeq Lspldone | no, all done
760-
subql #4,%sp | make room for RTE frame
761-
movl %sp@(4),%sp@(2) | position return address
762-
clrw %sp@(6) | set frame type 0
763-
movw #PSL_LOWIPL,%sp@ | and new SR
764-
jra Lgotsir | go handle it
765-
Lspldone:
766-
rts
767-
768709
/*
769710
* _delay(u_int N)
770711
*

sys/arch/mac68k/include/intr.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: intr.h,v 1.33 2024/02/28 13:05:40 thorpej Exp $ */
1+
/* $NetBSD: intr.h,v 1.34 2026/03/18 04:08:38 thorpej Exp $ */
22

33
/*
44
* Copyright (C) 1997 Scott Reynolds
@@ -40,8 +40,6 @@ typedef struct {
4040

4141
#ifdef _KERNEL
4242

43-
/* spl0 requires checking for software interrupts */
44-
4543
#define IPL_NONE 0
4644
#define IPL_SOFTCLOCK 1
4745
#define IPL_SOFTBIO 2
@@ -68,8 +66,8 @@ extern uint16_t ipl2psl_table[NIPL];
6866
*/
6967

7068
/* watch out for side effects */
71-
#define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0())
72-
69+
#define spl0() _spl0()
70+
#define splx(s) _splx(s)
7371

7472
typedef int ipl_t;
7573

@@ -95,9 +93,6 @@ void intr_init(void);
9593
void intr_establish(int (*)(void *), void *, int);
9694
void intr_disestablish(int);
9795
void intr_dispatch(struct clockframe);
98-
99-
/* locore.s */
100-
int spl0(void);
10196
#endif /* _KERNEL */
10297

10398
#endif /* _MAC68K_INTR_H_ */

sys/arch/mac68k/mac68k/intr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: intr.c,v 1.36 2024/02/28 13:05:40 thorpej Exp $ */
1+
/* $NetBSD: intr.c,v 1.37 2026/03/18 04:08:38 thorpej Exp $ */
22

33
/*-
44
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
3434
*/
3535

3636
#include <sys/cdefs.h>
37-
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.36 2024/02/28 13:05:40 thorpej Exp $");
37+
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.37 2026/03/18 04:08:38 thorpej Exp $");
3838

3939
#include <sys/param.h>
4040
#include <sys/systm.h>
@@ -84,7 +84,6 @@ int intr_debug = 0;
8484
*/
8585
uint16_t ipl2psl_table[NIPL];
8686
volatile unsigned int intr_depth;
87-
volatile int ssir;
8887

8988
extern u_int intrcnt[]; /* from locore.s */
9089

0 commit comments

Comments
 (0)