diff --git a/trunk/bootrom/build/libraries/os/ARM11/Makefile b/trunk/bootrom/build/libraries/os/ARM11/Makefile index 8247231..7a97110 100644 --- a/trunk/bootrom/build/libraries/os/ARM11/Makefile +++ b/trunk/bootrom/build/libraries/os/ARM11/Makefile @@ -28,14 +28,15 @@ BROM_CODEGEN_ALL ?= TRUE SRCDIR = . ../common SRCS = \ - os_thread.c \ - os_context.c \ + os_tick.c \ os_init.c \ os_system.c \ os_timer.c \ os_irqHandler.c \ os_interrupt.c \ os_interrupt_common.c \ + os_thread.c \ + os_context.c \ TARGET_LIB = libos$(BROM_LIBSUFFIX).a diff --git a/trunk/bootrom/build/libraries/os/ARM9/Makefile b/trunk/bootrom/build/libraries/os/ARM9/Makefile index 6ef0aae..c365378 100644 --- a/trunk/bootrom/build/libraries/os/ARM9/Makefile +++ b/trunk/bootrom/build/libraries/os/ARM9/Makefile @@ -31,8 +31,6 @@ BROM_PROC = ARM9 SRCDIR = . ../common SRCS = \ - os_thread.c \ - os_context.c \ os_init.c \ os_system.c \ os_timer.c \ @@ -40,6 +38,8 @@ SRCS = \ os_irqHandler.c \ os_interrupt.c \ os_interrupt_common.c \ + os_thread.c \ + os_context.c \ TARGET_LIB = libos_sp$(BROM_LIBSUFFIX).a diff --git a/trunk/bootrom/build/libraries/os/common/os_init.c b/trunk/bootrom/build/libraries/os/common/os_init.c index f7eca23..a8af821 100644 --- a/trunk/bootrom/build/libraries/os/common/os_init.c +++ b/trunk/bootrom/build/libraries/os/common/os_init.c @@ -31,23 +31,23 @@ *---------------------------------------------------------------------------*/ void osInitBROM(void) { + static BOOL isInit; + + if ( isInit == FALSE ) + { + isInit = TRUE; + #ifdef SDK_ARM9 #ifdef BROM_DEBUG_ITCM MI_CpuFillFast( (void*)HW_ITCM, 0, HW_ITCM_SIZE ); #endif // BROM_DEBUG_ITCM -#else // SDK_ARM7 - - //---- Init Exception System - // the exception vecter of ARM9 is in the noninitialized main memory. -// osInitException(); - -#endif // SDK_ARM7 - - //---- Init Interrupt - osInitInterrupt(); +#endif // SDK_ARM9 + osInitInterrupt(); +// osInitTimer(); + } } /*---------------------------------------------------------------------------* diff --git a/trunk/bootrom/build/libraries/os/ARM9/os_tick.c b/trunk/bootrom/build/libraries/os/common/os_tick.c similarity index 82% rename from trunk/bootrom/build/libraries/os/ARM9/os_tick.c rename to trunk/bootrom/build/libraries/os/common/os_tick.c index 2fd1c3d..58813bd 100644 --- a/trunk/bootrom/build/libraries/os/ARM9/os_tick.c +++ b/trunk/bootrom/build/libraries/os/common/os_tick.c @@ -18,17 +18,23 @@ //---------------------------------------------------------------------- -//---- timer control setting for tick -#define OSi_TICK_TIMERCONTROL ( REG_OS_TM0CNT_H_E_MASK | REG_OS_TM0CNT_H_I_MASK | OS_TIMER_PRESCALER_64 ) +#ifdef SDK_ARM11 +//---- timer interrupt ID +#define OSi_TICK_IE_TIMER_ID OS_INTR_ID_TIMER -//---- timer number tick uses -#define OSi_TICK_TIMER OS_TIMER_3 +#else // SDK_ARM9 +//---- timer interrupt ID +#define OSi_TICK_IE_TIMER_ID OS_INTR_ID_TIMER0 //---- timer interrupt mask (must be same number with OSi_TICK_TIMER) -#define OSi_TICK_IE_TIMER REG_OS_IF_T3_MASK +#define OSi_TICK_IE_TIMER REG_OS_IF_T0_MASK -//---- timer interrupt ID -#define OSi_TICK_IE_TIMER_ID OS_INTR_ID_TIMER3 +//---- timer number tick uses +#define OSi_TICK_TIMER OS_TIMER_0 + +//---- timer control setting for tick +#define OSi_TICK_TIMERCONTROL ( REG_OS_TM0CNT_H_E_MASK | REG_OS_TM0CNT_H_I_MASK | OS_TIMER_PRESCALER_64 ) +#endif // SDK_ARM9 //---- flag for initialization tick static u16 i_osUseTick = FALSE; @@ -59,6 +65,9 @@ void osInitTick(void) { i_osUseTick = TRUE; +#ifdef SDK_ARM11 + osStartTimerWithMSec(1, 0); +#else // SDK_ARM9 //---- OS reserves OSi_TICK_TIMER timer SDK_ASSERT(!i_osIsTimerReserved(OSi_TICK_TIMER)); i_osSetTimerReserved(OSi_TICK_TIMER); @@ -68,9 +77,10 @@ void osInitTick(void) i_osSetTimerControl(OSi_TICK_TIMER, 0); i_osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)0); i_osSetTimerControl(OSi_TICK_TIMER, (u16)OSi_TICK_TIMERCONTROL); +#endif // SDK_ARM9 //---- set interrupt callback - osSetInterruptHandler( OS_INTR_ID_TIMER3, i_osCountUpTick ); + osSetInterruptHandler( OSi_TICK_IE_TIMER_ID, i_osCountUpTick ); //---- enable timer interrupt osEnableInterruptID(OSi_TICK_IE_TIMER_ID); @@ -111,9 +121,14 @@ static void i_osCountUpTick(void) //---- setting for timer if (i_osNeedResetTimer) { +#ifdef SDK_ARM11 + osStopTimer(); + osStartTimerWithMSec(1, 0); +#else // SDK_ARM9 i_osSetTimerControl(OSi_TICK_TIMER, 0); i_osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)0); i_osSetTimerControl(OSi_TICK_TIMER, (u16)OSi_TICK_TIMERCONTROL); +#endif // SDK_ARM9 i_osNeedResetTimer = FALSE; } @@ -134,6 +149,9 @@ static void i_osCountUpTick(void) *---------------------------------------------------------------------------*/ u64 osGetTick(void) { +#ifdef SDK_ARM11 + return (i_osTickCounter << 32) | reg_OS_WD_COUNT; +#else // SDK_ARM9 vu16 countL; vu64 countH; @@ -152,8 +170,10 @@ u64 osGetTick(void) (void)osRestoreInterrupts(prev); return (countH << 16) | countL; +#endif // SDK_ARM9 } +#ifdef SDK_ARM9 /*---------------------------------------------------------------------------* Name: osGetTickLo @@ -168,6 +188,7 @@ u16 osGetTickLo(void) SDK_ASSERT(OSi_UseTick); return *(REGType16 *)((u32)REG_TM0CNT_L_ADDR + OSi_TICK_TIMER * 4); } +#endif // SDK_ARM9 /*---------------------------------------------------------------------------* Name: osSetTick @@ -185,15 +206,24 @@ void osSetTick(u64 count) SDK_ASSERT(i_osUseTick); prev = osDisableInterrupts(); - reg_OS_IF = OSi_TICK_IE_TIMER; - i_osNeedResetTimer = TRUE; +#ifdef SDK_ARM11 + osClearInterruptPending(OSi_TICK_IE_TIMER_ID); + + i_osTickCounter = (u64)(count >> 32); + + osStopTimer(); + osStartTimerWithMSec((u32)count, 0); +#else // SDK_ARM9 + reg_OS_IF = OSi_TICK_IE_TIMER; + i_osTickCounter = (u64)(count >> 16); i_osSetTimerControl(OSi_TICK_TIMER, 0); i_osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)(count & 0xffff)); i_osSetTimerControl(OSi_TICK_TIMER, (u16)OSi_TICK_TIMERCONTROL); +#endif // SDK_ARM9 (void)osRestoreInterrupts(prev); } diff --git a/trunk/include/ctr/hw/ARM11/arm11_reg.h b/trunk/include/ctr/hw/ARM11/arm11_reg.h index 8a41877..5b9cdc0 100644 --- a/trunk/include/ctr/hw/ARM11/arm11_reg.h +++ b/trunk/include/ctr/hw/ARM11/arm11_reg.h @@ -28,8 +28,13 @@ extern "C" { #define HW_CPU_CLOCK_ARM11 (67027964 * 4) #define HW_CPU_CLOCK HW_CPU_CLOCK_ARM11 +#ifndef SDK_MG20EMU #define HW_ARM11_IC_SIZE 0x4000 // Inst Cache #define HW_ARM11_DC_SIZE 0x4000 // Data Cache +#else // SDK_MG20EMU +#define HW_ARM11_IC_SIZE 0x8000 // Inst Cache +#define HW_ARM11_DC_SIZE 0x8000 // Data Cache +#endif // SDK_MG20EMU #define HW_ARM11_CACHE_LINE_SIZE 32 #define HW_IC_SIZE HW_ARM11_IC_SIZE