i digged a bit into ResLock stuff and will describe how i think it works.
struct struc_LockEntry
{
char *name;
int status;
int semaphore;
int some_prev;
int some_next;
unsigned int *pResource;
int resourceEntries;
void (*cbr)(struct struc_LockEntry *lockEntry, void *cbr_priv);
void *cbr_priv;
};
struct struc_LockEntry *CreateResLockEntry(uint32_t *resIds, resIdCount);
unsigned int LockEngineResources(struct struc_LockEntry *lockEntry);
unsigned int UnLockEngineResources(struct struc_LockEntry *lockEntry);
unsigned int AsyncLockEngineResources(struct struc_LockEntry *lockEntry, void (*cbr)(struct struc_LockEntry *lockEntry, void *cbr_priv), void *cbr_priv);
LockEngineResources:
Lock a previously allocated LockEntry and its associated devices
UnLockEngineResources:
Unlock a previously allocated LockEntry and its associated devices
CreateResLockEntry:
register a lock that will use semaphores to lock all the resources specified in a list.
when registering your lock, the resIds[] is a list of resources to be locked.
the number of entries in this list is passed as second parameter.
initial state of the lock is unlocked.
resId format:
resId = (block << 16) | (entry)
entry specifies the exact "device" in the given block, if any.
blocks are one of those:
0x00 = EDMAC[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x20, 0x21]
0x01 = EDMAC[0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x28, 0x29, 0x2A, 0x2B]
0x04 = HEAD
0x36 = encdrwrap
0x37 (max)
(...to be continued)
e.g. resId 0x1000C is block 0x01 and entry 0x0C. This is EDMAC 0x28 being locked whenever LockEngineResources is called with the LockEntry.