Skip to content

Commit 0c68c1d

Browse files
committed
Oops missed sun3x in previous changes:
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. 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). 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. Re-factor trap12 ("cachectl") into trap_subr.s. Already identical everywhere except for 68010, where it's a no-op.
1 parent 1617cf0 commit 0c68c1d

File tree

1 file changed

+1
-99
lines changed

1 file changed

+1
-99
lines changed

sys/arch/sun3/sun3x/locore.s

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.s,v 1.80 2026/03/18 04:15:32 thorpej Exp $ */
1+
/* $NetBSD: locore.s,v 1.81 2026/03/19 12:39:03 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 1988 University of Utah.
@@ -202,45 +202,6 @@ Lfptnull:
202202
* Other exceptions only cause four and six word stack frame and require
203203
* no post-trap stack adjustment.
204204
*/
205-
GLOBAL(badtrap)
206-
clrl %sp@- | stack adjust count
207-
moveml #0xFFFF,%sp@- | save std frame regs
208-
jbsr _C_LABEL(straytrap) | report
209-
moveml %sp@+,#0xFFFF | restore regs
210-
addql #4,%sp | stack adjust count
211-
jra _ASM_LABEL(rei) | all done
212-
213-
/*
214-
* Trap 0 is for system calls
215-
*/
216-
GLOBAL(trap0)
217-
clrl %sp@- | stack adjust count
218-
moveml #0xFFFF,%sp@- | save user registers
219-
movl %usp,%a0 | save the user SP
220-
movl %a0,%sp@(FR_SP) | in the savearea
221-
movl %d0,%sp@- | push syscall number
222-
jbsr _C_LABEL(syscall) | handle it
223-
addql #4,%sp | pop syscall arg
224-
movl %sp@(FR_SP),%a0 | grab and restore
225-
movl %a0,%usp | user SP
226-
moveml %sp@+,#0x7FFF | restore most registers
227-
addql #8,%sp | pop SP and stack adjust
228-
jra _ASM_LABEL(rei) | all done
229-
230-
/*
231-
* Trap 12 is the entry point for the cachectl "syscall"
232-
* cachectl(command, addr, length)
233-
* command in d0, addr in a1, length in d1
234-
*/
235-
GLOBAL(trap12)
236-
movl _C_LABEL(curlwp),%a0
237-
movl %a0@(L_PROC),%sp@- | push curproc pointer
238-
movl %d1,%sp@- | push length
239-
movl %a1,%sp@- | push addr
240-
movl %d0,%sp@- | push command
241-
jbsr _C_LABEL(cachectl1) | do it
242-
lea %sp@(16),%sp | pop args
243-
jra _ASM_LABEL(rei) | all done
244205

245206
/*
246207
* Trace (single-step) trap. Kernel-mode is special.
@@ -341,65 +302,6 @@ GLOBAL(_isr_clock)
341302
INTERRUPT_RESTOREREG
342303
jra _ASM_LABEL(rei)
343304

344-
/*
345-
* Emulation of VAX REI instruction.
346-
*
347-
* This code is (mostly) un-altered from the hp300 code,
348-
* except that sun machines do not need a simulated SIR
349-
* because they have a real software interrupt register.
350-
*
351-
* This code deals with checking for and servicing ASTs
352-
* (profiling, scheduling) and software interrupts (network, softclock).
353-
* We check for ASTs first, just like the VAX. To avoid excess overhead
354-
* the T_ASTFLT handling code will also check for software interrupts so we
355-
* do not have to do it here. After identifying that we need an AST we
356-
* drop the IPL to allow device interrupts.
357-
*
358-
* This code is complicated by the fact that sendsig may have been called
359-
* necessitating a stack cleanup.
360-
*/
361-
362-
ASGLOBAL(rei)
363-
#ifdef DIAGNOSTIC
364-
tstl _C_LABEL(panicstr) | have we panicked?
365-
jne Ldorte | yes, do not make matters worse
366-
#endif
367-
tstl _C_LABEL(astpending) | AST pending?
368-
jeq Ldorte | no, done
369-
Lrei1:
370-
btst #5,%sp@ | yes, are we returning to user mode?
371-
jne Ldorte | no, done
372-
movw #PSL_LOWIPL,%sr | lower SPL
373-
clrl %sp@- | stack adjust
374-
moveml #0xFFFF,%sp@- | save all registers
375-
movl %usp,%a1 | including
376-
movl %a1,%sp@(FR_SP) | the users SP
377-
clrl %sp@- | VA == none
378-
clrl %sp@- | code == none
379-
movl #T_ASTFLT,%sp@- | type == async system trap
380-
pea %sp@(12) | fp == address of trap frame
381-
jbsr _C_LABEL(trap) | go handle it
382-
lea %sp@(16),%sp | pop value args
383-
movl %sp@(FR_SP),%a0 | restore user SP
384-
movl %a0,%usp | from save area
385-
movw %sp@(FR_ADJ),%d0 | need to adjust stack?
386-
jne Laststkadj | yes, go to it
387-
moveml %sp@+,#0x7FFF | no, restore most user regs
388-
addql #8,%sp | toss SP and stack adjust
389-
rte | and do real RTE
390-
Laststkadj:
391-
lea %sp@(FR_HW),%a1 | pointer to HW frame
392-
addql #8,%a1 | source pointer
393-
movl %a1,%a0 | source
394-
addw %d0,%a0 | + hole size = dest pointer
395-
movl %a1@-,%a0@- | copy
396-
movl %a1@-,%a0@- | 8 bytes
397-
movl %a0,%sp@(FR_SP) | new SSP
398-
moveml %sp@+,#0x7FFF | restore user registers
399-
movl %sp@,%sp | and our SP
400-
Ldorte:
401-
rte | real return
402-
403305
/*
404306
* Initialization is at the beginning of this file, because the
405307
* kernel entry point needs to be at zero for compatibility with

0 commit comments

Comments
 (0)