/***************************************************************************** 函 数 名 : dual_modem_wakeup_init 功能描述 : 初始化睡眠投票,初始化定时器,注册icc通信 输入参数 : 无 输出参数 : 0:成功,-1:失败 返 回 值 : int *****************************************************************************/ int dual_modem_wakeup_init(DRV_DUAL_MODEM_STR DualModemNv) { struct softtimer_list *T1_timer =&g_dual_modem_ctrl.hold_wake_timer; struct softtimer_list *T2_timer =&g_dual_modem_ctrl.sleep_timer; T1_timer->func = modem_awaketimer_int; T1_timer->para = 0; T1_timer->timeout = DualModemNv.AwakeTmer; T1_timer->wake_type = SOFTTIMER_NOWAKE; T2_timer->func = modem_sleeptimer_int; T2_timer->para = 0; T2_timer->timeout= DualModemNv.DoSleepTimer; T2_timer->wake_type = SOFTTIMER_NOWAKE; wake_lock_init(&g_dual_modem_ctrl.wakelock ,PWRCTRL_SLEEP_UART0 ,"PWRCTRL_SLEEP_UART0"); g_dual_modem_ctrl.wakeup_3rdmodem_flag = DO_WAKEUP_3RD; if(OK !=bsp_softtimer_create(T1_timer)) { dm_print_err("T1_timer create fail!\n"); goto T1timerfail; } if(OK !=bsp_softtimer_create(T2_timer)) { dm_print_err("T2_timer create fail!\n"); goto T2timerfail; } return OK; T2timerfail: bsp_softtimer_free(T1_timer); T1timerfail: return ERROR; }
/*测试非唤醒源软timer申请和加入链表,在回调函数外删除软timer 超时时间较长*/ s32 st_softtimer_test_case13(void) { s32 ret= 0; my_softtimer.func = for_softtimer_test_1; my_softtimer.para = 123; my_softtimer.timeout = 100; my_softtimer.wake_type=SOFTTIMER_NOWAKE; osl_sem_init(0,&sem1); if (bsp_softtimer_create(&my_softtimer)) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"create error \n"); } bsp_softtimer_add(&my_softtimer); ret = bsp_softtimer_delete(&my_softtimer); if (ret ==OK) { ret = bsp_softtimer_free(&my_softtimer); if (ret !=OK) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"softtimer_test_6 free error\n"); return ERROR; } } else if(NOT_ACTIVE == ret) { osl_sem_down(&sem1); osl_sema_delete(&sem1); } return ret; }
/*测试非唤醒源软timer申请和加入链表,LOOP模式,执行一段时间后在回调函数外delete*/ s32 st_softtimer_test_case14(void) { s32 ret=0; my_softtimer.func = for_softtimer_test_8; my_softtimer.para = 123; my_softtimer.timeout = 1; my_softtimer.wake_type=SOFTTIMER_NOWAKE; if (bsp_softtimer_create(&my_softtimer)) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"create error\n"); return ERROR; } bsp_softtimer_add(&my_softtimer); delay(200); ret = bsp_softtimer_delete_sync(&my_softtimer); if(OK!=ret) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"bsp_softtimer_delete_sync failed\n"); return ERROR; } ret = bsp_softtimer_free(&my_softtimer); if (ret !=OK) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"st_softtimer_test_case16 free error\n"); return ERROR; } return OK; }
void for_softtimer_test_3(u32 para) { s32 ret = 0; num[1]++; if (num[1]<10) { ret = bsp_softtimer_modify(&my_softtimer,num[1]*100); if (ret !=OK) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"for_softtimer_test_3 11modify error\n"); return; } bsp_softtimer_add(&my_softtimer); } if (num[1]==10) { num[1] = 0; ret = bsp_softtimer_free(&my_softtimer); if (ret !=OK) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"for_softtimer_test_3 free error\n"); return; } osl_sem_up(&sem3); } return; }
s32 edma2_stress_test_stop() { set_test_switch_stat(EDMAC, TEST_STOP); while(OK == taskIdVerify(g_edma2_busstress_info.edma_stress_test_task_id)) { taskDelay(100); } if (NULL != g_edma2_busstress_info.edma_send_sem) { /*sema_delete(g_edma2_busstress_info.edma_send_sem);*/ semDelete(g_edma2_busstress_info.edma_send_sem); } bsp_softtimer_delete_sync(&g_edma2_busstress_info.edma_softtimer_list); bsp_softtimer_free(&g_edma2_busstress_info.edma_softtimer_list); cacheDmaFree(g_edma2_busstress_info.stDMATaskHandle[0].u32SrcAddr); cacheDmaFree(g_edma2_busstress_info.stDMATaskHandle[0].u32DstAddr); cacheDmaFree(g_edma2_busstress_info.stDMATaskHandle[1].u32SrcAddr); cacheDmaFree(g_edma2_busstress_info.stDMATaskHandle[3].u32DstAddr); return OK; }
/****************************************************************************** * Function: power_off_timeout_isr * Description: 如果应用没有一定时间内关机,底层直接关机 * Input: * None * Output: * None * Return: * None * Note : ********************************************************************************/ static int power_off_timeout_isr( void ) { pr_dbg("power_off_timeout_isr, reason :%d\n ",power_off_ctrl.reason); (void)bsp_softtimer_free(&power_off_ctrl.off_timer); power_off_excecute(power_off_ctrl.reason); return 0; }
/***************************************************************************** 函 数 名 : power_off_timeout_isr 功能描述 : 开机定时器处理,检测C核状态 输入参数 : 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : *****************************************************************************/ static int power_on_timeout_isr( void ) { c_power_st_e status = POWER_OS_OK; DRV_RUN_MODE run_mode = get_run_mode(); pr_dbg("power_on_timeout_isr, system had been powered one minute ago\n "); #if (MBB_CHARGE == FEATURE_ON) if(chg_is_powdown_charging()) { pr_dbg("CHG:no need to check c core status!\n "); return 0; } #endif /*MBB_CHG_PLATFORM_V7R2*/ if(RUN_MODE_NORMAL == run_mode) { /* 读取C核启动状态 */ status = power_on_c_status_get(); #if defined(DRV_BUILD_SEPARATE) /* C核异常,设置normal模式启动失败 */ if(status < POWER_BSP_OK) #else if(status < POWER_MSP_OK) #endif { pr_dbg("c core power on fail!\n "); /* 进入recovery模式 */ bsp_drv_power_reboot(); /* coverity[no_escape] */ for(;;) ; } } else if(RUN_MODE_RECOVERY == run_mode){ /* for test */ #if 0 bsp_drv_power_reboot(); /* 等待系统重启 */ while(1); #endif } pr_dbg("system power on ok!\n "); /* clear warm boot cnt */ power_on_wdt_cnt_set(); (void)bsp_softtimer_free(&power_item_info.on_timer); return 0; }
void for_softtimer_test_6(u32 para) { s32 ret; ret = bsp_softtimer_free(&my_thir_softtimer); if (ret !=OK) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"for_softtimer_test_6 free error\n"); return ; } osl_sem_up(&sem6); return ; }
void for_softtimer_test_2(u32 para) { s32 ret = 0; num[0]++; if (num[0]<10) { bsp_softtimer_add(&my_softtimer); } else if (num[0]==10) { num[0] = 0; ret = bsp_softtimer_free(&my_softtimer); if (ret !=OK) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"for_softtimer_test_2 free error\n"); return; } osl_sem_up(&sem2); } return; }
/*在case15或case16运行的情况下运行本测试用例,测试是否可以删除多个定时器*/ s32 st_softtimer_test_case17(void) { int i = 0; int ret; while(i<31) { ret = bsp_softtimer_delete_sync(&myown_timer[i]); if(OK!=ret) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"bsp_softtimer_delete_sync failed\n"); return ERROR; } ret = bsp_softtimer_free(&myown_timer[i]); if(OK!=ret) { bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"bsp_softtimer_free failed\n"); return ERROR; } i++; } return OK; }
s32 edma2_stress_test_start(s32 task_priority,s32 test_rate) { s32 ret = 0; u32 index = 0; s32 chann_id = 0;/*bsp_edma_channel_init(EDMA_MEMORY, 0, 0, 0);*/ for (index=0;index<EDMA_HANDLE_NUM;index++) { g_edma2_busstress_info.stDMATaskHandle[index].ulChIdx = chann_id; } logMsg("edma2_stress: use axi 0x%x \n", MEM_FOR_EDMAC2_BUSSTRESS,0,0,0,0,0); /* g_edma2_busstress_info.stDMATaskHandle[0] = {0, 0, EDMA_TEST_LEN, chann_id}; g_edma2_busstress_info.stDMATaskHandle[1] = {0, EDMA2_HANDLE_1_AXI_MEM_64_DST, EDMA_TEST_LEN, chann_id}; g_edma2_busstress_info.stDMATaskHandle[2] = {EDMA2_HANDLE_2_AXI_MEM_64_SRC, EDMA2_HANDLE_2_AXI_MEM_64_DST, EDMA_TEST_LEN, chann_id}; g_edma2_busstress_info.stDMATaskHandle[3] = {EDMA2_HANDLE_3_AXI_MEM_64_SRC, 0, EDMA_TEST_LEN, chann_id}; */ set_test_switch_stat(EDMAC, TEST_RUN); /*创建控制发送速率的信号量*/ /*sema_init(&(g_edma2_busstress_info.edma_send_sem) , SEM_EMPTY);*/ g_edma2_busstress_info.edma_send_sem = semBCreate(SEM_Q_FIFO, SEM_EMPTY); if (g_edma2_busstress_info.edma_send_sem == NULL) { printf("semBCreate gmac_send_sem fail.\n"); return ERROR; } g_edma2_busstress_info.edma_softtimer_list.func = ( softtimer_func )edma2_timer_event; g_edma2_busstress_info.edma_softtimer_list.para = 0; g_edma2_busstress_info.edma_softtimer_list.timeout = test_rate; g_edma2_busstress_info.edma_softtimer_list.wake_type =SOFTTIMER_NOWAKE; /*创建控制发送速率 的软timer*/ if( bsp_softtimer_create(&g_edma2_busstress_info.edma_softtimer_list)) { printf("SOFTTIMER_CREATE_TIMER fail.\n"); /*sema_delete(g_edma2_busstress_info.edma_send_sem);*/ semDelete(g_edma2_busstress_info.edma_send_sem); return ERROR; } g_edma2_busstress_info.stDMATaskHandle[0].u32SrcAddr = (u32)cacheDmaMalloc(EDMA_TEST_LEN); g_edma2_busstress_info.stDMATaskHandle[0].u32DstAddr = (u32)cacheDmaMalloc(EDMA_TEST_LEN); g_edma2_busstress_info.stDMATaskHandle[1].u32SrcAddr = (u32)cacheDmaMalloc(EDMA_TEST_LEN); g_edma2_busstress_info.stDMATaskHandle[3].u32DstAddr = (u32)cacheDmaMalloc(EDMA_TEST_LEN); /*创建发包测试任务,收包驱动会自行做处理*/ g_edma2_busstress_info.edma_stress_test_task_id \ = taskSpawn ("edmaBusTask", task_priority, 0, 20000, (FUNCPTR)edma2_stress_test_routine, 0, 0, 0, 0,0, 0, 0, 0, 0, 0); if(g_edma2_busstress_info.edma_stress_test_task_id == ERROR) { printf("taskSpawn edma2BusTask fail.\n"); /*sema_delete(g_edma2_busstress_info.edma_send_sem);*/ semDelete(g_edma2_busstress_info.edma_send_sem); ret = bsp_softtimer_free(&g_edma2_busstress_info.edma_softtimer_list); } else { bsp_softtimer_add( &g_edma2_busstress_info.edma_softtimer_list ); } return g_edma2_busstress_info.edma_stress_test_task_id; }