1 |
/* |
/* |
2 |
* Copyright (C) 2005-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $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 $ |
29 |
* |
* |
30 |
* PowerPC/POWER CPU emulation. |
* PowerPC/POWER CPU emulation. |
31 |
*/ |
*/ |
37 |
|
|
38 |
#include "cpu.h" |
#include "cpu.h" |
39 |
#include "devices.h" |
#include "devices.h" |
40 |
|
#include "interrupt.h" |
41 |
#include "machine.h" |
#include "machine.h" |
42 |
#include "memory.h" |
#include "memory.h" |
43 |
#include "misc.h" |
#include "misc.h" |
57 |
void ppc_pc_to_pointers(struct cpu *); |
void ppc_pc_to_pointers(struct cpu *); |
58 |
void ppc32_pc_to_pointers(struct cpu *); |
void ppc32_pc_to_pointers(struct cpu *); |
59 |
|
|
60 |
|
void ppc_irq_interrupt_assert(struct interrupt *interrupt); |
61 |
|
void ppc_irq_interrupt_deassert(struct interrupt *interrupt); |
62 |
|
|
63 |
|
|
64 |
/* |
/* |
65 |
* ppc_cpu_new(): |
* ppc_cpu_new(): |
219 |
CPU_SETTINGS_ADD_REGISTER32(tmpstr, cpu->cd.ppc.sr[i]); |
CPU_SETTINGS_ADD_REGISTER32(tmpstr, cpu->cd.ppc.sr[i]); |
220 |
} |
} |
221 |
|
|
222 |
|
/* Register the CPU as an interrupt handler: */ |
223 |
|
{ |
224 |
|
struct interrupt template; |
225 |
|
char name[150]; |
226 |
|
snprintf(name, sizeof(name), "%s", cpu->path); |
227 |
|
memset(&template, 0, sizeof(template)); |
228 |
|
template.line = 0; |
229 |
|
template.name = name; |
230 |
|
template.extra = cpu; |
231 |
|
template.interrupt_assert = ppc_irq_interrupt_assert; |
232 |
|
template.interrupt_deassert = ppc_irq_interrupt_deassert; |
233 |
|
interrupt_handler_register(&template); |
234 |
|
} |
235 |
|
|
236 |
return 1; |
return 1; |
237 |
} |
} |
238 |
|
|
675 |
|
|
676 |
|
|
677 |
/* |
/* |
678 |
* ppc_cpu_interrupt(): |
* ppc_irq_interrupt_assert(): |
|
* |
|
|
* 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! |
|
679 |
*/ |
*/ |
680 |
int ppc_cpu_interrupt(struct cpu *cpu, uint64_t irq_nr) |
void ppc_irq_interrupt_assert(struct interrupt *interrupt) |
681 |
{ |
{ |
682 |
/* fatal("ppc_cpu_interrupt(): 0x%x\n", (int)irq_nr); */ |
struct cpu *cpu = (struct cpu *) interrupt->extra; |
683 |
if (irq_nr <= 64) { |
cpu->cd.ppc.irq_asserted = 1; |
|
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; |
|
684 |
} |
} |
685 |
|
|
686 |
|
|
687 |
/* |
/* |
688 |
* ppc_cpu_interrupt_ack(): |
* ppc_irq_interrupt_deassert(): |
689 |
*/ |
*/ |
690 |
int ppc_cpu_interrupt_ack(struct cpu *cpu, uint64_t irq_nr) |
void ppc_irq_interrupt_deassert(struct interrupt *interrupt) |
691 |
{ |
{ |
692 |
if (irq_nr <= 64) { |
struct cpu *cpu = (struct cpu *) interrupt->extra; |
693 |
if (cpu->machine->md_interrupt != NULL) |
cpu->cd.ppc.irq_asserted = 0; |
|
cpu->machine->md_interrupt(cpu->machine, |
|
|
cpu, irq_nr, 0); |
|
|
} else { |
|
|
/* De-assert PPC IRQ: */ |
|
|
cpu->cd.ppc.irq_asserted = 0; |
|
|
} |
|
|
return 1; |
|
694 |
} |
} |
695 |
|
|
696 |
|
|