diff --git a/trunk/bootrom/build/libraries/os/common/os_tick.c b/trunk/bootrom/build/libraries/os/common/os_tick.c index 2dc66f6..011355b 100644 --- a/trunk/bootrom/build/libraries/os/common/os_tick.c +++ b/trunk/bootrom/build/libraries/os/common/os_tick.c @@ -75,7 +75,7 @@ void osInitTick(void) #ifdef SDK_ARM11 osStopTimer(); - osStartTimerWithMSec(1, 0); + osStartTimer(OS_TICK_LO_MASK+1, 0); #else // SDK_ARM9 //---- OS reserves OSi_TICK_TIMER timer SDK_ASSERT(!i_osIsTimerReserved(OSi_TICK_TIMER)); @@ -131,7 +131,7 @@ static void i_osCountUpTick(void) { #ifdef SDK_ARM11 osStopTimer(); - osStartTimerWithMSec(1, 0); + osStartTimer(OS_TICK_LO_MASK+1, 0); #else // SDK_ARM9 osSetTimerControl(OSi_TICK_TIMER, 0); osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)0); @@ -157,17 +157,18 @@ static void i_osCountUpTick(void) *---------------------------------------------------------------------------*/ u64 osGetTick(void) { -#ifdef SDK_ARM11 - return (i_osTickCounter << 32) | reg_OS_WD_COUNT; -#else // SDK_ARM9 - vu16 countL; + vu32 countL; vu64 countH; OSIntrMode prev = osDisableInterrupts(); SDK_ASSERT(i_osUseTick); +#ifdef SDK_ARM11 + countL = reg_OS_TM_COUNT; + countH = i_osTickCounter << OS_TICK_HI_SHIFT; +#else // SDK_ARM9 countL = *(REGType16 *)((u32)REG_TM0CNT_L_ADDR + OSi_TICK_TIMER * 4); - countH = i_osTickCounter & 0xffffffffffffULL; + countH = i_osTickCounter; //---- check if timer interrupt bit is on if (reg_OS_IF & OSi_TICK_IE_TIMER && !(countL & 0x8000)) @@ -175,10 +176,12 @@ u64 osGetTick(void) countH++; } + countH <<= OS_TICK_HI_SHIFT; + +#endif // SDK_ARM9 (void)osRestoreInterrupts(prev); - return (countH << 16) | countL; -#endif // SDK_ARM9 + return countH | countL; } #ifdef SDK_ARM9 @@ -219,17 +222,17 @@ void osSetTick(u64 count) #ifdef SDK_ARM11 osClearInterruptPending(OSi_TICK_IE_TIMER_ID); - i_osTickCounter = (u64)(count >> 32); + i_osTickCounter = (u64)(count >> OS_TICK_HI_SHIFT); osStopTimer(); - osStartTimerWithMSec((u32)count, 0); + osStartTimer((u32)(count & OS_TICK_LO_MASK), 0); #else // SDK_ARM9 reg_OS_IF = OSi_TICK_IE_TIMER; - i_osTickCounter = (u64)(count >> 16); + i_osTickCounter = (u64)(count >> OS_TICK_HI_SHIFT); osSetTimerControl(OSi_TICK_TIMER, 0); - osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)(count & 0xffff)); + osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)(count & OS_TICK_LO_MASK)); osSetTimerControl(OSi_TICK_TIMER, (u16)OSi_TICK_TIMERCONTROL); #endif // SDK_ARM9 diff --git a/trunk/bootrom/include/brom/os/common/tick.h b/trunk/bootrom/include/brom/os/common/tick.h index 3299c30..832f429 100644 --- a/trunk/bootrom/include/brom/os/common/tick.h +++ b/trunk/bootrom/include/brom/os/common/tick.h @@ -45,8 +45,12 @@ extern void osSetTick( u64 ); //---- conversion tick count <-> real time count #ifdef SDK_ARM11 #define OS_SYSTEM_CLOCK HW_CPU_CLOCK +#define OS_TICK_HI_SHIFT 31 // 2の累乗単位でチック管理するのであれば32は指定できない(ロード値0では割り込み発生せず) +#define OS_TICK_LO_MASK ((u32)((1ULL<