From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Date: Mon, 26 May 97 10:43:36 +0200
To: linux-m68k@phil.uni-sb.de
Subject: L68K: Kernel entry cleanup
X-Yow: Will the third world war keep ``Bosom Buddies'' off the air?
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: linux-m68k@phil.uni-sb.de

I have moved many of the definitions in entry.S to a new header file
<asm/entry.h>, so that it can be shared with other files, and don't have
to be repeated over and over.

Andreas.

--- linux/arch/m68k/atari/ataints.c.~1~	Thu May 15 13:21:19 1997
+++ linux/arch/m68k/atari/ataints.c	Sat May 24 22:06:38 1997
@@ -48,6 +48,7 @@
 #include <asm/atariints.h>
 #include <asm/atari_stdma.h>
 #include <asm/irq.h>
+#include <asm/entry.h>
 
 
 /*
@@ -161,22 +162,6 @@
 
 #define IRQ_NAME(nr) atari_slow_irq_##nr##_handler(void)
 
-#define	MFP_MK_BASE	"0xfa13"
-
-/* This must agree with entry.S.  */
-#define ORIG_DO "0x24"
-#define FORMATVEC "0x32"
-#define SR "0x2C"
-#define SAVE_ALL				\
-	"clrl	%%sp@-;"    /* stk_adj */	\
-	"pea	-1:w;"	    /* orig d0 = -1 */	\
-	"movel	%%d0,%%sp@-;" /* d0 */		\
-	"moveml	%%d1-%%d5/%%a0-%%a2,%%sp@-"
-#define GET_CURRENT(tmp) \
-	"movel	%%sp,"#tmp";" \
-	"andw	#-8192,"#tmp";" \
-	"movel	"#tmp",%%a2"
-
 #define	BUILD_SLOW_IRQ(n)						   \
 asmlinkage void IRQ_NAME(n);						   \
 /* Dummy function to allow asm with operands.  */			   \
@@ -184,29 +169,31 @@
 __asm__ (ALIGN_STR "\n"							   \
 SYMBOL_NAME_STR(atari_slow_irq_) #n "_handler:\t"			   \
 "	addql	#1,"SYMBOL_NAME_STR(local_irq_count)"\n"		   \
-	SAVE_ALL "\n"							   \
+	SAVE_ALL_INT "\n"						   \
 	GET_CURRENT(%%d0) "\n"						   \
-"	andb	#~(1<<(" #n "&7)),"	/* mask this interrupt */	   \
-	"("MFP_MK_BASE"+(((" #n "&8)^8)>>2)+((" #n "&16)<<3)):w\n"	   \
-"	bfextu	%%sp@("SR"){#5,#3},%%d0\n" /* get old IPL from stack frame */ \
+"	andb	#~(1<<(%c3&7)),%a4:w\n"	/* mask this interrupt */	   \
+	/* get old IPL from stack frame */				   \
+"	bfextu	%%sp@(%c2){#5,#3},%%d0\n"				   \
 "	movew	%%sr,%%d1\n"						   \
 "	bfins	%%d0,%%d1{#21,#3}\n"					   \
 "	movew	%%d1,%%sr\n"		/* set IPL = previous value */	   \
 "	addql	#1,%a0\n"						   \
-"	lea	"SYMBOL_NAME_STR(irq_handler)"+("#n"+8)*8,%%a0\n"	   \
+"	lea	%a1,%%a0\n"						   \
 "	pea 	%%sp@\n"		/* push addr of frame */	   \
 "	movel	%%a0@(4),%%sp@-\n"	/* push handler data */		   \
-"	pea 	(" #n "+8)\n"		/* push int number */		   \
+"	pea 	(%c3+8)\n"		/* push int number */		   \
 "	movel	%%a0@,%%a0\n"						   \
 "	jbsr	%%a0@\n"		/* call the handler */		   \
 "	addql	#8,%%sp\n"						   \
 "	addql	#4,%%sp\n"						   \
 "	orw	#0x0600,%%sr\n"						   \
 "	andw	#0xfeff,%%sr\n"		/* set IPL = 6 again */		   \
-"	orb 	#(1<<(" #n "&7)),"	/* now unmask the int again */	   \
-	    "("MFP_MK_BASE"+(((" #n "&8)^8)>>2)+((" #n "&16)<<3)):w\n"	   \
+"	orb 	#(1<<(%c3&7)),%a4:w\n"	/* now unmask the int again */	   \
 "	jbra	"SYMBOL_NAME_STR(ret_from_interrupt)"\n"		   \
-	 : : "i" (&kstat.interrupts[n+8])				   \
+	 : : "i" (&kstat.interrupts[n+8]), "i" (&irq_handler[n+8]),	   \
+	     "n" (PT_OFF_SR), "n" (n),					   \
+	     "i" (n & 8 ? (n & 16 ? &tt_mfp.int_mk_a : &mfp.int_mk_a)	   \
+		        : (n & 16 ? &tt_mfp.int_mk_b : &mfp.int_mk_b))	   \
 );									   \
 }
 
