Thfifo

From ProjectWiki
Revision as of 23:09, 11 August 2008 by Eris (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

What is this?

A novel approach to inter-processor communications and related resource management for the Nintendo DS. Based on the concepts of simplicity, ease of use, modularity, and run-time resource allocation.

In addition to the usual FIFO functionality, functions for managing the 4K shared memory space (swrmalloc/swrfree) are also provided.

Shared Work Ram Management

Functions detailed here are for managing the 4K shared work ram (swr) segment. This segment is uncached on the arm9 side and therefore slower so should only be used for variables and structures that routinely need to be immediately available to both CPUs.

Traditionally this area was managed at compile time using complex #define statements requiring careful planning to prevent two libraries reusing the same region twice. To avoid these potential pitfalls a simple dynamic runtime allocation system is provided so that libraries may request swr space with minimal concern.

These functions may be called from either CPU, and you should be able to malloc on one side and free on the other! (however this is discouraged).

ToDo:

  • the malloc/free functions should be recoded so that they use less space and store the malloc structures directly in swr. The functions are currently just modified version of vram malloc... >_>

SWR Functions

swrInit Initialize the swr functionality, called on both CPUs before using. Calling this function is unnecessary if using the FIFO because its called already in fifoInit().

void swrInit(void);

swrmalloc Allocate a region of swr. Only argument is the size requested. Returns a pointer to the newly allocated region or null if fail.

void *swrmalloc(int size);

swrfree Frees up a previously allocated region of swr. Only argument is the previously allocated swr pointer. returns true if successful.

Do not see this being used very often if at all, but it is provided for completeness.

bool swrfree(void *loc);

FIFO

The design philosophy here is based on simplicity and modularity. It is essentially a channelized version of the hardware rather than an attempt to provide facilities for every possible need.

FIFO Functions

fifoInit

void fifoInit(void);

fifoChanCreate

s8 fifoChanCreate(const char *name, void *udata);

fifoChanSetFunc

bool fifoChanSetFunc(s8 chan, _pHFifoFunc func);

fifoSendChan24

void fifoSendChan24(s8 chan, u32 data);

fifoFindChan

s8 fifoFindChan(const char *name);

fifoChanRecvChk

bool fifoChanRecvChk(s8 chan);

fifoGetUData

void *fifoGetUData(s8 chan);
Personal tools
irssi scripts
eggdrop scripts