void exception_handler(int exception)
{
+ u32 cookie = irq_kill();
// check if the exception was actually an external interrupt
if (exception == 0x500) {
- u32 cookie = irq_kill();
irq_handler();
- irq_restore(cookie);
- //_CPU_ISR_Enable(); //wtf
}
// check if exception happened due to the decrementer
for (;;)
;
}
+
+ irq_restore(cookie);
+ _CPU_ISR_Enable(); //wtf
}
void exception_init(void)
void irq_initialize(void)
{
- // enable hollywood-pic for ppc
+ // clear flipper-pic (processor interface)
+ write32(BW_PI_IRQMASK, 0);
+ write32(BW_PI_IRQFLAG, 0xffffffff);
+
+ // clear hollywood-pic
write32(HW_PPCIRQMASK, 0);
write32(HW_PPCIRQFLAG, 0xffffffff);
- // enable RESET and PIC (#14) interrupts on processor interface
- write32(BW_PI_IRQMASK, 0);
- write32(BW_PI_IRQFLAG, 0xffffffff);
+ printf("PPCIRQMASK: 0x%08X\n", read32(HW_PPCIRQMASK));
+
//??? -- needed?!
- /*
write32(HW_PPCIRQMASK+0x04, 0);
write32(HW_PPCIRQMASK+0x20, 0);
- */
_CPU_ISR_Enable()
}
flags = flags & enabled;
- if (flags & (1<<1)) { //RESET
+ if (flags & (1<<BW_PI_IRQ_RESET)) {
write32(BW_PI_IRQFLAG, 1<<BW_PI_IRQ_RESET);
- printf("IRQ RESET\n");
+ printf("IRQ-BW RESET\n");
}
- if (flags & (1<<14)) { //HW-PIC IRQ
+ if (flags & (1<<BW_PI_IRQ_HW)) { //HW-PIC IRQ
u32 hw_enabled = read32(HW_PPCIRQMASK);
u32 hw_flags = read32(HW_PPCIRQFLAG);
hw_flags = hw_flags & hw_enabled;
if(hw_flags & IRQF_TIMER) {
- // done by mini already?
- /*
- if (_alarm_frequency) {
- // currently we use the alarm timer only for lame usbgecko polling
- gecko_timer();
- write32(HW_ALARM, read32(HW_TIMER) + _alarm_frequency);
- }
- */
write32(HW_PPCIRQFLAG, IRQF_TIMER);
}
if(hw_flags & IRQF_NAND) {
printf("IRQ: unknown 0x%08x\n", hw_flags);
write32(HW_PPCIRQFLAG, hw_flags);
}
+
+ printf("hw_flags1: 0x%08x\n", read32(HW_PPCIRQFLAG));
+
+ // quirk for flipper pic? TODO :/
+ write32(HW_PPCIRQMASK, 0);
+
write32(BW_PI_IRQFLAG, 1<<BW_PI_IRQ_HW);
- u32 flags2 = read32(BW_PI_IRQFLAG);
- printf("flags2: 0x%08X\n", flags2);
+ printf("flags2: 0x%08X\n", read32(BW_PI_IRQFLAG));
+
+ write32(HW_PPCIRQMASK, hw_enabled);
}
-
-// flags &=
}
void irq_bw_enable(u32 irq)
exception_init();
dsp_reset();
- irq_initialize();
- irq_bw_enable(BW_PI_IRQ_RESET);
- irq_bw_enable(BW_PI_IRQ_HW); //hollywood pic
- irq_hw_enable(IRQ_OHCI0);
-
ipc_initialize();
ipc_slowping();
gecko_init();
input_init();
init_fb(vmode);
- ohci_init();
VIDEO_Init(vmode);
VIDEO_SetFrameBuffer(get_xfb());
VISetupEncoder();
+ irq_initialize();
+ irq_bw_enable(BW_PI_IRQ_RESET);
+ irq_bw_enable(BW_PI_IRQ_HW); //hollywood pic
+ irq_hw_enable(IRQ_OHCI0);
+
+ ohci_init();
+
u32 version = ipc_getvers();
u16 mini_version_major = version >> 16 & 0xFFFF;
u16 mini_version_minor = version & 0xFFFF;