/*---------------------------------------------------------------------------* Project: CtrBrom - OS - include File: tick.h Copyright 2008 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. $Date:: $ $Rev$ $Author$ *---------------------------------------------------------------------------*/ #ifndef BROM_OS_TICK_H_ #define BROM_OS_TICK_H_ #ifdef __cplusplus extern "C" { #endif #include #include #include #include //---- unit of tick typedef u64 OSTick; typedef u32 OSTick32; //---- tick APIs extern void osInitTick( void ); extern u64 osGetTick( void ); extern void i_osSetTick( u64 ); //---------------------------------------------------------------------- //---- ARM9 use 2 timers #ifdef SDK_ARM9 #define OS_TICK_USE_2TIMERS #endif // SDK_ARM9 //---- timer number tick uses #define OSi_TICK_TIMER OS_TIMER_0 #ifdef OS_TICK_USE_2TIMERS #define OSi_TICK_TIMER_H ((OSTimer)(OSi_TICK_TIMER + 1)) #endif // OS_TICK_USE_2TIMERS //---- timer interrupt ID #ifdef SDK_ARM11 #define OSi_TICK_IE_TIMER_ID ((OSIntrID)(OS_INTR_ID_TIMER + OSi_TICK_TIMER)) #else // SDK_ARM9 #ifndef OS_TICK_USE_2TIMERS #define OSi_TICK_IE_TIMER_ID ((OSIntrID)(OS_INTR_ID_TIMER0 + OSi_TICK_TIMER)) #else // OS_TICK_USE_2TIMERS #define OSi_TICK_IE_TIMER_ID ((OSIntrID)(OS_INTR_ID_TIMER0 + OSi_TICK_TIMER_H)) #endif // OS_TICK_USE_2TIMERS #endif // SDK_ARM9 //---- conversion tick count <-> real time count #ifdef SDK_ARM11 #ifndef BROM_RUN_ON_PALLADIUM #define OS_TICK_CLOCK HW_CPU_CLOCK #else // BROM_RUN_ON_PALLADIUM #define OS_TICK_CLOCK (HW_CPU_CLOCK/256) #endif // BROM_RUN_ON_PALLADIUM #define OS_TICK_PRESCALE 2 #define OS_TICK_HI_SHIFT 28 // 最大32 #define OS_TICK_LO_MASK ((u32)(OS_TICK_HI_LSB-1)) #define OS_TICK_LO_MSB ((u32)(OS_TICK_HI_LSB>>1)) #define OS_TICK_HI_LSB (1ULL<>1)) #else // OS_TICK_USE_2TIMERS #define OS_TICK_HI_SHIFT 32 // 最大32 #define OS_TICK_LO_MASK ((u32)(OS_TICK_HI_LSB-1)) #define OS_TICK_LO_MSB ((u32)(OS_TICK_HI_LSB>>1)) #endif // OS_TICK_USE_2TIMERS #define OS_TICK_HI_LSB (1ULL<