Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Add FIQ support.



details:   https://anonhg.NetBSD.org/src/rev/8c3c12518bdf
branches:  trunk
changeset: 985594:8c3c12518bdf
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Aug 30 23:20:00 2021 +0000

description:
Add FIQ support.

diffstat:

 sys/arch/aarch64/aarch64/trap.c    |  33 ++++++++++++++++++++++++++++++---
 sys/arch/aarch64/aarch64/vectors.S |  16 ++++++++--------
 sys/arch/aarch64/include/machdep.h |   5 +++--
 sys/arch/arm/fdt/arm_fdt.c         |  32 +++++++++++++++++++++++++++++---
 sys/arch/arm/fdt/arm_fdtvar.h      |   4 +++-
 sys/arch/arm/fdt/fdt_intr.h        |   5 ++++-
 6 files changed, 77 insertions(+), 18 deletions(-)

diffs (268 lines):

diff -r 49396cf1ca32 -r 8c3c12518bdf sys/arch/aarch64/aarch64/trap.c
--- a/sys/arch/aarch64/aarch64/trap.c   Mon Aug 30 23:16:17 2021 +0000
+++ b/sys/arch/aarch64/aarch64/trap.c   Mon Aug 30 23:20:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.46 2021/04/14 05:43:09 ryo Exp $ */
+/* $NetBSD: trap.c,v 1.47 2021/08/30 23:20:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.46 2021/04/14 05:43:09 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.47 2021/08/30 23:20:00 jmcneill Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -504,7 +504,7 @@
 }
 
 void
-interrupt(struct trapframe *tf)
+cpu_irq(struct trapframe *tf)
 {
        struct cpu_info * const ci = curcpu();
 
@@ -535,6 +535,33 @@
        cpu_dosoftints();
 }
 
+void
+cpu_fiq(struct trapframe *tf)
+{
+       struct cpu_info * const ci = curcpu();
+
+#ifdef STACKCHECKS
+       struct lwp *l = curlwp;
+       void *sp = (void *)reg_sp_read();
+       if (l->l_addr >= sp) {
+               panic("lwp/interrupt stack overflow detected."
+                   " lwp=%p, sp=%p, l_addr=%p", l, sp, l->l_addr);
+       }
+#endif
+
+       /* disable trace */
+       reg_mdscr_el1_write(reg_mdscr_el1_read() & ~MDSCR_SS);
+
+       /* enable traps */
+       daif_enable(DAIF_D|DAIF_A);
+
+       ci->ci_intr_depth++;
+       ARM_FIQ_HANDLER(tf);
+       ci->ci_intr_depth--;
+
+       cpu_dosoftints();
+}
+
 #ifdef COMPAT_NETBSD32
 
 /*
diff -r 49396cf1ca32 -r 8c3c12518bdf sys/arch/aarch64/aarch64/vectors.S
--- a/sys/arch/aarch64/aarch64/vectors.S        Mon Aug 30 23:16:17 2021 +0000
+++ b/sys/arch/aarch64/aarch64/vectors.S        Mon Aug 30 23:20:00 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vectors.S,v 1.22 2021/03/09 16:44:27 ryo Exp $ */
+/*     $NetBSD: vectors.S,v 1.23 2021/08/30 23:20:00 jmcneill Exp $    */
 
 #include <aarch64/asm.h>
 #include <aarch64/locore.h>
@@ -10,7 +10,7 @@
 #include "opt_ddb.h"
 #include "opt_dtrace.h"
 
-RCSID("$NetBSD: vectors.S,v 1.22 2021/03/09 16:44:27 ryo Exp $")
+RCSID("$NetBSD: vectors.S,v 1.23 2021/08/30 23:20:00 jmcneill Exp $")
 
        ARMV8_DEFINE_OPTIONS
 
@@ -130,18 +130,18 @@
 vector_func    el1t_error_handler, 1, trap_el1t_error
 
 vector_func    el1h_sync_handler,  1, trap_el1h_sync
-vector_func    el1h_intr_handler,  1, interrupt
-vector_func    el1h_fiq_handler,   1, trap_el1h_fiq
+vector_func    el1h_intr_handler,  1, cpu_irq
+vector_func    el1h_fiq_handler,   1, cpu_fiq
 vector_func    el1h_error_handler, 1, trap_el1h_error
 
 vector_func    el0_sync_handler,  0, trap_el0_sync
-vector_func    el0_intr_handler,  0, interrupt
-vector_func    el0_fiq_handler,   0, trap_el0_fiq
+vector_func    el0_intr_handler,  0, cpu_irq
+vector_func    el0_fiq_handler,   0, cpu_fiq
 vector_func    el0_error_handler, 0, trap_el0_error
 
 vector_func    el0_32sync_handler,  0, trap_el0_32sync, ro
-vector_func    el0_32intr_handler,  0, interrupt, ro
-vector_func    el0_32fiq_handler,   0, trap_el0_32fiq, ro
+vector_func    el0_32intr_handler,  0, cpu_irq, ro
+vector_func    el0_32fiq_handler,   0, cpu_fiq, ro
 vector_func    el0_32error_handler, 0, trap_el0_32error, ro
 
 /*
diff -r 49396cf1ca32 -r 8c3c12518bdf sys/arch/aarch64/include/machdep.h
--- a/sys/arch/aarch64/include/machdep.h        Mon Aug 30 23:16:17 2021 +0000
+++ b/sys/arch/aarch64/include/machdep.h        Mon Aug 30 23:20:00 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.h,v 1.17 2020/09/06 17:38:10 ryo Exp $ */
+/*     $NetBSD: machdep.h,v 1.18 2021/08/30 23:20:00 jmcneill Exp $    */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -111,7 +111,8 @@
 void trap_el0_32sync(struct trapframe *);
 void trap_el0_32fiq(struct trapframe *);
 void trap_el0_32error(struct trapframe *);
