/*---------------------------------------------------------------------------* Project: OS Mutex API File: OSFastMutex.h Copyright 1998-2011 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef __OSFASTMUTEX_H__ #define __OSFASTMUTEX_H__ #define OSFASTMUTEX_OFFSET_OWNEDLINKNEXT 20 #define OSFASTMUTEX_OFFSET_OWNEDLINKPREV 24 #define OSFASTMUTEX_OFFSET_LOCK 28 #define OSFASTMUTEX_OFFSET_LOCKCOUNT 32 #define OSFASTMUTEX_OFFSET_CONTENDEDLINKNEXT 36 #define OSFASTMUTEX_OFFSET_CONTENDEDLINKPREV 40 #define OSTHREAD_OFFSET_CANCELSTATE 1492 #define OSTHREAD_OFFSET_REQUESTFLAG 1496 #define OSTHREAD_OFFSET_CONTENDEDFASTMUTEXES 1648 #define OSTHREAD_OFFSET_OWNEDFASTMUTEXES 1656 #define OSFASTMUTEXQ_OFFSET_HEAD 0 #define OSFASTMUTEXQ_OFFSET_TAIL 4 #ifndef _ASSEMBLER #ifdef __cplusplus extern "C" { #endif #include #define OSFASTMUTEX_TXT_TAG 0x664D7458 #define OSFASTCOND_TXT_TAG 0x664E6456 #define OSFASTMUTEX_EMPTY 0 #define OSFASTMUTEX_WBIT 0x00000001 #define OSFASTMUTEX_THREAD(__fastMutex__) ((OSThread *)(__fastMutex__->lock & ~OSFASTMUTEX_WBIT)) #define OSFASTMUTEX_LOCK(__lock__) ((OSThread *)(__lock__ & ~OSFASTMUTEX_WBIT)) struct OSFastMutex { u32 txtTag; // +0 'fMtX' 0x664D7458 char * name; // +4 debug name or NULL BOOL in_contended_queue; // +8 OSThreadSmallQueue contendedQueue; // +12 queue of threads waiting on this fastmutex OSFastMutexLink ownedLink; // +20 updated by owner-thread only, list of fastmutxes held u32 lock; // +28 the current owner thread & waiters (low) bit s32 lockCount; // +32 per-thread lock count OSFastMutexLink contendedLink; // +36 updated underneath scheduler lock by contended thread(s) }; struct OSFastCond { u32 txtTag; // 'fNdV' 0x664E6456 char * name; // debug name or NULL u32 os_reserved1; OSThreadQueue queue; }; void OSFastMutex_Init ( OSFastMutex * fastMutex, char * name ); void OSFastMutex_Lock ( OSFastMutex * fastMutex ); void OSFastMutex_Unlock ( OSFastMutex * fastMutex ); BOOL OSFastMutex_TryLock( OSFastMutex * fastMutex ); void OSFastCond_Init ( OSFastCond * fastCond, char * name ); void OSFastCond_Wait ( OSFastCond * fastCond, OSFastMutex * fastMutex ); void OSFastCond_Signal( OSFastCond * fastCond ); #ifdef __cplusplus } #endif #endif // _ASSEMBLER #endif // __OSFASTMUTEX_H__