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 > IPC FIFO

#81361 - ProblemBaby - Fri Apr 28, 2006 6:30 pm

Hi

i have some problems with the ipc fifo.
I want to send a Command ID from the arm9 and handle that in the arm7.
my way of doing this is:

Ive a recieve interrupt function, that first Reads the command ID, handles it, and then make another read, to define as finished

in the arm 9, when I want to send a command I first wait until the FIFO is empty, Fill a global struct with the parameters, then Send first the Command ID and then a 0.
This works when the calls isnt to close, else only one command is processed. Can't understand why, cause it should not be able to send a new command before the recieve interrupt is finished. Is this probably a bug or is it something I don't know about the IPC that makes this don't work.

What I want to do is to control the sounds regs from arm9, maybe you have better ideas how to do that, I need to be able to update more then once in a frame.

#81368 - DekuTree64 - Fri Apr 28, 2006 7:34 pm

Sounds like a bug to me. If ARM9 is only waiting until the FIFO is empty, then as soon as ARM7 reads the command, ARM9 could wipe out the global struct before ARM7 reads it. Could make a local copy of the global struct before actually reading from the FIFO, or set some flag when it's safe to overwrite the global struct again.

I have a simple FIFO system that I could send to you tonight if you want. It's pretty basic, but reliable. Just writes a single word to the FIFO, and then waits until the other CPU processes it before returning.
The waiting is done by having each CPU keep track of how many commands they have sent, and how many commands they have processed. When sending, you increment the local sent counter, and then wait until the other CPU's processed counter is equal.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#81390 - ProblemBaby - Fri Apr 28, 2006 11:17 pm

a working example would be great! Check out the my profile to get my mail or are you going to upload it somewhere?

#81998 - DekuTree64 - Wed May 03, 2006 10:20 am

Oops, I kind of forgot about this post...
Well, here is my little IPC system.
Should convert over to libnds easily, you'll just need to put the arm9FifoSent, arm9FifoProcessed, etc. in a seperate struct and place it after the transfer region struct or something.

I also included my higher level sound code, which does the starting of sound channels using the fifo commands.

The mixer splits all the software channels across 8 batches, so it starts up all the hardware channels playing buffers. I'm not actually sure if splitting batches like that helps anything though... I think adding them all together and clipping manually might have the same result.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#82617 - ProblemBaby - Sun May 07, 2006 10:18 pm

thanks a lot, this really helped!