Skip to content

Commit fd89440

Browse files
committed
Now that all of the m68k copies of the "rei" function are functionally
equivalent, pick the one that uses the fewest cycles in the "no AST pending" case and re-factor it into trap_subr.s.
1 parent 38d0562 commit fd89440

14 files changed

Lines changed: 82 additions & 723 deletions

File tree

sys/arch/amiga/amiga/locore.s

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.176 2026/03/18 04:15:30 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.177 2026/03/18 13:56:06 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -515,63 +515,6 @@ ENTRY_NOPROFILE(lev7intr)
515515
*/
516516
rte | all done
517517

518-
519-
/*
520-
* Emulation of VAX REI instruction.
521-
*
522-
* This code deals with checking for and servicing ASTs
523-
* (profiling, scheduling) and software interrupts (network, softclock).
524-
* We check for ASTs first, just like the VAX. To avoid excess overhead
525-
* the T_ASTFLT handling code will also check for software interrupts so we
526-
* do not have to do it here. After identifying that we need an AST we
527-
* drop the IPL to allow device interrupts.
528-
*
529-
* This code is complicated by the fact that sendsig may have been called
530-
* necessitating a stack cleanup. A cleanup should only be needed at this
531-
* point for coprocessor mid-instruction frames (type 9), but we also test
532-
* for bus error frames (type 10 and 11).
533-
*/
534-
ASENTRY_NOPROFILE(rei)
535-
#ifdef DEBUG
536-
tstl _C_LABEL(panicstr) | have we panicked?
537-
jne Ldorte | yes, do not make matters worse
538-
#endif
539-
tstl _C_LABEL(astpending) | AST pending?
540-
jeq Ldorte | no, done
541-
Lrei1:
542-
btst #5,%sp@ | yes, are we returning to user mode?
543-
jne Ldorte | no, done
544-
movw #PSL_LOWIPL,%sr | lower SPL
545-
clrl %sp@- | stack adjust
546-
moveml %d0-%d7/%a0-%a7,%sp@- | save all registers
547-
movl %usp,%a1 | including
548-
movl %a1,%sp@(FR_SP) | the users SP
549-
clrl %sp@- | VA == none
550-
clrl %sp@- | code == none
551-
movl #T_ASTFLT,%sp@- | type == async system trap
552-
pea %sp@(12) | fp == address of trap frame
553-
jbsr _C_LABEL(trap) | go handle it
554-
lea %sp@(16),%sp | pop value args
555-
movl %sp@(FR_SP),%a0 | restore user SP
556-
movl %a0,%usp | from save area
557-
movw %sp@(FR_ADJ),%d0 | need to adjust stack?
558-
jne Laststkadj | yes, go to it
559-
moveml %sp@+,%d0-%d7/%a0-%a6 | no, restore most user regs
560-
addql #8,%sp | toss SP and stack adjust
561-
rte | and do real RTE
562-
Laststkadj:
563-
lea %sp@(FR_HW),%a1 | pointer to HW frame
564-
addql #8,%a1 | source pointer
565-
movl %a1,%a0 | source
566-
addw %d0,%a0 | + hole size = dest pointer
567-
movl %a1@-,%a0@- | copy
568-
movl %a1@-,%a0@- | 8 bytes
569-
movl %a0,%sp@(FR_SP) | new SSP
570-
moveml %sp@+,%d0-%d7/%a0-%a6 | restore user registers
571-
movl %sp@,%sp | and our SP
572-
Ldorte:
573-
rte | real return
574-
575518
/*
576519
* Kernel access to the current processes kernel stack is via a fixed
577520
* virtual address. It is at the same address as in the users VA space.

sys/arch/atari/atari/locore.s

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.131 2026/03/18 04:15:31 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.132 2026/03/18 13:56:06 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -592,63 +592,6 @@ ENTRY_NOPROFILE(lev7intr)
592592

593593
#endif /* _ATARIHW_ */
594594

