m68k: Use macro to generate 68000 interrupt entry sleds

Message ID 20240107014248.3651022-1-daniel@0x0f.com
State New
Headers
Series m68k: Use macro to generate 68000 interrupt entry sleds |

Commit Message

Daniel Palmer Jan. 7, 2024, 1:42 a.m. UTC
  In preparation for decoupling the plain 68000 code from
the DragonBall support clean entry.S a little bit by
using a macro to generic the interrupt sleds (needed to
put the vector number on the stack as the 68000 doesn't
do that) and use the correct numbers.

The function to call from the sled is a parameter so that
other interrupt types (i.e. autovectored ones) can specify
their handler when they are added later.

Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---

This is a small patch to show that I'm working on this before someone
comes along and deletes everything. For plain 68000 I have:
  - working QEMU setup using the newish m68k virt machine
  - working u-boot for mc68000 (Works on QEMU for now, will work on
    real hardware too..)
  - u-boot creates a devicetree from the bootinfo and the kernel uses
    that so things are *modern*.
  - buildroot working enough that it can generate a rootfs
  - kernel working enough that it can mount the rootfs over virtio
    and run the shell (there are some problems after that though..)

 arch/m68k/68000/entry.S | 100 ++++++++--------------------------------
 arch/m68k/68000/ints.c  |  14 +++---
 2 files changed, 27 insertions(+), 87 deletions(-)
  

Comments

Daniel Palmer Jan. 7, 2024, 1:17 p.m. UTC | #1
Hi me,

On Sun, 7 Jan 2024 at 10:42, Daniel Palmer <daniel@0x0f.com> wrote:
<snip>
>
> --- a/arch/m68k/68000/ints.c
> +++ b/arch/m68k/68000/ints.c
> +asmlinkage irqreturn_t inthandler65(void);
> +asmlinkage irqreturn_t inthandler66(void);
> +asmlinkage irqreturn_t inthandler67(void);
> +asmlinkage irqreturn_t inthandler68(void);
> +asmlinkage irqreturn_t inthandler69(void);
> +asmlinkage irqreturn_t inthandler70(void);
> +asmlinkage irqreturn_t inthandler71(void);
>
>  /* The 68k family did not have a good way to determine the source
>   * of interrupts until later in the family.  The EC000 core does
> --
> 2.43.0

There is a missing part of this that updates the symbols used when
populating the vector table that I missed when splitting this patch
out.
This will currently cause a build break that I didn't notice because
the change is actually in my tree.
I'll send a v2 if the general idea is ok.

Cheers,

Daniel
  

Patch

diff --git a/arch/m68k/68000/entry.S b/arch/m68k/68000/entry.S
index 72e95663b62f..e1fc740412f2 100644
--- a/arch/m68k/68000/entry.S
+++ b/arch/m68k/68000/entry.S
@@ -23,13 +23,6 @@ 
 .globl ret_from_exception
 .globl sys_call_table
 .globl bad_interrupt
-.globl inthandler1
-.globl inthandler2
-.globl inthandler3
-.globl inthandler4
-.globl inthandler5
-.globl inthandler6
-.globl inthandler7
 
 badsys:
 	movel	#-ENOSYS,%sp@(PT_OFF_D0)
@@ -119,85 +112,32 @@  Lsignal_return:
 	addql	#4,%sp
 	jra	1b
 
-/*
- * This is the main interrupt handler, responsible for calling process_int()
- */
-inthandler1:
-	SAVE_ALL_INT
-	movew	%sp@(PT_OFF_FORMATVEC), %d0
-	and	#0x3ff, %d0
-
-	movel	%sp,%sp@-
-	movel	#65,%sp@- 		/*  put vector # on stack*/
-	jbsr	process_int		/*  process the IRQ*/
-3:     	addql	#8,%sp			/*  pop parameters off stack*/
-	bra	ret_from_exception
-
-inthandler2:
-	SAVE_ALL_INT
-	movew	%sp@(PT_OFF_FORMATVEC), %d0
-	and	#0x3ff, %d0
-
-	movel	%sp,%sp@-
-	movel	#66,%sp@- 		/*  put vector # on stack*/
-	jbsr	process_int		/*  process the IRQ*/
-3:     	addql	#8,%sp			/*  pop parameters off stack*/
-	bra	ret_from_exception
-
-inthandler3:
-	SAVE_ALL_INT
-	movew	%sp@(PT_OFF_FORMATVEC), %d0
-	and	#0x3ff, %d0
-
-	movel	%sp,%sp@-
-	movel	#67,%sp@- 		/*  put vector # on stack*/
-	jbsr	process_int		/*  process the IRQ*/
-3:     	addql	#8,%sp			/*  pop parameters off stack*/
-	bra	ret_from_exception
-
-inthandler4:
+/* Create an interrupt vector sled */
+ .macro inthandler num func
+	.globl inthandler\num
+	inthandler\num:
 	SAVE_ALL_INT
 	movew	%sp@(PT_OFF_FORMATVEC), %d0
 	and	#0x3ff, %d0
 
 	movel	%sp,%sp@-
