summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-06-20 01:12:10 -0400
committerIan Moffett <ian@osmora.org>2025-06-20 01:16:57 -0400
commit66beb7829271712f6cd2bbe03b38a50c1d953f2c (patch)
treee5a8e9297355251118f02fb344d877b027b6e8f8 /sys
parent8688a083ab2d5e2fa0da737724cf12d130b4127f (diff)
kernel/amd64: intr: Add driver specific intr dataexpt
Allow the intr_hand structure to carry driver specific and interrupt related data so that it can be passed to an interrupt handler when it is invoked. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/intr.c10
-rw-r--r--sys/arch/amd64/amd64/vector.S3
-rw-r--r--sys/include/arch/amd64/intr.h18
3 files changed, 30 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c
index cb38cd8..685a16d 100644
--- a/sys/arch/amd64/amd64/intr.c
+++ b/sys/arch/amd64/amd64/intr.c
@@ -79,6 +79,8 @@ intr_register(const char *name, const struct intr_hand *ih)
{
uint32_t vec = MAX(ih->priority << IPL_SHIFT, 0x20);
struct intr_hand *ih_new;
+ struct intr_data *idp_new;
+ const struct intr_data *idp;
size_t name_len;
/* Sanity check */
@@ -115,6 +117,14 @@ intr_register(const char *name, const struct intr_hand *ih)
}
memcpy(ih_new->name, name, name_len);
+ idp_new = &ih_new->data;
+ idp = &ih->data;
+
+ /* Pass the interrupt data */
+ idp_new->ihp = ih_new;
+ idp_new->data_u64 = idp->data_u64;
+
+ /* Setup the new intr_hand */
ih_new->func = ih->func;
ih_new->priority = ih->priority;
ih_new->irq = ih->irq;
diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S
index e348ff4..c820a41 100644
--- a/sys/arch/amd64/amd64/vector.S
+++ b/sys/arch/amd64/amd64/vector.S
@@ -51,7 +51,8 @@ ioapic_common_func:
jz 1f // Nope, return
mov (%rdx), %rbx // intr_hand.func
- xor %rdi, %rdi // No data
+ add $8, %rdx // Get interrupt data
+ mov %rdx, %rdi // Pass the interrupt data
push %rcx // Save our counter
call *%rbx // Call the handler
pop %rcx // Restore our counter
diff --git a/sys/include/arch/amd64/intr.h b/sys/include/arch/amd64/intr.h
index b640e4b..c848b6f 100644
--- a/sys/include/arch/amd64/intr.h
+++ b/sys/include/arch/amd64/intr.h
@@ -47,6 +47,22 @@
#define IPL_CLOCK 2 /* Clock */
#define IPL_HIGH 3 /* Defer everything */
+struct intr_hand;
+
+/*
+ * Contains information passed to driver
+ *
+ * @ihp: Interrupt handler
+ * @data: Driver specific data
+ */
+struct intr_data {
+ struct intr_hand *ihp;
+ union {
+ void *data;
+ uint64_t data_u64;
+ };
+};
+
/*
* Interrupt handler
*
@@ -55,6 +71,7 @@
* [v]: Returned by intr_register()
*
* @func: The actual handler [r]
+ * @data: Interrupt data [o/v]
* @name: Interrupt name [v]
* @priority: Interrupt priority [r]
* @irq: Interrupt request number [o]
@@ -74,6 +91,7 @@
*/
struct intr_hand {
int(*func)(void *);
+ struct intr_data data;
char *name;
int priority;
int irq;