MOS Source Code
Loading...
Searching...
No Matches
interrupt.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
4
7
8#include <mos_stdlib.h>
9
17
20
23
25{
26 // spinlock_acquire(&irq_handlers_lock);
27
29 {
30 if (handler->irq == irq)
31 if (handler->handler(irq, handler->data))
32 break; // interrupt was handled
33 }
34
35 // spinlock_release(&irq_handlers_lock);
36}
37
38void interrupt_handler_register(u32 irq, irq_serve_t handler, void *data)
39{
40 interrupt_handler_t *new_handler = kmalloc(irq_handler_slab);
41 new_handler->irq = irq;
42 new_handler->handler = handler;
43 new_handler->data = data;
44
46 list_node_append(&irq_handlers, &new_handler->list_node);
48}
#define LIST_HEAD_INIT(container)
Definition list.h:38
MOSAPI void list_node_append(list_node_t *head, list_node_t *item)
Definition list.c:68
#define list_foreach(t, v, h)
Iterate over a list.
Definition list.h:83
list_node_t list_head
A linked list head.
Definition list.h:23
void interrupt_entry(u32 irq)
Definition interrupt.c:24
static slab_t * irq_handler_slab
Definition interrupt.c:21
static spinlock_t irq_handlers_lock
Definition interrupt.c:18
static list_head irq_handlers
Definition interrupt.c:19
void interrupt_handler_register(u32 irq, irq_serve_t handler, void *data)
Register an interrupt handler.
Definition interrupt.c:38
bool(* irq_serve_t)(u32 irq, void *data)
Function pointer type for interrupt handlers.
Definition interrupt.h:11
#define NULL
Definition pb_syshdr.h:46
#define SLAB_AUTOINIT(name, var, type)
#define spinlock_acquire(lock)
Definition spinlock.h:61
#define SPINLOCK_INIT
Definition spinlock.h:28
#define spinlock_release(lock)
Definition spinlock.h:62
irq_serve_t handler
Definition interrupt.c:14
Definition slab.h:45
unsigned int u32
Definition types.h:21