Skip to content

Commit d7b3090

Browse files
committed
Re-factor trap0 (system calls) into trap_subr.s. Here we pick the flavor
that has the in-line astpending check bcause it's a few cycles faster in the (common) case where no AST is pending at the end of a system call.
1 parent a84c5c7 commit d7b3090

14 files changed

Lines changed: 31 additions & 220 deletions

File tree

sys/arch/amiga/amiga/locore.s

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.178 2026/03/18 14:44:09 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.179 2026/03/18 15:50:08 thorpej Exp $ */
22

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

181-
ENTRY_NOPROFILE(trap0)
182-
clrl %sp@- | stack adjust count
183-
moveml %d0-%d7/%a0-%a7,%sp@- | save user registers
184-
movl %usp,%a0 | save the user SP
185-
movl %a0,%sp@(FR_SP) | in the savearea
186-
movl %d0,%sp@- | push syscall number
187-
jbsr _C_LABEL(syscall) | handle it
188-
addql #4,%sp | pop syscall arg
189-
movl %sp@(FR_SP),%a0 | grab and restore
190-
movl %a0,%usp | user SP
191-
moveml %sp@+,%d0-%d7/%a0-%a6 | restore most registers
192-
addql #8,%sp | pop SP and stack adjust
193-
jra _ASM_LABEL(rei) | all done
194-
195181
/*
196182
* Trap 12 is the entry point for the cachectl "syscall"
197183
* cachectl(command, addr, length)

sys/arch/atari/atari/locore.s

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.133 2026/03/18 14:44:09 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.134 2026/03/18 15:50:08 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -317,20 +317,6 @@ ENTRY_NOPROFILE(badmfpint)
317317
subql #1,_C_LABEL(intr_depth)
318318
jra _ASM_LABEL(rei) | all done
319319

320-
ENTRY_NOPROFILE(trap0)
321-
clrl %sp@- | stack adjust count
322-
moveml #0xFFFF,%sp@- | save user registers
323-
movl %usp,%a0 | save the user SP
324-
movl %a0,%sp@(FR_SP) | in the savearea
325-
movl %d0,%sp@- | push syscall number
326-
jbsr _C_LABEL(syscall) | handle it
327-
addql #4,%sp | pop syscall arg
328-
movl %sp@(FR_SP),%a0 | grab and restore
329-
movl %a0,%usp | user SP
330-
moveml %sp@+,#0x7FFF | restore most registers
331-
addql #8,%sp | pop SP and stack adjust
332-
jra _ASM_LABEL(rei) | all done
333-
334320
/*
335321
* Trap 12 is the entry point for the cachectl "syscall"
336322
* cachectl(command, addr, length)

sys/arch/cesfic/cesfic/locore.s

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.57 2026/03/18 14:44:09 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.58 2026/03/18 15:50:08 thorpej Exp $ */
22

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

451451

452-
ENTRY_NOPROFILE(trap0)
453-
clrl %sp@- | stack adjust count
454-
moveml #0xFFFF,%sp@- | save user registers
455-
movl %usp,%a0 | save the user SP
456-
movl %a0,%sp@(FR_SP) | in the savearea
457-
movl %d0,%sp@- | push syscall number
458-
jbsr _C_LABEL(syscall) | handle it
459-
addql #4,%sp | pop syscall arg
460-
tstl _C_LABEL(astpending) | AST pending?
461-
jne _ASM_LABEL(doast) | Yup, go deal with it.
462-
movl %sp@(FR_SP),%a0 | grab and restore
463-
movl %a0,%usp | user SP
464-
moveml %sp@+,#0x7FFF | restore most registers
465-
addql #8,%sp | pop SP and stack adjust
466-
rte
467-
468452
/*
469453
* Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD)
470454
* cachectl(command, addr, length)

sys/arch/hp300/hp300/locore.s

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.204 2026/03/18 14:44:09 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.205 2026/03/18 15:50:08 thorpej Exp $ */
22

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

