The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
irq.h File Reference

kernel IRQ handler manager: shared lines, per-handler control. More...

#include "common/stdint.h"
#include "arch/arch_irq.h"

Go to the source code of this file.

Macros

#define IRQ_MAX_SHARED   4
#define IRQ_FLAG_NONE   0u

Typedefs

typedef struct irq_handler_entry irq_handle_t

Functions

void irq_manager_init (void)
 initialize the IRQ manager.
irq_handle_t * irq_request (uint32_t irq, irq_handler_fn handler, uint32_t flags, const char *name)
 register a handler on an IRQ line, sharing it with any existing handlers.
void irq_free (irq_handle_t *handle)
 remove a previously requested handler.
void irq_handler_set_enabled (irq_handle_t *handle, bool enabled)
 enable or disable a single handler without removing it.
void irq_dump (void)
 print the registered handlers per line (debugging aid).
bool irq_set_cpu (uint32_t irq, uint32_t cpu)
 send the interrupts of an IRQ line to a core (arch_irq_set_cpu).
uint32_t irq_line_cpu (uint32_t irq)
 the core that handles an IRQ line.
void irq_spread (void)
 spread the device interrupts over the cores that run the scheduler: each IRQ line that has a handler, and each PCI device that uses MSI or MSI-X, goes to the next core in turn, as Linux gives each interrupt one core.

Detailed Description

kernel IRQ handler manager: shared lines, per-handler control.

sits on top of the arch-neutral IRQ primitives (arch/arch_irq.h). where the arch layer allows one handler per line, this manager keeps a list of handlers per line so several devices can share an IRQ, lets each handler be enabled/disabled independently, and tracks a name per handler for debugging.

drivers call irq_request()/irq_free() instead of arch_irq_register() directly. the manager owns line masking: a line is unmasked while it has at least one enabled handler and masked otherwise.

Macro Definition Documentation

◆ IRQ_MAX_SHARED

#define IRQ_MAX_SHARED   4

◆ IRQ_FLAG_NONE

#define IRQ_FLAG_NONE   0u

Typedef Documentation

◆ irq_handle_t

typedef struct irq_handler_entry irq_handle_t

Function Documentation

◆ irq_manager_init()

void irq_manager_init ( void )

initialize the IRQ manager.

must run before any irq_request() call.

◆ irq_request()

irq_handle_t * irq_request ( uint32_t irq,
irq_handler_fn handler,
uint32_t flags,
const char * name )

register a handler on an IRQ line, sharing it with any existing handlers.

the handler starts enabled and the line is unmasked automatically.

Parameters
irqthe IRQ line.
handlerthe function to call when the line fires.
flagsreserved for future use; pass IRQ_FLAG_NONE.
nameshort human-readable owner name (for debugging), may be NULL.
Returns
a handle to the registration, or NULL if the line is full/invalid.

◆ irq_free()

void irq_free ( irq_handle_t * handle)

remove a previously requested handler.

if it was the last enabled handler on its line, the line is masked.

Parameters
handlethe handle returned by irq_request() (NULL is ignored).

◆ irq_handler_set_enabled()

void irq_handler_set_enabled ( irq_handle_t * handle,
bool enabled )

enable or disable a single handler without removing it.

masks the line when no enabled handlers remain, unmasks it otherwise.

Parameters
handlethe handler to toggle.
enabledtrue to enable, false to disable.

◆ irq_dump()

void irq_dump ( void )

print the registered handlers per line (debugging aid).

◆ irq_set_cpu()

bool irq_set_cpu ( uint32_t irq,
uint32_t cpu )

send the interrupts of an IRQ line to a core (arch_irq_set_cpu).

Parameters
irqthe IRQ line (0 to 15).
cputhe index of the core (cpu_t.index).
Returns
false if the line cannot move; it stays on its core.

◆ irq_line_cpu()

uint32_t irq_line_cpu ( uint32_t irq)

the core that handles an IRQ line.

Parameters
irqthe IRQ line (0 to 15).
Returns
the index of the core; 0 (the boot core) until the line moves.

◆ irq_spread()

void irq_spread ( void )

spread the device interrupts over the cores that run the scheduler: each IRQ line that has a handler, and each PCI device that uses MSI or MSI-X, goes to the next core in turn, as Linux gives each interrupt one core.

IRQ 0 (the PIT) stays on the boot core. call it once, after smp_init().