summaryrefslogtreecommitdiff
path: root/kern/intr.c
diff options
context:
space:
mode:
Diffstat (limited to 'kern/intr.c')
-rw-r--r--kern/intr.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/kern/intr.c b/kern/intr.c
index fe69e3e9..8579b744 100644
--- a/kern/intr.c
+++ b/kern/intr.c
@@ -22,27 +22,29 @@
* Shared interrupts are supported.
*/
+#include <stdalign.h>
#include <stdbool.h>
#include <stddef.h>
-#include <stdio.h>
#include <kern/atomic.h>
#include <kern/kmem.h>
#include <kern/init.h>
#include <kern/intr.h>
#include <kern/list.h>
+#include <kern/log.h>
#include <kern/macros.h>
#include <kern/panic.h>
-#include <kern/param.h>
#include <kern/spinlock.h>
#include <kern/thread.h>
+#include <machine/boot.h>
#include <machine/cpu.h>
+#include <machine/trap.h>
struct intr_handler {
- struct list node;
+ alignas(CPU_L1_SIZE) struct list node;
intr_handler_fn_t fn;
void *arg;
-} __aligned(CPU_L1_SIZE);
+};
/*
* Interrupt controller.
@@ -67,16 +69,16 @@ struct intr_ctl {
* span a cache line to avoid false sharing.
*/
struct intr_entry {
- struct spinlock lock;
+ alignas(CPU_L1_SIZE) struct spinlock lock;
struct intr_ctl *ctl;
unsigned int cpu;
struct list handlers;
-} __aligned(CPU_L1_SIZE);
+};
/*
* Interrupt table.
*/
-static struct intr_entry intr_table[INTR_TABLE_SIZE];
+static struct intr_entry intr_table[TRAP_INTR_TABLE_SIZE];
/*
* List of registered controllers.
@@ -314,8 +316,8 @@ intr_get_entry(unsigned int intr)
return &intr_table[intr];
}
-void __init
-intr_setup(void)
+static int __init
+intr_bootstrap(void)
{
unsigned int i;
@@ -327,8 +329,27 @@ intr_setup(void)
for (i = 0; i < ARRAY_SIZE(intr_table); i++) {
intr_entry_init(intr_get_entry(i));
}
+
+ return 0;
}
+INIT_OP_DEFINE(intr_bootstrap,
+ INIT_OP_DEP(kmem_setup, true),
+ INIT_OP_DEP(log_setup, true),
+ INIT_OP_DEP(panic_setup, true),
+ INIT_OP_DEP(spinlock_setup, true),
+ INIT_OP_DEP(thread_bootstrap, true));
+
+static int __init
+intr_setup(void)
+{
+ return 0;
+}
+
+INIT_OP_DEFINE(intr_setup,
+ INIT_OP_DEP(boot_setup_intr, true),
+ INIT_OP_DEP(intr_bootstrap, true));
+
static void __init
intr_check_range(unsigned int first_intr, unsigned int last_intr)
{
@@ -388,7 +409,7 @@ intr_unregister(unsigned int intr, intr_handler_fn_t fn)
handler = intr_entry_remove(intr_get_entry(intr), fn);
if (handler == NULL) {
- printf("intr: warning: attempting to unregister unknown handler\n");
+ log_warning("intr: attempting to unregister unknown handler");
return;
}
@@ -410,7 +431,7 @@ intr_handle(unsigned int intr)
spinlock_lock(&entry->lock);
if (intr_entry_empty(entry)) {
- printf("intr: spurious interrupt %u\n", intr);
+ log_warning("intr: spurious interrupt %u", intr);
goto out;
}