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 > FIFO[SOLVED]

#133215 - yellowstar - Wed Jul 04, 2007 4:01 am

I need some help with FIFO.

The way I am doing it dosen't work.

I am trying to send messages to and from the ARM7 and ARM9,
and vice versa.

I quit using pointers,
and the other way I was doing it.

Now I am doing it a different way.

I am using FIFO normally.
That is, the FIFO items are
structs containg the data.(The structs are 4 bytes long.)

Note:
arm7.cpp is basicly the arm7 template code,
with the FIFO code added.
FIFO7.h and 9 don't have anything in them,
I just didn't remove them.
shared.h includes another header,
which includes FIFO.h.

*Source code removed*


Last edited by yellowstar on Fri Nov 09, 2007 8:36 pm; edited 5 times in total

#133247 - masscat - Wed Jul 04, 2007 4:47 pm

One thing you cannot do is allocate memory on one ARM and free it on the other ARM. The run-times of the two ARMs are completely independent, that is, memory allocated using malloc will only be known to the run-time of the ARM that made the call.
Mallocs on the ARM7 are (using the default linking) allocated out of the ARM7's private memory (03800000h) and this cannot be addressed by the ARM9.
If you want to share data between the ARMs it must be in an area of memory addressable by both ARMs (or use some other mechanism like passing the data through the fifo). You will also have to implement your own memory management (not using malloc/free).

DC_FlushAll() does not exist for the ARM7 because the ARM7 does not have a cache. To avoid the ARM9 cache place data in the non-cached main memory mirror (02400000-027FFFFF). This will slow down the ARM9's access to the data but is much simpler than handling the cache for shared data.

#133256 - yellowstar - Wed Jul 04, 2007 8:45 pm

I tried removing the calls to free,
but that didn't work.

I am now trying a differen't method,
but it dosen't work.

Now, the FIFO items don't contain anything.
Instead, the actual messages are stored in arrays.
These arrays are stored in shared memory.
When a processor receives a command from the FIFO,
it processes it.(see below)
When a command is processed, it uses
the first command in the array for its processor,
then it moves all the commands in the list forward.

When a command is sent,
it adds a command to the end of the array for the other
processor. It then puts the command's data in it.
Then it writes to the FIFO send register to send a
FIFO item to the other processor.

The new source is in my first post.

#134617 - yellowstar - Sat Jul 14, 2007 9:11 pm

I quit using pointers,
and the other way I was doing it.

Now I am doing it a different way.

I am using FIFO normally.
That is, the FIFO items are
structs containg the data.(The structs are 4 bytes long.)

But it still won't work.
(The ARM9 is supposed to print the
data when a FIFO item is recieved,
but it won't work.)

See my first post for source code.

Is there any other FIFO tutorials,
other than this one?

#144894 - yellowstar - Thu Nov 08, 2007 11:55 pm

Anybody?

#144917 - gmiller - Fri Nov 09, 2007 5:15 am

Not sure if this will help or is even correct ... but

Since the region you are using is in shared memory it is not the heap on either machine nor is the heap on either available to the other. If you organize the shared memory into a circular buffer with the information describing the buffer also in shared memory then you might be able to get this working. You should not use new/delete or malloc/free for any of this because they only work in the heap.

Of course I have not done this on the DS but I have done it in shared memory machines other than the DS

#144950 - yellowstar - Fri Nov 09, 2007 7:38 pm

I'm not using shared memory for this anymore.

Instead, I'm only using the FIFO normally.
That is, the FIFO messages are 4-byte structs.

#144958 - yellowstar - Fri Nov 09, 2007 8:35 pm

I have solved it.

It was caused by a mistake in my code.

For recieving,
there are lines which have this:
if(REC_ERROR!=0)

In the recieving function,
before doing anything,
it would set it to zero.
Then, for errors,
it set it to one.

This means it would only continue
on errors.(no messages)

I fixed it,
and it workes.

#145003 - TwentySeven - Sat Nov 10, 2007 10:24 am

I mean no insult, but your posts always remind me of haikus.