Home | History | Annotate | Line # | Download | only in boot
      1  1.15   andvar /*	$NetBSD: locore.S,v 1.15 2022/03/16 20:31:01 andvar Exp $	*/
      2   1.6  tsutsui 
      3   1.1  tsutsui /*
      4   1.1  tsutsui  * Copyright (c) 1992 OMRON Corporation.
      5   1.1  tsutsui  *
      6   1.1  tsutsui  * This code is derived from software contributed to Berkeley by
      7   1.1  tsutsui  * OMRON Corporation.
      8   1.1  tsutsui  *
      9   1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
     10   1.1  tsutsui  * modification, are permitted provided that the following conditions
     11   1.1  tsutsui  * are met:
     12   1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     13   1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     14   1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     16   1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     17   1.1  tsutsui  * 3. All advertising materials mentioning features or use of this software
     18   1.1  tsutsui  *    must display the following acknowledgement:
     19   1.1  tsutsui  *	This product includes software developed by the University of
     20   1.1  tsutsui  *	California, Berkeley and its contributors.
     21   1.1  tsutsui  * 4. Neither the name of the University nor the names of its contributors
     22   1.1  tsutsui  *    may be used to endorse or promote products derived from this software
     23   1.1  tsutsui  *    without specific prior written permission.
     24   1.1  tsutsui  *
     25   1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26   1.1  tsutsui  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27   1.1  tsutsui  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28   1.1  tsutsui  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29   1.1  tsutsui  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30   1.1  tsutsui  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31   1.1  tsutsui  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32   1.1  tsutsui  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33   1.1  tsutsui  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34   1.1  tsutsui  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35   1.1  tsutsui  * SUCH DAMAGE.
     36   1.1  tsutsui  *
     37   1.1  tsutsui  *	@(#)locore.s	8.1 (Berkeley) 6/10/93
     38   1.1  tsutsui  */
     39   1.1  tsutsui /*
     40   1.1  tsutsui  * Copyright (c) 1990, 1993
     41   1.1  tsutsui  *	The Regents of the University of California.  All rights reserved.
     42   1.1  tsutsui  *
     43   1.1  tsutsui  * This code is derived from software contributed to Berkeley by
     44   1.1  tsutsui  * OMRON Corporation.
     45   1.1  tsutsui  *
     46   1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
     47   1.1  tsutsui  * modification, are permitted provided that the following conditions
     48   1.1  tsutsui  * are met:
     49   1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     50   1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     51   1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     52   1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     53   1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     54   1.1  tsutsui  * 3. Neither the name of the University nor the names of its contributors
     55   1.1  tsutsui  *    may be used to endorse or promote products derived from this software
     56   1.1  tsutsui  *    without specific prior written permission.
     57   1.1  tsutsui  *
     58   1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     59   1.1  tsutsui  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     60   1.1  tsutsui  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     61   1.1  tsutsui  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     62   1.1  tsutsui  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     63   1.1  tsutsui  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     64   1.1  tsutsui  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     65   1.1  tsutsui  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     66   1.1  tsutsui  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     67   1.1  tsutsui  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     68   1.1  tsutsui  * SUCH DAMAGE.
     69   1.1  tsutsui  *
     70   1.1  tsutsui  *	@(#)locore.s	8.1 (Berkeley) 6/10/93
     71   1.1  tsutsui  */
     72   1.1  tsutsui 
     73   1.1  tsutsui /* For _C_LABEL() and friends. */
     74   1.1  tsutsui #include <m68k/asm.h>
     75   1.1  tsutsui 
     76   1.1  tsutsui #define	T_BUSERR	0
     77   1.1  tsutsui #define	T_ADDRERR	1
     78   1.1  tsutsui #define	T_ILLINST	2
     79   1.1  tsutsui #define	T_ZERODIV	3
     80   1.1  tsutsui #define	T_CHKINST	4
     81   1.1  tsutsui #define	T_TRAPVINST	5
     82   1.1  tsutsui #define	T_PRIVINST	6
     83   1.1  tsutsui #define	T_MMUFLT	8
     84   1.1  tsutsui #define	T_FMTERR	10
     85   1.1  tsutsui #define	T_FPERR		11
     86   1.1  tsutsui #define	T_COPERR	12
     87   1.1  tsutsui 
     88   1.7  tsutsui #define	PSL_LOWIPL	0x2000		/* PSL_S | PSL_IPL0 */
     89   1.7  tsutsui #define	PSL_HIGHIPL	0x2700		/* PSL_S | PSL_IPL7 */
     90   1.1  tsutsui 
     91   1.7  tsutsui #define	SPL1		0x2100		/* PSL_S | PSL_IPL1 */
     92   1.7  tsutsui #define	SPL2		0x2200		/* PSL_S | PSL_IPL2 */
     93   1.7  tsutsui #define	SPL3		0x2300		/* PSL_S | PSL_IPL3 */
     94   1.7  tsutsui #define	SPL4		0x2400		/* PSL_S | PSL_IPL4 */
     95   1.7  tsutsui #define	SPL5		0x2500		/* PSL_S | PSL_IPL5 */
     96   1.7  tsutsui #define	SPL6		0x2600		/* PSL_S | PSL_IPL6 */
     97   1.1  tsutsui 
     98   1.7  tsutsui #define	CLOCK_REG	0x63000000
     99   1.1  tsutsui #define	CLK_CLR		1
    100   1.1  tsutsui 
    101   1.1  tsutsui #define	ILLGINST	16
    102   1.1  tsutsui #define	NMIVEC		124
    103   1.1  tsutsui #define	EVTRAPF		188
    104   1.1  tsutsui 
    105   1.1  tsutsui 	.text
    106   1.1  tsutsui 
    107   1.1  tsutsui ASENTRY_NOPROFILE(start)
    108   1.2  tsutsui ASGLOBAL(Reset)
    109   1.1  tsutsui 	jmp _C_LABEL(start1)	/* 0: NOT USED (reset PC) */
    110   1.1  tsutsui 	.word	0		/* 1: NOT USED (reset PC) */
    111   1.2  tsutsui 	VECTOR(buserr)		/* 2: bus error */
    112   1.2  tsutsui 	VECTOR(addrerr)		/* 3: address error */
    113   1.2  tsutsui 	VECTOR(illinst)		/* 4: illegal instruction */
    114   1.2  tsutsui 	VECTOR(zerodiv)		/* 5: zero divide */
    115   1.2  tsutsui 	VECTOR(chkinst)		/* 6: CHK instruction */
    116   1.2  tsutsui 	VECTOR(trapvinst)	/* 7: TRAPV instruction */
    117   1.2  tsutsui 	VECTOR(privinst)	/* 8: privilege violation */
    118   1.2  tsutsui 	VECTOR(badtrap)		/* 9: trace */
    119   1.2  tsutsui 	VECTOR(illinst)		/* 10: line 1010 emulator */
    120   1.2  tsutsui 	VECTOR(illinst)		/* 11: line 1111 emulator */
    121   1.2  tsutsui 	VECTOR(badtrap)		/* 12: unassigned, reserved */
    122   1.2  tsutsui 	VECTOR(coperr)		/* 13: coprocessor protocol violation */
    123   1.2  tsutsui 	VECTOR(fmterr)		/* 14: format error */
    124   1.2  tsutsui 	VECTOR(badtrap)		/* 15: uninitialized interrupt vector */
    125   1.2  tsutsui 	VECTOR(badtrap)		/* 16: unassigned, reserved */
    126   1.2  tsutsui 	VECTOR(badtrap)		/* 17: unassigned, reserved */
    127   1.2  tsutsui 	VECTOR(badtrap)		/* 18: unassigned, reserved */
    128   1.2  tsutsui 	VECTOR(badtrap)		/* 19: unassigned, reserved */
    129   1.2  tsutsui 	VECTOR(badtrap)		/* 20: unassigned, reserved */
    130   1.2  tsutsui 	VECTOR(badtrap)		/* 21: unassigned, reserved */
    131   1.2  tsutsui 	VECTOR(badtrap)		/* 22: unassigned, reserved */
    132   1.2  tsutsui 	VECTOR(badtrap)		/* 23: unassigned, reserved */
    133   1.2  tsutsui 	VECTOR(badtrap)		/* 24: unassigned, reserved */
    134   1.2  tsutsui 	VECTOR(badtrap)		/* 25: unassigned, reserved */
    135   1.2  tsutsui 	VECTOR(lev2intr)	/* 26: level 2 interrupt autovector */
    136   1.2  tsutsui 	VECTOR(lev3intr)	/* 27: level 3 interrupt autovector */
    137   1.2  tsutsui 	VECTOR(badtrap)		/* 28: level 4 interrupt autovector */
    138   1.2  tsutsui 	VECTOR(lev5intr)	/* 29: level 5 interrupt autovector */
    139   1.2  tsutsui 	VECTOR(lev6intr)	/* 30: level 6 interrupt autovector */
    140  1.14    isaki 	VECTOR(exit)		/* 31: level 7 interrupt autovector */
    141   1.2  tsutsui 	VECTOR(illinst)		/* 32: syscalls */
    142   1.2  tsutsui 	VECTOR(illinst)		/* 33: sigreturn syscall or breakpoint */
    143   1.2  tsutsui 	VECTOR(illinst)		/* 34: breakpoint or sigreturn syscall */
    144   1.2  tsutsui 	VECTOR(illinst)		/* 35: TRAP instruction vector */
    145   1.2  tsutsui 	VECTOR(illinst)		/* 36: TRAP instruction vector */
    146   1.2  tsutsui 	VECTOR(illinst)		/* 37: TRAP instruction vector */
    147   1.2  tsutsui 	VECTOR(illinst)		/* 38: TRAP instruction vector */
    148   1.2  tsutsui 	VECTOR(illinst)		/* 39: TRAP instruction vector */
    149   1.2  tsutsui 	VECTOR(illinst)		/* 40: TRAP instruction vector */
    150   1.2  tsutsui 	VECTOR(illinst)		/* 41: TRAP instruction vector */
    151   1.2  tsutsui 	VECTOR(illinst)		/* 42: TRAP instruction vector */
    152   1.2  tsutsui 	VECTOR(illinst)		/* 43: TRAP instruction vector */
    153   1.2  tsutsui 	VECTOR(illinst)		/* 44: TRAP instruction vector */
    154   1.2  tsutsui 	VECTOR(illinst)		/* 45: TRAP instruction vector */
    155   1.2  tsutsui 	VECTOR(illinst)		/* 45: TRAP instruction vector */
    156   1.2  tsutsui 	VECTOR(illinst)		/* 47: TRAP instruction vector */
    157  1.10  tsutsui 	VECTOR(fptrap)		/* 48: FPCP branch/set on unordered cond */
    158  1.10  tsutsui 	VECTOR(fptrap)		/* 49: FPCP inexact result */
    159  1.10  tsutsui 	VECTOR(fptrap)		/* 50: FPCP divide by zero */
    160  1.10  tsutsui 	VECTOR(fptrap)		/* 51: FPCP underflow */
    161  1.10  tsutsui 	VECTOR(fptrap)		/* 52: FPCP operand error */
    162  1.10  tsutsui 	VECTOR(fptrap)		/* 53: FPCP overflow */
    163  1.10  tsutsui 	VECTOR(fptrap)		/* 54: FPCP signalling NAN */
    164   1.2  tsutsui 
    165   1.2  tsutsui 	VECTOR(badtrap)		/* 55: unassigned, reserved */
    166   1.2  tsutsui 	VECTOR(badtrap)		/* 56: unassigned, reserved */
    167   1.2  tsutsui 	VECTOR(badtrap)		/* 57: unassigned, reserved */
    168   1.2  tsutsui 	VECTOR(badtrap)		/* 58: unassigned, reserved */
    169   1.2  tsutsui 	VECTOR(badtrap)		/* 59: unassigned, reserved */
    170   1.2  tsutsui 	VECTOR(badtrap)		/* 60: unassigned, reserved */
    171   1.2  tsutsui 	VECTOR(badtrap)		/* 61: unassigned, reserved */
    172   1.2  tsutsui 	VECTOR(badtrap)		/* 62: unassigned, reserved */
    173   1.2  tsutsui 	VECTOR(badtrap)		/* 63: unassigned, reserved */
    174   1.2  tsutsui #define BADTRAP16       \
    175   1.2  tsutsui 	VECTOR(badtrap) ; VECTOR(badtrap) ; \
    176   1.2  tsutsui 	VECTOR(badtrap) ; VECTOR(badtrap) ; \
    177   1.2  tsutsui 	VECTOR(badtrap) ; VECTOR(badtrap) ; \
    178   1.2  tsutsui 	VECTOR(badtrap) ; VECTOR(badtrap) ; \
    179   1.2  tsutsui 	VECTOR(badtrap) ; VECTOR(badtrap) ; \
    180   1.2  tsutsui 	VECTOR(badtrap) ; VECTOR(badtrap) ; \
    181   1.2  tsutsui 	VECTOR(badtrap) ; VECTOR(badtrap) ; \
    182   1.2  tsutsui 	VECTOR(badtrap) ; VECTOR(badtrap)
    183   1.2  tsutsui 
    184   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    185   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    186   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    187   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    188   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    189   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    190   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    191   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    192   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    193   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    194   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    195   1.1  tsutsui 	BADTRAP16		/* 64-255: user interrupt vectors */
    196   1.1  tsutsui 
    197   1.1  tsutsui 
    198   1.1  tsutsui 	STACK = 0x800000
    199   1.1  tsutsui 	DIPSW = 0x49000000
    200   1.1  tsutsui 
    201   1.1  tsutsui ASENTRY_NOPROFILE(start1)
    202   1.1  tsutsui 	movw	#PSL_HIGHIPL,%sr	| no interrupts
    203   1.1  tsutsui 	movl	#STACK,%sp		| set SP
    204   1.1  tsutsui 
    205   1.1  tsutsui /* clear BSS area */
    206   1.1  tsutsui 	movl	#_C_LABEL(edata),%a2	| start of BSS
    207   1.1  tsutsui 	movl	#_C_LABEL(end),%a3	| end
    208   1.1  tsutsui Lbssclr:
    209   1.1  tsutsui 	clrb	%a2@+			| clear BSS
    210   1.1  tsutsui 	cmpl	%a2,%a3			| done?
    211   1.1  tsutsui 	bne	Lbssclr			| no, keep going
    212   1.1  tsutsui 
    213   1.1  tsutsui /* save address to goto ROM monitor */
    214  1.14    isaki 	movec	%vbr,%a0		| save ROM vbr
    215  1.14    isaki 	movl	%a0,_ASM_LABEL(romvbr)
    216   1.2  tsutsui 	movl	#_ASM_LABEL(Reset),%a0	| BP vbr to %a0
    217  1.14    isaki /* copy ROM vectors */
    218  1.14    isaki 	movl	%a0@(ILLGINST),_ASM_LABEL(Reset) + ILLGINST
    219  1.14    isaki 	movl	%a0@(EVTRAPF),_ASM_LABEL(Reset) + EVTRAPF
    220   1.1  tsutsui 	movec	%a0,%vbr
    221   1.1  tsutsui 
    222  1.14    isaki 	movw	DIPSW,%d0
    223  1.14    isaki 	clrl	%d1
    224  1.14    isaki 	movw	%d0,%d1
    225  1.14    isaki 	lsrl	#8,%d1
    226  1.14    isaki 	movl	%d1,_C_LABEL(dipsw1)
    227  1.14    isaki 	movb	%d0,%d1
    228  1.14    isaki 	movl	%d1,_C_LABEL(dipsw2)
    229   1.1  tsutsui 
    230   1.3  tsutsui /* determine our CPU */
    231   1.3  tsutsui 
    232   1.3  tsutsui 	/* XXX should be generated via assym.h */
    233   1.3  tsutsui 	CACHE_OFF = 0x0808
    234   1.3  tsutsui 	DC_FREEZE = 0x0200
    235   1.3  tsutsui 	CPU_68030 = 1
    236   1.3  tsutsui 	CPU_68040 = 2
    237   1.3  tsutsui 
    238   1.3  tsutsui 	movl	#CACHE_OFF,%d0
    239   1.3  tsutsui 	movc	%d0,%cacr		| clear and disable on-chip cache(s)
    240   1.3  tsutsui 	movl	#DC_FREEZE,%d0		| data freeze bit
    241   1.3  tsutsui 	movc	%d0,%cacr		|   only exists on 68030
    242   1.3  tsutsui 	movc	%cacr,%d0		| read it back
    243   1.3  tsutsui 	tstl	%d0			| zero?
    244   1.3  tsutsui 	jeq	Lnot68030		| yes, we have 68040
    245   1.3  tsutsui 	movl	#CPU_68030,%d0
    246   1.3  tsutsui 	jra	Lstart0
    247   1.3  tsutsui Lnot68030:
    248   1.3  tsutsui 	movl	#CPU_68040,%d0
    249   1.3  tsutsui Lstart0:
    250   1.3  tsutsui 	movl	%d0,_C_LABEL(cputype)
    251   1.3  tsutsui 
    252   1.1  tsutsui /* final setup for C code */
    253  1.12    isaki 	movw	#PSL_LOWIPL,%sr		| enable interrupts
    254   1.1  tsutsui 	jsr	_C_LABEL(main)		| lets go
    255   1.1  tsutsui 	jsr	start
    256   1.1  tsutsui 
    257   1.1  tsutsui /*
    258   1.1  tsutsui  * exit to ROM monitor
    259   1.1  tsutsui  */
    260   1.1  tsutsui ENTRY_NOPROFILE(exit)
    261   1.1  tsutsui GLOBAL(_rtt)
    262   1.1  tsutsui 	movw	#PSL_HIGHIPL,%sr	| no interrupts
    263  1.14    isaki 	movl	_ASM_LABEL(romvbr),%a0
    264   1.1  tsutsui 	movec	%a0,%vbr
    265  1.14    isaki 	movl	%a0@(NMIVEC),%a1
    266   1.1  tsutsui 	jmp	%a1@
    267   1.1  tsutsui 
    268   1.1  tsutsui /*
    269   1.1  tsutsui  * Trap/interrupt vector routines
    270   1.9  tsutsui  */
    271   1.1  tsutsui 
    272   1.2  tsutsui ENTRY_NOPROFILE(buserr)
    273   1.1  tsutsui 	tstl	_C_LABEL(nofault)	| device probe?
    274   1.2  tsutsui 	jeq	_C_LABEL(addrerr)	| no, handle as usual
    275   1.1  tsutsui 	movl	_C_LABEL(nofault),%sp@-	| yes,
    276   1.1  tsutsui 	jbsr	_C_LABEL(longjmp)	|  longjmp(nofault)
    277   1.2  tsutsui ENTRY_NOPROFILE(addrerr)
    278   1.1  tsutsui 	clrw	%sp@-			| pad SR to longword
    279   1.1  tsutsui 	moveml	#0xFFFF,%sp@-		| save user registers
    280   1.1  tsutsui 	movl	%usp,%a0		| save the user SP
    281   1.1  tsutsui 	movl	%a0,%sp@(60)		|   in the savearea
    282   1.1  tsutsui 	lea	%sp@(64),%a1		| grab base of HW berr frame
    283   1.1  tsutsui 	movw	%a1@(12),%d0		| grab SSW for fault processing
    284   1.1  tsutsui 	btst	#12,%d0			| RB set?
    285   1.1  tsutsui 	jeq	LbeX0			| no, test RC
    286   1.1  tsutsui 	bset	#14,%d0			| yes, must set FB
    287   1.1  tsutsui 	movw	%d0,%a1@(12)		| for hardware too
    288   1.1  tsutsui LbeX0:
    289   1.1  tsutsui 	btst	#13,%d0			| RC set?
    290   1.1  tsutsui 	jeq	LbeX1			| no, skip
    291   1.1  tsutsui 	bset	#15,%d0			| yes, must set FC
    292   1.1  tsutsui 	movw	%d0,%a1@(12)		| for hardware too
    293   1.1  tsutsui LbeX1:
    294   1.1  tsutsui 	btst	#8,%d0			| data fault?
    295   1.1  tsutsui 	jeq	Lbe0			| no, check for hard cases
    296   1.1  tsutsui 	movl	%a1@(18),%d1		| fault address is as given in frame
    297   1.1  tsutsui 	jra	Lbe10			| thats it
    298   1.1  tsutsui Lbe0:
    299   1.1  tsutsui 	btst	#4,%a1@(8)		| long (type B) stack frame?
    300   1.1  tsutsui 	jne	Lbe4			| yes, go handle
    301   1.1  tsutsui 	movl	%a1@(4),%d1		| no, can use save PC
    302   1.1  tsutsui 	btst	#14,%d0			| FB set?
    303   1.1  tsutsui 	jeq	Lbe3			| no, try FC
    304   1.1  tsutsui 	addql	#4,%d1			| yes, adjust address
    305   1.1  tsutsui 	jra	Lbe10			| done
    306   1.1  tsutsui Lbe3:
    307   1.1  tsutsui 	btst	#15,%d0			| FC set?
    308   1.1  tsutsui 	jeq	Lbe10			| no, done
    309   1.1  tsutsui 	addql	#2,%d1			| yes, adjust address
    310   1.1  tsutsui 	jra	Lbe10			| done
    311   1.1  tsutsui Lbe4:
    312   1.1  tsutsui 	movl	%a1@(38),%d1		| long format, use stage B address
    313   1.1  tsutsui 	btst	#15,%d0			| FC set?
    314   1.1  tsutsui 	jeq	Lbe10			| no, all done
    315   1.1  tsutsui 	subql	#2,%d1			| yes, adjust address
    316   1.1  tsutsui Lbe10:
    317   1.1  tsutsui 	movl	%d1,%sp@-		| push fault VA
    318   1.1  tsutsui 	movw	%d0,%sp@-		| and SSW
    319   1.1  tsutsui 	clrw	%sp@-			|   padded to longword
    320   1.1  tsutsui 	movw	%a1@(8),%d0		| get frame format/vector offset
    321   1.1  tsutsui 	andw	#0x0FFF,%d0		| clear out frame format
    322   1.1  tsutsui 	cmpw	#12,%d0			| address error vector?
    323   1.1  tsutsui 	jeq	Lisaerr			| yes, go to it
    324   1.1  tsutsui #if 0
    325   1.1  tsutsui 	movl	%d1,%a0			| fault address
    326   1.1  tsutsui 	.long	0xf0109e11		| ptestr #1,%a0@,#7
    327   1.1  tsutsui 	.long	0xf0176200		| pmove %psr,%sp@
    328   1.1  tsutsui 	btst	#7,%sp@			| bus error bit set?
    329   1.1  tsutsui 	jeq	Lismerr			| no, must be MMU fault
    330   1.1  tsutsui 	clrw	%sp@			| yes, re-clear pad word
    331   1.1  tsutsui #endif
    332   1.1  tsutsui 	jra	Lisberr			| and process as normal bus error
    333   1.1  tsutsui Lismerr:
    334   1.1  tsutsui 	movl	#T_MMUFLT,%sp@-		| show that we are an MMU fault
    335   1.1  tsutsui 	jra	Lbexit			| and deal with it
    336   1.1  tsutsui Lisaerr:
    337   1.1  tsutsui 	movl	#T_ADDRERR,%sp@-	| mark address error
    338   1.1  tsutsui 	jra	Lbexit			| and deal with it
    339   1.1  tsutsui Lisberr:
    340   1.1  tsutsui 	movl	#T_BUSERR,%sp@-		| mark bus error
    341   1.1  tsutsui Lbexit:
    342   1.1  tsutsui 	jbsr	_C_LABEL(trap)		| handle the error
    343   1.1  tsutsui 	lea	%sp@(12),%sp		| pop value args
    344   1.1  tsutsui 	movl	%sp@(60),%a0		| restore user SP
    345   1.1  tsutsui 	movl	%a0,%usp		|   from save area
    346   1.1  tsutsui 	moveml	%sp@+,#0x7FFF		| restore most user regs
    347   1.1  tsutsui 	addql	#4,%sp			| toss SSP
    348   1.1  tsutsui 	tstw	%sp@+			| do we need to clean up stack?
    349   1.2  tsutsui 	jeq	_ASM_LABEL(rei)		| no, just continue
    350   1.1  tsutsui 	btst	#7,%sp@(6)		| type 9/10/11 frame?
    351   1.2  tsutsui 	jeq	_ASM_LABEL(rei)		| no, nothing to do
    352   1.1  tsutsui 	btst	#5,%sp@(6)		| type 9?
    353   1.1  tsutsui 	jne	Lbex1			| no, skip
    354   1.1  tsutsui 	movw	%sp@,%sp@(12)		| yes, push down SR
    355   1.1  tsutsui 	movl	%sp@(2),%sp@(14)	| and PC
    356   1.1  tsutsui 	clrw	%sp@(18)		| and mark as type 0 frame
    357   1.1  tsutsui 	lea	%sp@(12),%sp		| clean the excess
    358   1.2  tsutsui 	jra	_ASM_LABEL(rei)		| all done
    359   1.1  tsutsui Lbex1:
    360   1.1  tsutsui 	btst	#4,%sp@(6)		| type 10?
    361   1.1  tsutsui 	jne	Lbex2			| no, skip
    362   1.1  tsutsui 	movw	%sp@,%sp@(24)		| yes, push down SR
    363   1.1  tsutsui 	movl	%sp@(2),%sp@(26)	| and PC
    364   1.1  tsutsui 	clrw	%sp@(30)		| and mark as type 0 frame
    365   1.1  tsutsui 	lea	%sp@(24),%sp		| clean the excess
    366   1.2  tsutsui 	jra	_ASM_LABEL(rei)		| all done
    367   1.1  tsutsui Lbex2:
    368   1.1  tsutsui 	movw	%sp@,%sp@(84)		| type 11, push down SR
    369   1.1  tsutsui 	movl	%sp@(2),%sp@(86)	| and PC
    370   1.1  tsutsui 	clrw	%sp@(90)		| and mark as type 0 frame
    371   1.1  tsutsui 	lea	%sp@(84),%sp		| clean the excess
    372   1.2  tsutsui 	jra	_ASM_LABEL(rei)		| all done
    373   1.1  tsutsui 
    374   1.2  tsutsui ENTRY_NOPROFILE(illinst)
    375   1.1  tsutsui 	clrw	%sp@-
    376   1.1  tsutsui 	moveml	#0xFFFF,%sp@-
    377   1.1  tsutsui 	moveq	#T_ILLINST,%d0
    378   1.2  tsutsui 	jra	_C_LABEL(fault)
    379   1.1  tsutsui 
    380   1.2  tsutsui ENTRY_NOPROFILE(zerodiv)
    381   1.1  tsutsui 	clrw	%sp@-
    382   1.1  tsutsui 	moveml	#0xFFFF,%sp@-
    383   1.1  tsutsui 	moveq	#T_ZERODIV,%d0
    384   1.2  tsutsui 	jra	_C_LABEL(fault)
    385   1.1  tsutsui 
    386   1.2  tsutsui ENTRY_NOPROFILE(chkinst)
    387   1.1  tsutsui 	clrw	%sp@-
    388   1.1  tsutsui 	moveml	#0xFFFF,%sp@-
    389   1.1  tsutsui 	moveq	#T_CHKINST,%d0
    390   1.2  tsutsui 	jra	_C_LABEL(fault)
    391   1.1  tsutsui 
    392   1.2  tsutsui ENTRY_NOPROFILE(trapvinst)
    393   1.1  tsutsui 	clrw	%sp@-
    394   1.1  tsutsui 	moveml	#0xFFFF,%sp@-
    395   1.1  tsutsui 	moveq	#T_TRAPVINST,%d0
    396   1.2  tsutsui 	jra	_C_LABEL(fault)
    397   1.1  tsutsui 
    398   1.2  tsutsui ENTRY_NOPROFILE(privinst)
    399   1.1  tsutsui 	clrw	%sp@-
    400   1.1  tsutsui 	moveml	#0xFFFF,%sp@-
    401   1.1  tsutsui 	moveq	#T_PRIVINST,%d0
    402   1.2  tsutsui 	jra	_C_LABEL(fault)
    403   1.1  tsutsui 
    404   1.2  tsutsui ENTRY_NOPROFILE(coperr)
    405   1.1  tsutsui 	clrw	%sp@-
    406   1.1  tsutsui 	moveml	#0xFFFF,%sp@-
    407   1.1  tsutsui 	moveq	#T_COPERR,%d0
    408   1.2  tsutsui 	jra	_C_LABEL(fault)
    409   1.1  tsutsui 
    410   1.2  tsutsui ENTRY_NOPROFILE(fmterr)
    411   1.1  tsutsui 	clrw	%sp@-
    412   1.1  tsutsui 	moveml	#0xFFFF,%sp@-
    413   1.1  tsutsui 	moveq	#T_FMTERR,%d0
    414   1.2  tsutsui 	jra	_C_LABEL(fault)
    415   1.1  tsutsui 
    416   1.2  tsutsui ENTRY_NOPROFILE(fptrap)
    417   1.1  tsutsui #ifdef FPCOPROC
    418   1.1  tsutsui 	clrw	%sp@-		| pad SR to longword
    419   1.1  tsutsui 	moveml	#0xFFFF,%sp@-	| save user registers
    420   1.1  tsutsui 	movl	%usp,%a0	| and save
    421   1.1  tsutsui 	movl	%a0,%sp@(60)	|   the user stack pointer
    422   1.1  tsutsui 	clrl	%sp@-		| no VA arg
    423   1.1  tsutsui #if 0
    424   1.1  tsutsui 	lea	_u+PCB_FPCTX,%a0	| address of FP savearea
    425   1.1  tsutsui 	.word	0xf310		| fsave %a0@
    426   1.1  tsutsui 	tstb	%a0@		| null state frame?
    427   1.1  tsutsui 	jeq	Lfptnull	| yes, safe
    428   1.1  tsutsui 	clrw	%d0		| no, need to tweak BIU
    429   1.1  tsutsui 	movb	a0@(1),d0	| get frame size
    430   1.1  tsutsui 	bset	#3,%a0@(0,%d0:w)	| set exc_pend bit of BIU
    431   1.1  tsutsui Lfptnull:
    432   1.1  tsutsui 	.word	0xf227,0xa800	| fmovem %fpsr,%sp@- (code arg)
    433   1.1  tsutsui 	.word	0xf350		| frestore %a0@
    434   1.1  tsutsui #else
    435   1.1  tsutsui 	clrl	%sp@-		| push dummy FPSR
    436   1.1  tsutsui #endif
    437   1.1  tsutsui 	movl	#T_FPERR,%sp@-	| push type arg
    438   1.1  tsutsui 	jbsr	_C_LABEL(trap)	| call trap
    439   1.1  tsutsui 	lea	%sp@(12),%sp	| pop value args
    440   1.1  tsutsui 	movl	%sp@(60),%a0	| restore
    441   1.1  tsutsui 	movl	%a0,%usp	|   user SP
    442   1.1  tsutsui 	moveml	%sp@+,#0x7FFF	| and remaining user registers
    443   1.1  tsutsui 	addql	#6,%sp		| pop SSP and align word
    444   1.2  tsutsui 	jra	_ASM_LABEL(rei)	| all done
    445   1.1  tsutsui #else
    446   1.2  tsutsui 	jra	_C_LABEL(badtrap)	| treat as an unexpected trap
    447   1.1  tsutsui #endif
    448   1.1  tsutsui 
    449   1.2  tsutsui ENTRY_NOPROFILE(fault)
    450   1.1  tsutsui 	movl	%usp,%a0	| get and save
    451   1.1  tsutsui 	movl	%a0,%sp@(60)	|   the user stack pointer
    452   1.1  tsutsui 	clrl	%sp@-		| no VA arg
    453   1.1  tsutsui 	clrl	%sp@-		| or code arg
    454   1.1  tsutsui 	movl	%d0,%sp@-	| push trap type
    455   1.1  tsutsui 	jbsr	_C_LABEL(trap)	| handle trap
    456   1.1  tsutsui 	lea	%sp@(12),%sp	| pop value args
    457   1.1  tsutsui 	movl	%sp@(60),%a0	| restore
    458   1.1  tsutsui 	movl	%a0,%usp	|   user SP
    459   1.1  tsutsui 	moveml	%sp@+,#0x7FFF	| restore most user regs
    460   1.1  tsutsui 	addql	#6,%sp		| pop SP and pad word
    461   1.2  tsutsui 	jra	_ASM_LABEL(rei)	| all done
    462   1.1  tsutsui 
    463   1.2  tsutsui ENTRY_NOPROFILE(badtrap)
    464   1.1  tsutsui 	clrw	%sp@-
    465   1.1  tsutsui 	moveml	#0xC0C0,%sp@-
    466   1.1  tsutsui 	movw	%sp@(24),%sp@-
    467   1.1  tsutsui 	clrw	%sp@-
    468   1.1  tsutsui 	jbsr	_C_LABEL(straytrap)
    469   1.1  tsutsui 	addql	#4,%sp
    470   1.1  tsutsui 	moveml	%sp@+,#0x0303
    471   1.1  tsutsui 	addql	#2,%sp
    472   1.2  tsutsui 	jra	_ASM_LABEL(rei)
    473   1.1  tsutsui 
    474   1.1  tsutsui /*
    475   1.1  tsutsui  * Interrupt handlers.
    476   1.1  tsutsui  * All device interrupts are auto-vectored.  Most can be configured
    477   1.1  tsutsui  * to interrupt in the range IPL2 to IPL6.  Here are our assignments:
    478   1.1  tsutsui  *
    479  1.10  tsutsui  *	Level 0:
    480  1.10  tsutsui  *	Level 1:
    481   1.1  tsutsui  *	Level 2:	SCSI SPC
    482  1.10  tsutsui  *	Level 3:	LANCE Ethernet
    483  1.10  tsutsui  *	Level 4:
    484   1.1  tsutsui  *	Level 5:	System Clock
    485   1.1  tsutsui  *	Level 6:	Internal SIO used uPD7201A
    486  1.10  tsutsui  *	Level 7:	NMI: Abort Key (Dispatched vector to ROM monitor)
    487   1.1  tsutsui  */
    488   1.1  tsutsui 
    489   1.2  tsutsui ENTRY_NOPROFILE(lev2intr)
    490   1.1  tsutsui 	clrw	%sp@-
    491   1.1  tsutsui 	moveml	#0xC0C0,%sp@-
    492   1.1  tsutsui 	jbsr	_C_LABEL(scintr)
    493   1.1  tsutsui 	moveml	%sp@+,#0x0303
    494   1.1  tsutsui 	addql	#2,%sp
    495   1.2  tsutsui 	jra	_ASM_LABEL(rei)
    496   1.1  tsutsui 
    497   1.2  tsutsui ENTRY_NOPROFILE(lev3intr)
    498   1.1  tsutsui 	clrw	%sp@-
    499   1.1  tsutsui 	moveml	#0xC0C0,%sp@-
    500   1.4  tsutsui 	jbsr	_C_LABEL(lance_intr)
    501   1.1  tsutsui 	moveml	%sp@+,#0x0303
    502   1.1  tsutsui 	addql	#2,%sp
    503   1.2  tsutsui 	jra	_ASM_LABEL(rei)
    504   1.1  tsutsui 
    505   1.2  tsutsui ENTRY_NOPROFILE(lev5intr)
    506   1.1  tsutsui 	clrw	%sp@-			| push pad word
    507   1.1  tsutsui 	moveml	#0xC0C0,%sp@-		| save scratch regs
    508   1.1  tsutsui 	movl	#CLOCK_REG,%a0		| get clock CR addr
    509   1.1  tsutsui 	movb	#CLK_CLR,%a0@		| reset system clock
    510   1.1  tsutsui 	lea	%sp@(16),%a1		| get pointer to PS
    511   1.1  tsutsui 	movl	%a1@,%sp@-		| push padded PS
    512   1.1  tsutsui 	movl	%a1@(4),%sp@-		| push PC
    513   1.1  tsutsui 	jbsr	_C_LABEL(hardclock)	| call generic clock int routine
    514   1.1  tsutsui 	addql	#8,%sp			| pop params
    515   1.1  tsutsui 	moveml	%sp@+,#0x0303		| restore scratch regs
    516   1.1  tsutsui 	addql	#2,%sp			| pop pad word
    517   1.2  tsutsui 	jra	_ASM_LABEL(rei)		| all done
    518   1.8  tsutsui 
    519   1.1  tsutsui ENTRY_NOPROFILE(hardclock)
    520   1.8  tsutsui 	addql	#1,_C_LABEL(tick)
    521   1.1  tsutsui 	rts
    522   1.1  tsutsui 
    523   1.8  tsutsui BSS(tick,4)
    524   1.8  tsutsui 
    525   1.2  tsutsui ENTRY_NOPROFILE(lev6intr)
    526   1.1  tsutsui 	clrw	%sp@-
    527   1.1  tsutsui 	moveml	#0xC0C0,%sp@-
    528   1.1  tsutsui 	jbsr	_C_LABEL(_siointr)
    529   1.1  tsutsui 	moveml	%sp@+,#0x0303
    530   1.1  tsutsui 	addql	#2,%sp
    531   1.2  tsutsui 	jra	_ASM_LABEL(rei)
    532   1.1  tsutsui 
    533   1.1  tsutsui 
    534   1.1  tsutsui /*
    535   1.1  tsutsui  * Emulation of VAX REI instruction.
    536   1.1  tsutsui  *
    537   1.1  tsutsui  * This code deals with checking for and servicing ASTs
    538   1.1  tsutsui  * (profiling, scheduling) and software interrupts (network, softclock).
    539   1.1  tsutsui  * We check for ASTs first, just like the VAX.  To avoid excess overhead
    540   1.1  tsutsui  * the T_ASTFLT handling code will also check for software interrupts so we
    541   1.1  tsutsui  * do not have to do it here.
    542   1.1  tsutsui  *
    543   1.1  tsutsui  * This code is complicated by the fact that sendsig may have been called
    544   1.1  tsutsui  * necessitating a stack cleanup.  A cleanup should only be needed at this
    545   1.1  tsutsui  * point for coprocessor mid-instruction frames (type 9), but we also test
    546   1.1  tsutsui  * for bus error frames (type 10 and 11).
    547   1.1  tsutsui  */
    548   1.1  tsutsui #if 0
    549   1.1  tsutsui 	.comm	_ssir,1
    550   1.2  tsutsui ASENTRY_NOPROFILE(rei)
    551   1.1  tsutsui #ifdef DEBUG
    552  1.15   andvar 	tstl	_C_LABEL(panicstr)		| have we panicked?
    553   1.1  tsutsui 	jne	Ldorte			| yes, do not make matters worse
    554   1.1  tsutsui #endif
    555   1.1  tsutsui 	btst	#PCB_ASTB,_u+PCB_FLAGS+1| AST pending?
    556   1.1  tsutsui 	jeq	Lchksir			| no, go check for SIR
    557   1.1  tsutsui 	btst	#5,%sp@			| yes, are we returning to user mode?
    558   1.1  tsutsui 	jne	Lchksir			| no, go check for SIR
    559   1.1  tsutsui 	clrw	%sp@-			| pad SR to longword
    560   1.1  tsutsui 	moveml	#0xFFFF,%sp@-		| save all registers
    561   1.1  tsutsui 	movl	%usp,%a1		| including
    562   1.1  tsutsui 	movl	%a1,%sp@(60)		|    the users SP
    563   1.1  tsutsui 	clrl	%sp@-			| VA == none
    564   1.1  tsutsui 	clrl	%sp@-			| code == none
    565   1.1  tsutsui 	movl	#T_ASTFLT,%sp@-		| type == async system trap
    566   1.2  tsutsui 	jbsr	_C_LABEL(trap)		| go handle it
    567   1.1  tsutsui 	lea	%sp@(12),%sp		| pop value args
    568   1.1  tsutsui 	movl	%sp@(60),%a0		| restore
    569   1.1  tsutsui 	movl	%a0,%usp		|   user SP
    570   1.1  tsutsui 	moveml	%sp@+,#0x7FFF		| and all remaining registers
    571   1.1  tsutsui 	addql	#4,%sp			| toss SSP
    572   1.1  tsutsui 	tstw	%sp@+			| do we need to clean up stack?
    573   1.1  tsutsui 	jeq	Ldorte			| no, just continue
    574   1.1  tsutsui 	btst	#7,%sp@(6)		| type 9/10/11 frame?
    575   1.1  tsutsui 	jeq	Ldorte			| no, nothing to do
    576   1.1  tsutsui 	btst	#5,%sp@(6)		| type 9?
    577   1.1  tsutsui 	jne	Last1			| no, skip
    578   1.1  tsutsui 	movw	%sp@,%sp@(12)		| yes, push down SR
    579   1.1  tsutsui 	movl	%sp@(2),%sp@(14)	| and PC
    580   1.1  tsutsui 	clrw	%sp@(18)		| and mark as type 0 frame
    581   1.1  tsutsui 	lea	%sp@(12),%sp		| clean the excess
    582   1.1  tsutsui 	jra	Ldorte			| all done
    583   1.1  tsutsui Last1:
    584   1.1  tsutsui 	btst	#4,%sp@(6)		| type 10?
    585   1.1  tsutsui 	jne	Last2			| no, skip
    586   1.1  tsutsui 	movw	%sp@,%sp@(24)		| yes, push down SR
    587   1.1  tsutsui 	movl	%sp@(2),%sp@(26)	| and PC
    588   1.1  tsutsui 	clrw	%sp@(30)		| and mark as type 0 frame
    589   1.1  tsutsui 	lea	%sp@(24),%sp		| clean the excess
    590   1.1  tsutsui 	jra	Ldorte			| all done
    591   1.1  tsutsui Last2:
    592   1.1  tsutsui 	movw	%sp@,%sp@(84)		| type 11, push down SR
    593   1.1  tsutsui 	movl	%sp@(2),%sp@(86)	| and PC
    594   1.1  tsutsui 	clrw	%sp@(90)		| and mark as type 0 frame
    595   1.1  tsutsui 	lea	%sp@(84),%sp		| clean the excess
    596   1.1  tsutsui 	jra	Ldorte			| all done
    597   1.1  tsutsui Lchksir:
    598   1.1  tsutsui 	tstb	_ssir			| SIR pending?
    599   1.1  tsutsui 	jeq	Ldorte			| no, all done
    600   1.1  tsutsui 	movl	%d0,%sp@-		| need a scratch register
    601   1.1  tsutsui 	movw	%sp@(4),%d0		| get SR
    602   1.1  tsutsui 	andw	#PSL_IPL7,%d0		| mask all but IPL
    603   1.1  tsutsui 	jne	Lnosir			| came from interrupt, no can do
    604   1.1  tsutsui 	movl	%sp@+,%d0		| restore scratch register
    605   1.1  tsutsui Lgotsir:
    606   1.1  tsutsui 	movw	#SPL1,%sr		| prevent others from servicing int
    607   1.1  tsutsui 	tstb	_ssir			| too late?
    608   1.1  tsutsui 	jeq	Ldorte			| yes, oh well...
    609   1.1  tsutsui 	clrw	%sp@-			| pad SR to longword
    610   1.1  tsutsui 	moveml	#0xFFFF,%sp@-		| save all registers
    611   1.1  tsutsui 	movl	%usp,%a1		| including
    612   1.1  tsutsui 	movl	%a1,%sp@(60)		|    the users SP
    613   1.1  tsutsui 	clrl	%sp@-			| VA == none
    614   1.1  tsutsui 	clrl	%sp@-			| code == none
    615   1.1  tsutsui 	movl	#T_SSIR,%sp@-		| type == software interrupt
    616   1.1  tsutsui 	jbsr	_trap			| go handle it
    617   1.1  tsutsui 	lea	%sp@(12),%sp		| pop value args
    618   1.1  tsutsui 	movl	%sp@(60),%a0		| restore
    619   1.1  tsutsui 	movl	%a0,%usp		|   user SP
    620   1.1  tsutsui 	moveml	%sp@+,#0x7FFF		| and all remaining registers
    621   1.1  tsutsui 	addql	#6,%sp			| pop SSP and align word
    622   1.1  tsutsui 	rte
    623   1.1  tsutsui Lnosir:
    624   1.1  tsutsui 	movl	%sp@+,%d0		| restore scratch register
    625   1.1  tsutsui Ldorte:
    626   1.1  tsutsui #else
    627   1.2  tsutsui ASENTRY_NOPROFILE(rei)			| dummy Entry of rei
    628   1.1  tsutsui #endif
    629   1.1  tsutsui 	rte				| real return
    630   1.1  tsutsui 
    631   1.1  tsutsui /*
    632   1.1  tsutsui  * non-local gotos
    633   1.1  tsutsui  */
    634   1.1  tsutsui ALTENTRY(savectx, _setjmp)
    635   1.1  tsutsui ENTRY(setjmp)
    636   1.1  tsutsui 	movl	%sp@(4),%a0	| savearea pointer
    637   1.1  tsutsui 	moveml	#0xFCFC,%a0@	| save d2-d7/a2-a7
    638   1.1  tsutsui 	movl	%sp@,%a0@(48)	| and return address
    639   1.1  tsutsui 	moveq	#0,%d0		| return 0
    640   1.1  tsutsui 	rts
    641   1.1  tsutsui 
    642   1.1  tsutsui ENTRY(qsetjmp)
    643   1.1  tsutsui 	movl	%sp@(4),%a0	| savearea pointer
    644   1.1  tsutsui 	lea	%a0@(40),%a0	| skip regs we do not save
    645   1.1  tsutsui 	movl	%a6,%a0@+		| save FP
    646   1.1  tsutsui 	movl	%sp,%a0@+		| save SP
    647   1.1  tsutsui 	movl	%sp@,%a0@		| and return address
    648   1.1  tsutsui 	moveq	#0,%d0		| return 0
    649   1.1  tsutsui 	rts
    650   1.1  tsutsui 
    651   1.1  tsutsui ENTRY(longjmp)
    652   1.1  tsutsui 	movl	%sp@(4),%a0
    653   1.1  tsutsui 	moveml	%a0@+,#0xFCFC
    654   1.1  tsutsui 	movl	%a0@,%sp@
    655   1.1  tsutsui 	moveq	#1,%d0
    656   1.1  tsutsui 	rts
    657   1.1  tsutsui 
    658   1.1  tsutsui ENTRY_NOPROFILE(getsfc)
    659   1.1  tsutsui 	movc	%sfc,%d0
    660   1.1  tsutsui 	rts
    661   1.1  tsutsui ENTRY_NOPROFILE(getdfc)
    662   1.1  tsutsui 	movc	%dfc,%d0
    663   1.1  tsutsui 	rts
    664   1.1  tsutsui 
    665   1.1  tsutsui /*
    666   1.1  tsutsui  * Set processor priority level calls.  Most could (should) be replaced
    667   1.1  tsutsui  * by inline asm expansions.  However, SPL0 and SPLX require special
    668   1.1  tsutsui  * handling.  If we are returning to the base processor priority (SPL0)
    669   1.1  tsutsui  * we need to check for our emulated software interrupts.
    670   1.1  tsutsui  */
    671   1.1  tsutsui 
    672   1.1  tsutsui ENTRY(spl0)
    673   1.1  tsutsui 	moveq	#0,%d0
    674   1.1  tsutsui 	movw	%sr,%d0			| get old SR for return
    675   1.1  tsutsui 	movw	#PSL_LOWIPL,%sr		| restore new SR
    676   1.1  tsutsui |	jra	Lsplsir
    677   1.1  tsutsui 	rts
    678   1.1  tsutsui 
    679   1.1  tsutsui ENTRY(splx)
    680   1.1  tsutsui 	moveq	#0,%d0
    681   1.1  tsutsui 	movw	%sr,%d0			| get current SR for return
    682   1.1  tsutsui 	movw	%sp@(6),%d1		| get new value
    683   1.1  tsutsui 	movw	%d1,%sr			| restore new SR
    684   1.1  tsutsui |	andw	#PSL_IPL7,%d1		| mask all but PSL_IPL
    685   1.1  tsutsui |	jne	Lspldone		| non-zero, all done
    686   1.1  tsutsui |Lsplsir:
    687   1.1  tsutsui |	tstb	_ssir			| software interrupt pending?
    688   1.1  tsutsui |	jeq	Lspldone		| no, all done
    689   1.1  tsutsui |	subql	#4,%sp			| make room for RTE frame
    690   1.1  tsutsui |	movl	%sp@(4),%sp@(2)		| position return address
    691   1.1  tsutsui |	clrw	%sp@(6)			| set frame type 0
    692   1.1  tsutsui |	movw	#PSL_LOWIPL,%sp@	| and new SR
    693   1.1  tsutsui |	jra	Lgotsir			| go handle it
    694   1.1  tsutsui |Lspldone:
    695   1.1  tsutsui 	rts
    696   1.1  tsutsui 
    697   1.1  tsutsui ENTRY(spl1)
    698   1.1  tsutsui 	moveq	#0,%d0
    699   1.1  tsutsui 	movw	%sr,%d0
    700   1.1  tsutsui 	movw	#SPL1,%sr
    701   1.1  tsutsui 	rts
    702   1.1  tsutsui 
    703   1.1  tsutsui ALTENTRY(splscsi, _spl2)
    704   1.1  tsutsui ENTRY(spl2)
    705   1.1  tsutsui 	moveq	#0,%d0
    706   1.1  tsutsui 	movw	%sr,%d0
    707   1.1  tsutsui 	movw	#SPL2,%sr
    708   1.1  tsutsui 	rts
    709   1.1  tsutsui 
    710   1.1  tsutsui ENTRY(spl3)
    711   1.1  tsutsui 	moveq	#0,%d0
    712   1.1  tsutsui 	movw	%sr,%d0
    713   1.1  tsutsui 	movw	#SPL3,%sr
    714   1.1  tsutsui 	rts
    715   1.1  tsutsui 
    716   1.1  tsutsui ENTRY(spl4)
    717   1.1  tsutsui 	moveq	#0,%d0
    718   1.1  tsutsui 	movw	%sr,%d0
    719   1.1  tsutsui 	movw	#SPL4,%sr
    720   1.1  tsutsui 	rts
    721   1.1  tsutsui 
    722   1.1  tsutsui ENTRY(spl5)
    723   1.1  tsutsui 	moveq	#0,%d0
    724   1.1  tsutsui 	movw	%sr,%d0
    725   1.1  tsutsui 	movw	#SPL5,%sr
    726   1.1  tsutsui 	rts
    727   1.1  tsutsui 
    728   1.1  tsutsui ENTRY(spl6)
    729   1.1  tsutsui 	moveq	#0,%d0
    730   1.1  tsutsui 	movw	%sr,%d0
    731   1.1  tsutsui 	movw	#SPL6,%sr
    732   1.1  tsutsui 	rts
    733   1.1  tsutsui 
    734   1.1  tsutsui ALTENTRY(splhigh, _spl7)
    735   1.1  tsutsui ENTRY(spl7)
    736   1.1  tsutsui 	moveq	#0,%d0
    737   1.1  tsutsui 	movw	%sr,%d0
    738   1.1  tsutsui 	movw	#PSL_HIGHIPL,%sr
    739   1.1  tsutsui 	rts
    740   1.1  tsutsui 
    741   1.1  tsutsui 
    742   1.1  tsutsui 	.data
    743   1.1  tsutsui 
    744   1.1  tsutsui /*
    745  1.11   martin  * Memory Information Field for secondary booter memory allocator
    746   1.1  tsutsui  */
    747   1.1  tsutsui 
    748  1.14    isaki ASLOCAL(romvbr)
    749   1.1  tsutsui 	.long	0
    750   1.1  tsutsui 
    751   1.1  tsutsui GLOBAL(dipsw1)
    752   1.1  tsutsui 	.long	0
    753   1.1  tsutsui 
    754   1.1  tsutsui GLOBAL(dipsw2)
    755   1.1  tsutsui 	.long	0
    756   1.3  tsutsui 
    757   1.3  tsutsui GLOBAL(cputype)
    758   1.3  tsutsui 	.long	CPU_68030
    759