WIP: irq handler
authorBernhard Urban <lewurm@gmx.net>
Thu, 3 Sep 2009 18:10:10 +0000 (20:10 +0200)
committerBernhard Urban <lewurm@gmx.net>
Thu, 3 Sep 2009 18:10:10 +0000 (20:10 +0200)
hw-pic still don't work, but the irq #14 will be cleared...
maybe all hw-ppc-flags should be cleared -- how?!

write32(HW_PPCIRQFLAG, ~0);
don't work :(

exception.c
irq.c
main.c

index 2d7451ecb8166db387559902ec6c43dc6c27b47e..39a1654e6cfb6e77b1efbf6168b920670567aefd 100644 (file)
@@ -18,12 +18,10 @@ extern char exception_2200_start, exception_2200_end;
 
 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
@@ -56,6 +54,9 @@ void exception_handler(int exception)
                for (;;)
                        ;
        }
+
+       irq_restore(cookie);
+       _CPU_ISR_Enable(); //wtf
 }
 
 void exception_init(void)
diff --git a/irq.c b/irq.c
index 1c5902b6de6f34af6700e3254f4452e7188b94b9..da2456b7084e9e6361fbf47a7ab9113e5252bc11 100644 (file)
--- a/irq.c
+++ b/irq.c
@@ -19,19 +19,20 @@ Copyright (C) 2009                  Andre Heider "dhewg" <dhewg@wiibrew.org>
 
 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()
 }
@@ -51,11 +52,11 @@ void irq_handler(void)
 
        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);
 
@@ -64,14 +65,6 @@ void irq_handler(void)
                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) {
@@ -128,12 +121,17 @@ void irq_handler(void)
                        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)
diff --git a/main.c b/main.c
index 51f43269c5302ff585aa05ca887a75c1b8668b91..2c1e41ff71a0b63938465d7207815259af95d491 100644 (file)
--- a/main.c
+++ b/main.c
@@ -84,23 +84,24 @@ int main(void)
        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;