595-
596-
/*
597-
* Emulation of VAX REI instruction.
598-
*
599-
* This code deals with checking for and servicing ASTs
600-
* (profiling, scheduling) and software interrupts (network, softclock).
601-
* We check for ASTs first, just like the VAX. To avoid excess overhead
602-
* the T_ASTFLT handling code will also check for software interrupts so we
603-
* do not have to do it here. After identifying that we need an AST we
604-
* drop the IPL to allow device interrupts.
605-
*
606-
* This code is complicated by the fact that sendsig may have been called
607-
* necessitating a stack cleanup. A cleanup should only be needed at this
608-
* point for coprocessor mid-instruction frames (type 9), but we also test
609-
* for bus error frames (type 10 and 11).
610-
*/
611-
ASENTRY_NOPROFILE(rei)
612-
#ifdef DEBUG
613-
tstl _C_LABEL(panicstr) | have we panicked?
614-
jne Ldorte | yes, do not make matters worse
615-
#endif
616-
tstl _C_LABEL(astpending) | AST pending?
617-
jeq Ldorte | Nope. Just return.
618-
Lrei1:
619-
btst #5,%sp@ | yes, are we returning to user mode?
620-
jne Ldorte | Nope. Just return.
621-
movw #PSL_LOWIPL,%sr | lower SPL
622-
clrl %sp@- | stack adjust
623-
moveml #0xFFFF,%sp@- | save all registers
624-
movl %usp,%a1 | including
625-
movl %a1,%sp@(FR_SP) | the users SP
626-
clrl %sp@- | VA == none
627-
clrl %sp@- | code == none
628-
movl #T_ASTFLT,%sp@- | type == async system trap
629-
pea %sp@(12) | fp == address of trap frame
630-
jbsr _C_LABEL(trap) | go handle it
631-
lea %sp@(16),%sp | pop value args
632-
movl %sp@(FR_SP),%a0 | restore user SP
633-
movl %a0,%usp | from save area
634-
movw %sp@(FR_ADJ),%d0 | need to adjust stack?
635-
jne Laststkadj | yes, go to it
636-
moveml %sp@+,#0x7FFF | no, restore most user regs
637-
addql #8,%sp | toss SP and stack adjust
638-
rte | and do real RTE
639-
Laststkadj:
640-
lea %sp@(FR_HW),%a1 | pointer to HW frame
641-
addql #8,%a1 | source pointer
642-
movl %a1,%a0 | source
643-
addw %d0,%a0 | + hole size = dest pointer
644-
movl %a1@-,%a0@- | copy
645-
movl %a1@-,%a0@- | 8 bytes
646-
movl %a0,%sp@(FR_SP) | new SSP
647-
moveml %sp@+,#0x7FFF | restore user registers
648-
movl %sp@,%sp | and our SP
649-
Ldorte:
650-
rte | and do real RTE
651-
652595
/*
653596
* Initialization
654597
*

sys/arch/cesfic/cesfic/locore.s

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.55 2026/03/18 04:15:31 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.56 2026/03/18 13:56:06 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1980, 1990, 1993
@@ -467,8 +467,8 @@ ENTRY_NOPROFILE(trap0)
467467
movl %d0,%sp@- | push syscall number
468468
jbsr _C_LABEL(syscall) | handle it
469469
addql #4,%sp | pop syscall arg
470-
tstl _C_LABEL(astpending)
471-
jne Lrei2
470+
tstl _C_LABEL(astpending) | AST pending?
471+
jne _ASM_LABEL(doast) | Yup, go deal with it.
472472
movl %sp@(FR_SP),%a0 | grab and restore
473473
movl %a0,%usp | user SP
474474
moveml %sp@+,#0x7FFF | restore most registers
@@ -611,57 +611,6 @@ ENTRY_NOPROFILE(lev7intr) /* level 7: parity errors, reset key */
611611
addql #8,%sp | pop SP and stack adjust
612612
jra _ASM_LABEL(rei) | all done
613613

