last snapshot before uploading
This commit is contained in:
parent
a2133ea268
commit
be4748c4d8
348
sys/arch/sun3/sun3/trap.s
Normal file
348
sys/arch/sun3/sun3/trap.s
Normal file
@ -0,0 +1,348 @@
|
||||
/*
|
||||
* Copyright (c) 1993 Adam Glass
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
* Copyright (c) 1980, 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Utah $Hdr: locore.s 1.58 91/04/22$
|
||||
*
|
||||
* from: @(#)locore.s 7.11 (Berkeley) 5/9/91
|
||||
* locore.s,v 1.2 1993/05/22 07:57:30 cgd Exp
|
||||
*/
|
||||
|
||||
/*
|
||||
* Trap/interrupt vector routines
|
||||
*/
|
||||
|
||||
/* the buserr/addrerr won't work on a sun3. in particular more interpretation
|
||||
* of the memory error register is necessary
|
||||
*/
|
||||
|
||||
|
||||
.globl _trap, _nofault, _longjmp
|
||||
_buserr:
|
||||
tstl _nofault | device probe?
|
||||
jeq _addrerr | no, handle as usual
|
||||
movl _nofault,sp@- | yes,
|
||||
jbsr _longjmp | longjmp(nofault)
|
||||
_addrerr:
|
||||
clrw sp@- | pad SR to longword
|
||||
moveml #0xFFFF,sp@- | save user registers
|
||||
movl usp,a0 | save the user SP
|
||||
movl a0,sp@(60) | in the savearea
|
||||
lea sp@(64),a1 | grab base of HW berr frame
|
||||
moveq #0,d0
|
||||
movw a1@(12),d0 | grab SSW for fault processing
|
||||
btst #12,d0 | RB set?
|
||||
jeq LbeX0 | no, test RC
|
||||
bset #14,d0 | yes, must set FB
|
||||
movw d0,a1@(12) | for hardware too
|
||||
LbeX0:
|
||||
btst #13,d0 | RC set?
|
||||
jeq LbeX1 | no, skip
|
||||
bset #15,d0 | yes, must set FC
|
||||
movw d0,a1@(12) | for hardware too
|
||||
LbeX1:
|
||||
btst #8,d0 | data fault?
|
||||
jeq Lbe0 | no, check for hard cases
|
||||
movl a1@(18),d1 | fault address is as given in frame
|
||||
jra Lbe10 | thats it
|
||||
Lbe0:
|
||||
btst #4,a1@(8) | long (type B) stack frame?
|
||||
jne Lbe4 | yes, go handle
|
||||
movl a1@(4),d1 | no, can use save PC
|
||||
btst #14,d0 | FB set?
|
||||
jeq Lbe3 | no, try FC
|
||||
addql #4,d1 | yes, adjust address
|
||||
jra Lbe10 | done
|
||||
Lbe3:
|
||||
btst #15,d0 | FC set?
|
||||
jeq Lbe10 | no, done
|
||||
addql #2,d1 | yes, adjust address
|
||||
jra Lbe10 | done
|
||||
Lbe4:
|
||||
movl a1@(38),d1 | long format, use stage B address
|
||||
btst #15,d0 | FC set?
|
||||
jeq Lbe10 | no, all done
|
||||
subql #2,d1 | yes, adjust address
|
||||
Lbe10:
|
||||
movl d1,sp@- | push fault VA
|
||||
movl d0,sp@- | and padded SSW
|
||||
movw a1@(8),d0 | get frame format/vector offset
|
||||
andw #0x0FFF,d0 | clear out frame format
|
||||
cmpw #12,d0 | address error vector?
|
||||
jeq Lisaerr | yes, go to it
|
||||
Lismerr:
|
||||
movl #T_MMUFLT,sp@- | show that we are an MMU fault
|
||||
jra Ltrapnstkadj | and deal with it
|
||||
Lisaerr:
|
||||
movl #T_ADDRERR,sp@- | mark address error
|
||||
jra Ltrapnstkadj | and deal with it
|
||||
Lisberr:
|
||||
movl #T_BUSERR,sp@- | mark bus error
|
||||
Ltrapnstkadj:
|
||||
jbsr _trap | handle the error
|
||||
lea sp@(12),sp | pop value args
|
||||
movl sp@(60),a0 | restore user SP
|
||||
movl a0,usp | from save area
|
||||
movw sp@(64),d0 | need to adjust stack?
|
||||
jne Lstkadj | yes, go to it
|
||||
moveml sp@+,#0x7FFF | no, restore most user regs
|
||||
addql #6,sp | toss SSP and pad
|
||||
jra rei | all done
|
||||
Lstkadj:
|
||||
lea sp@(66),a1 | pointer to HW frame
|
||||
addql #8,a1 | source pointer
|
||||
movl a1,a0 | source
|
||||
addw d0,a0 | + hole size = dest pointer
|
||||
movl a1@-,a0@- | copy
|
||||
movl a1@-,a0@- | 8 bytes
|
||||
movl a0,sp@(60) | new SSP
|
||||
moveml sp@+,#0x7FFF | restore user registers
|
||||
movl sp@,sp | and our SP
|
||||
jra rei | all done
|
||||
|
||||
/*
|
||||
* FP exceptions.
|
||||
*/
|
||||
_fpfline:
|
||||
jra _illinst
|
||||
|
||||
_fpunsupp:
|
||||
jra _illinst
|
||||
|
||||
/*
|
||||
* Handles all other FP coprocessor exceptions.
|
||||
* Note that since some FP exceptions generate mid-instruction frames
|
||||
* and may cause signal delivery, we need to test for stack adjustment
|
||||
* after the trap call.
|
||||
*/
|
||||
_fpfault:
|
||||
#ifdef FPCOPROC
|
||||
clrw sp@- | pad SR to longword
|
||||
moveml #0xFFFF,sp@- | save user registers
|
||||
movl usp,a0 | and save
|
||||
movl a0,sp@(60) | the user stack pointer
|
||||
clrl sp@- | no VA arg
|
||||
movl _curpcb,a0 | current pcb
|
||||
lea a0@(PCB_FPCTX),a0 | address of FP savearea
|
||||
fsave a0@ | save state
|
||||
tstb a0@ | null state frame?
|
||||
jeq Lfptnull | yes, safe
|
||||
clrw d0 | no, need to tweak BIU
|
||||
movb a0@(1),d0 | get frame size
|
||||
bset #3,a0@(0,d0:w) | set exc_pend bit of BIU
|
||||
Lfptnull:
|
||||
fmovem fpsr,sp@- | push fpsr as code argument
|
||||
frestore a0@ | restore state
|
||||
movl #T_FPERR,sp@- | push type arg
|
||||
jra Ltrapnstkadj | call trap and deal with stack cleanup
|
||||
#else
|
||||
jra _badtrap | treat as an unexpected trap
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Coprocessor and format errors can generate mid-instruction stack
|
||||
* frames and cause signal delivery hence we need to check for potential
|
||||
* stack adjustment.
|
||||
*/
|
||||
_coperr:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
movl usp,a0 | get and save
|
||||
movl a0,sp@(60) | the user stack pointer
|
||||
clrl sp@- | no VA arg
|
||||
clrl sp@- | or code arg
|
||||
movl #T_COPERR,sp@- | push trap type
|
||||
jra Ltrapnstkadj | call trap and deal with stack adjustments
|
||||
|
||||
_fmterr:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
movl usp,a0 | get and save
|
||||
movl a0,sp@(60) | the user stack pointer
|
||||
clrl sp@- | no VA arg
|
||||
clrl sp@- | or code arg
|
||||
movl #T_FMTERR,sp@- | push trap type
|
||||
jra Ltrapnstkadj | call trap and deal with stack adjustments
|
||||
|
||||
/*
|
||||
* Other exceptions only cause four and six word stack frame and require
|
||||
* no post-trap stack adjustment.
|
||||
*/
|
||||
_illinst:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
moveq #T_ILLINST,d0
|
||||
jra fault
|
||||
|
||||
_zerodiv:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
moveq #T_ZERODIV,d0
|
||||
jra fault
|
||||
|
||||
_chkinst:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
moveq #T_CHKINST,d0
|
||||
jra fault
|
||||
|
||||
_trapvinst:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
moveq #T_TRAPVINST,d0
|
||||
jra fault
|
||||
|
||||
_privinst:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
moveq #T_PRIVINST,d0
|
||||
jra fault
|
||||
|
||||
.globl fault
|
||||
fault:
|
||||
movl usp,a0 | get and save
|
||||
movl a0,sp@(60) | the user stack pointer
|
||||
clrl sp@- | no VA arg
|
||||
clrl sp@- | or code arg
|
||||
movl d0,sp@- | push trap type
|
||||
jbsr _trap | handle trap
|
||||
lea sp@(12),sp | pop value args
|
||||
movl sp@(60),a0 | restore
|
||||
movl a0,usp | user SP
|
||||
moveml sp@+,#0x7FFF | restore most user regs
|
||||
addql #6,sp | pop SP and pad word
|
||||
jra rei | all done
|
||||
|
||||
.globl _straytrap
|
||||
_badtrap:
|
||||
clrw sp@- | pad SR
|
||||
moveml #0xC0C0,sp@- | save scratch regs
|
||||
movw sp@(24),sp@- | push exception vector info
|
||||
clrw sp@-
|
||||
movl sp@(24),sp@- | and PC
|
||||
jbsr _straytrap | report
|
||||
addql #8,sp | pop args
|
||||
moveml sp@+,#0x0303 | restore regs
|
||||
addql #2,sp | pop padding
|
||||
jra rei | all done
|
||||
|
||||
.globl _syscall
|
||||
_trap0:
|
||||
clrw sp@- | pad SR to longword
|
||||
moveml #0xFFFF,sp@- | save user registers
|
||||
movl usp,a0 | save the user SP
|
||||
movl a0,sp@(60) | in the savearea
|
||||
movl d0,sp@- | push syscall number
|
||||
jbsr _syscall | handle it
|
||||
addql #4,sp | pop syscall arg
|
||||
movl sp@(60),a0 | grab and restore
|
||||
movl a0,usp | user SP
|
||||
moveml sp@+,#0x7FFF | restore most registers
|
||||
addql #6,sp | pop SSP and align word
|
||||
jra rei | all done
|
||||
|
||||
/*
|
||||
* Routines for traps 1 and 2. The meaning of the two traps depends
|
||||
* on whether we are an HPUX compatible process or a native 4.3 process.
|
||||
* Our native 4.3 implementation uses trap 1 as sigreturn() and trap 2
|
||||
* as a breakpoint trap. HPUX uses trap 1 for a breakpoint, so we have
|
||||
* to make adjustments so that trap 2 is used for sigreturn.
|
||||
*/
|
||||
_trap1:
|
||||
btst #PCB_TRCB,pcbflag | being traced by an HPUX process?
|
||||
jeq sigreturn | no, trap1 is sigreturn
|
||||
jra _trace | yes, trap1 is breakpoint
|
||||
|
||||
_trap2:
|
||||
btst #PCB_TRCB,pcbflag | being traced by an HPUX process?
|
||||
jeq _trace | no, trap2 is breakpoint
|
||||
jra sigreturn | yes, trap2 is sigreturn
|
||||
|
||||
/*
|
||||
* Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD)
|
||||
* cachectl(command, addr, length)
|
||||
* command in d0, addr in a1, length in d1
|
||||
*/
|
||||
.globl _cachectl
|
||||
_trap12:
|
||||
movl d1,sp@- | push length
|
||||
movl a1,sp@- | push addr
|
||||
movl d0,sp@- | push command
|
||||
jbsr _cachectl | do it
|
||||
lea sp@(12),sp | pop args
|
||||
jra rei | all done
|
||||
|
||||
/*
|
||||
* Trap 15 is used for:
|
||||
* - KGDB traps
|
||||
* - trace traps for SUN binaries (not fully supported yet)
|
||||
* We just pass it on and let trap() sort it all out
|
||||
*/
|
||||
_trap15:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
#ifdef KGDB
|
||||
moveq #T_TRAP15,d0
|
||||
movl sp@(64),d1 | from user mode?
|
||||
andl #PSL_S,d1
|
||||
jeq fault
|
||||
movl d0,sp@-
|
||||
.globl _kgdb_trap_glue
|
||||
jbsr _kgdb_trap_glue | returns if no debugger
|
||||
addl #4,sp
|
||||
#endif
|
||||
moveq #T_TRAP15,d0
|
||||
jra fault
|
||||
|
||||
/*
|
||||
* Hit a breakpoint (trap 1 or 2) instruction.
|
||||
* Push the code and treat as a normal fault.
|
||||
*/
|
||||
_trace:
|
||||
clrw sp@-
|
||||
moveml #0xFFFF,sp@-
|
||||
#ifdef KGDB
|
||||
moveq #T_TRACE,d0
|
||||
movl sp@(64),d1 | from user mode?
|
||||
andl #PSL_S,d1
|
||||
jeq fault
|
||||
movl d0,sp@-
|
||||
jbsr _kgdb_trap_glue | returns if no debugger
|
||||
addl #4,sp
|
||||
#endif
|
||||
moveq #T_TRACE,d0
|
||||
jra fault
|
Loading…
Reference in New Issue
Block a user