@@ -288,10 +275,10 @@
 	orw 	#0x700,%%sr		/* disable all interrupts */
 "SYMBOL_NAME_STR(atari_prio_irq_handler) ":\t
 	addql	#1,"SYMBOL_NAME_STR(local_irq_count)"\n"
-	SAVE_ALL "\n"
+	SAVE_ALL_INT "\n"
 	GET_CURRENT(%%d0) "
 	/* get vector number from stack frame and convert to source */
-	bfextu	%%sp@(" FORMATVEC "){#4,#10},%%d0
+	bfextu	%%sp@(%c1){#4,#10},%%d0
 	subw	#(0x40-8),%%d0
 	jpl 	1f
 	addw	#(0x40-8-0x18),%%d0
@@ -307,7 +294,7 @@
 	addql	#8,%%sp
 	addql	#4,%%sp
 	jbra	"SYMBOL_NAME_STR(ret_from_interrupt)
-	 : : "i" (&kstat.interrupts)
+	 : : "i" (&kstat.interrupts), "n" (PT_OFF_FORMATVEC)
 );
 }
 
--- linux/arch/m68k/fpsp040/skeleton.S.~1~	Tue May 20 17:45:50 1997
+++ linux/arch/m68k/fpsp040/skeleton.S	Sat May 24 20:38:03 1997
@@ -39,6 +39,7 @@
 |
 
 #include <linux/linkage.h>
+#include <asm/entry.h>
 
 |SKELETON	idnt    2,1 | Motorola 040 Floating Point Software Package
 
@@ -51,24 +52,6 @@
  
 	.include "fpsp.h"
 
-/*
- * This has to match entry.S
- */
-LOFF_ORIG_D0	= 0x24
-
-#define curptr a2
-
-#define SAVE_ALL				\
-	clrl	%sp@-;     /* stk_adj */	\
-	movel	%d0,%sp@-; /* orig d0 */	\
-	movel	%d0,%sp@-; /* d0 */		\
-	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@-;
-
-#define GET_CURRENT(tmp) \
-	movel	%sp,tmp; \
-	andw	&-8192,tmp; \
-	movel	tmp,%curptr;
-
 	|xref	b1238_fix
 
 |
@@ -86,11 +69,7 @@
 	frestore	(%sp)+
 	unlk		%a6
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -181,11 +160,7 @@
 	frestore	(%sp)+
 	unlk		%a6
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -211,11 +186,7 @@
 	frestore	(%sp)+
 	unlk		%a6
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -241,11 +212,7 @@
 	frestore	(%sp)+
 	unlk		%a6
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -267,11 +234,7 @@
 	frestore	(%sp)+
 	unlk		%a6
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -293,11 +256,7 @@
 	frestore	(%sp)+
 	unlk		%a6
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -325,11 +284,7 @@
 	frestore	(%sp)+
 	unlk		%a6
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -350,11 +305,7 @@
 	jmp	fpsp_fline
 real_fline:
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -376,11 +327,7 @@
 	frestore	(%sp)+
 	unlk		%a6
 
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | a -1 in the ORIG_D0 field
-					| signifies that the stack frame
-					| is NOT for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@- 		| stack frame pointer argument
 	bsrl	SYMBOL_NAME(trap_c)
@@ -435,9 +382,7 @@
 	bne	Lmustsched
 	rte
 Lmustsched:
-	SAVE_ALL
-	moveq	#-1,%d0
-	movel	%d0,%sp@(LOFF_ORIG_D0)    | indicate stack frame not for syscall
+	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	bral	SYMBOL_NAME(ret_from_exception)	| deliver signals, reschedule etc..
 
