Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

20.5 Framework-Level Interrupt Initialization

The second phase of the interrupt initialization pipeline is orchestrated by the function init_IRQ(), which serves as the definitive execution engine for bootstrapping the core generic IRQ subsystem. Because Linux provides native, comprehensive support across an extensive array of distinct processor architectures, the concrete implementation details of init_IRQ() vary significantly from one platform to another; consequently, this routine is typically hosted within the target platform's architecture subdirectory tree under the arch/ pathway (such as arch/arm/kernel/irq.c). Despite these platform-specific variations, the foundational architectural blueprint of this routine consistently encompasses the following three core operations:

  1. Invoking the Low-Level Interrupt Controller Driver: This represents the most critical milestone within the sequence. The initialization routine triggers irqchip_init() to actively scan the compiled __irqchip_of_table section in memory, resolving entries that match the hardware configuration specified inside the active Device Tree. This execution block represents the explicit location where the custom initialization callbacks registered via the IRQCHIP_DECLARE macro are physically executed.

  2. Configuring the Hardware Exception Vector Tables: This step bootstraps and populates the localized entry vectors consumed by the CPU core to catch and process hardware exceptions. For example, under the ARM architecture, the routine programs the base address of the hardware interrupt vector table directly into the Vector Base Address Register (VBAR), guaranteeing that the moment an external hardware signal line toggles its electrical state, the processor core instantly resolves the precise destination assembly code segment to execute.

  3. Initializing Architecture-Specific Interrupt Stacks: This milestone allocates distinct, isolated private interrupt stacks for each individual CPU core. This structural separation ensures that heavy nested memory operations executed during high-frequency interrupt service processing are entirely contained within an isolated execution canvas, preventing stack overflow anomalies from corrupting the private memory runtime stacks of active user or kernel processes.

Taking the ARM Generic Interrupt Controller (GIC) architecture as a concrete implementation example, we can examine the specific execution workflow and systemic functionalities of this initialization pipeline.

The init_IRQ() function for the ARM platform is declared within the architecture source file git/arch/arm/kernel/irq.c, and its definition is implemented as follows:

void __init init_IRQ(void)
{
	int ret;
	if (IS_ENABLED(CONFIG_OF) && !machine_desc->init_irq)
		irqchip_init();
	else
		machine_desc->init_irq();
	if (IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_CACHE_L2X0) &&
	    (machine_desc->l2c_aux_mask || machine_desc->l2c_aux_val)) {
		if (!outer_cache.write_sec)
			outer_cache.write_sec = machine_desc->l2c_write_sec;
		ret = l2x0_of_init(machine_desc->l2c_aux_val, machine_desc->l2c_aux_mask);
		if (ret && ret != -ENODEV)
			pr_err("L2C: failed to init: %d\n", ret);
	}
	uniphier_cache_init();
}

This function represents the init_IRQ() implementation unique to the 32-bit ARM architecture. It reflects the kernel's structural transition period from the legacy board-level machine descriptors (Machine Desc) toward Device Tree configurations. The operations within this routine are segmented into three operational blocks: initializing the interrupt controller, bootstrapping the L2 Cache, and setting up platform-specific cache layouts to finalize architecture-level interrupt subsystem initialization.

The function first initializes the interrupt controller (irqchip). Because some legacy systems might not feature device tree support, the ARM Linux kernel concurrently accommodates both machine descriptors and device trees to describe hardware topologies. The codebase dispatches different initialization sequences depending on which mechanism describes the interrupt controllers.

The initial section of the routine determines the definitive strategy used to drive the interrupt controller. If Device Tree support is active via CONFIG_OF and the platform configuration omits a machine-specific interrupt setup routine, the kernel invokes the generic irqchip_init() function to bootstrap the hardware. It actively scans all drivers registered via the IRQCHIP_DECLARE macro and matches them against the descriptors embedded inside the device tree. The pairing of a Device Tree with the irqchip framework represents the modern standard implementation layout across advanced System-on-Chips (SoCs, such as the i.MX6 or RK3288) and constitutes the recommended approach on modern ARM platforms, completely removing board-level hard-coded configurations from the kernel image.

Conversely, if the machine descriptor explicitly registers a board-specific initialization hook via machine_desc->init_irq(), that platform-specific routine is executed instead. This fallback path is maintained to ensure backward compatibility with legacy target equipment. Prior to the adoption of Device Trees, each independent development board declared a unique machine_desc structure inside the architecture path arch/arm/mach-xxx via the master configuration macro MACHINE_START, hard-coding the init_irq function pointer to target a custom setup routine.