-void interrupt(struct trapframe *);
+void cpu_irq(struct trapframe *);
+void cpu_fiq(struct trapframe *);
 
 /* cpu_onfault */
 int cpu_set_onfault(struct faultbuf *) __returns_twice;
diff -r 49396cf1ca32 -r 8c3c12518bdf sys/arch/arm/fdt/arm_fdt.c
--- a/sys/arch/arm/fdt/arm_fdt.c        Mon Aug 30 23:16:17 2021 +0000
+++ b/sys/arch/arm/fdt/arm_fdt.c        Mon Aug 30 23:20:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdt.c,v 1.17 2021/08/07 16:18:43 thorpej Exp $ */
+/* $NetBSD: arm_fdt.c,v 1.18 2021/08/30 23:20:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
 #include "opt_modular.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.17 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.18 2021/08/30 23:20:00 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -48,6 +48,8 @@
 
 #include <arm/fdt/arm_fdtvar.h>
 
+#include <arm/locore.h>
+
 #ifdef EFI_RUNTIME
 #include <arm/arm/efi_runtime.h>
 #include <dev/clock_subr.h>
@@ -57,6 +59,7 @@
 static void    arm_fdt_attach(device_t, device_t, void *);
 
 static void    arm_fdt_irq_default_handler(void *);
+static void    arm_fdt_fiq_default_handler(void *);
 
 #ifdef EFI_RUNTIME
 static void    arm_fdt_efi_init(device_t);
@@ -79,6 +82,7 @@
     TAILQ_HEAD_INITIALIZER(arm_fdt_cpu_hatch_cbs);
 
 static void (*_arm_fdt_irq_handler)(void *) = arm_fdt_irq_default_handler;
+static void (*_arm_fdt_fiq_handler)(void *) = arm_fdt_fiq_default_handler;
 static void (*_arm_fdt_timer_init)(void) = NULL;
 
 int
@@ -96,6 +100,8 @@
        aprint_naive("\n");
        aprint_normal("\n");
 
+       DISABLE_INTERRUPT();
+
 #ifdef EFI_RUNTIME
        arm_fdt_efi_init(self);
 #endif
@@ -174,7 +180,13 @@
 static void
 arm_fdt_irq_default_handler(void *frame)
 {
-       panic("missing interrupt controller driver");
+       panic("No IRQ handler installed");
+}
+
+static void
+arm_fdt_fiq_default_handler(void *frame)
+{
+       panic("No FIQ handler installed");
 }
 
 void
@@ -185,12 +197,25 @@
 }
 
 void
+arm_fdt_fiq_set_handler(void (*fiq_handler)(void *))
+{
+       KASSERT(_arm_fdt_fiq_handler == arm_fdt_fiq_default_handler);
+       _arm_fdt_fiq_handler = fiq_handler;
+}
+
+void
 arm_fdt_irq_handler(void *tf)
 {
        _arm_fdt_irq_handler(tf);
 }
 
 void
+arm_fdt_fiq_handler(void *tf)
+{
+       _arm_fdt_fiq_handler(tf);
+}
+
+void
 arm_fdt_timer_register(void (*timerfn)(void))
 {
        if (_arm_fdt_timer_init != NULL) {
@@ -232,6 +257,7 @@
        if (_arm_fdt_timer_init == NULL)
                panic("cpu_initclocks: no timer registered");
        _arm_fdt_timer_init();
+       ENABLE_INTERRUPT();
 }
 #endif
 
diff -r 49396cf1ca32 -r 8c3c12518bdf sys/arch/arm/fdt/arm_fdtvar.h
--- a/sys/arch/arm/fdt/arm_fdtvar.h     Mon Aug 30 23:16:17 2021 +0000
+++ b/sys/arch/arm/fdt/arm_fdtvar.h     Mon Aug 30 23:20:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdtvar.h,v 1.17 2020/06/21 17:25:03 jmcneill Exp $ */
+/* $NetBSD: arm_fdtvar.h,v 1.18 2021/08/30 23:20:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -94,6 +94,8 @@
 
 void   arm_fdt_irq_set_handler(void (*)(void *));
 void   arm_fdt_irq_handler(void *);
+void   arm_fdt_fiq_set_handler(void (*)(void *));
+void   arm_fdt_fiq_handler(void *);
 
 void   arm_fdt_memory_dump(paddr_t);
 
diff -r 49396cf1ca32 -r 8c3c12518bdf sys/arch/arm/fdt/fdt_intr.h
--- a/sys/arch/arm/fdt/fdt_intr.h       Mon Aug 30 23:16:17 2021 +0000
+++ b/sys/arch/arm/fdt/fdt_intr.h       Mon Aug 30 23:20:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.h,v 1.5 2018/11/09 23:35:06 jmcneill Exp $ */
+/* $NetBSD: fdt_intr.h,v 1.6 2021/08/30 23:20:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -30,6 +30,7 @@
 #define _ARM_FDT_INTR_H
 
 #define        ARM_IRQ_HANDLER         _C_LABEL(arm_fdt_irq_handler)
+#define        ARM_FIQ_HANDLER         _C_LABEL(arm_fdt_fiq_handler)
 
 #ifndef _LOCORE
 
@@ -41,6 +42,8 @@
 
 void   arm_fdt_irq_set_handler(void (*)(void *));
 void   arm_fdt_irq_handler(void *);
+void   arm_fdt_fiq_set_handler(void (*)(void *));
+void   arm_fdt_fiq_handler(void *);
 
 #include <arm/pic/picvar.h>
 



Home | Main Index | Thread Index | Old Index