On Feb 17, 2025, at 7:58 PM, Jd Lyons lyons_dj@yahoo.com wrote:
I think we need to assign the interrupt-parent to the /cpus node like we do for PCI/macio/ata and other devices, but I can’t figure out how to do it. The /cpus node is not finalized when the code runs in the pci.c from Openbios.
Do we need a cpus.c and run it there?
CPUs should have and interrupt-parent, no?
Outside of that I’m at a loss why everything works in Openbios, but when I boot a kernel I lose USB, RTC, ATA, and just about everything assigned an IRQ or Interrupt?
On Feb 17, 2025, at 5:01 PM, Jd Lyons lyons_dj@yahoo.com wrote:
Mark, anyone, is there code in Openbios that deals with IRQ’s or Interrupts?
I’m tracking down an issue with IRQ’s casing the IDE,, RTC, USB…… not to work with SMP patches and I’m not sure if it’s an issue with QEMU or Openbios patches I have applied.
I don’t know why, I can’t seem to get Openbios to set and interrupt-parent in the init.c for any /cpus, this code should work, no?
void add_cpu_nodes(void) { int num_cpus = fw_cfg_read_i32(FW_CFG_NB_CPUS); printk("Detected %d CPUs\n", num_cpus);
/* Ensure /cpus node exists */ phandle cpus_node = dt_find_by_path("/cpus"); if (!cpus_node) { printk("ERROR: /cpus node not found! Delaying CPU setup.\n"); return; }
/* Wait until the interrupt controller exists */ phandle intc_node = NULL; int retries = 5; while (retries-- > 0) { intc_node = dt_find_by_path("/pci/mac-io/@40000"); if (intc_node) { break; } printk("Waiting for /pci/mac-io/@40000...\n"); msleep(100); // Wait 100ms before retrying }
if (!intc_node) { printk("ERROR: Interrupt controller (/pci/mac-io/@40000) not found! SMP will not work.\n"); return; }
for (int i = 0; i < num_cpus; i++) { phandle cpu_node = dt_new_node(cpus_node); if (!cpu_node) { printk("ERROR: Failed to create CPU node for CPU %d!\n", i); continue; }
dt_set_property_string(cpu_node, "device_type", "cpu"); dt_set_property_string(cpu_node, "compatible", "PowerPC,G4");
/* Assign a unique CPU interrupt */ int cpu_irq[2] = { 16 + i, 0 }; dt_set_property_cells(cpu_node, "interrupts", cpu_irq, 2); printk("CPU %d assigned IRQ %d\n", i, cpu_irq[0]);
/* Ensure interrupt-parent is set */ dt_set_property_phandle(cpu_node, "interrupt-parent", intc_node); printk("CPU %d linked to interrupt-parent /pci/mac-io/@40000\n", i);
/* Register CPU ID */ PUSH(i); fword("encode-int"); push_str("reg"); fword("property");
fword("finish-device"); printk("Initialized CPU %d\n", i); } }