614-
/*
615-
* Emulation of VAX REI instruction.
616-
*
617-
* This code deals with checking for and servicing ASTs
618-
* (profiling, scheduling) and software interrupts (network, softclock).
619-
* We check for ASTs first, just like the VAX. To avoid excess overhead
620-
* the T_ASTFLT handling code will also check for software interrupts so we
621-
* do not have to do it here. After identifying that we need an AST we
622-
* drop the IPL to allow device interrupts.
623-
*
624-
* This code is complicated by the fact that sendsig may have been called
625-
* necessitating a stack cleanup.
626-
*/
627-
ASENTRY_NOPROFILE(rei)
628-
tstl _C_LABEL(astpending) | AST pending?
629-
jeq Ldorte | Nope. Just return.
630-
Lrei1:
631-
btst #5,%sp@ | Are we returning to user mode?
632-
jne Ldorte | Nope. Just return.
633-
movw #PSL_LOWIPL,%sr | lower SPL
634-
clrl %sp@- | stack adjust
635-
moveml #0xFFFF,%sp@- | save all registers
636-
movl %usp,%a1 | including
637-
movl %a1,%sp@(FR_SP) | the users SP
638-
Lrei2:
639-
clrl %sp@- | VA == none
640-
clrl %sp@- | code == none
641-
movl #T_ASTFLT,%sp@- | type == async system trap
642-
pea %sp@(12) | fp == address of trap frame
643-
jbsr _C_LABEL(trap) | go handle it
644-
lea %sp@(16),%sp | pop value args
645-
movl %sp@(FR_SP),%a0 | restore user SP
646-
movl %a0,%usp | from save area
647-
movw %sp@(FR_ADJ),%d0 | need to adjust stack?
648-
jne Laststkadj | yes, go to it
649-
moveml %sp@+,#0x7FFF | no, restore most user regs
650-
addql #8,%sp | toss SP and stack adjust
651-
rte | and do real RTE
652-
Laststkadj:
653-
lea %sp@(FR_HW),%a1 | pointer to HW frame
654-
addql #8,%a1 | source pointer
655-
movl %a1,%a0 | source
656-
addw %d0,%a0 | + hole size = dest pointer
657-
movl %a1@-,%a0@- | copy
658-
movl %a1@-,%a0@- | 8 bytes
659-
movl %a0,%sp@(FR_SP) | new SSP
660-
moveml %sp@+,#0x7FFF | restore user registers
661-
movl %sp@,%sp | and our SP
662-
Ldorte:
663-
rte | and do real RTE
664-
665614
/*
666615
* Primitives
667616
*/

sys/arch/hp300/hp300/locore.s

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.202 2026/03/18 04:15:31 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.203 2026/03/18 13:56:06 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1980, 1990, 1993
@@ -640,7 +640,7 @@ ENTRY_NOPROFILE(trap0)
640640
jbsr _C_LABEL(syscall) | handle it
641641
addql #4,%sp | pop syscall arg
642642
tstl _C_LABEL(astpending) | AST pending?
643-
jne Lrei | yes, handle it via trap
643+
jne _ASM_LABEL(doast) | yes, go deal with it.
644644
movl %sp@(FR_SP),%a0 | grab and restore
645645
movl %a0,%usp | user SP
646646
moveml %sp@+,#0x7FFF | restore most registers
@@ -869,58 +869,6 @@ ENTRY_NOPROFILE(lev7intr) /* level 7: parity errors, reset key */
869869
addql #8,%sp | pop SP and stack adjust
870870
jra _ASM_LABEL(rei) | all done
871871

872-
/*
873-
* Emulation of VAX REI instruction.
874-
*
875-
* This code deals with checking for and servicing
876-
* ASTs (profiling, scheduling).
877-
* After identifying that we need an AST we drop the IPL
878-
* to allow device interrupts.
879-
*
880-
* This code is complicated by the fact that sendsig may have been called
881-
* necessitating a stack cleanup.
882-
*/
883-
884-
ASENTRY_NOPROFILE(rei)
885-
tstl _C_LABEL(astpending) | AST pending?
886-
jne 1f | no, done
887-
rte
888-
1:
889-
btst #5,%sp@ | yes, are we returning to user mode?
890-
jeq 2f | no, done
891-
rte
892-
2:
893-
movw #PSL_LOWIPL,%sr | lower SPL
894-
clrl %sp@- | stack adjust
895-
moveml #0xFFFF,%sp@- | save all registers
896-
movl %usp,%a1 | including
897-
movl %a1,%sp@(FR_SP) | the users SP
898-
Lrei:
899-
clrl %sp@- | VA == none
900-
clrl %sp@- | code == none
901-
movl #T_ASTFLT,%sp@- | type == async system trap
902-
pea %sp@(12) | fp == address of trap frame
903-
jbsr _C_LABEL(trap) | go handle it
904-
lea %sp@(16),%sp | pop value args
905-
movl %sp@(FR_SP),%a0 | restore user SP
906-
movl %a0,%usp | from save area
907-
movw %sp@(FR_ADJ),%d0 | need to adjust stack?
908-
jne Laststkadj | yes, go to it
909-
moveml %sp@+,#0x7FFF | no, restore most user regs
910-
addql #8,%sp | toss SP and stack adjust
911-
rte | and do real RTE
912-
Laststkadj:
913-
lea %sp@(FR_HW),%a1 | pointer to HW frame
914-
addql #8,%a1 | source pointer
915-
movl %a1,%a0 | source
916-
addw %d0,%a0 | + hole size = dest pointer
917-
movl %a1@-,%a0@- | copy
918-
movl %a1@-,%a0@- | 8 bytes
919-
movl %a0,%sp@(FR_SP) | new SSP
920-
moveml %sp@+,#0x7FFF | restore user registers
921-
movl %sp@,%sp | and our SP
922-
rte | and do real RTE
923-
924872
/*
925873
* Primitives
926874
*/

