Skip to content

Commit

Permalink
intrng: fix INTR_ROOT_* constants
Browse files Browse the repository at this point in the history
Switch to INTR_ROOT_COUNT as this name better describes its purpose.

Remove the default INTR_ROOT_IRQ from the core.  Define it (redundantly)
in each architecture's header, but now placed alongside its sibling
values (if defined by the platform, e.g. arm64 INTR_ROOT_FIQ).

Reviewed by:	mhorne
Pull Request:	#1280
  • Loading branch information
ehem authored and mhorne committed Dec 16, 2024
1 parent e94684b commit 487788a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
3 changes: 3 additions & 0 deletions sys/arm/include/intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ void arm_irq_memory_barrier(uintptr_t);
#define NIRQ 1024 /* XXX - It should be an option. */
#endif

#define INTR_ROOT_IRQ 0
#define INTR_ROOT_COUNT 1

#endif /* _MACHINE_INTR_H */
3 changes: 2 additions & 1 deletion sys/arm64/include/intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ arm_irq_memory_barrier(uintptr_t irq)
#define ACPI_GPIO_XREF 3
#endif

#define INTR_ROOT_IRQ 0
#define INTR_ROOT_FIQ 1
#define INTR_ROOT_NUM 2
#define INTR_ROOT_COUNT 2

#endif /* _MACHINE_INTR_H */
19 changes: 5 additions & 14 deletions sys/kern/subr_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,6 @@

#define INTRNAME_LEN (2*MAXCOMLEN + 1)

/*
* Archs may define multiple roots with INTR_ROOT_NUM to support different kinds
* of interrupts (e.g. arm64 FIQs which use a different exception vector than
* IRQs).
*/
#if !defined(INTR_ROOT_NUM)
#define INTR_ROOT_NUM 1
#endif

#ifdef DEBUG
#define debugf(fmt, args...) do { printf("%s(): ", __func__); \
printf(fmt,##args); } while (0)
Expand All @@ -115,7 +106,7 @@ struct intr_irq_root {
void *arg;
};

static struct intr_irq_root intr_irq_roots[INTR_ROOT_NUM];
static struct intr_irq_root intr_irq_roots[INTR_ROOT_COUNT];

struct intr_pic_child {
SLIST_ENTRY(intr_pic_child) pc_next;
Expand Down Expand Up @@ -343,7 +334,7 @@ intr_irq_handler(struct trapframe *tf, uint32_t rootnum)
struct thread * td;
struct intr_irq_root *root;

KASSERT(rootnum < INTR_ROOT_NUM,
KASSERT(rootnum < INTR_ROOT_COUNT,
("%s: invalid interrupt root %d", __func__, rootnum));

root = &intr_irq_roots[rootnum];
Expand Down Expand Up @@ -497,7 +488,7 @@ isrc_free_irq(struct intr_irqsrc *isrc)
device_t
intr_irq_root_device(uint32_t rootnum)
{
KASSERT(rootnum < INTR_ROOT_NUM,
KASSERT(rootnum < INTR_ROOT_COUNT,
("%s: invalid interrupt root %d", __func__, rootnum));
return (intr_irq_roots[rootnum].dev);
}
Expand Down Expand Up @@ -925,7 +916,7 @@ intr_pic_claim_root(device_t dev, intptr_t xref, intr_irq_filter_t *filter,
* Note that we further suppose that there is not threaded interrupt
* routine (handler) on the root. See intr_irq_handler().
*/
KASSERT(rootnum < INTR_ROOT_NUM,
KASSERT(rootnum < INTR_ROOT_COUNT,
("%s: invalid interrupt root %d", __func__, rootnum));
root = &intr_irq_roots[rootnum];
if (root->dev != NULL) {
Expand Down Expand Up @@ -1586,7 +1577,7 @@ intr_pic_init_secondary(void)
* QQQ: Only root PICs are aware of other CPUs ???
*/
//mtx_lock(&isrc_table_lock);
for (rootnum = 0; rootnum < INTR_ROOT_NUM; rootnum++) {
for (rootnum = 0; rootnum < INTR_ROOT_COUNT; rootnum++) {
dev = intr_irq_roots[rootnum].dev;
if (dev != NULL) {
PIC_INIT_SECONDARY(dev, rootnum);
Expand Down
3 changes: 3 additions & 0 deletions sys/riscv/include/intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ enum {
};
#endif /* !LOCORE */

#define INTR_ROOT_IRQ 0
#define INTR_ROOT_COUNT 1

#endif /* !_MACHINE_INTR_MACHDEP_H_ */
2 changes: 0 additions & 2 deletions sys/sys/intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

#define INTR_IRQ_INVALID 0xFFFFFFFF

#define INTR_ROOT_IRQ 0

#ifndef LOCORE

enum intr_map_data_type {
Expand Down

0 comments on commit 487788a

Please sign in to comment.