624-
ENTRY_NOPROFILE(trap0)
625-
clrl %sp@- | stack adjust count
626-
moveml #0xFFFF,%sp@- | save user registers
627-
movl %usp,%a0 | save the user SP
628-
movl %a0,%sp@(FR_SP) | in the savearea
629-
movl %d0,%sp@- | push syscall number
630-
jbsr _C_LABEL(syscall) | handle it
631-
addql #4,%sp | pop syscall arg
632-
tstl _C_LABEL(astpending) | AST pending?
633-
jne _ASM_LABEL(doast) | yes, go deal with it.
634-
movl %sp@(FR_SP),%a0 | grab and restore
635-
movl %a0,%usp | user SP
636-
moveml %sp@+,#0x7FFF | restore most registers
637-
addql #8,%sp | pop SP and stack adjust
638-
rte
639-
640624
/*
641625
* Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD)
642626
* cachectl(command, addr, length)

sys/arch/luna68k/luna68k/locore.s

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.100 2026/03/18 14:44:10 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.101 2026/03/18 15:50:08 thorpej Exp $ */
22

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

369-
ENTRY_NOPROFILE(trap0)
370-
clrl %sp@- | stack adjust count
371-
moveml #0xFFFF,%sp@- | save user registers
372-
movl %usp,%a0 | save the user SP
373-
movl %a0,%sp@(FR_SP) | in the savearea
374-
movl %d0,%sp@- | push syscall number
375-
jbsr _C_LABEL(syscall) | handle it
376-
addql #4,%sp | pop syscall arg
377-
tstl _C_LABEL(astpending) | AST pending?
378-
jne _ASM_LABEL(doast) | Yup, go deal with it.
379-
movl %sp@(FR_SP),%a0 | grab and restore
380-
movl %a0,%usp | user SP
381-
moveml %sp@+,#0x7FFF | restore most registers
382-
addql #8,%sp | pop SP and stack adjust
383-
rte
384-
385369
/*
386370
* Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD)
387371
* cachectl(command, addr, length)

sys/arch/m68k/m68k/trap_subr.s

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: trap_subr.s,v 1.22 2026/03/18 14:44:10 thorpej Exp $ */
1+
/* $NetBSD: trap_subr.s,v 1.23 2026/03/18 15:50:08 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -214,6 +214,23 @@ ENTRY_NOPROFILE(badtrap)
214214
addql #8,%sp | pop stack adjust count and %sp
215215
jra _ASM_LABEL(rei) | all done
216216

217+
/* trap #0 -- system calls */
218+
ENTRY_NOPROFILE(trap0)
219+
clrl -(%sp) | stack adjust count
220+
moveml #0xFFFF,-(%sp) | save user registers
221+
movl %usp,%a0 | save the user SP
222+
movl %a0,%sp@(FR_SP) | in the savearea
223+
movl %d0,-(%sp) | push syscall number
224+
jbsr _C_LABEL(syscall) | handle it
225+
addql #4,%sp | pop syscall arg
226+
tstl _C_LABEL(astpending) | AST pending?
227+
jne _ASM_LABEL(doast) | Yup, go deal with it.
228+
movl %sp@(FR_SP),%a0 | grab and restore
229+
movl %a0,%usp | user SP
230+
moveml (%sp)+,#0x7FFF | restore most registers
231+
addql #8,%sp | pop SP and stack adjust
232+
rte | all done
233+
217234
/*
218235
* Emulation of VAX REI instruction.
219236
*

sys/arch/mac68k/mac68k/locore.s

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.195 2026/03/18 14:44:10 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.196 2026/03/18 15:50:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -545,22 +545,6 @@ Lfptnull:
545545
* no post-trap stack adjustment.
546546
*/
547547