--- linux/arch/m68k/kernel/entry.S.~7~	Sat May 24 15:40:40 1997
+++ linux/arch/m68k/kernel/entry.S	Sat May 24 21:54:53 1997
@@ -22,24 +22,6 @@
  * NOTE: This code handles signal-recognition, which happens every time
  * after a timer-interrupt and after each system call.
  *
- * Stack layout in 'ret_from_exception':
- *
- *	This allows access to the syscall arguments in registers d1-d5
- *
- *	 0(sp) - d1
- *	 4(sp) - d2
- *	 8(sp) - d3
- *	 C(sp) - d4
- *	10(sp) - d5
- *	14(sp) - a0
- *	18(sp) - a1
- *	1C(sp) - a2
- *	20(sp) - d0
- *	24(sp) - orig_d0
- *	28(sp) - stack adjustment
- *	2C(sp) - sr
- *	2E(sp) - pc
- *	32(sp) - format & vector
  */
 
 /*
@@ -48,112 +30,12 @@
  *               number 0 in the 'current_set' list.
  */
 
-/*
- * 97/05/14 Andreas: Register %a2 is now set to the current task throughout
- *		     the whole kernel.
- */
-
 #include <linux/sys.h>
 #include <linux/config.h>
 #include <linux/linkage.h>
+#include <asm/entry.h>
 #include <asm/setup.h>
 #include <asm/segment.h>
-#ifdef CONFIG_KGDB
-#include <asm/kgdb.h>
-.globl SYMBOL_NAME(kgdb_registers)
-#endif
-
-#define curptr a2
-
-LENOSYS = 38
-
-/*
- * these are offsets into the task-struct
- */
-LTASK_STATE	=  0
-LTASK_COUNTER	=  4
-LTASK_PRIORITY	=  8
-LTASK_SIGNAL	= 12
-LTASK_BLOCKED	= 16
-LTASK_FLAGS	= 20
-
-/* the following macro is used when enabling interrupts */
-#if defined(MACH_ATARI_ONLY)
-	/* block out HSYNC on the atari */
-#define ALLOWINT 0xfbff
-#define	MAX_NOINT_IPL	3
-#else
-	/* portable version */
-#define ALLOWINT 0xf8ff
-#define	MAX_NOINT_IPL	0
-#endif /* machine compilation types */ 
-
-LD0		= 0x20
-LORIG_D0	= 0x24
-LSR		= 0x2C
-LFORMATVEC	= 0x32
-
-/*
- * This defines the normal kernel pt-regs layout.
- *
- * regs a3-a6 and d6-d7 are preserved by C code
- * the kernel doesn't mess with usp unless it needs to
- */
-#ifndef CONFIG_KGDB
-/*
- * a -1 in the orig_d0 field signifies
- * that the stack frame is NOT for syscall
- */
-#define SAVE_ALL_INT				\
-	clrl	%sp@-;		/* stk_adj */	\
-	pea	-1:w;		/* orig d0 */	\
-	movel	%d0,%sp@-;	/* d0 */	\
-	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@-
-
-#define SAVE_ALL_SYS				\
-	clrl	%sp@-;		/* stk_adj */	\
-	movel	%d0,%sp@-;	/* orig d0 */	\
-	movel	%d0,%sp@-;	/* d0 */	\
-	moveml  %d1-%d5/%a0-%a1/%curptr,%sp@-
-#else
-/* Need to save the "missing" registers for kgdb...
- */
-#define SAVE_ALL_INT						\
-	clrl	%sp@-;		/* stk_adj */			\
-	pea	-1:w;		/* orig d0 */			\
-	movel	%d0,%sp@-;	/* d0 */			\
-	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@-;			\
-	moveml	%d6-%d7,SYMBOL_NAME(kgdb_registers)+GDBOFFA_D6;	\
-	moveml	%a3-%a6,SYMBOL_NAME(kgdb_registers)+GDBOFFA_A3
-
-#define SAVE_ALL_SYS						\
-	clrl	%sp@-;		/* stk_adj */			\
-	movel	%d0,%sp@-;	/* orig d0 */			\
-	movel	%d0,%sp@-;	/* d0 */			\
-	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@-;			\
-	moveml	%d6-%d7,SYMBOL_NAME(kgdb_registers)+GDBOFFA_D6;	\
-	moveml	%a3-%a6,SYMBOL_NAME(kgdb_registers)+GDBOFFA_A3
-#endif
-
-#define RESTORE_ALL			\
-	moveml	%sp@+,%a0-%a1/%curptr/%d1-%d5;	\
-	movel	%sp@+,%d0;		\
-	addql	#4,%sp;	 /* orig d0 */	\
-	addl	%sp@+,%sp; /* stk adj */	\
-	rte
-
-#define SWITCH_STACK_SIZE (6*4+4)	/* includes return address */
-
-#define SAVE_SWITCH_STACK \
-	moveml	%a3-%a6/%d6-%d7,%sp@-
-
-#define RESTORE_SWITCH_STACK \
-	moveml	%sp@+,%a3-%a6/%d6-%d7
-
-#define GET_CURRENT(tmp) \
-	movel	%sp,tmp; \
-	andw	&-8192,tmp; \
-	movel	tmp,%curptr;
 
 .globl SYMBOL_NAME(system_call), SYMBOL_NAME(buserr), SYMBOL_NAME(trap)
 .globl SYMBOL_NAME(resume), SYMBOL_NAME(ret_from_exception)
