AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
irq.c File Reference

The interrupts' handlers on the virt machine, installed by their drivers (see dev/irq.h). More...

#include <core/system.h>
#include <core/string.h>
#include <mm/mm.h>
#include <dev/irq.h>
#include <platform/virt.h>
#include <aquila/errno.h>

Go to the source code of this file.

Data Structures

struct  handler
 An installed handler, on its interrupt's list. More...

Functions

int irq_install (unsigned irq, irq_handler_t fn, void *arg)
 Installs a handler for an IRQ.
void irq_uninstall (unsigned irq, irq_handler_t fn, void *arg)
 Removes a handler that irq_install() installed.
void irq_handle (void)
 Runs the handlers of the interrupt that came, then tells the GIC it's done, before any thread switch, so that the next interrupts keep coming.
int arch_interrupts_info (char *buf, size_t size)

Variables

static struct handler * handlers [IRQ_NR]
static uint64_t counts [IRQ_NR]

Detailed Description

The interrupts' handlers on the virt machine, installed by their drivers (see dev/irq.h).

An interrupt may have several handlers (a shared line), and each is called. The GIC says which interrupt came; the first handler installed enables it, and the last one uninstalled disables it.

Definition in file irq.c.

Function Documentation

◆ arch_interrupts_info()

int arch_interrupts_info ( char * buf,
size_t size )

Definition at line 105 of file irq.c.

References arch_interrupts_info(), counts, IRQ_NR, and snprintf().

Referenced by arch_interrupts_info(), and procfs_interrupts().

◆ irq_handle()

void irq_handle ( void )

Runs the handlers of the interrupt that came, then tells the GIC it's done, before any thread switch, so that the next interrupts keep coming.

Definition at line 84 of file irq.c.

References counts, gic_ack(), gic_eoi(), handlers, irq_handle(), IRQ_NR, and handler::next.

Referenced by __x86_irq_handler(), aarch64_irq(), irq_dispatch(), irq_handle(), and irq_handle().

◆ irq_install()

int irq_install ( unsigned irq,
irq_handler_t fn,
void * arg )

Installs a handler for an IRQ.

The first handler installed unmasks the IRQ at its interrupt controller.

Parameters
irqthe IRQ, the platform's number for it
fnthe handler
argthe argument the handler is called with
Returns
0, -EINVAL if there's no such IRQ, or -ENOMEM if there was no memory for the handler

Definition at line 32 of file irq.c.

References handler::arg, handler::fn, gic_enable(), handlers, irq_install(), IRQ_NR, kmalloc(), M_ZERO, and handler::next.

Referenced by arch_msi_alloc(), ata_probe(), e1000_probe(), i8042_init(), irq_install(), pl011_init(), platform_timer_setup(), timer_setup(), uart_8250_attach(), and x86_lapic_timer_setup().

◆ irq_uninstall()

void irq_uninstall ( unsigned irq,
irq_handler_t fn,
void * arg )

Removes a handler that irq_install() installed.

The last handler removed masks the IRQ at its interrupt controller.

Parameters
irqthe IRQ
fnthe handler, as it was installed
argits argument, as it was installed

Definition at line 62 of file irq.c.

References handler::arg, handler::fn, gic_disable(), handlers, IRQ_NR, irq_uninstall(), kfree(), and handler::next.

Referenced by irq_uninstall().

Variable Documentation

◆ counts

uint64_t counts[IRQ_NR]
static

Definition at line 27 of file irq.c.

Referenced by arch_interrupts_info(), and irq_handle().

◆ handlers

struct handler* handlers[IRQ_NR]
static