Kernelite 0.1.0
Kernelite is a minimalist, educational operating system kernel built from scratch. The project aims to recreate core components of the Linux architecture to explore the fundamentals of operating system design and hardware-software interaction.
Loading...
Searching...
No Matches
Functions
icu.c File Reference

Implementation of the Interrupt Controller Unit (ICU) helpers. More...

#include "icu/icu.h"
#include "fdt/fdt.h"
#include "linker/symbols.h"
#include "page_table/page_table.h"
#include "utils/kprintf.h"
#include "utils/string.h"
#include "../drivers/gicv3.h"
#include <stdint.h>
Include dependency graph for icu.c:

Functions

void icu_init (const void *fdt)
 Initialize the interrupt controller unit.
 
bool icu_register_irq (uint32_t irq_num, handler_data_t handler_data)
 Register a handler for a hardware interrupt source and enable it.
 
void icu_unregister_irq (uint32_t irq_num)
 Unregister a handler for a hardware interrupt source and disable it.
 
void icu_handle_irq (void)
 Top-level IRQ dispatch entry point.
 

Detailed Description

Implementation of the Interrupt Controller Unit (ICU) helpers.

Reads the interrupt controller's compatible string from the FDT and dispatches initialization and IRQ (un)registration to the matching platform driver. Currently only "arm,gic-v3" is supported.

Author
Abhin Parekadan Jose
Date
2026-06-07

Function Documentation

◆ icu_handle_irq()

void icu_handle_irq ( void  )

Top-level IRQ dispatch entry point.

Called directly from the EL1 IRQ exception vector. Delegates to the GICv3 handler which acknowledges the interrupt via ICC_IAR1_EL1, dispatches based on INTID, and signals EOI via ICC_EOIR1_EL1.

This indirection layer allows the ICU (Interrupt Controller Unit) interface to remain decoupled from the underlying GIC implementation, making it straightforward to swap in a different interrupt controller without modifying the vector table or exception entry code.

◆ icu_init()

void icu_init ( const void *  fdt)

Initialize the interrupt controller unit.

Performs any platform-specific ICU startup required before the kernel can enable and service hardware interrupts.

Parameters
fdtPointer to the Flattened Device Tree (FDT) blob, which may be used to discover interrupt controller properties and configuration.

◆ icu_register_irq()

bool icu_register_irq ( uint32_t  irq_num,
handler_data_t  handler_data 
)

Register a handler for a hardware interrupt source and enable it.

Parameters
irq_numPhysical interrupt irq_num to register.
handler_dataHandler function and private data to register.
Returns
true if the handler was registered and the interrupt enabled successfully, false if the irq_num is out of range or already registered.

◆ icu_unregister_irq()

void icu_unregister_irq ( uint32_t  irq_num)

Unregister a handler for a hardware interrupt source and disable it.

Disables the interrupt in the GIC and clears the corresponding entry in the dispatch table. After this call the irq_num will no longer fire and any previously registered handler will not be invoked.

Parameters
irq_numPhysical interrupt irq_num to unregister.