548-
ENTRY_NOPROFILE(trap0)
549-
clrl %sp@- | pad SR to longword
550-
moveml #0xFFFF,%sp@- | save user registers
551-
movl %usp,%a0 | save %USP
552-
movl %a0,%sp@(FR_SP) | in the savearea
553-
movl %d0,%sp@- | push syscall number
554-
jbsr _C_LABEL(syscall) | handle it
555-
addql #4,%sp | pop syscall arg
556-
tstl _C_LABEL(astpending) | AST pending?
557-
jne _ASM_LABEL(doast) | Yup, go deal with it.
558-
movl %sp@(FR_SP),%a0 | grab and restore
559-
movl %a0,%usp | %USP
560-
moveml %sp@+,#0x7FFF | restore most registers
561-
addql #8,%sp | pop SSP and align word
562-
rte
563-
564548
/*
565549
* Trap 12 is the entry point for the cachectl "syscall" (both HP-UX & BSD)
566550
* cachectl(command, addr, length)

sys/arch/mvme68k/mvme68k/locore.s

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.153 2026/03/18 14:44:10 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.154 2026/03/18 15:50:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -722,22 +722,6 @@ Lfptnull:
722722
* no post-trap stack adjustment.
723723
*/
724724

725-
ENTRY_NOPROFILE(trap0)
726-
clrl %sp@- | stack adjust count
727-
moveml #0xFFFF,%sp@- | save user registers
728-
movl %usp,%a0 | save the user SP
729-
movl %a0,%sp@(FR_SP) | in the savearea
730-
movl %d0,%sp@- | push syscall number
731-
jbsr _C_LABEL(syscall) | handle it
732-
addql #4,%sp | pop syscall arg
733-
tstl _C_LABEL(astpending) | AST pending?
734-
jne _ASM_LABEL(doast) | Yup, go deal with it.
735-
movl %sp@(FR_SP),%a0 | grab and restore
736-
movl %a0,%usp | user SP
737-
moveml %sp@+,#0x7FFF | restore most registers
738-
addql #8,%sp | pop SP and stack adjust
739-
rte
740-
741725
/*
742726
* Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD)
743727
* cachectl(command, addr, length)

sys/arch/news68k/news68k/locore.s

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.102 2026/03/18 14:44:10 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.103 2026/03/18 15:50:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -448,22 +448,6 @@ Lfptnull:
448448
* no post-trap stack adjustment.
449449
*/
450450

451-
ENTRY_NOPROFILE(trap0)
452-
clrl %sp@- | stack adjust count
453-
moveml #0xFFFF,%sp@- | save user registers
454-
movl %usp,%a0 | save the user SP
455-
movl %a0,%sp@(FR_SP) | in the savearea
456-
movl %d0,%sp@- | push syscall number
457-
jbsr _C_LABEL(syscall) | handle it
458-
addql #4,%sp | pop syscall arg
459-
tstl _C_LABEL(astpending) | AST pending?
460-
jne _ASM_LABEL(doast) | Yup, go deal with it.
461-
movl %sp@(FR_SP),%a0 | grab and restore
462-
movl %a0,%usp | user SP
463-
moveml %sp@+,#0x7FFF | restore most registers
464-
addql #8,%sp | pop SP and stack adjust
465-
rte
466-
467451
/*
468452
* Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD)
469453
* cachectl(command, addr, length)

sys/arch/next68k/next68k/locore.s

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.100 2026/03/18 14:44:10 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.101 2026/03/18 15:50:09 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1998 Darrin B. Jewell
@@ -459,22 +459,6 @@ Lfptnull:
459459
* no post-trap stack adjustment.
460460
*/
461461

462-
ENTRY_NOPROFILE(trap0)
463-
clrl %sp@- | stack adjust count
464-
moveml #0xFFFF,%sp@- | save user registers
465-
movl %usp,%a0 | save the user SP
466-
movl %a0,%sp@(FR_SP) | in the savearea
467-
movl %d0,%sp@- | push syscall number
468-
jbsr _C_LABEL(syscall) | handle it
469-
addql #4,%sp | pop syscall arg
470-
tstl _C_LABEL(astpending) | AST pending?
471-
jne _ASM_LABEL(doast) | Yup, go deal with it.
472-
movl %sp@(FR_SP),%a0 | grab and restore
473-
movl %a0,%usp | user SP
474-
moveml %sp@+,#0x7FFF | restore most registers
475-
addql #8,%sp | pop SP and stack adjust
476-
rte
477-
478462
/*
479463
* Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD)
480464
* cachectl(command, addr, length)

0 commit comments

Comments
 (0)