-	movel	#68,%sp@- 		/*  put vector # on stack*/
-	jbsr	process_int		/*  process the IRQ*/
-3:     	addql	#8,%sp			/*  pop parameters off stack*/
-	bra	ret_from_exception
-
-inthandler5:
-	SAVE_ALL_INT
-	movew	%sp@(PT_OFF_FORMATVEC), %d0
-	and	#0x3ff, %d0
-
-	movel	%sp,%sp@-
-	movel	#69,%sp@- 		/*  put vector # on stack*/
-	jbsr	process_int		/*  process the IRQ*/
-3:     	addql	#8,%sp			/*  pop parameters off stack*/
-	bra	ret_from_exception
-
-inthandler6:
-	SAVE_ALL_INT
-	movew	%sp@(PT_OFF_FORMATVEC), %d0
-	and	#0x3ff, %d0
-
-	movel	%sp,%sp@-
-	movel	#70,%sp@- 		/*  put vector # on stack*/
-	jbsr	process_int		/*  process the IRQ*/
-3:     	addql	#8,%sp			/*  pop parameters off stack*/
-	bra	ret_from_exception
-
-inthandler7:
-	SAVE_ALL_INT
-	movew	%sp@(PT_OFF_FORMATVEC), %d0
-	and	#0x3ff, %d0
-
-	movel	%sp,%sp@-
-	movel	#71,%sp@- 		/*  put vector # on stack*/
-	jbsr	process_int		/*  process the IRQ*/
-3:     	addql	#8,%sp			/*  pop parameters off stack*/
+	/* put vector # on stack*/
+	movel	#\num,%sp@-
+	/* process the IRQ*/
+	jbsr	\func
+	/* pop parameters off stack*/
+	addql	#8,%sp
 	bra	ret_from_exception
+ .endm
+
+/* Dragonball interrupts */
+inthandler 65 process_int
+inthandler 66 process_int
+inthandler 67 process_int
+inthandler 68 process_int
+inthandler 69 process_int
+inthandler 70 process_int
+inthandler 71 process_int
 
 inthandler:
 	SAVE_ALL_INT
diff --git a/arch/m68k/68000/ints.c b/arch/m68k/68000/ints.c
index 2ba9926e91ae..3d93255c2fe4 100644
--- a/arch/m68k/68000/ints.c
+++ b/arch/m68k/68000/ints.c
@@ -63,13 +63,13 @@  asmlinkage void trap46(void);
 asmlinkage void trap47(void);
 asmlinkage irqreturn_t bad_interrupt(int, void *);
 asmlinkage irqreturn_t inthandler(void);
-asmlinkage irqreturn_t inthandler1(void);
-asmlinkage irqreturn_t inthandler2(void);
-asmlinkage irqreturn_t inthandler3(void);
-asmlinkage irqreturn_t inthandler4(void);
-asmlinkage irqreturn_t inthandler5(void);
-asmlinkage irqreturn_t inthandler6(void);
-asmlinkage irqreturn_t inthandler7(void);
+asmlinkage irqreturn_t inthandler65(void);
+asmlinkage irqreturn_t inthandler66(void);
+asmlinkage irqreturn_t inthandler67(void);
+asmlinkage irqreturn_t inthandler68(void);
+asmlinkage irqreturn_t inthandler69(void);
+asmlinkage irqreturn_t inthandler70(void);
+asmlinkage irqreturn_t inthandler71(void);
 
 /* The 68k family did not have a good way to determine the source
  * of interrupts until later in the family.  The EC000 core does