1 | /*--------------------------------------------------------------------------------- |
---|
2 | $Id$ |
---|
3 | |
---|
4 | Copyright (C) 2005 |
---|
5 | Dave Murphy (WinterMute) |
---|
6 | |
---|
7 | This software is provided 'as-is', without any express or implied |
---|
8 | warranty. In no event will the authors be held liable for any |
---|
9 | damages arising from the use of this software. |
---|
10 | |
---|
11 | Permission is granted to anyone to use this software for any |
---|
12 | purpose, including commercial applications, and to alter it and |
---|
13 | redistribute it freely, subject to the following restrictions: |
---|
14 | |
---|
15 | 1. The origin of this software must not be misrepresented; you |
---|
16 | must not claim that you wrote the original software. If you use |
---|
17 | this software in a product, an acknowledgment in the product |
---|
18 | documentation would be appreciated but is not required. |
---|
19 | 2. Altered source versions must be plainly marked as such, and |
---|
20 | must not be misrepresented as being the original software. |
---|
21 | 3. This notice may not be removed or altered from any source |
---|
22 | distribution. |
---|
23 | |
---|
24 | $Log$ |
---|
25 | Revision 1.1 2008/04/16 18:37:33 joel |
---|
26 | 2008-04-16 Matthieu Bucchianeri <mbucchia@gmail.com> |
---|
27 | |
---|
28 | * ChangeLog, Makefile.am, README, bsp_specs, configure.ac, |
---|
29 | mk_libnds.sh, patch.libnds, preinstall.am, block/block.c, |
---|
30 | clock/clock.c, console/console.c, coproc/coproc.S, coproc/coproc.c, |
---|
31 | coproc/coproc.ld, dswifi/dswifi_license.txt, dswifi/makefile, |
---|
32 | dswifi/arm7/makefile, dswifi/arm7/source/wifi_arm7.c, |
---|
33 | dswifi/arm7/source/wifi_arm7.h, dswifi/arm9/makefile, |
---|
34 | dswifi/arm9/source/sgIP.c, dswifi/arm9/source/sgIP.h, |
---|
35 | dswifi/arm9/source/sgIP_ARP.c, dswifi/arm9/source/sgIP_ARP.h, |
---|
36 | dswifi/arm9/source/sgIP_Config.h, dswifi/arm9/source/sgIP_DHCP.c, |
---|
37 | dswifi/arm9/source/sgIP_DHCP.h, dswifi/arm9/source/sgIP_DNS.c, |
---|
38 | dswifi/arm9/source/sgIP_DNS.h, dswifi/arm9/source/sgIP_Hub.c, |
---|
39 | dswifi/arm9/source/sgIP_Hub.h, dswifi/arm9/source/sgIP_ICMP.c, |
---|
40 | dswifi/arm9/source/sgIP_ICMP.h, dswifi/arm9/source/sgIP_IP.c, |
---|
41 | dswifi/arm9/source/sgIP_IP.h, dswifi/arm9/source/sgIP_TCP.c, |
---|
42 | dswifi/arm9/source/sgIP_TCP.h, dswifi/arm9/source/sgIP_UDP.c, |
---|
43 | dswifi/arm9/source/sgIP_UDP.h, dswifi/arm9/source/sgIP_memblock.c, |
---|
44 | dswifi/arm9/source/sgIP_memblock.h, |
---|
45 | dswifi/arm9/source/sgIP_sockets.c, dswifi/arm9/source/sgIP_sockets.h, |
---|
46 | dswifi/arm9/source/wifi_arm9.c, dswifi/arm9/source/wifi_arm9.h, |
---|
47 | dswifi/common/source/dsregs.h, dswifi/common/source/spinlock.h, |
---|
48 | dswifi/common/source/spinlock.s, dswifi/common/source/wifi_shared.h, |
---|
49 | dswifi/include/dswifi7.h, dswifi/include/dswifi9.h, |
---|
50 | dswifi/include/dswifi_version.h, dswifi/include/netdb.h, |
---|
51 | dswifi/include/sgIP_errno.h, dswifi/include/netinet/in.h, fb/fb.c, |
---|
52 | fb/fb.h, include/bsp.h, include/my_ipc.h, include/tm27.h, |
---|
53 | include/types.h, include/sys/iosupport.h, irq/irq.c, irq/irq.h, |
---|
54 | libfat/gba/include/fat.h, libfat/include/fat.h, |
---|
55 | libfat/nds/include/fat.h, libfat/source/bit_ops.h, |
---|
56 | libfat/source/cache.c, libfat/source/cache.h, libfat/source/common.h, |
---|
57 | libfat/source/directory.c, libfat/source/directory.h, |
---|
58 | libfat/source/fatdir.c, libfat/source/fatdir.h, |
---|
59 | libfat/source/fatfile.c, libfat/source/fatfile.h, |
---|
60 | libfat/source/file_allocation_table.c, |
---|
61 | libfat/source/file_allocation_table.h, libfat/source/filetime.c, |
---|
62 | libfat/source/filetime.h, libfat/source/libfat.c, |
---|
63 | libfat/source/mem_allocate.h, libfat/source/partition.c, |
---|
64 | libfat/source/partition.h, libfat/source/disc_io/disc.c, |
---|
65 | libfat/source/disc_io/disc.h, libfat/source/disc_io/disc_io.h, |
---|
66 | libfat/source/disc_io/io_cf_common.c, |
---|
67 | libfat/source/disc_io/io_cf_common.h, |
---|
68 | libfat/source/disc_io/io_dldi.h, libfat/source/disc_io/io_dldi.s, |
---|
69 | libfat/source/disc_io/io_efa2.c, libfat/source/disc_io/io_efa2.h, |
---|
70 | libfat/source/disc_io/io_fcsr.c, libfat/source/disc_io/io_fcsr.h, |
---|
71 | libfat/source/disc_io/io_m3_common.c, |
---|
72 | libfat/source/disc_io/io_m3_common.h, |
---|
73 | libfat/source/disc_io/io_m3cf.c, libfat/source/disc_io/io_m3cf.h, |
---|
74 | libfat/source/disc_io/io_m3sd.c, libfat/source/disc_io/io_m3sd.h, |
---|
75 | libfat/source/disc_io/io_mpcf.c, libfat/source/disc_io/io_mpcf.h, |
---|
76 | libfat/source/disc_io/io_njsd.c, libfat/source/disc_io/io_njsd.h, |
---|
77 | libfat/source/disc_io/io_nmmc.c, libfat/source/disc_io/io_nmmc.h, |
---|
78 | libfat/source/disc_io/io_sc_common.c, |
---|
79 | libfat/source/disc_io/io_sc_common.h, |
---|
80 | libfat/source/disc_io/io_sccf.c, libfat/source/disc_io/io_sccf.h, |
---|
81 | libfat/source/disc_io/io_scsd.c, libfat/source/disc_io/io_scsd.h, |
---|
82 | libfat/source/disc_io/io_scsd_s.s, |
---|
83 | libfat/source/disc_io/io_sd_common.c, |
---|
84 | libfat/source/disc_io/io_sd_common.h, libnds/Makefile.arm7, |
---|
85 | libnds/Makefile.arm9, libnds/libnds_license.txt, |
---|
86 | libnds/basicARM7/source/defaultARM7.c, |
---|
87 | libnds/include/default_font_bin.h, libnds/include/gbfs.h, |
---|
88 | libnds/include/nds.h, libnds/include/nds/bios.h, |
---|
89 | libnds/include/nds/card.h, libnds/include/nds/dma.h, |
---|
90 | libnds/include/nds/interrupts.h, libnds/include/nds/ipc.h, |
---|
91 | libnds/include/nds/jtypes.h, libnds/include/nds/memory.h, |
---|
92 | libnds/include/nds/registers_alt.h, libnds/include/nds/reload.h, |
---|
93 | libnds/include/nds/system.h, libnds/include/nds/timers.h, |
---|
94 | libnds/include/nds/arm7/audio.h, libnds/include/nds/arm7/clock.h, |
---|
95 | libnds/include/nds/arm7/serial.h, libnds/include/nds/arm7/touch.h, |
---|
96 | libnds/include/nds/arm9/background.h, |
---|
97 | libnds/include/nds/arm9/boxtest.h, libnds/include/nds/arm9/cache.h, |
---|
98 | libnds/include/nds/arm9/console.h, |
---|
99 | libnds/include/nds/arm9/exceptions.h, |
---|
100 | libnds/include/nds/arm9/image.h, libnds/include/nds/arm9/input.h, |
---|
101 | libnds/include/nds/arm9/math.h, libnds/include/nds/arm9/ndsmotion.h, |
---|
102 | libnds/include/nds/arm9/pcx.h, libnds/include/nds/arm9/postest.h, |
---|
103 | libnds/include/nds/arm9/rumble.h, libnds/include/nds/arm9/sound.h, |
---|
104 | libnds/include/nds/arm9/sprite.h, libnds/include/nds/arm9/trig_lut.h, |
---|
105 | libnds/include/nds/arm9/video.h, libnds/include/nds/arm9/videoGL.h, |
---|
106 | libnds/source/arm7/audio.c, libnds/source/arm7/clock.c, |
---|
107 | libnds/source/arm7/microphone.c, libnds/source/arm7/spi.c, |
---|
108 | libnds/source/arm7/touch.c, libnds/source/arm7/userSettings.c, |
---|
109 | libnds/source/arm9/COS.bin, libnds/source/arm9/COS.s, |
---|
110 | libnds/source/arm9/SIN.bin, libnds/source/arm9/SIN.s, |
---|
111 | libnds/source/arm9/TAN.bin, libnds/source/arm9/TAN.s, |
---|
112 | libnds/source/arm9/boxtest.c, libnds/source/arm9/console.c, |
---|
113 | libnds/source/arm9/dcache.s, libnds/source/arm9/default_font.bin, |
---|
114 | libnds/source/arm9/default_font.s, |
---|
115 | libnds/source/arm9/exceptionHandler.S, |
---|
116 | libnds/source/arm9/exceptionHandler.s, |
---|
117 | libnds/source/arm9/exceptions.c, libnds/source/arm9/gurumeditation.c, |
---|
118 | libnds/source/arm9/icache.s, libnds/source/arm9/image.c, |
---|
119 | libnds/source/arm9/initSystem.c, libnds/source/arm9/keys.c, |
---|
120 | libnds/source/arm9/ndsmotion.c, libnds/source/arm9/pcx.c, |
---|
121 | libnds/source/arm9/rumble.c, libnds/source/arm9/sound.c, |
---|
122 | libnds/source/arm9/system.c, libnds/source/arm9/touch.c, |
---|
123 | libnds/source/arm9/video.c, libnds/source/arm9/videoGL.c, |
---|
124 | libnds/source/common/biosCalls.s, libnds/source/common/card.c, |
---|
125 | libnds/source/common/gbfs.c, |
---|
126 | libnds/source/common/interruptDispatcher.s, |
---|
127 | libnds/source/common/interrupts.c, rtc/rtc.c, sound/sound.c, |
---|
128 | sound/sound.h, start/start.S, startup/linkcmds, startup/start.c, |
---|
129 | timer/timer.c, tools/Makefile.am, tools/bin2s, tools/bin2s.c, |
---|
130 | tools/configure.ac, tools/runtest, |
---|
131 | tools/ndstool/include/arm7_sha1_homebrew.h, |
---|
132 | tools/ndstool/include/arm7_sha1_nintendo.h, |
---|
133 | tools/ndstool/include/banner.h, tools/ndstool/include/bigint.h, |
---|
134 | tools/ndstool/include/crc.h, tools/ndstool/include/default_icon.h, |
---|
135 | tools/ndstool/include/encryption.h, tools/ndstool/include/header.h, |
---|
136 | tools/ndstool/include/hook.h, tools/ndstool/include/little.h, |
---|
137 | tools/ndstool/include/loadme.h, tools/ndstool/include/logo.h, |
---|
138 | tools/ndstool/include/ndscreate.h, |
---|
139 | tools/ndstool/include/ndsextract.h, tools/ndstool/include/ndstool.h, |
---|
140 | tools/ndstool/include/ndstree.h, tools/ndstool/include/overlay.h, |
---|
141 | tools/ndstool/include/passme.h, tools/ndstool/include/passme_sram.h, |
---|
142 | tools/ndstool/include/passme_vhd1.h, |
---|
143 | tools/ndstool/include/passme_vhd2.h, tools/ndstool/include/raster.h, |
---|
144 | tools/ndstool/include/sha1.h, tools/ndstool/include/types.h, |
---|
145 | tools/ndstool/source/arm7_sha1_homebrew.c, |
---|
146 | tools/ndstool/source/arm7_sha1_nintendo.c, |
---|
147 | tools/ndstool/source/banner.cpp, tools/ndstool/source/bigint.cpp, |
---|
148 | tools/ndstool/source/compile_date.c, tools/ndstool/source/crc.cpp, |
---|
149 | tools/ndstool/source/default_icon.c, |
---|
150 | tools/ndstool/source/encryption.cpp, tools/ndstool/source/header.cpp, |
---|
151 | tools/ndstool/source/hook.cpp, tools/ndstool/source/loadme.c, |
---|
152 | tools/ndstool/source/logo.cpp, tools/ndstool/source/ndscodes.cpp, |
---|
153 | tools/ndstool/source/ndscreate.cpp, |
---|
154 | tools/ndstool/source/ndsextract.cpp, |
---|
155 | tools/ndstool/source/ndstool.cpp, tools/ndstool/source/ndstree.cpp, |
---|
156 | tools/ndstool/source/passme.cpp, tools/ndstool/source/passme_sram.c, |
---|
157 | tools/ndstool/source/raster.cpp, tools/ndstool/source/sha1.cpp, |
---|
158 | touchscreen/README.reco, touchscreen/parser.c, touchscreen/reco.c, |
---|
159 | touchscreen/reco.h, touchscreen/touchscreen.c, |
---|
160 | touchscreen/touchscreen.h, wifi/compat.c, wifi/compat.h, wifi/wifi.c: |
---|
161 | New files. |
---|
162 | |
---|
163 | Revision 1.10 2007/02/06 12:00:32 wntrmute |
---|
164 | use uint32 for irqEnable |
---|
165 | |
---|
166 | Revision 1.9 2006/06/16 07:35:14 wntrmute |
---|
167 | more moves to REG_ values |
---|
168 | implement SetYtrigger helper function |
---|
169 | set bits in REG_DISPSTAT for IRQ_VCOUNT |
---|
170 | |
---|
171 | Revision 1.8 2006/02/21 00:12:35 wntrmute |
---|
172 | clear interrupts and enable REG_IME in irqInit |
---|
173 | |
---|
174 | Revision 1.7 2005/12/12 13:03:29 wntrmute |
---|
175 | set/clear LCD interrupts in irqEnable/Disable |
---|
176 | |
---|
177 | Revision 1.6 2005/11/07 01:11:08 wntrmute |
---|
178 | more doxygen |
---|
179 | moved IntrMain declaration to C file |
---|
180 | |
---|
181 | Revision 1.5 2005/09/20 05:00:24 wntrmute |
---|
182 | use new register definitions |
---|
183 | |
---|
184 | Revision 1.4 2005/09/04 16:28:04 wntrmute |
---|
185 | place irqTable in ewram |
---|
186 | |
---|
187 | Revision 1.3 2005/09/03 17:09:35 wntrmute |
---|
188 | added interworking aware interrupt dispatcher |
---|
189 | |
---|
190 | |
---|
191 | ---------------------------------------------------------------------------------*/ |
---|
192 | |
---|
193 | #include <nds/interrupts.h> |
---|
194 | #include <nds/system.h> |
---|
195 | |
---|
196 | void IntrMain(void); // Prototype for assembly interrupt dispatcher |
---|
197 | |
---|
198 | //--------------------------------------------------------------------------------- |
---|
199 | void irqDummy(void) {} |
---|
200 | //--------------------------------------------------------------------------------- |
---|
201 | |
---|
202 | |
---|
203 | #ifdef ARM9 |
---|
204 | #define INT_TABLE_SECTION __attribute__((section(".itcm"))) |
---|
205 | #else |
---|
206 | #define INT_TABLE_SECTION |
---|
207 | #endif |
---|
208 | |
---|
209 | struct IntTable irqTable[MAX_INTERRUPTS] INT_TABLE_SECTION; |
---|
210 | |
---|
211 | //--------------------------------------------------------------------------------- |
---|
212 | void irqSet(int mask, IntFn handler) { |
---|
213 | //--------------------------------------------------------------------------------- |
---|
214 | if (!mask) return; |
---|
215 | |
---|
216 | int i; |
---|
217 | |
---|
218 | for (i=0;i<MAX_INTERRUPTS;i++) |
---|
219 | if (!irqTable[i].mask || irqTable[i].mask == mask) break; |
---|
220 | |
---|
221 | if ( i == MAX_INTERRUPTS ) return; |
---|
222 | |
---|
223 | irqTable[i].handler = handler; |
---|
224 | irqTable[i].mask = mask; |
---|
225 | |
---|
226 | if(mask & IRQ_VBLANK) |
---|
227 | REG_DISPSTAT |= DISP_VBLANK_IRQ ; |
---|
228 | if(mask & IRQ_HBLANK) |
---|
229 | REG_DISPSTAT |= DISP_HBLANK_IRQ ; |
---|
230 | |
---|
231 | REG_IE |= mask; |
---|
232 | } |
---|
233 | |
---|
234 | //--------------------------------------------------------------------------------- |
---|
235 | void irqInit() { |
---|
236 | //--------------------------------------------------------------------------------- |
---|
237 | int i; |
---|
238 | |
---|
239 | // Set all interrupts to dummy functions. |
---|
240 | for(i = 0; i < MAX_INTERRUPTS; i ++) |
---|
241 | { |
---|
242 | irqTable[i].handler = irqDummy; |
---|
243 | irqTable[i].mask = 0; |
---|
244 | } |
---|
245 | |
---|
246 | IRQ_HANDLER = IntrMain; |
---|
247 | |
---|
248 | REG_IE = 0; // disable all interrupts |
---|
249 | REG_IF = IRQ_ALL; // clear all pending interrupts |
---|
250 | REG_IME = 1; // enable global interrupt |
---|
251 | |
---|
252 | } |
---|
253 | |
---|
254 | |
---|
255 | //--------------------------------------------------------------------------------- |
---|
256 | void irqClear(int mask) { |
---|
257 | //--------------------------------------------------------------------------------- |
---|
258 | int i = 0; |
---|
259 | |
---|
260 | for (i=0;i<MAX_INTERRUPTS;i++) |
---|
261 | if (irqTable[i].mask == mask) break; |
---|
262 | |
---|
263 | if ( i == MAX_INTERRUPTS ) return; |
---|
264 | |
---|
265 | irqTable[i].handler = irqDummy; |
---|
266 | |
---|
267 | if (mask & IRQ_VBLANK) |
---|
268 | REG_DISPSTAT &= ~DISP_VBLANK_IRQ ; |
---|
269 | if (mask & IRQ_HBLANK) |
---|
270 | REG_DISPSTAT &= ~DISP_HBLANK_IRQ ; |
---|
271 | if (mask & IRQ_VCOUNT) |
---|
272 | REG_DISPSTAT &= ~DISP_YTRIGGER_IRQ; |
---|
273 | |
---|
274 | REG_IE &= ~mask; |
---|
275 | } |
---|
276 | |
---|
277 | |
---|
278 | //--------------------------------------------------------------------------------- |
---|
279 | void irqInitHandler(IntFn handler) { |
---|
280 | //--------------------------------------------------------------------------------- |
---|
281 | REG_IME = 0; |
---|
282 | REG_IF = ~0; |
---|
283 | REG_IE = 0; |
---|
284 | |
---|
285 | IRQ_HANDLER = handler; |
---|
286 | |
---|
287 | REG_IME = 1; |
---|
288 | } |
---|
289 | |
---|
290 | //--------------------------------------------------------------------------------- |
---|
291 | void irqEnable(uint32 irq) { |
---|
292 | //--------------------------------------------------------------------------------- |
---|
293 | if (irq & IRQ_VBLANK) |
---|
294 | REG_DISPSTAT |= DISP_VBLANK_IRQ ; |
---|
295 | if (irq & IRQ_HBLANK) |
---|
296 | REG_DISPSTAT |= DISP_HBLANK_IRQ ; |
---|
297 | if (irq & IRQ_VCOUNT) |
---|
298 | REG_DISPSTAT |= DISP_YTRIGGER_IRQ; |
---|
299 | |
---|
300 | REG_IE |= irq; |
---|
301 | REG_IME = 1; |
---|
302 | } |
---|
303 | |
---|
304 | //--------------------------------------------------------------------------------- |
---|
305 | void irqDisable(uint32 irq) { |
---|
306 | //--------------------------------------------------------------------------------- |
---|
307 | if (irq & IRQ_VBLANK) |
---|
308 | REG_DISPSTAT &= ~DISP_VBLANK_IRQ ; |
---|
309 | if (irq & IRQ_HBLANK) |
---|
310 | REG_DISPSTAT &= ~DISP_HBLANK_IRQ ; |
---|
311 | if (irq & IRQ_VCOUNT) |
---|
312 | REG_DISPSTAT &= ~DISP_YTRIGGER_IRQ; |
---|
313 | |
---|
314 | REG_IE &= ~irq; |
---|
315 | } |
---|
316 | |
---|