@@ -189,18 +71,18 @@
 	jmp	SYMBOL_NAME(schedule)
 
 badsys:
-	movel	#-LENOSYS,LD0(%sp)
+	movel	#-LENOSYS,LPT_OFF_D0(%sp)
 	jra	SYMBOL_NAME(ret_from_exception)
 
 do_trace:
-	movel	#-LENOSYS,LD0(%sp)	| needed for strace
+	movel	#-LENOSYS,LPT_OFF_D0(%sp)	| needed for strace
 	subql	#4,%sp
 	SAVE_SWITCH_STACK
 	jbsr	SYMBOL_NAME(syscall_trace)
 	RESTORE_SWITCH_STACK
 	addql	#4,%sp
 	jbsr	@(SYMBOL_NAME(sys_call_table),%d2:l:4)@(0)
-	movel	%d0,%sp@(LD0)		| save the return value
+	movel	%d0,%sp@(LPT_OFF_D0)	| save the return value
 	subql	#4,%sp			| dummy return address
 	SAVE_SWITCH_STACK
 	jbsr	SYMBOL_NAME(syscall_trace)
@@ -222,19 +104,20 @@
 
 	cmpl	#NR_syscalls,%d2
 	jcc	badsys
-	btst	#5,%curptr@(LTASK_FLAGS+3)	| PF_TRACESYS
+	btst	#LPF_TRACESYS_BIT,%curptr@(LTASK_FLAGS+LPF_TRACESYS_OFF)
 	jne	do_trace
 	jbsr	@(SYMBOL_NAME(sys_call_table),%d2:l:4)@(0)
-	movel	%d0,%sp@(LD0)		| save the return value
+	movel	%d0,%sp@(LPT_OFF_D0)	| save the return value
 
 SYMBOL_NAME_LABEL(ret_from_exception)
-	btst	#5,%sp@(LSR)		| check if returning to kernel
+	btst	#5,%sp@(LPT_OFF_SR)	| check if returning to kernel
 	bnes	2f			| if so, skip resched, signals
 	tstl	SYMBOL_NAME(need_resched)
 	jne	SYMBOL_NAME(reschedule)
 	cmpl	#SYMBOL_NAME(task),%curptr	| task[0] cannot have signals
 	jeq	2f
-	bclr	#5,%curptr@(LTASK_FLAGS+1)	| check for delayed trace
+					| check for delayed trace
+	bclr	#LPF_DTRACE_BIT,%curptr@(LTASK_FLAGS+LPF_DTRACE_OFF)
 	jne	do_delayed_trace
 5:
 	tstl	%curptr@(LTASK_STATE)	| state
@@ -245,7 +128,7 @@
 	movel	%curptr@(LTASK_BLOCKED),%d0
 	movel	%d0,%d1			| save blocked in d1 for sig handling
 	notl	%d0
-	btst	#4,%curptr@(LTASK_FLAGS+3)	| PF_PTRACED
+	btst	#LPF_PTRACED_BIT,%curptr@(LTASK_FLAGS+LPF_PTRACED_OFF)
 	jeq	1f
 	moveq	#-1,%d0			| let the debugger see all signals
 1:	andl	%curptr@(LTASK_SIGNAL),%d0
@@ -264,10 +147,10 @@
 	RESTORE_ALL
 
 do_delayed_trace:
-	bclr	#7,%sp@(LSR)		| clear trace bit in SR
+	bclr	#7,%sp@(LPT_OFF_SR)	| clear trace bit in SR
 	pea	1			| send SIGTRAP
 	movel	%curptr,%sp@-
