-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterrupt.c
More file actions
58 lines (46 loc) · 1.31 KB
/
Copy pathinterrupt.c
File metadata and controls
58 lines (46 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* SPDX-License-Identifier: MIT */
#include <x86.h>
#include <apic.h>
#include <platform.h>
#define NUM_ISR 256
/**
* An interrupt service routine.
*/
typedef void (*isr_ptr_t)(void *arg);
/**
* Represents a single entry in the interrupt handler table.
*/
typedef struct int_table_entry {
isr_ptr_t callback; /* Pointer to the ISR. */
void *arg; /* Arguments to the ISR. */
uint32_t allocated : 1; /* Whether or not this ISR was
* allocated.
*/
uint32_t edge : 1; /* Edge(1)/Level(0) triggered. */
} int_table_entry_t;
/**
* Interrupt handler table.
*/
static int_table_entry_t int_table[NUM_ISR];
void platform_init_interrupts(void)
{
}
void platform_int_handler(x86_interrupt_frame_t *frame)
{
uint32_t vector = frame->vector;
int_table_entry_t *handler = &int_table[vector];
/* edge triggered interrupt */
if (handler->edge) {}
/* invoke the registered callback */
if (handler->callback) {
handler->callback(handler->arg);
}
/* level triggered interrupt */
if (!handler->edge) {}
}
void register_isr(uint32_t vector, isr_ptr_t callback, bool edge)
{
int_table[vector].callback = callback;
int_table[vector].allocated = true;
int_table[vector].edge = edge;
}