summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-13 18:55:48 -0400
committerIan Moffett <ian@osmora.org>2025-07-13 18:55:48 -0400
commit25d4aca4bf49bdbee6a7a35ef5d63ae45138ddf5 (patch)
tree877a3acb25d02e72449701e52808f5d2345d4248
parent2f1902f6e554f6bc36b5a3e4cf8add8c3e5197cc (diff)
kernel/amd64: Track interrupt countmain
Keep track of how many times an interrupt fires, this can be used for interrupt statistics later on. Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/arch/amd64/amd64/intr.c1
-rw-r--r--sys/arch/amd64/amd64/vector.S10
-rw-r--r--sys/include/arch/amd64/intr.h3
3 files changed, 12 insertions, 2 deletions
diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c
index 685a16d..a545788 100644
--- a/sys/arch/amd64/amd64/intr.c
+++ b/sys/arch/amd64/amd64/intr.c
@@ -129,6 +129,7 @@ intr_register(const char *name, const struct intr_hand *ih)
ih_new->priority = ih->priority;
ih_new->irq = ih->irq;
ih_new->vector = i;
+ ih_new->nintr = 0;
g_intrs[i] = ih_new;
if (ih->irq >= 0) {
diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S
index c820a41..890b314 100644
--- a/sys/arch/amd64/amd64/vector.S
+++ b/sys/arch/amd64/amd64/vector.S
@@ -51,16 +51,22 @@ ioapic_common_func:
jz 1f // Nope, return
mov (%rdx), %rbx // intr_hand.func
- add $8, %rdx // Get interrupt data
+ add $16, %rdx // Get interrupt data
mov %rdx, %rdi // Pass the interrupt data
push %rcx // Save our counter
+ push %rdx
call *%rbx // Call the handler
+ pop %rdx
pop %rcx // Restore our counter
or %rax, %rax // Was it theirs? (RET >= 1)
- jnz done // Yes, we are done.
+ jnz handled // Yes, we are done.
1: inc %rcx // Next
cmp $256, %rcx // Did we reach the end?
jl .walk // Nope, keep going
+ jmp done // Out of entries
+handled:
+ sub $8, %rdx
+ addq $1, (%rdx)
done:
call lapic_eoi
retq
diff --git a/sys/include/arch/amd64/intr.h b/sys/include/arch/amd64/intr.h
index c848b6f..1877d20 100644
--- a/sys/include/arch/amd64/intr.h
+++ b/sys/include/arch/amd64/intr.h
@@ -69,9 +69,11 @@ struct intr_data {
* [r]: Required for intr_register()
* [o]: Not required for intr_register()
* [v]: Returned by intr_register()
+ * [i]: Internal
*
* @func: The actual handler [r]
* @data: Interrupt data [o/v]
+ * @nintr: Number of times it fired [o]
* @name: Interrupt name [v]
* @priority: Interrupt priority [r]
* @irq: Interrupt request number [o]
@@ -91,6 +93,7 @@ struct intr_data {
*/
struct intr_hand {
int(*func)(void *);
+ size_t nintr;
struct intr_data data;
char *name;
int priority;