irqchip_init() serves as the definitive execution entry point when bootstrapping interrupt controllers via the Device Tree paradigm, and its primary systemic responsibility is to scan and initialize every hardware interrupt controller residing in the system. It parses the specific interrupt-controller nodes populated inside the device tree, executes pattern-matching loops using the compatibility string parameters provided by the compatible fields to resolve the correct controller driver, fires the corresponding irqchip initialization callbacks, establishes the necessary irq_domain mapping layers, hooks the high-level flow handlers onto irq_desc->handle_irq, and finally registers the low-level hardware interrupt handling vectors. If the kernel configuration completely omits CONFIG_IRQCHIP, this function resolves to an empty inline stub to preserve compilation compatibility.

The routine irqchip_init() is hosted within the driver tree source file git/drivers/irqchip/irqchip.c, and its definition is implemented as follows:

void __init irqchip_init(void)
{
	of_irq_init(__irqchip_of_table);
	acpi_probe_device_table(irqchip);
}

This code details the standard contemporary manifestation of irqchip_init() deployed across modern Linux kernels (routinely seen on ARM64 or ACPI-enabled ARM32 environments). Its core technical task is to discover and initialize the hardware interrupt controller infrastructure using firmware descriptors supplied via either the Device Tree (DT) or Advanced Configuration and Power Interface (ACPI) tables.

  • of_irq_init(__irqchip_of_table) acts as the primary initialization entry funnel for Device Tree (DT) based systems. As established across preceding structural analyses, the static global matrix __irqchip_of_table stores the comprehensive registry of all drivers declared via the IRQCHIP_DECLARE macro, associating their custom initialization callbacks with their matching compatible string signatures. Each discrete entry within this table marries an explicit compatibility string identifier to its matching initialization handler pointer. The utility of_irq_init() executes a full traversal across the active device tree layout to resolve nodes decorated with the interrupt-controller property (helper functions designed to parse the device tree typically prepend their functional labels with the prefix of_). Furthermore, of_irq_init resolves and maps out the absolute hierarchical dependencies of the system's interrupt layers. It guarantees that the root-tier interrupt controller (such as the primary GIC block) undergoes initialization first, because the hardware interrupt lines of peripheral components (such as local GPIO multiplexers or DMA channels) cascade and aggregate directly into its upstream inputs. Subordinate child controllers are permitted to execute their respective initialization callbacks only after their parent tracking nodes have successfully been bootstrapped.

  • acpi_probe_device_table(irqchip) serves as the primary initialization entry funnel for ACPI (Advanced Configuration and Power Interface) driven systems, a topology routinely deployed on server-grade ARM or enterprise x86 architectures. This routine scans the compiled ACPI firmware tables (such as the Multiple APIC Description Table, or MADT) to resolve records matching the target irqchip entry properties. Under environments that omit device tree structures entirely, it parses the configuration matrices supplied by the platform firmware to safely map and route the system's interrupt topology.

Modern kernel distributions may alternative incorporate the IRQCHIP_ACPI_DECLARE macro layout to support hardware probing sequences driven by ACPI tables. On systems that omit device tree capabilities (such as enterprise ARM64 servers or specialized x86 hardware environments), IRQCHIP_ACPI_DECLARE is utilized to map the initialization callbacks of the underlying interrupt controller to specific table identifiers exposed within the ACPI firmware layout. It leverages GCC compilation attributes to place these registered configuration metadata lines into a specialized section named __irqchip_acpi_table. The routine acpi_probe_device_table() executes a systematic traversal across this section, matching the stored entry tags against the IDs exposed inside the active ACPI firmware tables.

The second operational block of the function manages the Level 2 cache controllers (such as the ARM L2C-310 / PL310 macros) that are widely integrated into legacy ARM architectures, triggering the function l2x0_of_init() to bootstrap the PL310 hardware blocks. While Level 1 (L1) lookaside caches are natively integrated tightly inside the internal core boundary of the CPU, Level 2 (L2) caches are structurally handled as an external block (Outer Cache) that requires specialized register manipulation sequences and explicit synchronization barrier primitives to coordinate coherency. The routine l2x0_of_init() interfaces with the parent machine_desc structure to parse the baseline L2 configuration parameters.

The final operational step of this initialization pipeline handles the configuration of platform-specific custom cache architectures (such as the UniPhier cache blocks). The routine uniphier_cache_init() acts as a specialized platform patch tailored exclusively to support the Socionext UniPhier SoC family. This functions as a vendor-specific architecture hook designed to manage the unique internal cache controller characteristics specific to that proprietary platform.

Copyright © 2026 Guangzhou eSmart Information Technology Co., Ltd. All Rights Reserved.
All content in this book is copyrighted by the author. For personal learning and exchange only. Commercial use without authorization is strictly prohibited. Email:

✉ 3348194517@qq.com | hai616878@gmail.com