1 /* 2 * Copyright 2007 3 * Green Hills Software, Inc. 4 * 5 * This program is the property of Green Hills Software, Inc, 6 * its contents are proprietary information and no part of it 7 * is to be disclosed to anyone except employees of Green Hills 8 * Software, Inc., or as agreed in writing signed by the President 9 * of Green Hills Software, Inc. 10 * 11 */ 12 13 #include "ind_thrd.h" 14 #include <stddef.h> 15 #include <setjmp.h> 16 #include <cafe/os.h> 17 #include <cafe/os/OSMutex.h> 18 #include <cafe/mem.h> 19 20 #if !defined(MINIMAL_STARTUP) 21 /* Acquire global lock. Blocks until the lock becomes available. */ 22 #if 0 // CAFE GHS ORIG 23 void __ghsLock(void) 24 { 25 } 26 #endif // CAFE GHS ORIG 27 28 /* Release global lock */ 29 #if 0 // CAFE GHS ORIG 30 void __ghsUnlock(void) 31 { 32 } 33 #endif // CAFE GHS ORIG 34 35 #endif /* !defined(MINIMAL_STARTUP) */ 36 37 /* A callback to initialize the lock data structure before it is used. */ 38 #if 0 // CAFE GHS ORIG 39 void __gh_lock_init(void) 40 { 41 } 42 #endif // CAFE GHS ORIG 43 44 #define MUTEX_ALIGN 8 45 __ghs_mtx_init(void * mtx)46void __ghs_mtx_init(void *mtx) 47 { 48 OSMutex **mutex_ptr_ptr = (OSMutex **)mtx; 49 *mutex_ptr_ptr = (OSMutex *)MEMAllocFromDefaultHeapEx(sizeof(OSMutex), MUTEX_ALIGN); 50 OSInitMutex(*mutex_ptr_ptr); 51 } 52 __ghs_mtx_dst(void * mtx)53void __ghs_mtx_dst(void *mtx) 54 { 55 OSMutex **mutex_ptr_ptr = (OSMutex **)mtx; 56 MEMFreeToDefaultHeap(*mutex_ptr_ptr); 57 *mutex_ptr_ptr = NULL; 58 } 59 __ghs_mtx_lock(void * mtx)60void __ghs_mtx_lock(void *mtx) 61 { 62 OSMutex **mutex_ptr_ptr = (OSMutex **)mtx; 63 OSLockMutex(*mutex_ptr_ptr); 64 } 65 __ghs_mtx_unlock(void * mtx)66void __ghs_mtx_unlock(void *mtx) 67 { 68 OSMutex **mutex_ptr_ptr = (OSMutex **)mtx; 69 OSUnlockMutex(*mutex_ptr_ptr); 70 } 71