sys/arch/luna68k/luna68k/locore.s

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.98 2026/03/18 04:15:31 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.99 2026/03/18 13:56:07 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -385,7 +385,7 @@ ENTRY_NOPROFILE(trap0)
385385
jbsr _C_LABEL(syscall) | handle it
386386
addql #4,%sp | pop syscall arg
387387
tstl _C_LABEL(astpending) | AST pending?
388-
jne Lrei | yes, handle it via trap
388+
jne _ASM_LABEL(doast) | Yup, go deal with it.
389389
movl %sp@(FR_SP),%a0 | grab and restore
390390
movl %a0,%usp | user SP
391391
moveml %sp@+,#0x7FFF | restore most registers
@@ -553,60 +553,6 @@ ENTRY_NOPROFILE(lev5intr)
553553
jbra _C_LABEL(intrstub_autovec)
554554
#endif
555555

556-
/*
557-
* Emulation of VAX REI instruction.
558-
*
559-
* This code deals with checking for and servicing ASTs
560-
* (profiling, scheduling) and software interrupts (network, softclock).
561-
* We check for ASTs first, just like the VAX. To avoid excess overhead
562-
* the T_ASTFLT handling code will also check for software interrupts so we
563-
* do not have to do it here. After identifying that we need an AST we
564-
* drop the IPL to allow device interrupts.
565-
*
566-
* This code is complicated by the fact that sendsig may have been called
567-
* necessitating a stack cleanup.
568-
*/
569-
570-
ASENTRY_NOPROFILE(rei)
571-
tstl _C_LABEL(astpending) | AST pending?
572-
jne 1f | no, done
573-
rte
574-
1:
575-
btst #5,%sp@ | yes, are we returning to user mode?
576-
jeq 2f | no, done
577-
rte
578-
2:
579-
movw #PSL_LOWIPL,%sr | lower SPL
580-
clrl %sp@- | stack adjust
581-
moveml #0xFFFF,%sp@- | save all registers
582-
movl %usp,%a1 | including
583-
movl %a1,%sp@(FR_SP) | the users SP
584-
Lrei:
585-
clrl %sp@- | VA == none
586-
clrl %sp@- | code == none
587-
movl #T_ASTFLT,%sp@- | type == async system trap
588-
pea %sp@(12) | fp == address of trap frame
589-
jbsr _C_LABEL(trap) | go handle it
590-
lea %sp@(16),%sp | pop value args
591-
movl %sp@(FR_SP),%a0 | restore user SP
592-
movl %a0,%usp | from save area
593-
movw %sp@(FR_ADJ),%d0 | need to adjust stack?
594-
jne Laststkadj | yes, go to it
595-
moveml %sp@+,#0x7FFF | no, restore most user regs
596-
addql #8,%sp | toss SP and stack adjust
597-
rte | and do real RTE
598-
Laststkadj:
599-
lea %sp@(FR_HW),%a1 | pointer to HW frame
600-
addql #8,%a1 | source pointer
601-
movl %a1,%a0 | source
602-
addw %d0,%a0 | + hole size = dest pointer
603-
movl %a1@-,%a0@- | copy
604-
movl %a1@-,%a0@- | 8 bytes
605-
movl %a0,%sp@(FR_SP) | new SSP
606-
moveml %sp@+,#0x7FFF | restore user registers
607-
movl %sp@,%sp | and our SP
608-
rte | and do real RTE
609-
610556
/*
611557
* Primitives
612558
*/

0 commit comments

Comments
 (0)