Esempio n. 1
0
/**
 * The game loop, this function is called periodically to update the game.
 */
void game_loop()
{
    static int last_time = -1;
    int delta, now;
    
    /* Update the game */
    now = GET_CURRENT_TIME();
    
    if( last_time == -1 )
    {
        last_time = now;
        return;
    }
    
    // Get the time since the last update (minimum of one millisecond)
    delta = 1 + now - last_time; // TODO: remove the 1
    update_world(delta);
    
    /* Update the render module */
    render_update(delta);
    
    /* Render the game */
    render();
    
    last_time = now;
}
Esempio n. 2
0
/*************************************************************************
* FUNCTION
*  isrC_Main
*
* DESCRIPTION
*   This function implement IRQ's LISR main dispatch routine
*
* CALLS
*
* CALL BY
*  INT_IRQ_Parse()
*
* PARAMETERS
*
* RETURNS
*
*************************************************************************/
#if !defined(__SSDVT_TEST__)
#if defined(MT6290) && defined(__ARM7EJ_S__)
void DEVDRV_LS_COPRO_INTSRAM_ROCODE isrC_Main(kal_uint32 irqx)
#else /* defined(MT6290) && defined(__ARM7EJ_S__) */
void DEVDRV_LS_INTSRAM_ROCODE isrC_Main(kal_uint32 irqx)
#endif /* else of "defined(MT6290) && defined(__ARM7EJ_S__)" */
{
#if defined(__UNIFIED_ISR_LEVEL__)
//   kal_hisr processing_ehisrid;
   kal_hisrid processing_hisrid;
#else /* __UNIFIED_ISR_LEVEL__ */
   void       *processing_lisr_backup;
   kal_uint16 processing_irqx_backup;

   processing_lisr_backup = processing_lisr;
   processing_irqx_backup = processing_irqx;
#endif /* __UNIFIED_ISR_LEVEL__ */

   processing_irqx = irqx;
   processing_lisr = (void*)lisr_dispatch_tbl[irqx].lisr_handler;
   processing_irqCnt++;
   
#if defined __MALMO_ASM_SWTR__
	ST_MALMO_ASM_ChangeContextID();
#endif /* __MALMO_ASM_SWTR */  
   
   if (KAL_FALSE == SLA_IsLmuLogging())
   {
      LMU_Write_ISR_CSM(0xaaaa0000 | ((kal_uint32)processing_irqx));
   }
   if (SA_LoggingIndex != 0)
   {
      SLA_LoggingLISR(0xaaaa0000 | ((kal_uint32)processing_irqx));
   }

   CPU_SET_CONTEXT_ID(0xaaaa0000 | ((kal_uint32)processing_irqx));

#ifdef __SWDBG_SUPPORT__
   *SWDBG_MPCON = ((irqx + 0x100) << 16) | 0x8000;
#endif   /* __SWDBG_SUPPORT__ */

#ifdef __WAKEUP_IRQ_DEBUG__
   if (wkup_intr_log_indx != WKUP_LOG_BUF_MAX) {
      wkup_intr_log_buf[wkup_intr_log_indx].irq = processing_irqx;
      wkup_intr_log_indx++;
      if (wkup_intr_log_indx == WKUP_LOG_BUF_MAX) {
         wkup_intr_log_indx = 0;
      }
   }
   if (wkup_timer_log_indx != WKUP_LOG_BUF_MAX) {
      if (wake_tm_name != NULL) {
         wkup_timer_log_buf[wkup_timer_log_indx].timer_name = wake_tm_name;
         wake_tm_name = NULL;
         wkup_timer_log_indx++;
         if (wkup_timer_log_indx == WKUP_LOG_BUF_MAX) {
            wkup_timer_log_indx = 0;
         }
      }
   }
#endif  /* __WAKEUP_IRQ_DEBUG__ */

#if defined(DEBUG_KAL) && defined(DEBUG_TIMER) && defined(__CR4__)
   if(TimerHISR_State == 1)
   {
       GET_CURRENT_TIME(TimerHISR_Exclude_Start_Time);
       TimerHISR_State = 2;
   }
#endif

#if defined(__TP_SUPPORT_TIMING_CHECK__)
   if(Thread_Protect_State==1)
   {
       Thread_Protect_State=2;
       TP_Exclude_Start_Time = ust_get_current_time();
   }
#endif

#ifdef __DEMAND_PAGING_PERFORMANCE_PROFILING__   
   demp_preempt_time_start();
#endif

#if defined(__UNIFIED_ISR_LEVEL__)
//   processing_ehisrid = intrID2hisrEID[irqx];
//   ASSERT(0xFF != processing_ehisrid);
//   processing_hisrid = hisrid_g[processing_ehisrid];

   processing_hisrid = intrID2hisrID[irqx];
   if(processing_hisrid != drv_hisr)
   {
       EXT_ASSERT(NULL != processing_hisrid, irqx, processing_irqCnt, (kal_uint32)processing_lisr);
       kal_activate_hisr(processing_hisrid);
   }
   else
   {
       drv_active_hisr(irqx);
   }
     

   /* no nested interrupt */
   processing_lisr = NULL;
   processing_irqx = IRQ_NOT_LISR_CONTEXT;
#else  /* __UNIFIED_ISR_LEVEL__ */
   ReEnableIRQ();
#if defined(__CR4__)
   IFDEF_LISR_MEASURE_TIME(CP15_PMU_GET_CYCLE_CNT(lisr_enter_time[irqx]));
#elif defined(__MTK_MMU_V2__)
   IFDEF_LISR_MEASURE_TIME(lisr_enter_time[irqx]=CACHE_FREE_RUN_CYCLE_COUNTER_GET_CYCLE());
#endif
   lisr_dispatch_tbl[irqx].lisr_handler(irqx);
#if defined(__CR4__)
   IFDEF_LISR_MEASURE_TIME(CP15_PMU_GET_CYCLE_CNT(lisr_leave_time[irqx]));
#elif defined(__MTK_MMU_V2__)
   IFDEF_LISR_MEASURE_TIME(lisr_leave_time[irqx]=CACHE_FREE_RUN_CYCLE_COUNTER_GET_CYCLE());
#endif
   DisableIRQ();
   processing_irqx = processing_irqx_backup;
   processing_lisr = processing_lisr_backup; 
#endif /* __UNIFIED_ISR_LEVEL__ */
   
   if (KAL_FALSE == SLA_IsLmuLogging())
   {
      LMU_Write_ISR_END_CSM(0xaaaaaaaa);
   }
   if (SA_LoggingIndex != 0)
   {
      SLA_LoggingLISR(0xaaaaaaaa);
   }
   CPU_SET_CONTEXT_ID(0xaaaaaaaa);

   #if defined __MALMO_ASM_SWTR__
	ST_MALMO_ASM_ChangeContextID();
   #endif /* __MALMO_ASM_SWTR */  
   
   /* Binary-coded IRQ idx */
   SYS_endIsr((kal_uint8)irqx);

}
void isrC_Main(void)
{
   kal_uint32 irqx;
   void       *processing_lisr_backup;
   kal_uint16 processing_irqx_backup;
	 
   irqx = IRQ_Status();
   if(irqx== -1)
      return;

   processing_lisr_backup = processing_lisr;
   processing_irqx_backup = processing_irqx;
   processing_irqx = irqx;
   processing_lisr = (void*)lisr_dispatch_tbl[irqx].lisr_handler;
   processing_irqCnt++;
   
#if defined __MALMO_ASM_SWTR__
	ST_MALMO_ASM_ChangeContextID();
#endif /* __MALMO_ASM_SWTR */  
   
   if (KAL_FALSE == SLA_IsLmuLogging())
   {
      LMU_Write_ISR_CSM(0xaaaa0000 | ((kal_uint32)processing_irqx));
   }
   if (SA_LoggingIndex != 0)
   {
      SLA_LoggingLISR(0xaaaa0000 | ((kal_uint32)processing_irqx));
   }

#ifdef __SWDBG_SUPPORT__
   *SWDBG_MPCON = ((irqx + 0x100) << 16) | 0x8000;
#endif   /* __SWDBG_SUPPORT__ */

#ifdef __WAKEUP_IRQ_DEBUG__
   if (wkup_intr_log_indx != WKUP_LOG_BUF_MAX) {
      wkup_intr_log_buf[wkup_intr_log_indx].irq = processing_irqx;
      wkup_intr_log_indx++;
      if (wkup_intr_log_indx == WKUP_LOG_BUF_MAX) {
         wkup_intr_log_indx = 0;
      }
   }
   if (wkup_timer_log_indx != WKUP_LOG_BUF_MAX) {
      if (wake_tm_name != NULL) {
         wkup_timer_log_buf[wkup_timer_log_indx].timer_name = wake_tm_name;
         wake_tm_name = NULL;
         wkup_timer_log_indx++;
         if (wkup_timer_log_indx == WKUP_LOG_BUF_MAX) {
            wkup_timer_log_indx = 0;
         }
      }
   }
#endif  /* __WAKEUP_IRQ_DEBUG__ */

#if defined(DEBUG_KAL) && defined(DEBUG_TIMER) && defined(__CR4__)
   if(TimerHISR_State == 1)
   {
       GET_CURRENT_TIME(TimerHISR_Exclude_Start_Time);
       TimerHISR_State = 2;
   }
#endif

#if defined(__TP_SUPPORT_TIMING_CHECK__)
   if(Thread_Protect_State==1)
   {
       Thread_Protect_State=2;
       TP_Exclude_Start_Time = ust_get_current_time();
   }
#endif

#ifdef __DEMAND_PAGING_PERFORMANCE_PROFILING__   
   demp_preempt_time_start();
#endif

   ReEnableIRQ();
   lisr_dispatch_tbl[irqx].lisr_handler();
   DisableIRQ();
   
   /* restore global variable processing_lisr and processing_irqx to value of preempted IRQ */
   processing_irqx = processing_irqx_backup;
   processing_lisr = processing_lisr_backup;   
   
   if (KAL_FALSE == SLA_IsLmuLogging())
   {
      LMU_Write_ISR_END_CSM(0xaaaaaaaa);
      if( processing_irqx != IRQ_NOT_LISR_CONTEXT )
      {
         LMU_Write_ISR_RESUME_CSM(0xaaaa0000 | ((kal_uint32)processing_irqx));
      }
   }
   if (SA_LoggingIndex != 0)
   {
      SLA_LoggingLISR(0xaaaaaaaa);
   }
   
#if defined __MALMO_ASM_SWTR__
	ST_MALMO_ASM_ChangeContextID();
#endif /* __MALMO_ASM_SWTR */  
   
   /* Binary-coded IRQ idx */
   SYS_ClearInt2((kal_uint8)irqx);

}