--- trunk/src/cpus/cpu_ppc.c 2007/10/08 16:21:06 33 +++ trunk/src/cpus/cpu_ppc.c 2007/10/08 16:21:17 34 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2006 Anders Gavare. All rights reserved. + * Copyright (C) 2005-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: cpu_ppc.c,v 1.64 2006/09/21 11:53:26 debug Exp $ + * $Id: cpu_ppc.c,v 1.67 2006/12/30 13:30:54 debug Exp $ * * PowerPC/POWER CPU emulation. */ @@ -37,6 +37,7 @@ #include "cpu.h" #include "devices.h" +#include "interrupt.h" #include "machine.h" #include "memory.h" #include "misc.h" @@ -56,6 +57,9 @@ void ppc_pc_to_pointers(struct cpu *); void ppc32_pc_to_pointers(struct cpu *); +void ppc_irq_interrupt_assert(struct interrupt *interrupt); +void ppc_irq_interrupt_deassert(struct interrupt *interrupt); + /* * ppc_cpu_new(): @@ -215,6 +219,20 @@ CPU_SETTINGS_ADD_REGISTER32(tmpstr, cpu->cd.ppc.sr[i]); } + /* Register the CPU as an interrupt handler: */ + { + struct interrupt template; + char name[150]; + snprintf(name, sizeof(name), "%s", cpu->path); + memset(&template, 0, sizeof(template)); + template.line = 0; + template.name = name; + template.extra = cpu; + template.interrupt_assert = ppc_irq_interrupt_assert; + template.interrupt_deassert = ppc_irq_interrupt_deassert; + interrupt_handler_register(&template); + } + return 1; } @@ -657,44 +675,22 @@ /* - * ppc_cpu_interrupt(): - * - * 0..31 are used as BeBox interrupt numbers, 32..47 = ISA, - * 64 is used as a "re-assert" signal to cpu->machine->md_interrupt(). - * - * TODO: don't hardcode to BeBox! + * ppc_irq_interrupt_assert(): */ -int ppc_cpu_interrupt(struct cpu *cpu, uint64_t irq_nr) +void ppc_irq_interrupt_assert(struct interrupt *interrupt) { - /* fatal("ppc_cpu_interrupt(): 0x%x\n", (int)irq_nr); */ - if (irq_nr <= 64) { - if (cpu->machine->md_interrupt != NULL) - cpu->machine->md_interrupt( - cpu->machine, cpu, irq_nr, 1); - else - fatal("ppc_cpu_interrupt(): md_interrupt == NULL\n"); - } else { - /* Assert PPC IRQ: */ - cpu->cd.ppc.irq_asserted = 1; - } - return 1; + struct cpu *cpu = (struct cpu *) interrupt->extra; + cpu->cd.ppc.irq_asserted = 1; } /* - * ppc_cpu_interrupt_ack(): + * ppc_irq_interrupt_deassert(): */ -int ppc_cpu_interrupt_ack(struct cpu *cpu, uint64_t irq_nr) +void ppc_irq_interrupt_deassert(struct interrupt *interrupt) { - if (irq_nr <= 64) { - if (cpu->machine->md_interrupt != NULL) - cpu->machine->md_interrupt(cpu->machine, - cpu, irq_nr, 0); - } else { - /* De-assert PPC IRQ: */ - cpu->cd.ppc.irq_asserted = 0; - } - return 1; + struct cpu *cpu = (struct cpu *) interrupt->extra; + cpu->cd.ppc.irq_asserted = 0; }