From e781b2f723c72e3746fa90abfaae9822311745a6 Mon Sep 17 00:00:00 2001 From: nakasima Date: Wed, 10 Dec 2008 10:33:22 +0000 Subject: [PATCH] =?UTF-8?q?gl=E3=81=AB=E5=90=88=E3=82=8F=E3=81=9B=E3=81=A6?= =?UTF-8?q?OSi=5F=E2=86=92i=5Fos=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@99 b871894f-2f95-9b40-918c-086798483c85 --- .../build/libraries/os/ARM11/os_irqHandler.c | 28 +- .../build/libraries/os/ARM9/os_irqHandler.c | 28 +- .../build/libraries/os/common/os_thread.c | 388 +++++++++--------- trunk/bootrom/include/brom/os/common/mutex.h | 76 ++-- trunk/bootrom/include/brom/os/common/thread.h | 36 +- 5 files changed, 278 insertions(+), 278 deletions(-) diff --git a/trunk/bootrom/build/libraries/os/ARM11/os_irqHandler.c b/trunk/bootrom/build/libraries/os/ARM11/os_irqHandler.c index af874a5..8d46bb6 100644 --- a/trunk/bootrom/build/libraries/os/ARM11/os_irqHandler.c +++ b/trunk/bootrom/build/libraries/os/ARM11/os_irqHandler.c @@ -22,7 +22,7 @@ extern OSIntrFunction osIntrTable[OS_INTR_ID_NUM]; //---- thread queue for interrupt -OSThreadQueue OSi_IrqThreadQueue; +OSThreadQueue i_osIrqThreadQueue; /*---------------------------------------------------------------------------* Name: osIrqHandler @@ -87,15 +87,15 @@ my_undefined_interrupt_1 *---------------------------------------------------------------------------*/ asm void osIrqHandler_ThreadSwitch(void) { - INASM_EXTERN( OSi_IrqThreadQueue ) - INASM_EXTERN( OSi_ThreadInfo ) + INASM_EXTERN( i_osIrqThreadQueue ) + INASM_EXTERN( i_osThreadInfo ) //-------------------------------------------------- - // wakeup threads in OSi_IrqThreadQueue + // wakeup threads in i_osIrqThreadQueue //-------------------------------------------------- - ldr r12, =OSi_IrqThreadQueue + ldr r12, =i_osIrqThreadQueue mov r3, #0 // avoid stall - ldr r12, [r12, #__cpp(offsetof(OSThreadQueue,head))] // r12 = OSi_IrqThreadQueue.head + ldr r12, [r12, #__cpp(offsetof(OSThreadQueue,head))] // r12 = i_osIrqThreadQueue.head mov r2, #__cpp(OS_THREAD_STATE_READY) // avoid stall cmp r12, #0 @@ -111,11 +111,11 @@ LSYM(1) str r2, [r12, #__cpp(offsetof(OSThread,state))] cmp r12, #0 bne BSYM(1) - ldr r12, =OSi_IrqThreadQueue - str r3, [r12, #__cpp(offsetof(OSThreadQueue,head))] // clear OSi_IrqThreadQueue.head - str r3, [r12, #__cpp(offsetof(OSThreadQueue,tail))] // clear OSi_IrqThreadQueue.tail + ldr r12, =i_osIrqThreadQueue + str r3, [r12, #__cpp(offsetof(OSThreadQueue,head))] // clear i_osIrqThreadQueue.head + str r3, [r12, #__cpp(offsetof(OSThreadQueue,tail))] // clear i_osIrqThreadQueue.tail - ldr r12, =OSi_ThreadInfo // need to do scheduling + ldr r12, =i_osThreadInfo // need to do scheduling mov r1, #1 strh r1, [ r12, #OS_THREADINFO_OFFSET_ISNEEDRESCHEDULING ] @@ -130,7 +130,7 @@ thread_switch // isNeedRescheduling = FALSE; // // // OS_SelectThread - // OSThread* t = OSi_ThreadInfo.list; + // OSThread* t = i_osThreadInfo.list; // while( t && ! OS_IsThreadRunnable( t ) ){ t = t->next; } // return t; // @@ -143,10 +143,10 @@ thread_switch // // [[[ new OS_SelectThread ]]] - ldr r12, =OSi_ThreadInfo + ldr r12, =i_osThreadInfo ldrh r1, [ r12, #OS_THREADINFO_OFFSET_ISNEEDRESCHEDULING ] cmp r1, #0 - beq _dont_switched_ // return if OSi_IsNeedResceduling == 0 + beq _dont_switched_ // return if i_osIsNeedResceduling == 0 mov r1, #0 strh r1, [ r12, #OS_THREADINFO_OFFSET_ISNEEDRESCHEDULING ] @@ -155,7 +155,7 @@ thread_switch mov r3, #HW_PSR_IRQ_MODE|HW_PSR_FIQ_DISABLE|HW_PSR_IRQ_DISABLE|HW_PSR_ARM_STATE msr cpsr_c, r3 - add r2, r12, #OS_THREADINFO_OFFSET_LIST // r2 = &OSi_ThreadInfo.list + add r2, r12, #OS_THREADINFO_OFFSET_LIST // r2 = &i_osThreadInfo.list ldr r1, [r2] // r1 = *r2 = TopOfList LSYM(11) cmp r1, #0 diff --git a/trunk/bootrom/build/libraries/os/ARM9/os_irqHandler.c b/trunk/bootrom/build/libraries/os/ARM9/os_irqHandler.c index ff245ec..f817f21 100644 --- a/trunk/bootrom/build/libraries/os/ARM9/os_irqHandler.c +++ b/trunk/bootrom/build/libraries/os/ARM9/os_irqHandler.c @@ -24,7 +24,7 @@ #endif //---- thread queue for interrupt -OSThreadQueue OSi_IrqThreadQueue; +OSThreadQueue i_osIrqThreadQueue; #ifdef SDK_ARM9 #include @@ -110,15 +110,15 @@ irq_return *---------------------------------------------------------------------------*/ asm void osIrqHandler_ThreadSwitch(void) { - INASM_EXTERN( OSi_IrqThreadQueue ) - INASM_EXTERN( OSi_ThreadInfo ) + INASM_EXTERN( i_osIrqThreadQueue ) + INASM_EXTERN( i_osThreadInfo ) //-------------------------------------------------- - // wakeup threads in OSi_IrqThreadQueue + // wakeup threads in i_osIrqThreadQueue //-------------------------------------------------- - ldr r12, =OSi_IrqThreadQueue + ldr r12, =i_osIrqThreadQueue mov r3, #0 // avoid stall - ldr r12, [r12, #__cpp(offsetof(OSThreadQueue,head))] // r12 = OSi_IrqThreadQueue.head + ldr r12, [r12, #__cpp(offsetof(OSThreadQueue,head))] // r12 = i_osIrqThreadQueue.head mov r2, #__cpp(OS_THREAD_STATE_READY) // avoid stall cmp r12, #0 @@ -134,11 +134,11 @@ LSYM(1) str r2, [r12, #__cpp(offsetof(OSThread,state))] cmp r12, #0 bne BSYM(1) - ldr r12, =OSi_IrqThreadQueue - str r3, [r12, #__cpp(offsetof(OSThreadQueue,head))] // clear OSi_IrqThreadQueue.head - str r3, [r12, #__cpp(offsetof(OSThreadQueue,tail))] // clear OSi_IrqThreadQueue.tail + ldr r12, =i_osIrqThreadQueue + str r3, [r12, #__cpp(offsetof(OSThreadQueue,head))] // clear i_osIrqThreadQueue.head + str r3, [r12, #__cpp(offsetof(OSThreadQueue,tail))] // clear i_osIrqThreadQueue.tail - ldr r12, =OSi_ThreadInfo // need to do scheduling + ldr r12, =i_osThreadInfo // need to do scheduling mov r1, #1 strh r1, [ r12, #OS_THREADINFO_OFFSET_ISNEEDRESCHEDULING ] @@ -153,7 +153,7 @@ thread_switch // isNeedRescheduling = FALSE; // // // OS_SelectThread - // OSThread* t = OSi_ThreadInfo.list; + // OSThread* t = i_osThreadInfo.list; // while( t && ! OS_IsThreadRunnable( t ) ){ t = t->next; } // return t; // @@ -166,10 +166,10 @@ thread_switch // // [[[ new OS_SelectThread ]]] - ldr r12, =OSi_ThreadInfo + ldr r12, =i_osThreadInfo ldrh r1, [ r12, #OS_THREADINFO_OFFSET_ISNEEDRESCHEDULING ] cmp r1, #0 - beq _dont_switched_ // return if OSi_IsNeedResceduling == 0 + beq _dont_switched_ // return if i_osIsNeedResceduling == 0 mov r1, #0 strh r1, [ r12, #OS_THREADINFO_OFFSET_ISNEEDRESCHEDULING ] @@ -178,7 +178,7 @@ thread_switch mov r3, #HW_PSR_IRQ_MODE|HW_PSR_FIQ_DISABLE|HW_PSR_IRQ_DISABLE|HW_PSR_ARM_STATE msr cpsr_c, r3 - add r2, r12, #OS_THREADINFO_OFFSET_LIST // r2 = &OSi_ThreadInfo.list + add r2, r12, #OS_THREADINFO_OFFSET_LIST // r2 = &i_osThreadInfo.list ldr r1, [r2] // r1 = *r2 = TopOfList LSYM(11) cmp r1, #0 diff --git a/trunk/bootrom/build/libraries/os/common/os_thread.c b/trunk/bootrom/build/libraries/os/common/os_thread.c index 8e32576..2126cae 100644 --- a/trunk/bootrom/build/libraries/os/common/os_thread.c +++ b/trunk/bootrom/build/libraries/os/common/os_thread.c @@ -18,7 +18,7 @@ #define osPrintf(...) ((void)0) #define osTPrintf(...) ((void)0) -#define OSi_Panic(...) ((void)0) +#define i_osPanic(...) ((void)0) //--------------------------------------------------------------------------- @@ -68,61 +68,61 @@ extern void *Load$$DTCM$$Base; #include #endif //---- threads -OSThread OSi_LauncherThread; -OSThread OSi_IdleThread; +OSThread i_osLauncherThread; +OSThread i_osIdleThread; //---- thread information -OSThreadInfo OSi_ThreadInfo; +OSThreadInfo i_osThreadInfo; //---- current thread pointer (for quick reference) -OSThread **OSi_CurrentThreadPtr; -#define OSi_GetCurrentThread() (*OSi_CurrentThreadPtr) +OSThread **i_osCurrentThreadPtr; +#define i_osGetCurrentThread() (*i_osCurrentThreadPtr) //---- thread initialization flag -BOOL OSi_IsThreadInitialized = FALSE; +BOOL i_osIsThreadInitialized = FALSE; //---- idle thread stack -u32 OSi_IdleThreadStack[OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32)]; +u32 i_osIdleThreadStack[OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32)]; //---- system callback in switch thread ( maybe for profile ) -void *OSi_SystemCallbackInSwitchThread = NULL; +void *i_osSystemCallbackInSwitchThread = NULL; //---- reschedule counter. if value>=0, do not reschedule. -u32 OSi_RescheduleCount = 0; +u32 i_osRescheduleCount = 0; #if defined(SDK_TCM_APPLY) && defined(SDK_ARM9) #include #endif #ifdef SDK_THREAD_INFINITY //---- thread id count -static int OSi_ThreadIdCount = 0; +static int i_osThreadIdCount = 0; #endif -void *OSi_StackForDestructor = NULL; +void *i_osStackForDestructor = NULL; #ifndef SDK_THREAD_INFINITY -static int OSi_SearchFreeEntry(void); +static int i_osSearchFreeEntry(void); #endif -static void OSi_CancelThreadAlarmForSleep(OSThread *thread); -static void OSi_InsertThreadToList(OSThread *thread); -static void OSi_RemoveThreadFromList(OSThread *thread); -static void OSi_SleepAlarmCallback(void *arg); -static void OSi_IdleThreadProc(void *); -void OSi_SetSystemCallbackInSwitchThread(void *callback); +static void i_osCancelThreadAlarmForSleep(OSThread *thread); +static void i_osInsertThreadToList(OSThread *thread); +static void i_osRemoveThreadFromList(OSThread *thread); +static void i_osSleepAlarmCallback(void *arg); +static void i_osIdleThreadProc(void *); +void i_osSetSystemCallbackInSwitchThread(void *callback); -static void OSi_ExitThread_ArgSpecified(OSThread *thread, void *arg); -static void OSi_ExitThread(void *arg); -static void OSi_ExitThread_Destroy(void); +static void i_osExitThread_ArgSpecified(OSThread *thread, void *arg); +static void i_osExitThread(void *arg); +static void i_osExitThread_Destroy(void); #if defined(SDK_TCM_APPLY) && defined(SDK_ARM9) #include #endif -static void OSi_RescheduleThread(void); +static void i_osRescheduleThread(void); #ifdef SDK_THREAD_INFINITY /*---------------------------------------------------------------------------* - Name: OSi_GetUnusedThreadId + Name: i_osGetUnusedThreadId Description: get unused thread id @@ -130,16 +130,16 @@ static void OSi_RescheduleThread(void); Returns: thread id (0-0x7fffffff) which is never used. *---------------------------------------------------------------------------*/ -static int OSi_GetUnusedThreadId(void) +static int i_osGetUnusedThreadId(void) { - ++OSi_ThreadIdCount; - SDK_ASSERT(OSi_ThreadIdCount > 0); // overflow check - return OSi_ThreadIdCount; + ++i_osThreadIdCount; + SDK_ASSERT(i_osThreadIdCount > 0); // overflow check + return i_osThreadIdCount; } #endif /* ; */ /*---------------------------------------------------------------------------* - Name: OSi_InsertLinkToQueue + Name: i_osInsertLinkToQueue Description: insert thread to thread queue @@ -148,7 +148,7 @@ static int OSi_GetUnusedThreadId(void) Returns: None *---------------------------------------------------------------------------*/ -static void OSi_InsertLinkToQueue(OSThreadQueue *queue, OSThread *thread) +static void i_osInsertLinkToQueue(OSThreadQueue *queue, OSThread *thread) { OSThread *next = queue->head; @@ -198,7 +198,7 @@ static void OSi_InsertLinkToQueue(OSThreadQueue *queue, OSThread *thread) } /*---------------------------------------------------------------------------* - Name: OSi_RemoveLinkFromQueue + Name: i_osRemoveLinkFromQueue Description: remove head thread from thread queue @@ -206,7 +206,7 @@ static void OSi_InsertLinkToQueue(OSThreadQueue *queue, OSThread *thread) Returns: thread pointer which is removed *---------------------------------------------------------------------------*/ -static OSThread *OSi_RemoveLinkFromQueue(OSThreadQueue *queue) +static OSThread *i_osRemoveLinkFromQueue(OSThreadQueue *queue) { OSThread *t = queue->head; @@ -231,7 +231,7 @@ static OSThread *OSi_RemoveLinkFromQueue(OSThreadQueue *queue) } /*---------------------------------------------------------------------------* - Name: OSi_RemoveSpecifiedLinkFromQueue + Name: i_osRemoveSpecifiedLinkFromQueue Description: remove specified thread from thread queue @@ -239,7 +239,7 @@ static OSThread *OSi_RemoveLinkFromQueue(OSThreadQueue *queue) Returns: thread pointer which is removed *---------------------------------------------------------------------------*/ -static OSThread *OSi_RemoveSpecifiedLinkFromQueue(OSThreadQueue *queue, OSThread *thread) +static OSThread *i_osRemoveSpecifiedLinkFromQueue(OSThreadQueue *queue, OSThread *thread) { OSThread *t = queue->head; OSThread *next; @@ -283,7 +283,7 @@ static OSThread *OSi_RemoveSpecifiedLinkFromQueue(OSThreadQueue *queue, OSThread } /*---------------------------------------------------------------------------* - Name: OSi_RemoveMutexLinkFromQueue + Name: i_osRemoveMutexLinkFromQueue Description: remove mutex from mutex queue @@ -291,7 +291,7 @@ static OSThread *OSi_RemoveSpecifiedLinkFromQueue(OSThreadQueue *queue, OSThread Returns: mutex pointer which is removed *---------------------------------------------------------------------------*/ -OSMutex *OSi_RemoveMutexLinkFromQueue(OSMutexQueue * queue) +OSMutex *i_osRemoveMutexLinkFromQueue(OSMutexQueue * queue) { OSMutex *t = queue->head; @@ -315,7 +315,7 @@ OSMutex *OSi_RemoveMutexLinkFromQueue(OSMutexQueue * queue) } /*---------------------------------------------------------------------------* - Name: OSi_SetSystemCallbackInSwitchThread + Name: i_osSetSystemCallbackInSwitchThread Description: set system callback in switching thread @@ -323,14 +323,14 @@ OSMutex *OSi_RemoveMutexLinkFromQueue(OSMutexQueue * queue) Returns: None *---------------------------------------------------------------------------*/ -void OSi_SetSystemCallbackInSwitchThread(void *callback) +void i_osSetSystemCallbackInSwitchThread(void *callback) { - OSi_SystemCallbackInSwitchThread = callback; + i_osSystemCallbackInSwitchThread = callback; } #ifndef SDK_THREAD_INFINITY /*---------------------------------------------------------------------------* - Name: OSi_SearchFreeEntry + Name: i_osSearchFreeEntry Description: search free thread entry area @@ -339,13 +339,13 @@ void OSi_SetSystemCallbackInSwitchThread(void *callback) Returns: 0 - OS_THREAD_MAX_NUM-1 ... entry index -1 ... not found *---------------------------------------------------------------------------*/ -static int OSi_SearchFreeEntry(void) +static int i_osSearchFreeEntry(void) { int i; for (i = 0; i < OS_THREAD_MAX_NUM; i++) { - if (!OSi_ThreadInfo.entry[i]) + if (!i_osThreadInfo.entry[i]) { return i; } @@ -355,7 +355,7 @@ static int OSi_SearchFreeEntry(void) #endif /*---------------------------------------------------------------------------* - Name: OSi_InsertThreadToList + Name: i_osInsertThreadToList Description: insert thread to thread list which is arranged by priority @@ -363,9 +363,9 @@ static int OSi_SearchFreeEntry(void) Returns: None *---------------------------------------------------------------------------*/ -static void OSi_InsertThreadToList(OSThread *thread) +static void i_osInsertThreadToList(OSThread *thread) { - OSThread *t = OSi_ThreadInfo.list; + OSThread *t = i_osThreadInfo.list; OSThread *pre = NULL; while (t && t->priority < thread->priority) @@ -376,8 +376,8 @@ static void OSi_InsertThreadToList(OSThread *thread) if (!pre) { - thread->next = OSi_ThreadInfo.list; - OSi_ThreadInfo.list = thread; + thread->next = i_osThreadInfo.list; + i_osThreadInfo.list = thread; } else { @@ -387,7 +387,7 @@ static void OSi_InsertThreadToList(OSThread *thread) } /*---------------------------------------------------------------------------* - Name: OSi_RemoveThreadFromList + Name: i_osRemoveThreadFromList Description: remove thread from thread list @@ -395,9 +395,9 @@ static void OSi_InsertThreadToList(OSThread *thread) Returns: None *---------------------------------------------------------------------------*/ -static void OSi_RemoveThreadFromList(OSThread *thread) +static void i_osRemoveThreadFromList(OSThread *thread) { - OSThread *t = OSi_ThreadInfo.list; + OSThread *t = i_osThreadInfo.list; OSThread *pre = NULL; while (t && t != thread) @@ -410,7 +410,7 @@ static void OSi_RemoveThreadFromList(OSThread *thread) if (!pre) { - OSi_ThreadInfo.list = thread->next; + i_osThreadInfo.list = thread->next; } else { @@ -419,7 +419,7 @@ static void OSi_RemoveThreadFromList(OSThread *thread) } /*---------------------------------------------------------------------------* - Name: OSi_RescheduleThread + Name: i_osRescheduleThread Description: Switch to the runnable thread highest priority without interrupts disabled. @@ -428,12 +428,12 @@ static void OSi_RemoveThreadFromList(OSThread *thread) Returns: None or Never return *---------------------------------------------------------------------------*/ -static void OSi_RescheduleThread(void) +static void i_osRescheduleThread(void) { //---- if scheduler is set to be disabled, do nothing. - if (OSi_RescheduleCount <= 0) + if (i_osRescheduleCount <= 0) { - OSThreadInfo *info = &OSi_ThreadInfo; + OSThreadInfo *info = &i_osThreadInfo; if (info->irqDepth > 0 || osGetProcMode() == OS_PROCMODE_IRQ) { // If in IRQ, do rescheduling at end of IRQ handler @@ -442,7 +442,7 @@ static void OSi_RescheduleThread(void) else { OSThread *currentThread, *nextThread; - currentThread = OSi_GetCurrentThread(); + currentThread = i_osGetCurrentThread(); nextThread = osSelectThread(); if (currentThread == nextThread || !nextThread) // maybe nextThread != NULL @@ -457,9 +457,9 @@ static void OSi_RescheduleThread(void) } //---- call thread switch callback for system - if (OSi_SystemCallbackInSwitchThread) + if (i_osSystemCallbackInSwitchThread) { - ((OSSwitchThreadCallback)OSi_SystemCallbackInSwitchThread) (currentThread, + ((OSSwitchThreadCallback)i_osSystemCallbackInSwitchThread) (currentThread, nextThread); } @@ -493,41 +493,41 @@ void osInitThread(void) int i; #endif - if (OSi_IsThreadInitialized) + if (i_osIsThreadInitialized) { return; } - OSi_IsThreadInitialized = TRUE; + i_osIsThreadInitialized = TRUE; #ifndef SDK_THREAD_INFINITY //---- Set thread info for (i = 0; i < OS_THREAD_MAX_NUM; i++) { - OSi_ThreadInfo.entry[i] = NULL; + i_osThreadInfo.entry[i] = NULL; } #endif //---- set pointer to current thread buffer // (for quick reference) - OSi_CurrentThreadPtr = &(OSi_ThreadInfo.current); + i_osCurrentThreadPtr = &(i_osThreadInfo.current); //---- Setup launcher thread - OSi_LauncherThread.priority = OS_THREAD_LAUNCHER_PRIORITY; - OSi_LauncherThread.id = 0; - OSi_LauncherThread.state = OS_THREAD_STATE_READY; - OSi_LauncherThread.next = NULL; + i_osLauncherThread.priority = OS_THREAD_LAUNCHER_PRIORITY; + i_osLauncherThread.id = 0; + i_osLauncherThread.state = OS_THREAD_STATE_READY; + i_osLauncherThread.next = NULL; //---- clear profile pointer - OSi_LauncherThread.profiler = NULL; + i_osLauncherThread.profiler = NULL; //---- clear thread entry and listPtr #ifndef SDK_THREAD_INFINITY - OSi_ThreadInfo.entry[0] = &OSi_LauncherThread; + i_osThreadInfo.entry[0] = &i_osLauncherThread; #endif - OSi_ThreadInfo.list = &OSi_LauncherThread; + i_osThreadInfo.list = &i_osLauncherThread; //---- let launch thread be current - osSetCurrentThread(&OSi_LauncherThread); + osSetCurrentThread(&i_osLauncherThread); //---- StackLo stackLo = (OSi_SYS_STACKSIZE <= 0) ? @@ -537,33 +537,33 @@ void osInitThread(void) && (u32)stackLo <= (u32)OSi_LAUNCHER_STACK_HI_MAX); //---- set Stack Bottom & Top - OSi_LauncherThread.stackBottom = (u32)OSi_LAUNCHER_STACK_BOTTOM; - OSi_LauncherThread.stackTop = (u32)stackLo; - OSi_LauncherThread.stackWarningOffset = 0; + i_osLauncherThread.stackBottom = (u32)OSi_LAUNCHER_STACK_BOTTOM; + i_osLauncherThread.stackTop = (u32)stackLo; + i_osLauncherThread.stackWarningOffset = 0; //---- Set Stack CheckNumber - *(u32 *)(OSi_LauncherThread.stackBottom - sizeof(u32)*2) = OSi_STACK_CHECKNUM_BOTTOM; - *(u32 *)OSi_LauncherThread.stackTop = OSi_STACK_CHECKNUM_TOP; + *(u32 *)(i_osLauncherThread.stackBottom - sizeof(u32)*2) = OSi_STACK_CHECKNUM_BOTTOM; + *(u32 *)i_osLauncherThread.stackTop = OSi_STACK_CHECKNUM_TOP; //---- clear join queue - osInitThreadQueue(&OSi_LauncherThread.joinQueue); + osInitThreadQueue(&i_osLauncherThread.joinQueue); #ifndef SDK_THREAD_INFINITY //---- max number of thread - OSi_ThreadInfo.max_entry = OS_THREAD_MAX_NUM; + i_osThreadInfo.max_entry = OS_THREAD_MAX_NUM; #endif //---- around IRQ - OSi_ThreadInfo.isNeedRescheduling = FALSE; - OSi_ThreadInfo.irqDepth = 0; + i_osThreadInfo.isNeedRescheduling = FALSE; + i_osThreadInfo.irqDepth = 0; SDK_ASSERTMSG(OSi_IRQ_STACKSIZE > 0, "IRQ STACKSIZE must be >0"); //---- store thread info pointer #if 0 // for ISD #ifdef SDK_ARM9 - osGetSystemWork()->threadinfo_mainp = &OSi_ThreadInfo; + osGetSystemWork()->threadinfo_mainp = &i_osThreadInfo; #else - osGetSystemWork()->threadinfo_subp = &OSi_ThreadInfo; + osGetSystemWork()->threadinfo_subp = &i_osThreadInfo; #endif #endif @@ -571,14 +571,14 @@ void osInitThread(void) (void)osSetSwitchThreadCallback(NULL); //---- idle thread - osCreateThread(&OSi_IdleThread, - OSi_IdleThreadProc, + osCreateThread(&i_osIdleThread, + i_osIdleThreadProc, (void *)NULL, - OSi_IdleThreadStack + OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32), + i_osIdleThreadStack + OSi_IDLE_THREAD_STACK_SIZE / sizeof(u32), OSi_IDLE_THREAD_STACK_SIZE, OS_THREAD_PRIORITY_MAX /*pseudo. change at next line. */ ); - OSi_IdleThread.priority = OS_THREAD_PRIORITY_MAX + 1; // lower priority than the lowest (=OS_THREAD_PRIORITY_MAX) - OSi_IdleThread.state = OS_THREAD_STATE_READY; + i_osIdleThread.priority = OS_THREAD_PRIORITY_MAX + 1; // lower priority than the lowest (=OS_THREAD_PRIORITY_MAX) + i_osIdleThread.state = OS_THREAD_STATE_READY; } /*---------------------------------------------------------------------------* @@ -593,9 +593,9 @@ void osInitThread(void) #include asm BOOL osIsThreadAvailable( void ) { - INASM_EXTERN( OSi_IsThreadInitialized ) + INASM_EXTERN( i_osIsThreadInitialized ) - ldr r0, =OSi_IsThreadInitialized + ldr r0, =i_osIsThreadInitialized ldr r0, [r0, #0] bx lr } @@ -623,7 +623,7 @@ void osCreateThread(OSThread *thread, OSIntrMode enable; int index; - SDK_ASSERTMSG(OSi_GetCurrentThread(), "thread system were not initialized"); + SDK_ASSERTMSG(i_osGetCurrentThread(), "thread system were not initialized"); SDK_ASSERTMSG(OS_THREAD_PRIORITY_MIN <= prio && prio <= OS_THREAD_PRIORITY_MAX, "invalid priority"); SDK_ASSERTMSG(stackSize % STACK_ALIGN == 0, "stack size must be aligned by %d", STACK_ALIGN); @@ -633,14 +633,14 @@ void osCreateThread(OSThread *thread, #ifndef SDK_THREAD_INFINITY //---- search free entry - if ((index = OSi_SearchFreeEntry()) < 0) + if ((index = i_osSearchFreeEntry()) < 0) { SDK_ASSERTMSG(index >= 0, "osCreateThread: thread entry not allocated"); (void)osRestoreInterrupts(enable); return; } #else - index = OSi_GetUnusedThreadId(); + index = i_osGetUnusedThreadId(); #endif //---- setup thread @@ -653,9 +653,9 @@ void osCreateThread(OSThread *thread, //---- set thread entry and listPtr #ifndef SDK_THREAD_INFINITY - OSi_ThreadInfo.entry[index] = thread; + i_osThreadInfo.entry[index] = thread; #endif - OSi_InsertThreadToList(thread); + i_osInsertThreadToList(thread); //---- set Stack Bottom & Top thread->stackBottom = (u32)stack; @@ -723,22 +723,22 @@ void osExitThread(void) (void)osDisableInterrupts(); #ifdef SDK_THREAD_INFINITY - OSi_ExitThread_ArgSpecified(osGetCurrentThread(), 0); + i_osExitThread_ArgSpecified(osGetCurrentThread(), 0); #else - OSi_ExitThread_Destroy(); + i_osExitThread_Destroy(); #endif } #ifdef SDK_THREAD_INFINITY // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// デストラクタスタックを考慮する OSi_ExitThread +// デストラクタスタックを考慮する i_osExitThread // 割込み禁止状態で呼び出すこと -static void OSi_ExitThread_ArgSpecified(OSThread *thread, void *arg) +static void i_osExitThread_ArgSpecified(OSThread *thread, void *arg) { - if (OSi_StackForDestructor) + if (i_osStackForDestructor) { - osInitContext(&thread->context, (u32)OSi_ExitThread, (u32)OSi_StackForDestructor); + osInitContext(&thread->context, (u32)i_osExitThread, (u32)i_osStackForDestructor); thread->context.r[0] = (u32)arg; thread->context.cpsr |= HW_PSR_IRQ_DISABLE; thread->state = OS_THREAD_STATE_READY; @@ -747,7 +747,7 @@ static void OSi_ExitThread_ArgSpecified(OSThread *thread, void *arg) } else { - OSi_ExitThread(arg); + i_osExitThread(arg); // Never Returns } } @@ -758,9 +758,9 @@ static void OSi_ExitThread_ArgSpecified(OSThread *thread, void *arg) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // osKillThread において参照されるコンテキストスイッチ先 // 割り込み禁止状態で呼び出すこと -static void OSi_ExitThread(void *arg) +static void i_osExitThread(void *arg) { - OSThread *currentThread = OSi_GetCurrentThread(); + OSThread *currentThread = i_osGetCurrentThread(); OSThreadDestructor destructor; SDK_ASSERT(currentThread); @@ -774,16 +774,16 @@ static void OSi_ExitThread(void *arg) (void)osDisableInterrupts(); // 再び割り込み禁止へ } - OSi_ExitThread_Destroy(); // Never return + i_osExitThread_Destroy(); // Never return } #endif // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // osDestroyThread からカレントスレッドを destroy するときに呼び出される // 割り込み禁止状態で呼び出すこと -static void OSi_ExitThread_Destroy(void) +static void i_osExitThread_Destroy(void) { - OSThread *currentThread = OSi_GetCurrentThread(); + OSThread *currentThread = i_osGetCurrentThread(); SDK_ASSERT(currentThread); #ifdef SDK_THREAD_INFINITY @@ -792,25 +792,25 @@ static void OSi_ExitThread_Destroy(void) #ifndef SDK_THREAD_INFINITY //---- current thread check - SDK_ASSERT(OSi_ThreadInfo.entry[currentThread->id] == currentThread); + SDK_ASSERT(i_osThreadInfo.entry[currentThread->id] == currentThread); #endif //---- Release all the locked mutexes by current thread - OSi_UnlockAllMutex(currentThread); + i_osUnlockAllMutex(currentThread); //---- remove from thread queue list if (currentThread->queue) { - (void)OSi_RemoveSpecifiedLinkFromQueue(currentThread->queue, currentThread); + (void)i_osRemoveSpecifiedLinkFromQueue(currentThread->queue, currentThread); } //---- remove from thread list - OSi_RemoveThreadFromList(currentThread); + i_osRemoveThreadFromList(currentThread); //---- delete this thread #ifndef SDK_THREAD_INFINITY - OSi_ThreadInfo.entry[currentThread->id] = NULL; + i_osThreadInfo.entry[currentThread->id] = NULL; #endif currentThread->state = OS_THREAD_STATE_TERMINATED; @@ -877,7 +877,7 @@ void osDestroyThread(OSThread *thread) //---- check current thread if (osGetCurrentThread() == thread) { - OSi_ExitThread_Destroy(); + i_osExitThread_Destroy(); // not reached } @@ -886,23 +886,23 @@ void osDestroyThread(OSThread *thread) #endif //---- Release all the locked mutexed by specified thread - OSi_UnlockAllMutex(thread); + i_osUnlockAllMutex(thread); //---- cancel alarm for sleep - OSi_CancelThreadAlarmForSleep(thread); + i_osCancelThreadAlarmForSleep(thread); //---- remove from thread queue list if (thread->queue) { - (void)OSi_RemoveSpecifiedLinkFromQueue(thread->queue, thread); + (void)i_osRemoveSpecifiedLinkFromQueue(thread->queue, thread); } //---- remove from thread list - OSi_RemoveThreadFromList(thread); + i_osRemoveThreadFromList(thread); //---- delete thread #ifndef SDK_THREAD_INFINITY - OSi_ThreadInfo.entry[thread->id] = NULL; + i_osThreadInfo.entry[thread->id] = NULL; #endif thread->state = OS_THREAD_STATE_TERMINATED; @@ -929,15 +929,15 @@ void osDestroyThread(OSThread *thread) *---------------------------------------------------------------------------*/ #ifdef SDK_THREAD_INFINITY // TESTEE -static inline void OSi_KillThreadWithPriority(OSThread *thread, void *arg, u32 prio); -static inline void OSi_KillThreadWithPriority(OSThread *thread, void *arg, u32 prio) +static inline void i_osKillThreadWithPriority(OSThread *thread, void *arg, u32 prio); +static inline void i_osKillThreadWithPriority(OSThread *thread, void *arg, u32 prio) { SDK_ASSERT(thread); { - u32 stack = (OSi_StackForDestructor) ? (u32)OSi_StackForDestructor : thread->stackBottom - sizeof(u32)*2; // minus for stack CheckNumber and padding + u32 stack = (i_osStackForDestructor) ? (u32)i_osStackForDestructor : thread->stackBottom - sizeof(u32)*2; // minus for stack CheckNumber and padding - osInitContext(&thread->context, (u32)OSi_ExitThread, stack); + osInitContext(&thread->context, (u32)i_osExitThread, stack); } thread->context.r[0] = (u32)arg; thread->context.cpsr |= HW_PSR_IRQ_DISABLE; // デストラクタ内では IRQ 割り込みを禁止する @@ -961,16 +961,16 @@ void osKillThreadWithPriority(OSThread *thread, void *arg, u32 prio) if (thread == osGetCurrentThread()) { - OSi_ExitThread_ArgSpecified(thread, arg); + i_osExitThread_ArgSpecified(thread, arg); // Never returns } //---- cancel alarm for sleep - OSi_CancelThreadAlarmForSleep(thread); + i_osCancelThreadAlarmForSleep(thread); - OSi_KillThreadWithPriority(thread, arg, prio); + i_osKillThreadWithPriority(thread, arg, prio); - OSi_RescheduleThread(); + i_osRescheduleThread(); (void)osRestoreInterrupts(enabled); } @@ -989,10 +989,10 @@ void UTEST_osKillThread_1(void) t->stackBottom = 0x6789abcd; t->state = OS_THREAD_STATE_TERMINATED; - OSi_KillThreadWithPriority(t, (void *)0x12345678, 16); + i_osKillThreadWithPriority(t, (void *)0x12345678, 16); // コンテクスト内の主要レジスタチェック - UT_AssertEq(t->context.pc_plus4, (u32)OSi_ExitThread + 4); // osExitThread + UT_AssertEq(t->context.pc_plus4, (u32)i_osExitThread + 4); // osExitThread UT_AssertEq(t->context.r[0], (u32)0x12345678); // arg flag = ((u32)osExitThread & 1) ? (u32)HW_PSR_THUMB_STATE : (u32)HW_PSR_ARM_STATE; UT_AssertEq(t->context.cpsr, (u32)HW_PSR_IRQ_DISABLE | HW_PSR_SYS_MODE | flag); @@ -1000,7 +1000,7 @@ void UTEST_osKillThread_1(void) // ステートチェック UT_AssertEq(t->state, OS_THREAD_STATE_READY); - UT_AssertAsserted(OSi_KillThreadWithPriority(0, 0, 16)); + UT_AssertAsserted(i_osKillThreadWithPriority(0, 0, 16)); } // test2 @@ -1055,7 +1055,7 @@ void UTEST_osKillThread_2(void) #endif // ifdef SDK_THREAD_INFINITY /*---------------------------------------------------------------------------* - Name: OSi_CancelThreadAlarmForSleep + Name: i_osCancelThreadAlarmForSleep Description: Cancel alarm used to sleep thread. If sleeping alarm is not set, do nothing. @@ -1064,7 +1064,7 @@ void UTEST_osKillThread_2(void) Returns: None *---------------------------------------------------------------------------*/ -static void OSi_CancelThreadAlarmForSleep(OSThread *thread) +static void i_osCancelThreadAlarmForSleep(OSThread *thread) { OSAlarm *alarm = thread->alarmForSleep; @@ -1154,11 +1154,11 @@ void osSleepThreadDirect(OSThread *thread, OSThreadQueue *queue) *queue |= (OSThreadQueue)(1UL << thread->id); #else thread->queue = queue; - OSi_InsertLinkToQueue(queue, thread); + i_osInsertLinkToQueue(queue, thread); #endif } thread->state = OS_THREAD_STATE_WAITING; - OSi_RescheduleThread(); + i_osRescheduleThread(); } (void)osRestoreInterrupts(bak_intr); } @@ -1181,7 +1181,7 @@ void osSleepThread(OSThreadQueue *queue) enable = osDisableInterrupts(); #ifndef SDK_THREAD_INFINITY { - currentThread = OSi_GetCurrentThread(); + currentThread = i_osGetCurrentThread(); SDK_ASSERT(currentThread); if (queue) @@ -1190,21 +1190,21 @@ void osSleepThread(OSThreadQueue *queue) } currentThread->state = OS_THREAD_STATE_WAITING; - OSi_RescheduleThread(); + i_osRescheduleThread(); } #else { - currentThread = OSi_GetCurrentThread(); + currentThread = i_osGetCurrentThread(); SDK_ASSERT(currentThread); if (queue) { currentThread->queue = queue; - OSi_InsertLinkToQueue(queue, currentThread); + i_osInsertLinkToQueue(queue, currentThread); } currentThread->state = OS_THREAD_STATE_WAITING; - OSi_RescheduleThread(); + i_osRescheduleThread(); } #endif (void)osRestoreInterrupts(enable); @@ -1235,7 +1235,7 @@ void osWakeupThread(OSThreadQueue *queue) if (mask) { //---- wakeup threads - OSThread *t = OSi_ThreadInfo.list; + OSThread *t = i_osThreadInfo.list; while (t) { if (mask & (1UL << t->id)) @@ -1247,14 +1247,14 @@ void osWakeupThread(OSThreadQueue *queue) } osInitThreadQueue(queue); - OSi_RescheduleThread(); + i_osRescheduleThread(); } #else if (queue->head) { while (queue->head) { - OSThread *thread = OSi_RemoveLinkFromQueue(queue); + OSThread *thread = i_osRemoveLinkFromQueue(queue); thread->state = OS_THREAD_STATE_READY; thread->queue = NULL; @@ -1262,7 +1262,7 @@ void osWakeupThread(OSThreadQueue *queue) } osInitThreadQueue(queue); - OSi_RescheduleThread(); + i_osRescheduleThread(); } #endif @@ -1288,7 +1288,7 @@ void osWakeupThreadDirect(OSThread *thread) enable = osDisableInterrupts(); { thread->state = OS_THREAD_STATE_READY; - OSi_RescheduleThread(); + i_osRescheduleThread(); } (void)osRestoreInterrupts(enable); @@ -1307,7 +1307,7 @@ void osWakeupThreadDirect(OSThread *thread) *---------------------------------------------------------------------------*/ OSThread *osSelectThread(void) { - OSThread *t = OSi_ThreadInfo.list; + OSThread *t = i_osThreadInfo.list; while (t && !osIsThreadRunnable(t)) { @@ -1329,7 +1329,7 @@ OSThread *osSelectThread(void) void osRescheduleThread(void) { OSIntrMode bak_intr = osDisableInterrupts(); - OSi_RescheduleThread(); + i_osRescheduleThread(); (void)osRestoreInterrupts(bak_intr); } @@ -1353,7 +1353,7 @@ void osYieldThread(void) OSIntrMode enable = osDisableInterrupts(); { - OSThread *t = OSi_ThreadInfo.list; + OSThread *t = i_osThreadInfo.list; OSThread *tPre = NULL; while (t) @@ -1384,7 +1384,7 @@ void osYieldThread(void) //---- remove thread from list if (!pre) { - OSi_ThreadInfo.list = current->next; + i_osThreadInfo.list = current->next; } else { @@ -1396,7 +1396,7 @@ void osYieldThread(void) lastThread->next = current; //---- re-schedule - OSi_RescheduleThread(); + i_osRescheduleThread(); (void)osRestoreInterrupts(enable); } @@ -1418,13 +1418,13 @@ void osDumpThreadList(void) int i; #endif - osPrintf("thread list top %08x\n", OSi_ThreadInfo.list); + osPrintf("thread list top %08x\n", i_osThreadInfo.list); #ifndef SDK_THREAD_INFINITY osPrintf("No: address prio next\n"); for (i = 0; i < OS_THREAD_MAX_NUM; i++) { - OSThread *thread = OSi_ThreadInfo.entry[i]; + OSThread *thread = i_osThreadInfo.entry[i]; osPrintf("%02d: %08x %5d %08x\n", i, thread, (thread) ? thread->priority : 0, (thread) ? thread->next : 0); } @@ -1432,7 +1432,7 @@ void osDumpThreadList(void) // osPrintf("Id: address prio next\n"); osPrintf("Id: address prio next st queue.h queue.t link.p link.n\n"); { - OSThread *thread = OSi_ThreadInfo.list; + OSThread *thread = i_osThreadInfo.list; while (thread) { // osPrintf("%02d: %08x %5d %08x\n", thread->id, thread, thread->priority, thread->next ); @@ -1468,13 +1468,13 @@ int osGetNumberOfThread(void) for (i = 0; i < OS_THREAD_MAX_NUM; i++) { - if (OSi_ThreadInfo.entry[i]) + if (i_osThreadInfo.entry[i]) { threads++; } } #else - OSThread *thread = OSi_ThreadInfo.list; + OSThread *thread = i_osThreadInfo.list; while (thread) { threads++; @@ -1525,7 +1525,7 @@ OSStackStatus osGetStackStatus(const OSThread *thread) } /*---------------------------------------------------------------------------* - Name: OSi_CheckStack + Name: i_osCheckStack Description: check thread stack. check each CheckNUM. if changed, display warning and halt. @@ -1537,13 +1537,13 @@ OSStackStatus osGetStackStatus(const OSThread *thread) Returns: None ( if error occurred, never return ) *---------------------------------------------------------------------------*/ -static char *OSi_CheckStack_mesg[] = { +static char *i_osCheckStack_mesg[] = { "overflow", "about to overflow", "underflow" }; #ifndef SDK_FINALROM #ifndef SDK_NO_MESSAGE -void OSi_CheckStack(const char *file, int line, const OSThread *thread) +void i_osCheckStack(const char *file, int line, const OSThread *thread) { OSStackStatus st = osGetStackStatus(thread); @@ -1552,10 +1552,10 @@ void OSi_CheckStack(const char *file, int line, const OSThread *thread) return; } - OSi_Panic(file, line, " stack %x(id:%d) %s.\nstack area: %08x-%08x, warning offset: %x", + i_osPanic(file, line, " stack %x(id:%d) %s.\nstack area: %08x-%08x, warning offset: %x", thread, thread->id, - OSi_CheckStack_mesg[(int)st - 1], + i_osCheckStack_mesg[(int)st - 1], thread->stackTop, thread->stackBottom, thread->stackWarningOffset); // Never return } @@ -1563,7 +1563,7 @@ void OSi_CheckStack(const char *file, int line, const OSThread *thread) #endif /*---------------------------------------------------------------------------* - Name: OSi_GetSystemStackPointer + Name: i_osGetSystemStackPointer Description: Get system mode stack pointer at svc/irq mode @@ -1571,14 +1571,14 @@ void OSi_CheckStack(const char *file, int line, const OSThread *thread) Returns: Stack Pointer *---------------------------------------------------------------------------*/ -static u32 OSi_SystemStackBuffer; +static u32 i_osSystemStackBuffer; #include -asm u32 OSi_GetSystemStackPointer( void ) +asm u32 i_osGetSystemStackPointer( void ) { - INASM_EXTERN( OSi_SystemStackBuffer ) + INASM_EXTERN( i_osSystemStackBuffer ) - ldr r0, =OSi_SystemStackBuffer + ldr r0, =i_osSystemStackBuffer stmia r0, { sp }^ ldr r0, [ r0 ] bx lr @@ -1586,7 +1586,7 @@ asm u32 OSi_GetSystemStackPointer( void ) #include /*---------------------------------------------------------------------------* - Name: OSi_GetCurrentStackPointer + Name: i_osGetCurrentStackPointer Description: Get current mode stack pointer @@ -1594,7 +1594,7 @@ asm u32 OSi_GetSystemStackPointer( void ) Returns: Stack Pointer *---------------------------------------------------------------------------*/ -asm u32 OSi_GetCurrentStackPointer( void ) +asm u32 i_osGetCurrentStackPointer( void ) { mov r0, sp bx lr @@ -1638,13 +1638,13 @@ void osSetThreadStackWarningOffset(OSThread *thread, u32 offset) *---------------------------------------------------------------------------*/ BOOL osSetThreadPriority(OSThread *thread, u32 prio) { - OSThread *t = OSi_ThreadInfo.list; + OSThread *t = i_osThreadInfo.list; OSThread *pre = NULL; OSIntrMode enable; SDK_ASSERTMSG(OS_THREAD_PRIORITY_MIN <= prio && prio <= OS_THREAD_PRIORITY_MAX, "invalid priority"); - SDK_ASSERTMSG(thread != &OSi_IdleThread, "cannot change idle thread priority."); + SDK_ASSERTMSG(thread != &i_osIdleThread, "cannot change idle thread priority."); enable = osDisableInterrupts(); @@ -1655,7 +1655,7 @@ BOOL osSetThreadPriority(OSThread *thread, u32 prio) } //---- thread not found or thread is idle - if (!t || t == &OSi_IdleThread) + if (!t || t == &i_osIdleThread) { (void)osRestoreInterrupts(enable); return FALSE; @@ -1666,7 +1666,7 @@ BOOL osSetThreadPriority(OSThread *thread, u32 prio) //---- remove thread from list if (!pre) { - OSi_ThreadInfo.list = thread->next; + i_osThreadInfo.list = thread->next; } else { @@ -1675,10 +1675,10 @@ BOOL osSetThreadPriority(OSThread *thread, u32 prio) //---- set priority and insert proper position thread->priority = prio; - OSi_InsertThreadToList(thread); + i_osInsertThreadToList(thread); //---- re-schedule - OSi_RescheduleThread(); + i_osRescheduleThread(); } (void)osRestoreInterrupts(enable); @@ -1718,17 +1718,17 @@ void osSleep(u32 msec) SDK_ASSERTMSG(osIsTickAvailable() && osIsAlarmAvailable(), "osSleep: need to start Tick and Alarm beforehand."); - SDK_ASSERTMSG(OSi_IsThreadInitialized, "osSleep: thread system not initialized."); + SDK_ASSERTMSG(i_osIsThreadInitialized, "osSleep: thread system not initialized."); osCreateAlarm(&alarm); { - OSThread *volatile p_thread = OSi_GetCurrentThread(); + OSThread *volatile p_thread = i_osGetCurrentThread(); OSIntrMode bak_cpsr = osDisableInterrupts(); // ---- remember alarm p_thread->alarmForSleep = &alarm; - osSetAlarm(&alarm, OS_MSEC_TO_TICK(msec), &OSi_SleepAlarmCallback, + osSetAlarm(&alarm, OS_MSEC_TO_TICK(msec), &i_osSleepAlarmCallback, (void *)&p_thread); while (p_thread != NULL) { @@ -1739,7 +1739,7 @@ void osSleep(u32 msec) } //---------------- callback to wakeup sleeping thread -static void OSi_SleepAlarmCallback(void *arg) +static void i_osSleepAlarmCallback(void *arg) { OSThread **pp_thread = (OSThread **)arg; OSThread *p_thread = *pp_thread; @@ -1767,15 +1767,15 @@ OSSwitchThreadCallback osSetSwitchThreadCallback(OSSwitchThreadCallback callback OSIntrMode enabled; enabled = osDisableInterrupts(); - prev = (OSSwitchThreadCallback)OSi_ThreadInfo.switchCallback; - OSi_ThreadInfo.switchCallback = (void*)callback; + prev = (OSSwitchThreadCallback)i_osThreadInfo.switchCallback; + i_osThreadInfo.switchCallback = (void*)callback; (void)osRestoreInterrupts(enabled); return prev; } /*---------------------------------------------------------------------------* - Name: OSi_IdleThreadProc + Name: i_osIdleThreadProc Description: procedure of idle thread which system creates @@ -1783,7 +1783,7 @@ OSSwitchThreadCallback osSetSwitchThreadCallback(OSSwitchThreadCallback callback Returns: None (never return) *---------------------------------------------------------------------------*/ -static void OSi_IdleThreadProc(void *arg) +static void i_osIdleThreadProc(void *arg) { (void)osEnableInterrupts(); while (1) @@ -1794,7 +1794,7 @@ static void OSi_IdleThreadProc(void *arg) } /*---------------------------------------------------------------------------* - Name: OSi_GetIdleThread + Name: i_osGetIdleThread Description: get pointer to idle thread structure @@ -1802,12 +1802,12 @@ static void OSi_IdleThreadProc(void *arg) Returns: pointer to idle thread structure *---------------------------------------------------------------------------*/ -OSThread *OSi_GetIdleThread(void) +OSThread *i_osGetIdleThread(void) { OSThread *t = NULL; - if (OSi_IsThreadInitialized) + if (i_osIsThreadInitialized) { - t = &OSi_IdleThread; + t = &i_osIdleThread; } return t; } @@ -1827,9 +1827,9 @@ u32 osDisableScheduler(void) OSIntrMode enabled = osDisableInterrupts(); u32 count = 0; - if (OSi_RescheduleCount < (u32)(0 - 1) /* u32 max value -1 */ ) + if (i_osRescheduleCount < (u32)(0 - 1) /* u32 max value -1 */ ) { - count = OSi_RescheduleCount++; + count = i_osRescheduleCount++; } (void)osRestoreInterrupts(enabled); @@ -1851,9 +1851,9 @@ u32 osEnableScheduler(void) OSIntrMode enabled = osDisableInterrupts(); u32 count = 0; - if (OSi_RescheduleCount > 0) + if (i_osRescheduleCount > 0) { - count = OSi_RescheduleCount--; + count = i_osRescheduleCount--; } (void)osRestoreInterrupts(enabled); @@ -1873,7 +1873,7 @@ u32 osEnableScheduler(void) OSThread *osGetThread(u32 id) { OSThread *retval = NULL; - OSThread *t = OSi_ThreadInfo.list; + OSThread *t = i_osThreadInfo.list; while (t) { @@ -1957,7 +1957,7 @@ void *osGetThreadParameter(const OSThread *thread) /*---------------------------------------------------------------------------* - Name: OSi_SetSystemErrno + Name: i_osSetSystemErrno Description: set system error number. @@ -1966,14 +1966,14 @@ void *osGetThreadParameter(const OSThread *thread) Returns: None *---------------------------------------------------------------------------*/ -void OSi_SetSystemErrno(OSThread *thread, int errno) +void i_osSetSystemErrno(OSThread *thread, int errno) { SDK_ASSERT(thread); thread->systemErrno = errno; } /*---------------------------------------------------------------------------* - Name: OSi_GetSystemErrno + Name: i_osGetSystemErrno Description: get system error number. @@ -1981,7 +1981,7 @@ void OSi_SetSystemErrno(OSThread *thread, int errno) Returns: error number *---------------------------------------------------------------------------*/ -int OSi_GetSystemErrno(const OSThread *thread) +int i_osGetSystemErrno(const OSThread *thread) { SDK_ASSERT(thread); return thread->systemErrno; @@ -1998,8 +1998,8 @@ int OSi_GetSystemErrno(const OSThread *thread) *---------------------------------------------------------------------------*/ int osGetErrno(void) { - OSThread *thread = OSi_GetCurrentThread(); - return OSi_GetSystemErrno(thread); + OSThread *thread = i_osGetCurrentThread(); + return i_osGetSystemErrno(thread); } #endif @@ -2015,7 +2015,7 @@ int osGetErrno(void) BOOL osIsThreadInList(const OSThread *thread) { BOOL r = FALSE; - OSThread *t = OSi_ThreadInfo.list; + OSThread *t = i_osThreadInfo.list; OSIntrMode enabled = osDisableInterrupts(); while (t) @@ -2048,7 +2048,7 @@ void osSetThreadDestructorStack(void *stack) SDK_ASSERT(stack); SDK_ASSERT((u32)stack % STACK_ALIGN == 0); - OSi_StackForDestructor = stack; + i_osStackForDestructor = stack; } //================================================================================ diff --git a/trunk/bootrom/include/brom/os/common/mutex.h b/trunk/bootrom/include/brom/os/common/mutex.h index de82dd7..94e803e 100644 --- a/trunk/bootrom/include/brom/os/common/mutex.h +++ b/trunk/bootrom/include/brom/os/common/mutex.h @@ -57,38 +57,38 @@ struct OSMutex //#pragma warn_padding reset -static inline void OS_SetMutexCount( OSMutex* mutex, s32 count ) +static inline void osSetMutexCount( OSMutex* mutex, s32 count ) { mutex->count = (s32)( (mutex->count & OSi_MUTEX_TYPE_MASK) | (count & OSi_MUTEX_COUNT_MASK) ); } -static inline s32 OS_GetMutexCount( OSMutex* mutex ) +static inline s32 osGetMutexCount( OSMutex* mutex ) { return (s32)( mutex->count & OSi_MUTEX_COUNT_MASK); } -static inline void OS_IncreaseMutexCount( OSMutex* mutex ) +static inline void osIncreaseMutexCount( OSMutex* mutex ) { u32 type = (u32)(mutex->count & OSi_MUTEX_TYPE_MASK); mutex->count ++; mutex->count = (s32)( type | (mutex->count & OSi_MUTEX_COUNT_MASK) ); } -static inline void OS_DecreaseMutexCount( OSMutex* mutex ) +static inline void osDecreaseMutexCount( OSMutex* mutex ) { u32 type = (u32)(mutex->count & OSi_MUTEX_TYPE_MASK); mutex->count --; mutex->count = (s32)( type | (mutex->count & OSi_MUTEX_COUNT_MASK) ); } -static inline void OS_SetMutexType( OSMutex* mutex, u32 type ) +static inline void osSetMutexType( OSMutex* mutex, u32 type ) { mutex->count = (s32)( type | (mutex->count & OSi_MUTEX_COUNT_MASK) ); } -static inline u32 OS_GetMutexType( OSMutex* mutex ) +static inline u32 osGetMutexType( OSMutex* mutex ) { return (u32)( mutex->count & OSi_MUTEX_TYPE_MASK ); } /*---------------------------------------------------------------------------* - Name: OS_InitMutex + Name: osInitMutex Description: initialize mutex @@ -97,10 +97,10 @@ static inline u32 OS_GetMutexType( OSMutex* mutex ) Returns: None *---------------------------------------------------------------------------*/ -void OS_InitMutex(OSMutex *mutex); +void osInitMutex(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_LockMutex + Name: osLockMutex Description: lock mutex @@ -108,10 +108,10 @@ void OS_InitMutex(OSMutex *mutex); Returns: None *---------------------------------------------------------------------------*/ -void OS_LockMutex(OSMutex *mutex); +void osLockMutex(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_UnlockMutex + Name: osUnlockMutex Description: unlock mutex @@ -119,10 +119,10 @@ void OS_LockMutex(OSMutex *mutex); Returns: None *---------------------------------------------------------------------------*/ -void OS_UnlockMutex(OSMutex *mutex); +void osUnlockMutex(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_TryLockMutex + Name: osTryLockMutex Description: try to lock mutex @@ -130,10 +130,10 @@ void OS_UnlockMutex(OSMutex *mutex); Returns: True if lock *---------------------------------------------------------------------------*/ -BOOL OS_TryLockMutex(OSMutex *mutex); +BOOL osTryLockMutex(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OSi_UnlockAllMutex + Name: i_osUnlockAllMutex Description: unlocks all the mutexes locked by the thread @@ -141,11 +141,11 @@ BOOL OS_TryLockMutex(OSMutex *mutex); Returns: None. *---------------------------------------------------------------------------*/ -void OSi_UnlockAllMutex(OSThread *thread); +void i_osUnlockAllMutex(OSThread *thread); /*---------------------------------------------------------------------------* - Name: OS_LockMutexR + Name: osLockMutexR Description: lock RW mutex as READ access @@ -153,10 +153,10 @@ void OSi_UnlockAllMutex(OSThread *thread); Returns: None *---------------------------------------------------------------------------*/ -void OS_LockMutexR(OSMutex *mutex); +void osLockMutexR(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_LockMutexW + Name: osLockMutexW Description: lock RW mutex as WRITE access @@ -164,10 +164,10 @@ void OS_LockMutexR(OSMutex *mutex); Returns: None *---------------------------------------------------------------------------*/ -void OS_LockMutexW(OSMutex *mutex); +void osLockMutexW(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_TryLockMutexR + Name: osTryLockMutexR Description: try to lock RW mutex as READ access @@ -175,10 +175,10 @@ void OS_LockMutexW(OSMutex *mutex); Returns: TRUE if locked *---------------------------------------------------------------------------*/ -BOOL OS_TryLockMutexR(OSMutex *mutex); +BOOL osTryLockMutexR(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_TryLockMutexW + Name: osTryLockMutexW Description: try to lock RW mutex as WRITE access @@ -186,10 +186,10 @@ BOOL OS_TryLockMutexR(OSMutex *mutex); Returns: TRUE if locked *---------------------------------------------------------------------------*/ -BOOL OS_TryLockMutexW(OSMutex *mutex); +BOOL osTryLockMutexW(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_UnlockMutexR + Name: osUnlockMutexR Description: unlock mutex locked as READ access @@ -197,10 +197,10 @@ BOOL OS_TryLockMutexW(OSMutex *mutex); Returns: None *---------------------------------------------------------------------------*/ -void OS_UnlockMutexR(OSMutex *mutex); +void osUnlockMutexR(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_UnlockMutexW + Name: osUnlockMutexW Description: unlock mutex locked as WRITE access @@ -208,10 +208,10 @@ void OS_UnlockMutexR(OSMutex *mutex); Returns: None *---------------------------------------------------------------------------*/ -void OS_UnlockMutexW(OSMutex *mutex); +void osUnlockMutexW(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_UnlockMutexRW + Name: osUnlockMutexRW Description: unlock mutex locked as READ/WRITE access @@ -219,10 +219,10 @@ void OS_UnlockMutexW(OSMutex *mutex); Returns: None *---------------------------------------------------------------------------*/ -void OS_UnlockMutexRW(OSMutex *mutex); +void osUnlockMutexRW(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_LockMutexFromRToW + Name: osLockMutexFromRToW Description: Promote mutexR lock to mutexW lock without unlock. Wait till success. @@ -231,10 +231,10 @@ void OS_UnlockMutexRW(OSMutex *mutex); Returns: None *---------------------------------------------------------------------------*/ -void OS_LockMutexFromRToW(OSMutex *mutex); +void osLockMutexFromRToW(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_TryLockMutexFromRToW + Name: osTryLockMutexFromRToW Description: Try to promote mutexR lock to mutexW lock without unlock. @@ -242,10 +242,10 @@ void OS_LockMutexFromRToW(OSMutex *mutex); Returns: TRUE if success *---------------------------------------------------------------------------*/ -BOOL OS_TryLockMutexFromRToW(OSMutex *mutex); +BOOL osTryLockMutexFromRToW(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_LockMutexFromWToR + Name: osLockMutexFromWToR Description: Demote mutexW lock to mutexR lock without unlock. Wait till success. @@ -254,10 +254,10 @@ BOOL OS_TryLockMutexFromRToW(OSMutex *mutex); Returns: None *---------------------------------------------------------------------------*/ -void OS_LockMutexFromWToR(OSMutex *mutex); +void osLockMutexFromWToR(OSMutex *mutex); /*---------------------------------------------------------------------------* - Name: OS_TryLockMutexFromWToR + Name: osTryLockMutexFromWToR Description: Try to demote mutexW lock to mutexR lock without unlock. @@ -265,7 +265,7 @@ void OS_LockMutexFromWToR(OSMutex *mutex); Returns: TRUE if success *---------------------------------------------------------------------------*/ -BOOL OS_TryLockMutexFromWToR(OSMutex *mutex); +BOOL osTryLockMutexFromWToR(OSMutex *mutex); #ifdef __cplusplus } /* extern "C" */ diff --git a/trunk/bootrom/include/brom/os/common/thread.h b/trunk/bootrom/include/brom/os/common/thread.h index a9ce0d2..ceb463a 100644 --- a/trunk/bootrom/include/brom/os/common/thread.h +++ b/trunk/bootrom/include/brom/os/common/thread.h @@ -224,11 +224,11 @@ typedef struct OSThreadResource OSThreadResource; //---------------------------------------------------------------------------- -//---- private function ( don't use these OSi_* function ) -void OSi_CheckStack(const char *file, int line, const OSThread *thread); -u32 OSi_GetSystemStackPointer(void); -u32 OSi_GetCurrentStackPointer(void); -OSThread *OSi_GetIdleThread(void); +//---- private function ( don't use these i_os* function ) +void i_osCheckStack(const char *file, int line, const OSThread *thread); +u32 i_osGetSystemStackPointer(void); +u32 i_osGetCurrentStackPointer(void); +OSThread *i_osGetIdleThread(void); /*---------------------------------------------------------------------------* Name: osInitThread @@ -440,11 +440,11 @@ int osGetNumberOfThread(void); Returns: pointer of thread info structure *---------------------------------------------------------------------------*/ -extern OSThreadInfo OSi_ThreadInfo; +extern OSThreadInfo i_osThreadInfo; static inline OSThreadInfo *osGetThreadInfo(void) { - return &OSi_ThreadInfo; + return &i_osThreadInfo; } /*---------------------------------------------------------------------------* @@ -630,7 +630,7 @@ OSStackStatus osGetStackStatus(const OSThread *thread); ( if error occurred, never return ) *---------------------------------------------------------------------------*/ #if !defined(SDK_FINALROM) && !defined(SDK_NO_MESSAGE) -#define osCheckStack( thread ) OSi_CheckStack( __FILE__, __LINE__, (const OSThread*)thread ); +#define osCheckStack( thread ) i_osCheckStack( __FILE__, __LINE__, (const OSThread*)thread ); #else #define osCheckStack( thread ) ((void)0) #endif @@ -811,7 +811,7 @@ void osSetThreadDestructorStack(void *stack); // The following functions are for internal use. Not for user. //================================================================================ /*---------------------------------------------------------------------------* - Name: OSi_RemoveMutexLinkFromQueue + Name: i_osRemoveMutexLinkFromQueue Description: remove mutex from mutex queue @@ -819,10 +819,10 @@ void osSetThreadDestructorStack(void *stack); Returns: mutex pointer which is removed *---------------------------------------------------------------------------*/ -extern OSMutex *OSi_RemoveMutexLinkFromQueue(OSMutexQueue * queue); +extern OSMutex *i_osRemoveMutexLinkFromQueue(OSMutexQueue * queue); /*---------------------------------------------------------------------------* - Name: OSi_SetSystemErrno + Name: i_osSetSystemErrno Description: set system error number. @@ -831,10 +831,10 @@ extern OSMutex *OSi_RemoveMutexLinkFromQueue(OSMutexQueue * queue); Returns: None *---------------------------------------------------------------------------*/ -void OSi_SetSystemErrno(OSThread *thread, int errno); +void i_osSetSystemErrno(OSThread *thread, int errno); /*---------------------------------------------------------------------------* - Name: OSi_GetSystemErrno + Name: i_osGetSystemErrno Description: get system error number. @@ -842,13 +842,13 @@ void OSi_SetSystemErrno(OSThread *thread, int errno); Returns: error number *---------------------------------------------------------------------------*/ -int OSi_GetSystemErrno(const OSThread *thread); +int i_osGetSystemErrno(const OSThread *thread); #define OSi_SPECIFIC_CPS 0 /*---------------------------------------------------------------------------* - Name: OSi_SetSpecificData + Name: i_osSetSpecificData Description: set system specific data @@ -858,14 +858,14 @@ int OSi_GetSystemErrno(const OSThread *thread); Returns: None *---------------------------------------------------------------------------*/ -static inline void OSi_SetSpecificData(OSThread *thread, int index, void *data) +static inline void i_osSetSpecificData(OSThread *thread, int index, void *data) { SDK_ASSERT(thread && 0 <= index && index < OS_THREAD_SPECIFIC_MAX); thread->specific[index] = data; } /*---------------------------------------------------------------------------* - Name: OSi_GetSpecificData + Name: i_osGetSpecificData Description: get system specific data @@ -874,7 +874,7 @@ static inline void OSi_SetSpecificData(OSThread *thread, int index, void *data) Returns: error number *---------------------------------------------------------------------------*/ -static inline void *OSi_GetSpecificData(const OSThread *thread, int index) +static inline void *i_osGetSpecificData(const OSThread *thread, int index) { SDK_ASSERT(thread && 0 <= index && index < OS_THREAD_SPECIFIC_MAX); return thread->specific[index];