Module Name:    src
Committed By:   skrll
Date:           Sun Jan 21 08:48:21 UTC 2024

Modified Files:
        src/sys/arch/riscv/fdt: intc_fdt.c

Log Message:
Make this compile without MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/riscv/fdt/intc_fdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/riscv/fdt/intc_fdt.c
diff -u src/sys/arch/riscv/fdt/intc_fdt.c:1.5 src/sys/arch/riscv/fdt/intc_fdt.c:1.6
--- src/sys/arch/riscv/fdt/intc_fdt.c:1.5	Sun Jan 21 08:41:00 2024
+++ src/sys/arch/riscv/fdt/intc_fdt.c	Sun Jan 21 08:48:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: intc_fdt.c,v 1.5 2024/01/21 08:41:00 skrll Exp $	*/
+/*	$NetBSD: intc_fdt.c,v 1.6 2024/01/21 08:48:21 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intc_fdt.c,v 1.5 2024/01/21 08:41:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intc_fdt.c,v 1.6 2024/01/21 08:48:21 skrll Exp $");
 
 #include <sys/param.h>
 
@@ -57,7 +57,6 @@ static const struct device_compatible_en
 
 struct intc_irqhandler;
 struct intc_irq;
-struct intc_softc;
 
 typedef int (*intcih_t)(void *);
 
@@ -121,6 +120,20 @@ static const char * const intc_sources[I
 	"(reserved)"
 };
 
+#ifndef MULTIPROCESSOR
+struct intc_fdt_softc *intc_sc;
+#endif
+
+
+static inline struct intc_fdt_softc *
+intc_getsc(struct cpu_info *ci)
+{
+#ifdef MULTIPROCESSOR
+	return ci->ci_intcsoftc;
+#else
+	return intc_sc;
+#endif
+}
 
 static void *
 intc_intr_establish(struct intc_fdt_softc *sc, u_int source, u_int ipl,
@@ -246,7 +259,7 @@ intc_intr_handler(struct trapframe *tf, 
 
 	KASSERT(CAUSE_INTERRUPT_P(cause));
 
-	struct intc_fdt_softc * const sc = ci->ci_intcsoftc;
+	struct intc_fdt_softc * const sc = intc_getsc(ci);
 
 	ci->ci_intr_depth++;
 	ci->ci_data.cpu_nintr++;
@@ -334,13 +347,15 @@ intc_attach(device_t parent, device_t se
 	sc->sc_dev = self;
 	sc->sc_ci = ci;
 	sc->sc_hartid = ci->ci_cpuid;
-	ci->ci_intcsoftc = sc;
 
 	intc_intr_establish(sc, IRQ_SUPERVISOR_TIMER, IPL_SCHED, IST_MPSAFE,
 	    riscv_timer_intr, NULL, "clock");
 #ifdef MULTIPROCESSOR
+	ci->ci_intcsoftc = sc;
 	intc_intr_establish(sc, IRQ_SUPERVISOR_SOFTWARE, IPL_HIGH, IST_MPSAFE,
 	    riscv_ipi_intr, NULL, "ipi");
+#else
+	intc_sc = sc;
 #endif
 }
 

Reply via email to