git: 7b16a4a75dc1 - main - sys/intr.h: Make it safe to include from assembler

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 06 Dec 2024 17:54:50 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=7b16a4a75dc14224efc72f1ff2cc98f6f857f757

commit 7b16a4a75dc14224efc72f1ff2cc98f6f857f757
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-12-06 17:30:02 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-12-06 17:31:36 +0000

    sys/intr.h: Make it safe to include from assembler
    
    Sometimes we need defines from this file in assembler code. Today we do
    the heavyweight approach of using genassym for that. However, they are
    just #defines, so in the future we want to include sys/intr.h to pick up
    the needed constants in exception.S.
    
    PR:                     283041
    Sponsored by:           Netflix
    Reviewed by:            mmel, andrew
    Differential Revision:  https://reviews.freebsd.org/D47846
---
 sys/arm/include/intr.h   |  6 ++++--
 sys/arm64/include/intr.h | 10 ++++++----
 sys/riscv/include/intr.h |  2 ++
 sys/sys/intr.h           |  6 ++++--
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/sys/arm/include/intr.h b/sys/arm/include/intr.h
index e64edd47dad2..5facd5dbccdb 100644
--- a/sys/arm/include/intr.h
+++ b/sys/arm/include/intr.h
@@ -39,14 +39,16 @@
 #ifndef _MACHINE_INTR_H_
 #define _MACHINE_INTR_H_
 
+#ifndef LOCORE
 #ifdef FDT
 #include <dev/ofw/openfirm.h>
 #endif
 
+void arm_irq_memory_barrier(uintptr_t);
+#endif /* !LOCORE */
+
 #ifndef NIRQ
 #define	NIRQ		1024	/* XXX - It should be an option. */
 #endif
 
-void arm_irq_memory_barrier(uintptr_t);
-
 #endif	/* _MACHINE_INTR_H */
diff --git a/sys/arm64/include/intr.h b/sys/arm64/include/intr.h
index 38cba6ae8b0d..56bce911cd32 100644
--- a/sys/arm64/include/intr.h
+++ b/sys/arm64/include/intr.h
@@ -27,18 +27,20 @@
 #ifndef _MACHINE_INTR_H_
 #define	_MACHINE_INTR_H_
 
+#ifndef LOCORE
 #ifdef FDT
 #include <dev/ofw/openfirm.h>
 #endif
 
-#ifndef NIRQ
-#define	NIRQ		16384	/* XXX - It should be an option. */
-#endif
-
 static inline void
 arm_irq_memory_barrier(uintptr_t irq)
 {
 }
+#endif /* !LOCORE */
+
+#ifndef NIRQ
+#define	NIRQ		16384	/* XXX - It should be an option. */
+#endif
 
 #ifdef DEV_ACPI
 #define	ACPI_INTR_XREF	1
diff --git a/sys/riscv/include/intr.h b/sys/riscv/include/intr.h
index 657781efb620..ea98f0632108 100644
--- a/sys/riscv/include/intr.h
+++ b/sys/riscv/include/intr.h
@@ -39,6 +39,7 @@
 #define	NIRQ			1024
 #endif
 
+#ifndef LOCORE
 enum {
 	IRQ_SOFTWARE_USER,
 	IRQ_SOFTWARE_SUPERVISOR,
@@ -53,5 +54,6 @@ enum {
 	IRQ_EXTERNAL_HYPERVISOR,
 	IRQ_EXTERNAL_MACHINE,
 };
+#endif /* !LOCORE */
 
 #endif /* !_MACHINE_INTR_MACHDEP_H_ */
diff --git a/sys/sys/intr.h b/sys/sys/intr.h
index f11e96777927..d60eac937d93 100644
--- a/sys/sys/intr.h
+++ b/sys/sys/intr.h
@@ -33,14 +33,14 @@
 #error Need INTRNG for this file
 #endif
 
-#include <sys/systm.h>
-
 #include <machine/intr.h>
 
 #define	INTR_IRQ_INVALID	0xFFFFFFFF
 
 #define INTR_ROOT_IRQ	0
 
+#ifndef LOCORE
+
 enum intr_map_data_type {
 	INTR_MAP_DATA_ACPI = 0,
 	INTR_MAP_DATA_FDT,
@@ -171,4 +171,6 @@ void intr_ipi_dispatch(u_int ipi);
 /* Main interrupt handler called from asm on most archs except riscv. */
 void intr_irq_handler(struct trapframe *tf, uint32_t rootnum);
 
+#endif /* !LOCORE */
+
 #endif	/* _SYS_INTR_H */