init_IRQ() の続き

init_IRQ() を追いかけるの続き。これ系のエントリは早目にカテゴリでまとめた方が良さげ。
続ける前にプロセス起動時の irq_desc 配列の状態を以下に。

メンバ名データ型状態
handlerhw_irq_controller *&no_irq_type
handler_datavoid *NULL
actionstruct irqaction *NULL
statusunsigned intIRQ_DISABLED (2)
depthunsigned int0
irq_countunsigned int0
irqs_unhandledunsigned int0
lockspinlock_tSPIN_LOCK_UNLOCKED
で、

  • init_IRQ()#arch/i386/kernel/i8259.c
    • pre_intr_init_hook()#arch/i386/mach-default/setup.c
      • init_ISA_IRQS()#arch/i386/kernel/i8259.c
	for (i = 0; i < NR_IRQS; i++) {
		irq_desc[i].status = IRQ_DISABLED;
		irq_desc[i].action = NULL;
		irq_desc[i].depth = 1;

		if (i < 16) {
			/*
			 * 16 old-style INTA-cycle interrupts:
			 */
			irq_desc[i].handler = &i8259A_irq_type;
		} else {
			/*
			 * 'high' PCI IRQs filled in on demand
			 */
			irq_desc[i].handler = &no_irq_type;
		}
	}

上記処理を経て、以下の状態になると考えられる。

メンバ名データ型状態
handlerhw_irq_controller *&i8259A_irq_type (i < 16)
&no_irq_type (i >= 16)
handler_datavoid *NULL
actionstruct irqaction *NULL
statusunsigned intIRQ_DISABLED (2)
depthunsigned int1
irq_countunsigned int0
irqs_unhandledunsigned int0
lockspinlock_tSPIN_LOCK_UNLOCKED
depth が 1 になり、0 〜 15 番目の要素の handler が &i8259A_irq_type で初期化されると考えられる。別に全部 &no_irq_type でいいぢゃん、と思うがこのあたりに丁寧さというか初期化は大切だ、という思想が感じられる。
# どうせ、デバイス初期化時に何かで置きかえられるハズ、なだけに。

i8259A_irq_type は arch/i386/kernel/i8259.c にて定義。

static struct hw_interrupt_type i8259A_irq_type = {
	.typename = "XT-PIC",
	.startup = startup_8259A_irq,
	.shutdown = shutdown_8259A_irq,
	.enable = enable_8259A_irq,
	.disable = disable_8259A_irq,
	.ack = mask_and_ack_8259A,
	.end = end_8259A_irq,
};

上記関数も arch/i386/kernel/i8259.c にて定義されているが、内容については別途トレース。init_ISA_irqs()#arch/i386/kernel/i8259.c から呼ばれている init_bsp_APIC() については APIC な部分のトレースに着手するまで保留。次は上記関数と init_8259A() について調べてみたい。