port-work; won't compile or even work
[ppcskel.git] / irq.c
diff --git a/irq.c b/irq.c
index 1c5902b6de6f34af6700e3254f4452e7188b94b9..1217ee2adecf7ec606e1bdd16ea595e2fd09c918 100644 (file)
--- a/irq.c
+++ b/irq.c
@@ -2,9 +2,8 @@
        ppcskel - a Free Software replacement for the Nintendo/BroadOn IOS.
        IRQ support
 
-Copyright (C) 2008, 2009       Hector Martin "marcan" <marcan@marcansoft.com>
-Copyright (C) 2008, 2009       Sven Peter <svenpeter@gmail.com>
-Copyright (C) 2009                     Andre Heider "dhewg" <dhewg@wiibrew.org>
+Copyright (C) 2009             Bernhard Urban <lewurm@gmx.net>
+Copyright (C) 2009             Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
 
 # This code is licensed to you under the terms of the GNU GPL, version 2;
 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
@@ -14,24 +13,34 @@ Copyright (C) 2009                  Andre Heider "dhewg" <dhewg@wiibrew.org>
 #include "hollywood.h"
 #include "ipc.h"
 #include "bootmii_ppc.h"
-//debug only
-#include "printf.h"
+#include "usb/host/host.h"
+#include "mini_ipc.h"
+
+void show_frame_no(void);
 
 void irq_initialize(void)
 {
-       // enable hollywood-pic for ppc
-       write32(HW_PPCIRQMASK, 0);
-       write32(HW_PPCIRQFLAG, 0xffffffff);
-
-       // enable RESET and PIC (#14) interrupts on processor interface
+       // clear flipper-pic (processor interface)
        write32(BW_PI_IRQMASK, 0);
        write32(BW_PI_IRQFLAG, 0xffffffff);
 
-       //??? -- needed?!
-       /*
-       write32(HW_PPCIRQMASK+0x04, 0);
-       write32(HW_PPCIRQMASK+0x20, 0);
-       */
+       // clear hollywood-pic
+       write32(HW_PPCIRQMASK, 0);
+       write32(HW_PPCIRQFLAG, 0xffffffff);
+
+       /* ??? -- needed?!
+        * in mini they do
+        *
+        * write32(HW_ARMIRQMASK+0x04, 0);
+        * write32(HW_ARMIRQMASK+0x20, 0);
+        *
+        *
+        * may it's here following; on the other 
+        * hand it's already done by mini...
+        *
+        * write32(HW_PPCIRQMASK+0x04+0x08, 0);
+        * write32(HW_PPCIRQMASK+0x20+0x08, 0);
+        */
 
        _CPU_ISR_Enable()
 }
@@ -47,31 +56,23 @@ void irq_handler(void)
 {
        u32 enabled = read32(BW_PI_IRQMASK);
        u32 flags = read32(BW_PI_IRQFLAG);
-       printf("flags1: 0x%08X\n", flags);
 
        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");
+               boot2_run(1,2); //sysmenu
        }
-       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);
 
-               printf("In IRQ handler: 0x%08x 0x%08x 0x%08x\n", hw_enabled, hw_flags, hw_flags & hw_enabled);
+               //printf("In IRQ handler: 0x%08x 0x%08x 0x%08x\n", hw_enabled, hw_flags, hw_flags & hw_enabled);
 
                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) {
@@ -113,14 +114,12 @@ void irq_handler(void)
                        //sdhc_irq();
                }
                if (hw_flags & IRQF_OHCI0) {
-                       printf("IRQ: OHCI0\n");
+                       hcdi_irq(OHCI0_REG_BASE);
                        write32(HW_PPCIRQFLAG, IRQF_OHCI0);
-                       //TODO: ohci0_irq();
                }
                if (hw_flags & IRQF_OHCI1) {
-                       printf("IRQ: OHCI1\n");
+                       hcdi_irq(OHCI1_REG_BASE);
                        write32(HW_PPCIRQFLAG, IRQF_OHCI1);
-                       //TODO: ohci1_irq();
                }
 
                hw_flags &= ~IRQF_ALL;
@@ -128,12 +127,10 @@ void irq_handler(void)
                        printf("IRQ: unknown 0x%08x\n", hw_flags);
                        write32(HW_PPCIRQFLAG, hw_flags);
                }
+
+               // not necessary here, but "cleaner"?
                write32(BW_PI_IRQFLAG, 1<<BW_PI_IRQ_HW);
-               u32 flags2 = read32(BW_PI_IRQFLAG);
-               printf("flags2: 0x%08X\n", flags2);
        }
-
-//     flags &= 
 }
 
 void irq_bw_enable(u32 irq)
@@ -163,5 +160,6 @@ u32 irq_kill() {
 
 void irq_restore(u32 cookie) {
        _CPU_ISR_Restore(cookie);
+       _CPU_ISR_Enable(); //wtf :/
 }