freemyipod r258 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r257‎ | r258 | r259 >
Date:11:43, 9 November 2010
Author:theseven
Status:new
Tags:
Comment:
emBIOS: Allow hooking of DMA IRQs from userspace.
Modified paths:
  • /embios/trunk/export/syscallapi.h (modified) (history)
  • /embios/trunk/export/syscallwrappers.h (modified) (history)
  • /embios/trunk/interrupt.h (modified) (history)
  • /embios/trunk/syscallapi.c (modified) (history)
  • /embios/trunk/target/ipodnano2g/interrupt.c (modified) (history)
  • /embios/trunk/target/ipodnano4g/interrupt.c (modified) (history)

Diff [purge]

Index: embios/trunk/target/ipodnano2g/interrupt.c
@@ -93,7 +93,7 @@
9494 if (TDCON & 0x00038000) timervector[3]();
9595 }
9696
97 -static void (* const dmavector[])(void) IDATA_ATTR =
 97+static void (* dmavector[])(void) IDATA_ATTR =
9898 {
9999 INT_DMA0,INT_DMA1,INT_DMA2,INT_DMA3,INT_DMA4,INT_DMA5,INT_DMA6,INT_DMA7,INT_DMA8
100100 };
@@ -148,6 +148,12 @@
149149 else timervector[timer] = unhandled_irq;
150150 }
151151
 152+void int_dma_set_handler(int channel, void* handler)
 153+{
 154+ if (handler) dmavector[channel] = handler;
 155+ else dmavector[channel] = unhandled_irq;
 156+}
 157+
152158 void interrupt_init(void)
153159 {
154160 INTMSK = (1 << IRQ_TIMER) | (1 << IRQ_DMA);
Index: embios/trunk/target/ipodnano4g/interrupt.c
@@ -141,16 +141,16 @@
142142
143143 void irqhandler(void)
144144 {
145 - uint32_t dummy = VIC0ADDRESS;
 145+ uint32_t dummy = VIC0ADDRESS;
146146 dummy = VIC1ADDRESS;
147147 uint32_t irqs0 = VIC0IRQSTATUS;
148148 uint32_t irqs1 = VIC1IRQSTATUS;
149 - for (current_irq = 0; irqs0; current_irq++, irqs0 >>= 1)
150 - if (irqs0 & 1)
151 - irqvector[current_irq]();
152 - for (current_irq = 32; irqs1; current_irq++, irqs1 >>= 1)
153 - if (irqs1 & 1)
154 - irqvector[current_irq]();
 149+ for (current_irq = 0; irqs0; current_irq++, irqs0 >>= 1)
 150+ if (irqs0 & 1)
 151+ irqvector[current_irq]();
 152+ for (current_irq = 32; irqs1; current_irq++, irqs1 >>= 1)
 153+ if (irqs1 & 1)
 154+ irqvector[current_irq]();
155155 VIC0ADDRESS = 0;
156156 VIC1ADDRESS = 0;
157157 }
@@ -157,22 +157,28 @@
158158
159159 void interrupt_enable(int irq, bool state)
160160 {
161 - if (state) VICINTENABLE(irq >> 5) = 1 << (irq & 0x1f);
162 - else VICINTENCLEAR(irq >> 5) = 1 << (irq & 0x1f);
 161+ if (state) VICINTENABLE(irq >> 5) = 1 << (irq & 0x1f);
 162+ else VICINTENCLEAR(irq >> 5) = 1 << (irq & 0x1f);
163163 }
164164
165165 void interrupt_set_handler(int irq, void* handler)
166166 {
167 - if (handler) irqvector[irq] = handler;
168 - else irqvector[irq] = unhandled_irq;
 167+ if (handler) irqvector[irq] = handler;
 168+ else irqvector[irq] = unhandled_irq;
169169 }
170170
171171 void int_timer_set_handler(int timer, void* handler)
172172 {
173 - if (handler) timervector[timer] = handler;
174 - else timervector[timer] = unhandled_irq;
 173+ if (handler) timervector[timer] = handler;
 174+ else timervector[timer] = unhandled_irq;
175175 }
176176
 177+void int_dma_set_handler(int channel, void* handler)
 178+{
 179+ void(channel);
 180+ void(handler);
 181+}
 182+
177183 void interrupt_init(void)
178184 {
179185 VIC0INTENABLE = 1 << IRQ_TIMER;
Index: embios/trunk/export/syscallwrappers.h
@@ -184,6 +184,7 @@
185185 #define hwkeyaes(args...) __embios_syscall->hwkeyaes(args)
186186 #define hmacsha1(args...) __embios_syscall->hmacsha1(args)
187187 #define reset(args...) __embios_syscall->reset(args)
 188+#define int_dma_set_handler(args...) __embios_syscall->int_dma_set_handler(args)
188189
189190
190191 #endif
Index: embios/trunk/export/syscallapi.h
@@ -63,7 +63,7 @@
6464 #include "../libc/tlsf/tlsf.h"
6565
6666 /* increase this every time the api struct changes */
67 -#define EMBIOS_API_VERSION 0
 67+#define EMBIOS_API_VERSION 1
6868
6969 /* update this to latest version if a change to the api struct breaks
7070 backwards compatibility (and please take the opportunity to sort in any
@@ -79,8 +79,8 @@
8080 {
8181 uint32_t table_version;
8282 uint32_t table_minversion;
83 - typeof(panic) *panic;
84 - typeof(panicf) *panicf;
 83+ typeof(panic) *panic;
 84+ typeof(panicf) *panicf;
8585 typeof(cprintf) *cprintf;
8686 typeof(cvprintf) *cvprintf;
8787 typeof(cputc) *cputc;
@@ -228,6 +228,7 @@
229229 typeof(hwkeyaes) *hwkeyaes;
230230 typeof(hmacsha1) *hmacsha1;
231231 typeof(reset) *reset;
 232+ typeof(int_dma_set_handler) *int_dma_set_handler;
232233 };
233234
234235
Index: embios/trunk/interrupt.h
@@ -34,5 +34,6 @@
3535 void interrupt_enable(int irq, bool state);
3636 void interrupt_set_handler(int irq, void* handler);
3737 void int_timer_set_handler(int timer, void* handler);
 38+void int_dma_set_handler(int channel, void* handler);
3839
3940 #endif
Index: embios/trunk/syscallapi.c
@@ -194,6 +194,7 @@
195195 .hwkeyaes = hwkeyaes,
196196 #endif
197197 #ifdef HAVE_HMACSHA1
198 - .hmacsha1 = hmacsha1
 198+ .hmacsha1 = hmacsha1,
199199 #endif
 200+ .int_dma_set_handler = int_dma_set_handler
200201 };