/* * Function : sc_icc_task * Discription: c core nv init,this phase build upon the a core kernel init, * this phase after icc init,this phase ensure to use all nv api normal * start at this phase ,ops global ddr need spinlock * Parameter : none * Output : result * History : */ void sc_icc_task(void) { s32 read_len = 0; s32 sc_fp = 0; s8* sc_path = (s8*)SC_PACKET_TRANS_FILE; sc_icc_stru icc_recv = {MISC_SC_OPT_BUTT}; /* coverity[no_escape] */ /* coverity[loop_top] */ for(;;) { osl_sem_down(&g_sc_stat.sc_tsk_sem); sc_debug_printf("get sem ok!\n"); read_len = bsp_icc_read(SC_ICC_CHAN_ID, (u8*)&icc_recv, sizeof(sc_icc_stru)); if(read_len > (s32)sizeof(sc_icc_stru)) { osl_sem_up(&g_sc_stat.sc_tsk_sem); sc_error_printf("bsp icc read error, chanid :0x%x ret :0x%x\n",SC_ICC_CHAN_ID,read_len); continue; } else if(0 >= read_len) { sc_error_printf("bsp icc read error, length is 0x%x!\n", read_len); continue ; } if( MISC_SC_OPT_READ == icc_recv.sc_opt_type) { if(SC_OK == icc_recv.sc_cnf_ret) { sc_fp = bsp_open(sc_path, (RFILE_RDONLY), 0660); /* [false alarm]: fortify 误报*/ if(sc_fp < 0) { sc_error_printf("open file %s failed!\n",sc_path); g_sc_stat.sc_opt_ret = BSP_ERR_SC_NO_FILE; osl_sem_up(&g_sc_stat.sc_api_sem); continue ; } read_len = bsp_read((u32)sc_fp, (s8 *)(g_sc_stat.sc_ram_addr), g_sc_stat.sc_ram_len); /* [false alarm]: fortify 误报*/ if(read_len != (s32)(g_sc_stat.sc_ram_len)) { sc_error_printf("read %s fail, read len is 0x%x, given len is 0x%x!\n",sc_path,read_len,g_sc_stat.sc_ram_len); bsp_close((u32)sc_fp); g_sc_stat.sc_opt_ret = BSP_ERR_SC_READ_FILE_FAIL; osl_sem_up(&g_sc_stat.sc_api_sem); continue ; } bsp_close((u32)sc_fp); } } sc_debug_printf("send to api interface\n"); g_sc_stat.sc_opt_ret = icc_recv.sc_cnf_ret; osl_sem_up(&g_sc_stat.sc_api_sem); } }
/******************************************************** *函数名 : mbb_common_mlog_recv *函数功能 : 接收C核需要发到mobile log模块的日志 *输入参数 : u32 channel_id , u32 len, void* context *输出参数 : 无 *返回值 : 执行成功返回0,失败返回非0值 *修改历史 : * 2014-2-18 徐超 初版作成 ********************************************************/ static int mbb_common_mlog_recv( u32 channel_id , u32 len, void* context ) { int rt = 0; int read_len = 0; stMbbCommonMlog mlogbuf; mlogbuf.len = 0; mlogbuf.loglv = 0; read_len = bsp_icc_read(channel_id, (u8*)&mlogbuf, len); if((read_len > len) || (read_len < 0)) { printk(KERN_ERR "[Mbb Common Drv] mlogbuf.len =(%d),read len(%d),len(%d), msg: %s.\n", mlogbuf.len, read_len,len, mlogbuf.msg); return -1; } printk(KERN_INFO "[Mbb Common Drv] module=(%s),mlogbuf.len =(%d),read len(%d),len(%d),lv=(%d),msg: %s.\n", mlogbuf.module, mlogbuf.len, read_len, len, mlogbuf.loglv, mlogbuf.msg); #if (FEATURE_ON == MBB_MLOG) mlog_print(mlogbuf.module, mlogbuf.loglv, "%s", mlogbuf.msg); #endif #if ( FEATURE_ON == MBB_MLOG) mstat_thermal_protection(mlogbuf.module); #endif return 0; }
/* 收对方核回过来的确认信息: 如果信息是ICC_CONF_MSG_TYPE1 */ s32 icc_send_test_cb1_new(u32 channel_id , u32 len, void* context) { u8 confirm = (u8)ICC_RECV_OK; u32 channel_idx = GET_CHN_ID(channel_id); u32 sub_chn_idx = GET_FUNC_ID(channel_id); s32 read_len = sizeof(confirm); icc_print_debug("enter\n"); if(read_len == bsp_icc_read(channel_id, &confirm, len)) { icc_print_debug("confirm:0x%x\n", confirm); if(ICC_CONF_MSG_TYPE1 == confirm) { g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx-1].success_cnt++; osl_sem_up(&(g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx-1].confirm_sem)); /*lint !e40 !e516 */ } else if(ICC_CONF_MSG_TYPE2 == confirm) { g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx+1].success_cnt++; osl_sem_up(&(g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx+1].confirm_sem)); /*lint !e40 !e516 */ } else { icc_print_error("error: wrong confirm:0x%x\n", confirm); } } else { icc_print_error("icc read error\n", confirm); } return ICC_OK; }
int socp_debug_icc_task(void* para) { int ret; u32 i; u32 chanid = ICC_CHN_ACORE_CCORE_MIN <<16 | IFC_RECV_FUNC_SOCP_DEBUG; u8 p[32]; while(1) { osl_sem_down(&g_stSocpDebugCtrl.task_sem); ret = bsp_icc_read(chanid,p, sizeof(p)); if(ret< (int)0 || ret > (int)sizeof(p)) { socp_printf("enter here %s %d\n",__FUNCTION__,__LINE__); continue; } socp_printf("%s :%s\n",__FUNCTION__,p); for(i = 0;i<sizeof(g_strSocpOps)/sizeof(g_strSocpOps[0]);i++) { if(!strncmp(g_strSocpOps[i].OpsCmd,(char*)p,strlen(g_strSocpOps[i].OpsCmd))){ g_strSocpOps[i].OpsFunc(); } } } }
/* 1. 比较发过来的信息是否是正确的(事先约定); * 2. 往对方核发确认信息,确认发过来的信息正确与否 */ static s32 icc_send_test_001_cb0(u32 channel_id , u32 len, void* context) { u32 i = 0; s32 confirm = ICC_RECV_OK; u32 start = (u32)context; u32 channel_idx = GET_CHN_ID(channel_id); u32 sub_chn_idx = GET_FUNC_ID(channel_id); icc_print_debug("====start:0x%x\n", start); if((s32)len != bsp_icc_read(channel_id, g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx].rd_buf, len)) { confirm = ICC_RECV_ERR; goto out; } for(i = 0; i < len; i++) { if(((u8)i + start) != g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx].rd_buf[i]) { confirm = ICC_RECV_ERR; goto out; } } confirm = ICC_RECV_OK; out: channel_id = ((channel_idx << 16) | (sub_chn_idx + 1)); bsp_icc_send(g_icc_dbg.send_cpu_id, channel_id, (u8 *)&confirm, sizeof(confirm)); return ICC_OK; }
static int recv_lpm3_msg_icc_cb(u32 chan_id, u32 len, void* context) { u8 flag = 0; s32 read_size = 0; read_size = bsp_icc_read((ICC_CHN_MCORE_CCORE << 16)|MCORE_CCORE_FUNC_UART, &flag, len); if ((read_size > (s32)len) && (read_size <= 0)) { return ERROR; } if(g_dual_modem_ctrl.init_flag != DUAl_MODEM_ENABLE) { dm_print_err("dual modem not init\n"); return OK; } if(flag == VIA_WAKEUP_BALONG) { wake_lock(&g_dual_modem_ctrl.wakelock); dual_modem_restart_timer(&g_dual_modem_ctrl.sleep_timer); cpcp_msg_count_record(&g_dm_dump_info->via_wakeup_balong_cnt, "WakeupBalongcnt"); } if(flag == UART_INIT_ENABLE) { dm_print_err("lpm3 revc uart init icc\n"); } return OK; }
/* 此处是否需要起任务其所在任务进行了锁中断处理。。。 */ static int cshell_read_cb(u32 channel_id , u32 len, void* context) { int i = 0; int read_size = 0; SHELL_IO_CHAN *ptr_shell = &shell_io_channel; if (!g_cshell_dbg.state) { cshell_print_error("C:cshell_read_cb fail for icc channel is no opened\n"); return 1; } if (!len) { cshell_print_error("C:cshell_read_cb fail for zero length data\n"); return 1; } read_size = (int)bsp_icc_read((ptr_shell->icc_channel_id), ptr_shell->ptr_recv_buf, len); if ((read_size > (int)len) || (read_size < 0)) { cshell_print_error("C:cshell_read_cb fail [0x%x]\n", read_size); return 1; } g_cshell_dbg.recv_data_cnt++; for (i = 0; i < read_size; i++) { (void)(ptr_shell->put_rx_char)(ptr_shell->put_rx_arg, *(ptr_shell->ptr_recv_buf + i)); } return 0; }
static s32 cpufreq_icc_read_cb(u32 id , u32 len, void* context) { s32 ret = 0; u8 data[32]; T_CPUFREQ_MAIL *smail; if((len == 0) || (len > 32)) { M3CPUFREQ_PRINT("readcb len is 0 \n"); return -1; } ret = bsp_icc_read(id, data, len); if(len != ret)/*lint !e737*/ { M3CPUFREQ_PRINT("readcb error \r\n"); return -1; } /*lint --e{569} */ smail = osMailCAlloc(cpufreq_mail, osWaitForever); memcpy(smail, data, len); osMailPut(cpufreq_mail, smail); return 0; }
s32 bsp_RfileCallback(u32 channel_id, u32 len, void *context) { void *pData; s32 ret; pData = Rfile_Malloc(len); if(!pData) { bsp_trace(BSP_LOG_LEVEL_DEBUG, BSP_MODU_RFILE, "%d.\n", __LINE__); return BSP_ERROR; } ret = bsp_icc_read(RFILE_MCORE_ICC_RD_CHAN, pData, len); if(len != ret) { bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_RFILE, "icc_read failed %d.\n", ret); Rfile_Free(pData); return BSP_ERROR; } rfile_CommonCnf(pData); Rfile_Free(pData); osSemaphoreRelease(g_stRfileMain.semReq); return BSP_OK; }
/* 回复确认信息或者核间函数调用结果返回 */ static s32 icc_send_test_001_cb1(u32 channel_id , u32 len, void* context) { s32 confirm = ICC_RECV_OK; u8 *buf = NULL; buf = g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)].rd_buf; if(!buf) { icc_print_error("malloc mem error!\n"); return ICC_ERR; } icc_print_debug("channel_id:0x%x\n", channel_id); //icc_task_delay(20); icc_print_debug("confirm_sem:0x%x\n", &(g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)-1].confirm_sem)); /*lint !e40 */ if((s32)len == bsp_icc_read(channel_id, buf, len)) { memcpy(&confirm, buf, sizeof(confirm)); icc_print_debug("confirm:0x%x\n", confirm); if(ICC_RECV_OK == confirm) { g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)-1].success_cnt++; osl_sem_up(&(g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)-1].confirm_sem)); /*lint !e40 !e516 */ } } return ICC_SEND_SYNC_RET; }
/* * nv read data from global ddr of icc through the chanel id */ u32 nv_icc_read(u32 chanid, u32 len) { u32 ret = NV_ERROR; memset(g_nv_ctrl.nv_icc_buf,0,NV_ICC_BUF_LEN); ret = (u32)bsp_icc_read(chanid,g_nv_ctrl.nv_icc_buf,len); if(len != ret) { return BSP_ERR_NV_ICC_CHAN_ERR; } return NV_OK; }
BSP_S32 BSP_ICC_Read(BSP_U32 u32ChanId, BSP_U8* pData, BSP_S32 s32Size) { u32 func_id = ICC_DEFAULT_SUB_CHANNEL; u32 channel_id = u32ChanId << 16 | func_id; if(!pData || u32ChanId >= ICC_CHN_ID_MAX) { icc_print_error("invalid param[%d], pData[%p]\n", u32ChanId, pData); return BSP_ERR_ICC_INVALID_PARAM; } return (BSP_S32)bsp_icc_read(channel_id, (u8*)pData, (u32)s32Size); }
void bsp_efuse_data_receive(void) { int length = 0; u32 channel_id = ICC_CHN_IFC << 16 | IFC_RECV_FUNC_EFUSE; length = bsp_icc_read(channel_id, (u8*)&efuse_msg, sizeof(EFUSE_DATA_STRU)); if(length != (int)sizeof(EFUSE_DATA_STRU)) { efuse_print_error("read len(%x) != expected len(%lu).\n", length, (unsigned long)sizeof(EFUSE_DATA_STRU)); return; } schedule_work(&efuse_work); }
static s32 balong_cpufreq_cb_getprofile(u32 channel_id , u32 len, void* context) { s32 ret = 0; struct cpufreq_msg cm = {0}; ret = bsp_icc_read(channel_id, (u8*)&cm, len); if(len != (u32)ret) { cpufreq_err("balong_cpufreq_cb_getload error \r\n"); return -1; } g_stDfsCpuControl.enCurProfile = cm.profile; cpufreq_info("get icc from Mcore msg_type->>%d, source->>%d, profile->>%d\n", cm.msg_type, cm.source, cm.profile); return 0; }
/** * balong_rtc_cb_settime-the icc callback function when ccore set the time through icc * @channel_id: the icc channel id. * @len: the type of the container struct this is embedded in. * @context: the parameter pass from the register * */ static s32 balong_rtc_cb_settime(u32 channel_id , u32 len, void* context) { s32 ret = 0; struct rtc_time tm = {0}; rtc_dbg("balong_rtc_cb_settime is actived\r\n"); ret = bsp_icc_read(channel_id, (u8*)&tm, len); rtc_dbg("%4d-%02d-%02d %02d:%02d:%02d\n", RTC_BASE_YEAR + tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); if(len != (u32)ret) { rtc_print_error("balong_rtc_cb_settime error \r\n"); return BSP_ERROR; } return balong_rtc_settime(NULL, &tm); }
static int cshell_command_cb(u32 chan_id, u32 len, void* context) { SHELL_IO_CHAN *ptr_shell = &shell_io_channel; s32 read_size = 0; u8 flag = 0; read_size = bsp_icc_read((ICC_CHN_IFC << 16)|IFC_RECV_FUNC_CSHELL, &flag, len); if ((read_size > (s32)len) && (read_size < 0)) { return 1; } ptr_shell->cshell_send_permission = (s32)flag; return 0; }
/******************************************************************************* * 函 数 名 : cshell_read_cb * * 功能描述 : cshell读回调,用于从C核读取数据 * * 输入参数 : id: icc通道 * len:数据大小 * * 输出参数 : 无 * * 返 回 值 : 1-读失败,0-读成功 * *******************************************************************************/ static int cshell_read_cb(u32 channel_id , u32 len, void* context) { cshell_ctx_t *cshell_ctx = &g_cshell_ctx; cshell_mem_handle_t *cshell_send_mem = NULL; int read_size = 0; if (!cshell_ctx->valid) { printk("A: [Warning] cshell send_buf has not allocated\n"); return CSHELL_ERROR; } memset(cshell_ctx->send_buf, 0, CSHELL_BUFFER_SIZE); read_size = (int)bsp_icc_read((cshell_ctx->icc_channel_id << 16), cshell_ctx->send_buf, len); if((read_size > (s32)len) || (read_size < 0)) { printk("A:cshell_read_cb read icc len[%d] data from c-core chan[0x%x] fail\n", read_size, channel_id); return CSHELL_ERROR; } cshell_send_mem = &cshell_ctx->send_mem[cshell_ctx->cshell_send_index]; if (!cshell_buf_valid_check(cshell_send_mem, (u32)read_size)) { cshell_send_mem = cshell_send_mem->next; if (!cshell_buf_valid_check(cshell_send_mem, (u32)read_size)) { //printk("A:cshell buffer full\n"); cshell_log.send_mem_drop_times += 1; return CSHELL_ERROR; } } memcpy(cshell_send_mem->buf + cshell_send_mem->buf_size, cshell_ctx->send_buf, (u32)read_size); cshell_send_mem->buf_size += (u32)read_size; cshell_ctx->cshell_send_index = cshell_send_mem->index; if (cshell_ctx->valid) { up(&(cshell_ctx->cshell_send_sem)); } return CSHELL_OK; }
s32 balong_cpufreq_cb_getprofile(u32 channel_id , u32 len, void* context) { s32 ret = 0; struct cpufreq_msg cm = {0}; ret = bsp_icc_read(channel_id, (u8*)&cm, len); if((s32)len != ret) { cpufreq_err("balong_cpufreq_cb_getload error \r\n"); return BSP_ERROR; } cpufreq_info("get icc from Mcore msg_type->>%d, source->>%d, profile->>%d\n", cm.msg_type, cm.source, cm.profile); return BSP_OK; }
/*lint --e{715 } */ static int bsp_on_off_icc_callback(u32 icc_channel_id , u32 len, void* context) { int ret = 0; int mode = 0; ret = bsp_icc_read(icc_channel_id, (u8*)&mode, len); if (ret != (int)sizeof(mode)) { mode = (int)DRV_START_MODE_NORMAL; bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_ONOFF, "on off icc read error, return length:%x", ret); } g_start_mode = mode; osl_sem_up(&g_sem_mode); return 0; }
/***************************************************************************** 函 数 名 : pastar_notify_exception 功能描述 : 接收C核发送的数据 输入参数 : @channel_id - icc 通道id @len - 数据长度 @context - 参数地址 输出参数 : 无 返 回 值 : 0 - 成功; else - 失败 *****************************************************************************/ s32 pastar_notify_exception(u32 channel_id , u32 len, void* context) { s32 ret = ERROR; pastar_print_info("Execuing ..."); /* recive data from ccore */ ret = bsp_icc_read(PASTAR_ICC_CHN_ID, (u8 *)reg_val, sizeof(reg_val)); if(sizeof(reg_val) != ret) { pastar_print_error("icc read failed, ret = %d\n", ret); return ret; } queue_work(pastar_dsm_wq, &pastar_dsm_work); /* success */ return OK; }
static int bsp_hkadc_icc_callback(u32 icc_channel_id , u32 len, void* context) { int ret; u16 voltage = 0; ret = bsp_icc_read(icc_channel_id, (u8*)&voltage, len); if (ret != (int)sizeof(voltage)) { g_hkadc_voltage = 0xFFFF; bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_HKADC, "hkadc icc read error, error code: 0x%x\r\n", ret); } else { g_hkadc_voltage = voltage; } osl_sem_up(&g_hkadc_value_sem_id); return 0; }
int BSP_ICC_Read(unsigned int u32ChanId, unsigned char* pData, int s32Size) { u32 channel_id = 0; u32 channel_index = 0; if (icc_channel_logic2phy(u32ChanId, &channel_id)) { icc_print_error("icc_channel_logic2phy err logic id 0x%x\n", u32ChanId); return ICC_INVALID_PARA; } channel_index = channel_id >> 16; if(!pData || channel_index >= ICC_CHN_ID_MAX) { icc_print_error("invalid param[%d], pData[0x%p]\n", channel_index, pData); return ICC_INVALID_PARA; } return (BSP_S32)bsp_icc_read(channel_id, (u8*)pData, (u32)s32Size); }
/***************************************************************************** 函 数 名 : bsp_loadps_ccore_callback 功能描述 : loadps的C核的ICC消息回调函数 输入参数 : channel_id ICC通道号 输出参数 : 成功返回0,失败返回非0 *****************************************************************************/ s32 bsp_loadps_ccore_callback ( u32 channel_id , u32 len, void* context ) { s32 read_len = 0; /*参数判断*/ if ( channel_id != LOADPS_ICC_IFC_ID ) { loadps_trace(BSP_LOG_LEVEL_ERROR ,"loadps icc channel error: channel_id = 0x%x, LOADPS_ICC_IFC_ID = 0x%x\n", channel_id, LOADPS_ICC_IFC_ID); return -1; } /*把A核发生的icc消息读出来查看*/ read_len = bsp_icc_read( LOADPS_ICC_IFC_ID, (u8*)(&g_loadps_status), sizeof(loadps_status)); if ( read_len != sizeof(loadps_status)) { loadps_trace(BSP_LOG_LEVEL_ERROR ,"read_len != msg_size: read_len = 0x%x, msg_size = 0x%x\n", read_len, sizeof(loadps_status)); return -1; } loadps_trace(BSP_LOG_LEVEL_ERROR ,"bsp_loadps_ccore_callback \n"); osl_sem_up(&loadps_wait_complete_mutex); return 0; }
static int bsp_efuse_data_receive(unsigned int channel_id , unsigned int len, void* context) { int length = 0; u32 *buf = efuse_buf; EFUSE_DATA_STRU msg ; length = bsp_icc_read(channel_id, (u8*)&msg, sizeof(EFUSE_DATA_STRU)); if(length != (int)sizeof(EFUSE_DATA_STRU)) { efuse_print_error("read len(%x) != expected len(%x).\n", length, sizeof(EFUSE_DATA_STRU)); efuse_ret = -1; osl_sem_up(&efuse_sem_id); return EFUSE_ERROR; } memcpy(buf, msg.buf, EFUSE_MAX_ALLOW_SIZE*EFUSE_GROUP_SIZE); efuse_ret = msg.ret; osl_sem_up(&efuse_sem_id); return EFUSE_OK; }
/* 任务处理函数,读取通道里的数据 */ s32 icc_read_task_entry(void *obj) { u32 channel_id = (u32)obj; u32 channel_idx = GET_CHN_ID(channel_id); u32 sub_chn_idx = GET_FUNC_ID(channel_id); s32 read_len = 0; u32 start = 0; u8 confirm = (u8)ICC_RECV_OK; s32 i = 0; u8 buf[ICC_NEW_DATA_LEN] = {0}; icc_print_debug("enter!!!"); for(;g_icc_test.recv_task_flag;) { osl_sem_down(&g_icc_test.recv_task_sem); read_len = bsp_icc_read(channel_id, buf, ICC_NEW_DATA_LEN); if(read_len < 0 || read_len > ICC_NEW_DATA_LEN) { confirm = (u8)ICC_RECV_ERR; } else { for(i = 0; i < read_len; i++) { if(((u8)i + start) != buf[i]) { confirm = (u8)ICC_RECV_ERR; } } confirm = ICC_CONF_MSG_TYPE2; } icc_print_debug("channel_id=0x%x, confirm=0x%x\n", channel_id, confirm); bsp_icc_send(g_icc_dbg.send_cpu_id, (channel_idx << 16) | (sub_chn_idx - 1), &confirm, sizeof(confirm)); } return 0; }
s32 bsp_tem_data_receive(void) { int len = 0; unsigned status = 0; unsigned region = 0; struct tem_msg_stru msg = {0}; u32 channel_id = ICC_CHN_MCORE_ACORE << 16 | MCORE_ACORE_FUNC_TEMPERATURE; len = bsp_icc_read(channel_id, (u8*)&msg, sizeof(struct tem_msg_stru)); if(len != (int)sizeof(struct tem_msg_stru)) { tem_print_error("read len(%x) != expected len(%lu).\n", len, (unsigned long)sizeof(struct tem_msg_stru)); return TEMPERATURE_ERROR; } if(msg.id != channel_id) { tem_print_error("msg id(%d) != expected channel_id(%d).\n", msg.id, channel_id); return TEMPERATURE_ERROR; } region = msg.region; status = msg.status; tem_print_info("temperature region = %d, status = %d.\n", region, status); /*POWER_SUPPLY数据上报*/ if(HKADC_BATTERY == region && (HIGH_TEMPERATURE == status) && (NULL != p_tem_fun)) { (*p_tem_fun)(DEVICE_ID_TEMP, POWER_SUPPLY_HEALTH_DEAD); } else if(HKADC_BATTERY == region && (LOW_TEMPERATURE == status) && (NULL != p_tem_fun)) { (*p_tem_fun)(DEVICE_ID_TEMP, POWER_SUPPLY_HEALTH_COLD); } return TEMPERATURE_OK; }
/***************************************************************************** * 函 数 名 : socp_icc_read_cb * * 功能描述 : icc通道读回调函数 * * 输入参数 : 无 * * 输出参数 : 无 * * 返 回 值 : 释放成功与否的标识码 *****************************************************************************/ __ao_func s32 socp_icc_read_cb(u32 id, u32 len, void * context) { s32 ret = 0; socp_vote_req_stru req_data; ret = bsp_icc_read(id, (u8 *)&req_data, len); if(len != (u32)ret) { return BSP_ERROR; } if(req_data.type == SOCP_VOTE_FOR_WAKE) { socp_power_on(socp_power_req_cb); } else { socp_power_off(socp_power_req_cb); } return BSP_OK; }
/***************************************************************************** 函 数 名 : bsp_power_ctrl_read_cb 功能描述 : C核核间回调函数 输入参数 : 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : *****************************************************************************/ static s32 bsp_power_ctrl_read_cb( void ) { int rt = 0; int read_len = 0; stCtrlMsg msg; u32 channel_id = ICC_CHN_IFC << 16 | IFC_RECV_FUNC_ONOFF; read_len = bsp_icc_read(channel_id, (u8*)&msg, sizeof(stCtrlMsg)); if(read_len != (int)sizeof(stCtrlMsg)) { pr_dbg("read len(%x) != expected len(%x)\n", read_len, sizeof(stCtrlMsg)); return -1; } pr_dbg("bsp_power_ctrl_read_cb 0x%x\n", msg.pwr_type); switch(msg.pwr_type) { case E_POWER_ON_MODE_GET: bsp_power_icc_send_state(); break; case E_POWER_SHUT_DOWN: drv_shut_down(msg.reason); break; case E_POWER_POWER_OFF: bsp_drv_power_off(); break; case E_POWER_POWER_REBOOT: bsp_drv_power_reboot(); break; default: pr_dbg("invalid ctrl by ccore\n"); break; } return rt; }
/* * Function : sc_icc_task * Discription: c core nv init,this phase build upon the a core kernel init, * this phase after icc init,this phase ensure to use all nv api normal * start at this phase ,ops global ddr need spinlock * Parameter : none * Output : result * History : */ void sc_icc_task(void) { s32 ret = -1; s32 icc_len = 0; sc_icc_stru icc_trans; /* coverity[no_escape] */ for(;;) { osl_sem_down(&g_sc_stat.sc_tsk_sem); sc_debug_printf("icc task, recv from acore ok, chanid :0x%x\n",SC_ICC_CHAN_ID); icc_len = bsp_icc_read(SC_ICC_CHAN_ID, (u8 * )&icc_trans, sizeof(sc_icc_stru)); if((icc_len > sizeof(sc_icc_stru))) { sc_error_printf("bsp icc read error, chanid :0x%x opt_len :0x%x\n",SC_ICC_CHAN_ID,icc_len); osl_sem_up(&g_sc_stat.sc_tsk_sem); continue; } else if(0 >= icc_len) { sc_debug_printf("bsp icc read error, length is 0!\n"); continue ; } g_sc_stat.sc_ram_len = icc_trans.sc_total_len; sc_debug_printf("len is 0x%x\n", g_sc_stat.sc_ram_len); icc_trans.sc_cnf_ret = SC_OK; /* get buffer */ g_sc_stat.sc_ram_addr = (u8* )osl_malloc(icc_trans.sc_total_len); if(!g_sc_stat.sc_ram_addr) { sc_error_printf("bsp icc read error, chanid :0x%x ret :0x%x\n",SC_ICC_CHAN_ID,ret); icc_trans.sc_cnf_ret = BSP_ERR_SC_MALLOC_FAIL; goto confirm; } else { sc_debug_printf("malloc ok!\n"); } if(MISC_SC_OPT_WRITE== icc_trans.sc_opt_type) { if(SC_OK != sc_bakup(g_sc_stat.sc_ram_addr, g_sc_stat.sc_ram_len)) { icc_trans.sc_cnf_ret = BSP_ERR_SC_WRITE_FILE_FAIL; } } else { if(SC_OK != sc_restore(g_sc_stat.sc_ram_addr, g_sc_stat.sc_ram_len)) { icc_trans.sc_cnf_ret = BSP_ERR_SC_READ_FILE_FAIL; } } osl_free(g_sc_stat.sc_ram_addr); confirm: /* send pkt to modem */ icc_len = bsp_icc_send(ICC_CPU_MODEM, SC_ICC_CHAN_ID, (u8*)&icc_trans, sizeof(sc_icc_stru)); if(icc_len != sizeof(sc_icc_stru)) { sc_error_printf("send to modem failed 0,icc_len is 0x%x!\n",icc_len); } else { sc_debug_printf("send to mdoem ok,icc_len is 0x%x!\n",icc_len); } continue; } }