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

x86 implementation of the arch-neutral IRQ API. More...

#include "arch/arch_irq.h"
#include "arch/x86/cpu/irq.h"
#include "arch/x86/cpu/isr.h"
#include "arch/x86/cpu/pic.h"
#include "arch/x86/cpu/apic.h"
#include "kernel/cpu/cpu.h"

Macros

#define IRQ_LINE_COUNT   16

Functions

int arch_irq_register (uint32_t irq, irq_handler_fn handler)
 register a handler for a hardware IRQ line.
void arch_irq_enable (uint32_t irq)
 unmask (enable) a hardware IRQ line so it can be delivered.
void arch_irq_disable (uint32_t irq)
 mask (disable) a hardware IRQ line.
void arch_irq_ack (uint32_t irq)
 acknowledge an IRQ (end-of-interrupt) at the interrupt controller.
bool arch_irq_set_cpu (uint32_t irq, uint32_t cpu)
 send the interrupts of an ISA IRQ line to a core.
bool irq_line_wanted (uint32_t irq)
 true if the IRQ layer has enabled the line (arch_irq_enable).
bool arch_frame_is_user (const trap_frame_t *frame)
 true if the interrupt came while user code ran (CPU time accounting).

Detailed Description

x86 implementation of the arch-neutral IRQ API.

wraps the existing PIC/IRQ machinery. neutral handlers are kept in a table indexed by IRQ line; a single adapter registered with the x86 IRQ layer recovers the line number from the saved register state and forwards to the neutral handler. this keeps irq.c's dispatch, spurious-IRQ handling, and EOI logic untouched while giving portable drivers a stable interface.

on x86, trap_frame_t is the ISR register dump (struct registers); the cast lives here because this is the only place that legitimately knows the layout.

Macro Definition Documentation

◆ IRQ_LINE_COUNT

#define IRQ_LINE_COUNT   16

Function Documentation

◆ arch_irq_register()

int arch_irq_register ( uint32_t irq,
irq_handler_fn handler )

register a handler for a hardware IRQ line.

Parameters
irqthe IRQ line to handle.
handlerthe function to call when the line fires.
Returns
0 on success, -1 if the IRQ number is out of range.

◆ arch_irq_enable()

void arch_irq_enable ( uint32_t irq)

unmask (enable) a hardware IRQ line so it can be delivered.

Parameters
irqthe IRQ line to enable.

◆ arch_irq_disable()

void arch_irq_disable ( uint32_t irq)

mask (disable) a hardware IRQ line.

Parameters
irqthe IRQ line to disable.

◆ arch_irq_ack()

void arch_irq_ack ( uint32_t irq)

acknowledge an IRQ (end-of-interrupt) at the interrupt controller.

Parameters
irqthe IRQ line to acknowledge.

◆ arch_irq_set_cpu()

bool arch_irq_set_cpu ( uint32_t irq,
uint32_t cpu )

send the interrupts of an ISA IRQ line to a core.

the vector does not change, so an interrupt that comes during the change goes to the old core or to the new one, and both handle it.

Parameters
irqthe IRQ line (0 to 15).
cputhe index of the core (cpu_t.index).
Returns
false if the line cannot move: the line has no I/O APIC entry, or the 8259 PICs are in use (they interrupt only the boot core).

◆ irq_line_wanted()

bool irq_line_wanted ( uint32_t irq)

true if the IRQ layer has enabled the line (arch_irq_enable).

apic_init uses it to enable the same lines on the I/O APIC.

◆ arch_frame_is_user()

bool arch_frame_is_user ( const trap_frame_t * frame)

true if the interrupt came while user code ran (CPU time accounting).

Parameters
framethe frame a handler was given.