gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Calling a function on the ARM7 when a button is pressed.

#128619 - tondopie - Sun May 13, 2007 2:57 pm

SO I finally was able to get a GBA booting code running on DKA r20 working thanks to wintermute telling me that the 'S' in 'gbaScreen' was supposed to be capitolized... (There's my cluelessness again). After a long confusing discussion with strager on #tod2 , i was wondering if there was a reletivly easy way to call the arm7 side of the booting code when the arm9 says its ok (When a button (Start) is pressed). Help is very much apperciated.

#128620 - simonjhall - Sun May 13, 2007 3:17 pm

If you want the arm7 to do something when the arm9 wants it to, the normal way is to have some kind of inter-processor communication going on.
You'd have a shared piece of memory which they can both read/write data from/into and both processors need to be checking this data structure frequently to see if a message is pending, which they will need to act upon.

For instace, if you '9 wants '7 to do something, it'll go like this:

9:
check to see if the data structure is empty
if so, write in a code corresponding to the job you want the '7 to do
block until this message has been 'consumed'

7: <this function needs to run constantly, so but it on a timer or something>
check to see if the data structure is not empty
if so, read the code out of the structure
act on this message
clear the data structure (ie it has been consumed)

And the really important bits:
- as this is effectively makes your program multi-threaded you'll need to ensure that all your use of this data structure is thread-safe, which is normally a pain in the ass.

- also don't forget that there is no cache coherency between the two processors, so if you want data to be accessed by the '7 that the '9 has recently used you'll need to flush your data cache (or the relavent parts). Or alternatively use an uncached mirror of the memory space.

Read this:
http://en.wikipedia.org/wiki/Producers-consumers
http://en.wikipedia.org/wiki/Concurrent_programming
_________________
Big thanks to everyone who donated for Quake2

#128667 - tondopie - Sun May 13, 2007 11:47 pm

I learn better from example so I'm just going to look around some code.

EDIT: FIFO CODE NEEDED.... done!