-	pea	5
+	pea	LSIGTRAP
 	jbsr	SYMBOL_NAME(send_sig)
 	addql	#8,%sp
 	addql	#4,%sp
@@ -281,7 +164,7 @@
 	GET_CURRENT(%d0)
 	addql	#1,SYMBOL_NAME(local_irq_count)
 					|  put exception # in d0
-	bfextu %sp@(LFORMATVEC){#4,#10},%d0
+	bfextu %sp@(LPT_OFF_FORMATVEC){#4,#10},%d0
 
 	movel	%sp,%sp@-
 	movel	%d0,%sp@- 		|  put vector # on stack
@@ -295,7 +178,7 @@
 	RESTORE_ALL
 1:
 #if 1
-	bfextu  %sp@(LSR){#5,#3},%d0    | Check for nested interrupt.
+	bfextu  %sp@(LPT_OFF_SR){#5,#3},%d0	| Check for nested interrupt.
 #if MAX_NOINT_IPL > 0
 	cmpiw	#MAX_NOINT_IPL,%d0
 #endif
@@ -351,14 +234,6 @@
 	jbsr	SYMBOL_NAME(do_sigreturn)
 	RESTORE_SWITCH_STACK
 	rts
-
-LFLUSH_I_AND_D = 0x00000808
-LTSS_KSP	= 0
-LTSS_USP	= 4
-LTSS_SR		= 8
-LTSS_FS		= 10
-LTSS_CRP	= 12
-LTSS_FPCTXT	= 24
 
 SYMBOL_NAME_LABEL(resume)
 	/*
--- /dev/null	Fri Apr 29 15:43:48 1994
+++ linux/include/asm-m68k/entry.h	Sat May 24 22:00:16 1997
@@ -0,0 +1,176 @@
+#ifndef __M68K_ENTRY_H
+#define __M68K_ENTRY_H
+
+#include <linux/config.h>
+#include <asm/setup.h>
+#ifdef CONFIG_KGDB
+#include <asm/kgdb.h>
+#endif
+
+/*
+ * Stack layout in 'ret_from_exception':
+ *
+ *	This allows access to the syscall arguments in registers d1-d5
+ *
+ *	 0(sp) - d1
+ *	 4(sp) - d2
+ *	 8(sp) - d3
+ *	 C(sp) - d4
+ *	10(sp) - d5
+ *	14(sp) - a0
+ *	18(sp) - a1
+ *	1C(sp) - a2
+ *	20(sp) - d0
+ *	24(sp) - orig_d0
+ *	28(sp) - stack adjustment
+ *	2C(sp) - sr
+ *	2E(sp) - pc
+ *	32(sp) - format & vector
+ */
+
+/*
+ * 97/05/14 Andreas: Register %a2 is now set to the current task throughout
+ *		     the whole kernel.
+ */
+
+#ifdef __ASSEMBLY__
+
+#define curptr a2
+
+/*
+ * these are offsets into the task-struct
+ */
+LTASK_STATE	=  0
+LTASK_COUNTER	=  4
+LTASK_PRIORITY	=  8
+LTASK_SIGNAL	= 12
+LTASK_BLOCKED	= 16
+LTASK_FLAGS	= 20
+
+LTSS_KSP	= 0
+LTSS_USP	= 4
+LTSS_SR		= 8
+LTSS_FS		= 10
+LTSS_CRP	= 12
+LTSS_FPCTXT	= 24
+
+/* the following macro is used when enabling interrupts */
+#if defined(MACH_ATARI_ONLY)
+	/* block out HSYNC on the atari */
+#define ALLOWINT 0xfbff
+#define	MAX_NOINT_IPL	3
+#else
+	/* portable version */
+#define ALLOWINT 0xf8ff
+#define	MAX_NOINT_IPL	0
+#endif /* machine compilation types */ 
+
+LPT_OFF_D0	  = 0x20
+LPT_OFF_ORIG_D0	  = 0x24
+LPT_OFF_SR	  = 0x2C
+LPT_OFF_FORMATVEC = 0x32
+
+LFLUSH_I_AND_D = 0x00000808
+LENOSYS = 38
+LSIGTRAP = 5
+
+LPF_TRACESYS_OFF = 3
+LPF_TRACESYS_BIT = 5
+LPF_PTRACED_OFF = 3
+LPF_PTRACED_BIT = 4
+LPF_DTRACE_OFF = 1
+LPF_DTRACE_BIT = 5
+
+/*
+ * This defines the normal kernel pt-regs layout.
+ *
+ * regs a3-a6 and d6-d7 are preserved by C code
+ * the kernel doesn't mess with usp unless it needs to
+ */
+#ifndef CONFIG_KGDB
+/*
+ * a -1 in the orig_d0 field signifies
+ * that the stack frame is NOT for syscall
+ */
+#define SAVE_ALL_INT				\
+	clrl	%sp@-;		/* stk_adj */	\
+	pea	-1:w;		/* orig d0 */	\
+	movel	%d0,%sp@-;	/* d0 */	\
+	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@-
+
+#define SAVE_ALL_SYS				\
+	clrl	%sp@-;		/* stk_adj */	\
+	movel	%d0,%sp@-;	/* orig d0 */	\
+	movel	%d0,%sp@-;	/* d0 */	\
+	moveml  %d1-%d5/%a0-%a1/%curptr,%sp@-
+#else
+/* Need to save the "missing" registers for kgdb...
+ */
+#define SAVE_ALL_INT					\
+	clrl	%sp@-;		/* stk_adj */		\
+	pea	-1:w;		/* orig d0 */		\
+	movel	%d0,%sp@-;	/* d0 */		\
+	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@-;		\
+	moveml	%d6-%d7,kgdb_registers+GDBOFFA_D6;	\
+	moveml	%a3-%a6,kgdb_registers+GDBOFFA_A3
+
+#define SAVE_ALL_SYS					\
+	clrl	%sp@-;		/* stk_adj */		\
+	movel	%d0,%sp@-;	/* orig d0 */		\
+	movel	%d0,%sp@-;	/* d0 */		\
+	moveml	%d1-%d5/%a0-%a1/%curptr,%sp@-;		\
+	moveml	%d6-%d7,kgdb_registers+GDBOFFA_D6;	\
+	moveml	%a3-%a6,kgdb_registers+GDBOFFA_A3
+#endif
+
+#define RESTORE_ALL			\
+	moveml	%sp@+,%a0-%a1/%curptr/%d1-%d5;	\
+	movel	%sp@+,%d0;		\
+	addql	#4,%sp;	 /* orig d0 */	\
+	addl	%sp@+,%sp; /* stk adj */	\
+	rte
+
+#define SWITCH_STACK_SIZE (6*4+4)	/* includes return address */
+
+#define SAVE_SWITCH_STACK \
+	moveml	%a3-%a6/%d6-%d7,%sp@-
+
+#define RESTORE_SWITCH_STACK \
+	moveml	%sp@+,%a3-%a6/%d6-%d7
+
+#define GET_CURRENT(tmp) \
+	movel	%sp,tmp; \
+	andw	&-8192,tmp; \
+	movel	tmp,%curptr;
+
+#else /* C source */
+
+#define STR(X) STR1(X)
+#define STR1(X) #X
+
+#define PT_OFF_ORIG_D0	 0x24
+#define PT_OFF_FORMATVEC 0x32
+#define PT_OFF_SR	 0x2C
+#ifndef CONFIG_KGDB
+#define SAVE_ALL_INT				\
+	"clrl	%%sp@-;"    /* stk_adj */	\
+	"pea	-1:w;"	    /* orig d0 = -1 */	\
+	"movel	%%d0,%%sp@-;" /* d0 */		\
+	"moveml	%%d1-%%d5/%%a0-%%a2,%%sp@-"
+#else
+#define SAVE_ALL_INT				\
+	"clrl	%%sp@-\n\t" /* stk_adj */	\
+	"pea	-1:w\n\t"   /* orig d0 = -1 */	\
+	"movel	%%d0,%%sp@-\n\t" /* d0 */	\
+	"moveml	%%d1-%%d5/%%a0-%%a2,%%sp@-\n\t"	\
+	"moveml	%%d6-%%d7,kgdb_registers+"STR(GDBOFFA_D6)"\n\t" \
+	"moveml	%%a3-%%a6,kgdb_registers+"STR(GDBOFFA_A3)
+#endif
+#define GET_CURRENT(tmp) \
+	"movel	%%sp,"#tmp"\n\t" \
+	"andw	#-8192,"#tmp"\n\t" \
+	"movel	"#tmp",%%a2"
+
+#endif
+
+#endif /* __M68K_ENTRY_H */
