/* 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; }
/******************************************************************************* * 函 数 名 : cshell_udi_close_cb * * 功能描述 : USB拔出通知回调 * * 输入参数 : 无 * * 输出参数 : 无 * * 返 回 值 : 无 * *******************************************************************************/ void cshell_udi_close_cb(void) { /*lint --e{550} */ cshell_ctx_t *cshell_ctx = &g_cshell_ctx; int ret = 0; printk("A:cshell_udi_close_cb acm unplug: [0x%p]\n", cshell_ctx->cshell_acm_fd); /* 注意, cshell_acm_fd 是指针, 不是整形 */ if (cshell_ctx->cshell_acm_fd) { bsp_acm_ioctl(cshell_ctx->cshell_acm_fd, ACM_IOCTL_SET_READ_CB, NULL); ret = bsp_acm_close(cshell_ctx->cshell_acm_fd); if (CSHELL_OK != ret) { printk("A:cshell_init cb register fail: [0x%x]\n", ret); return; } cshell_ctx->cshell_acm_fd = 0; } (void)cshell_clear_bit(USB_CSHELL); if(g_cshell_ctx.ccshell_work_flg) { ret = (int)bsp_icc_send((u32)ICC_CPU_MODEM, (ICC_CHN_IFC << 16)|IFC_RECV_FUNC_CSHELL, &cshell_ctx->acshell_permit, 1); if(ret <= 0) { printk("A:fail to send close flag to c-core\n"); return; } }else{ printk("[ACSHELL] modem is being reset\n"); } }
/* 测试发送函数 */ static s32 icc_send_test(enum CPU_ID send_cpu_id, u32 channel_id, u8 *buf, u32 data_len, u32 start, u32 timeout) { u32 i = 0; for(i = 0; i < data_len; i++) { buf[i]= (u8)(i + start); } icc_print_debug("enter: channel_id=0x%x\n", channel_id); if((s32)data_len != bsp_icc_send(send_cpu_id, channel_id, buf, data_len)) { icc_print_error("bsp_icc_send error\n"); return ICC_ERR; } if(osl_sem_downtimeout(&(g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)].confirm_sem), (long)timeout)) /*lint !e732 */ { icc_print_error("icc_sem_take error\n"); return ICC_ERR; } return ICC_OK; }
/***************************************************************************** 函 数 名 : bsp_drv_power_reboot 功能描述 : 用于C核进行重启处理,通过核间调用 输入参数 : 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : *****************************************************************************/ void bsp_drv_power_reboot( void ) { u32 channel_id = ICC_CHN_IFC << 16 | IFC_RECV_FUNC_ONOFF; stCtrlMsg msg = g_pwrctrl.curr; int rt = 0; msg.pwr_type = E_POWER_POWER_REBOOT; if(!g_pwrctrl.is_init) return; osl_sem_down(&(g_pwrctrl.pwr_sem)); if(sizeof(stCtrlMsg) != (u32)(rt = bsp_icc_send(ICC_CPU_APP, channel_id, (u8*)&msg, sizeof(stCtrlMsg)))) { osl_sem_up(&(g_pwrctrl.pwr_sem)); bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_ONOFF,"[onoff]c core excute power reboot failed rt=0x%x \n", rt); return ; } osl_sem_up(&(g_pwrctrl.pwr_sem)); bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_ONOFF,"[onoff]ccore power reboot cmd send success,waiting for system power reboot\n"); return ; }
static void hisi_sim_det_msg_to_ccore(struct hisi_sim_hotplug_info *info, u8 sim_state) { #ifdef CONFIG_HISI_BALONG_MODEM u32 channel_id = 0; int det_gpio_state = 0; int len = 0; if (NULL == info) { pr_err("%s: input param is null, just return.\n", __func__); return; } if (0 == info->send_msg_to_lpm3) { pr_err("%s: send_msg_to_lpm3 is 0.\n", __func__); return; } det_gpio_state = gpio_get_value(info->det_gpio); pr_info("%s, sim_id=%d, old_det_gpio=%d, det_gpio=%d \n", __func__, info->sim_id, info->old_det_gpio_state, det_gpio_state); if (det_gpio_state == info->old_det_gpio_state) { pr_info("%s, det_gpio_state not changed, just return \n", __func__); return; } info->old_det_gpio_state = det_gpio_state; if (SIM0_ID == info->sim_id) { channel_id = SIM0_CHANNEL_ID; } else if (SIM1_ID == info->sim_id) { channel_id = SIM1_CHANNEL_ID; } else { pr_err("%s: sim_id invalid:%d.\n", __func__, info->sim_id); return; } if (SIM_CARD_OUT != sim_state && SIM_CARD_IN != sim_state) { pr_err("%s: sim_state invalid and it is %d.\n", __func__, sim_state); return; } pr_info("%s: sim_id=%d, sim_state=%s \n", __func__, info->sim_id, s_sim_state_tbl[sim_state].sim_state_str); len = bsp_icc_send(ICC_CPU_MODEM, channel_id, &sim_state, sizeof(sim_state)); if( len != sizeof(sim_state)) { pr_err("%s: bsp_icc_send failed! len = %d, expected len = %d\n", __func__, len, sizeof(sim_state)); return; } update_sim_state_info(info->sim_id, sim_state); pr_info("%s: end \n", __func__); #else pr_info("%s: CONFIG_HISI_BALONG_MODEM not defined \n", __func__); #endif }
/***************************************************************************** 函 数 名 : drv_shut_down 功能描述 : 用于C核进行关机处理,通过核间调用 输入参数 : 关机原因 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : *****************************************************************************/ void drv_shut_down( DRV_SHUTDOWN_REASON_ENUM enReason ) { u32 channel_id = ICC_CHN_IFC << 16 | IFC_RECV_FUNC_ONOFF; stCtrlMsg msg = g_pwrctrl.curr; int rt = 0; msg.pwr_type = E_POWER_SHUT_DOWN; msg.reason = enReason; if(!g_pwrctrl.is_init) return; osl_sem_down(&(g_pwrctrl.pwr_sem)); if(sizeof(stCtrlMsg) != (u32)(rt = bsp_icc_send(ICC_CPU_APP, channel_id, (u8*)&msg, sizeof(stCtrlMsg)))) { osl_sem_up(&(g_pwrctrl.pwr_sem)); bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_ONOFF,"[onoff]c core excute shut down failed rt=0x%x \n", rt); return ; } osl_sem_up(&(g_pwrctrl.pwr_sem)); bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_ONOFF,"[onoff]ccore shut down cmd send success,waiting for system shut down\n"); return ; }
int cshell_mode_reset_cb(DRV_RESET_CALLCBFUN_MOMENT eparam, int usrdata) { int ret = 0; switch(eparam) { case DRV_RESET_CALLCBFUN_RESET_BEFORE: g_cshell_ctx.ccshell_work_flg = 0; break; case DRV_RESET_CALLCBFUN_RESET_AFTER: g_cshell_ctx.ccshell_work_flg = 1; if(g_cshell_ctx.acshell_permit) { ret = bsp_icc_send((u32)ICC_CPU_MODEM, (ICC_CHN_IFC << 16)|IFC_RECV_FUNC_CSHELL, &g_cshell_ctx.acshell_permit, 1); if(ret <= 0) { printk("<cshell> fail to send permit flg\n"); g_cshell_ctx.reset_infor_fail_times++; } else { ret = 0; } } break; default: break; } return ret; }
int balong_cpufreq_icc_send(struct cpufreq_msg *msg) { u32 channel_id = ICC_CHN_MCORE_ACORE << 16 | MCU_ACORE_CPUFREQ; s32 ret = 0; u32 msg_len = sizeof(struct cpufreq_msg); if (!g_cpufreq_lock_status_flag) { return BSP_ERROR; } ret = balong_check_msg(msg); if (BSP_ERROR == ret) { return BSP_OK; } if (msg->msg_type != CPUFREQ_GET_FREQ_FROM_M) { debug_msg.msg_type = msg->msg_type; debug_msg.source = msg->source; debug_msg.content = msg->content; debug_msg.profile = msg->profile; } ret = bsp_icc_send(ICC_CPU_MCU, channel_id, (u8 *)msg, msg_len); if(ret != (s32)msg_len) { cpufreq_err("mcore return an ERROR please check m3 %d\n", ret); return BSP_ERROR; } return BSP_OK; }
int bsp_hkadc_convert(enum HKADC_CHANNEL_ID channel, u16* value) { int ret; u32 hkadc_channel_id = (u32)channel; u32 icc_channel_id = ICC_CHN_MCORE_ACORE << 16 | MCORE_ACORE_FUNC_HKADC; osl_sem_down(&g_hkadc_icc_sem_id); ret = bsp_icc_send(ICC_CPU_MCU, icc_channel_id, (u8*)&hkadc_channel_id, sizeof(hkadc_channel_id)); if (ret != (int)sizeof(hkadc_channel_id)) { osl_sem_up(&g_hkadc_icc_sem_id); bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_HKADC, "icc send error, error code: 0x%x\r\n", ret); return ret; } /*coverity[lock] */ osl_sem_down(&g_hkadc_value_sem_id); if (0xFFFF == g_hkadc_voltage) { ret = -1; } else { ret = 0; *value = g_hkadc_voltage; } osl_sem_up(&g_hkadc_icc_sem_id); /*coverity[missing_unlock] */ return ret; }
s32 bsp_close(u32 fd) { s32 ret; struct bsp_rfile_close_req stReq; osSemaphoreWait(g_stRfileMain.semAll, osWaitForever); stReq.opType = EN_RFILE_OP_CLOSE; stReq.pstlist = NULL; stReq.fd = fd; ret = bsp_icc_send(ICC_CPU_APP, RFILE_MCORE_ICC_WR_CHAN, &stReq, sizeof(struct bsp_rfile_close_req)); if (sizeof(struct bsp_rfile_close_req) != ret) { bsp_trace(BSP_LOG_LEVEL_DEBUG, BSP_MODU_RFILE, "%d.\n", __LINE__); g_stRfileMain.ret = -1; } else { osSemaphoreWait(g_stRfileMain.semReq, osWaitForever); } osSemaphoreRelease(g_stRfileMain.semAll); return g_stRfileMain.ret; }
int cshell_enable(int val) { int ret = 0; if(val >= (int)INVAL_CSHELL || val < 0) { printk("<cshell>:input param err. %d:USB_CSHELL, %d:FILE_CSHELL, %d:AUART_CSHELL\n", (int)USB_CSHELL,(int)FILE_CSHELL,(int)AUART_CSHELL); return -1; } (void)cshell_set_bit(val); if(!g_cshell_ctx.ccshell_work_flg) { printk("<cshell>: modem is being reseting\n"); return 0; } ret = bsp_icc_send((u32)ICC_CPU_MODEM, (ICC_CHN_IFC << 16)|IFC_RECV_FUNC_CSHELL, &g_cshell_ctx.acshell_permit, sizeof(g_cshell_ctx.acshell_permit)); if(ret != (int)sizeof(g_cshell_ctx.acshell_permit)) { printk("<cshell>: fail to send permit flag to cp.\n"); return ret; } return 0; }
void efuse_handle_work(struct work_struct *work) { u32 i = 0; int length = 0; u32 channel_id = ICC_CHN_IFC << 16 | IFC_RECV_FUNC_EFUSE; EFUSE_DATA_STRU *msg = &efuse_msg; if(EFUSE_READ == (u32)msg->opt) { if(1 == efuse_debug_flag) { pr_info("efuse read start group %d length %d.\n", msg->start, msg->len); } msg->ret = bsp_efuse_read(msg->buf, msg->start,msg->len); if(1 == efuse_debug_flag) { pr_info("efuse read end group %d length %d.\n", msg->start, msg->len); for(i = 0;i < msg->len;i++) { pr_info("efuse buf[%d] is 0x%x.\n", i, msg->buf[i]); } pr_info("efuse read ret %d\n", msg->ret); } } else if(EFUSE_WRITE == (u32)msg->opt) { if(1 == efuse_debug_flag) { pr_info("efuse write start group %d length %d.\n", msg->start, msg->len); for(i = 0;i < msg->len;i++) { pr_info("efuse buf[%d] is 0x%x.\n", i, msg->buf[i]); } } msg->ret = bsp_efuse_write(msg->buf, msg->start,msg->len); if(1 == efuse_debug_flag) { pr_info("efuse write ret %d.\n", msg->ret); } } else { msg->ret = EFUSE_ERROR; } length = bsp_icc_send(ICC_CPU_MODEM, channel_id, (unsigned char*)msg, sizeof(EFUSE_DATA_STRU)); if(length != (int)sizeof(EFUSE_DATA_STRU)) { efuse_print_error("send len(%x) != expected len(%lu).\n", length, (unsigned long)sizeof(EFUSE_DATA_STRU)); return; } }
s32 bsp_open(const s8 *path, s32 flags, s32 mode) { s32 ret; u32 ulNameLen, ulSize; struct bsp_rfile_open_req *pstReq; osSemaphoreWait(g_stRfileMain.semAll, osWaitForever); if(!path) { return BSP_ERROR; } ulNameLen = strlen(path) + 1; ulSize = sizeof(struct bsp_rfile_open_req) + ulNameLen; if(ulSize > RFILE_LEN_MAX) { return BSP_ERROR; } pstReq = Rfile_Malloc(ulSize); if(!pstReq) { return BSP_ERROR; } pstReq->opType = EN_RFILE_OP_OPEN; pstReq->pstlist = NULL; pstReq->nameLen = ulNameLen; pstReq->mode = mode; pstReq->flags = flags; memcpy(pstReq->aucData, path, ulNameLen); ret = bsp_icc_send(ICC_CPU_APP, RFILE_MCORE_ICC_WR_CHAN, pstReq, ulSize); if (ulSize != ret) { bsp_trace(BSP_LOG_LEVEL_DEBUG, BSP_MODU_RFILE, "%d.\n", __LINE__); g_stRfileMain.ret = -1; } else { osSemaphoreWait(g_stRfileMain.semReq, osWaitForever); } Rfile_Free(pstReq); osSemaphoreRelease(g_stRfileMain.semAll); return g_stRfileMain.ret; }
/* * nv use this inter to send data through the icc channel */ u32 nv_icc_send(u8* pdata,u32 len) { u32 ret = NV_ERROR; u32 chanid = 0; chanid = ICC_CHN_MCORE_ACORE << 16 | NV_RECV_FUNC_AM; ret = (u32)bsp_icc_send(ICC_CPU_APP,chanid,pdata,len); if(len != ret) { return BSP_ERR_NV_ICC_CHAN_ERR; } return NV_OK; }
BSP_S32 BSP_ICC_Write(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_send(ICC_SEND_CPU, channel_id, (u8*)pData, (u32)s32Size); }
static s32 cpufreq_icc_send_ccore(T_CPUFREQ_MAIL *msg) { u32 channel_id = (ICC_CHN_MCORE_CCORE << 16) | MCU_CCORE_CPUFREQ; s32 ret = 0; u32 msglen = sizeof(T_CPUFREQ_MAIL); ret = bsp_icc_send(ICC_CPU_MODEM, channel_id, (u8*)msg, msglen); if(ret != msglen)/*lint !e737*/ { M3CPUFREQ_PRINT("send_ccore error\n"); return -1; } return 0; }
/***************************************************************************** 函 数 名 : bsp_power_icc_send_state 功能描述 : C核核间通信函数 输入参数 : 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : *****************************************************************************/ static void bsp_power_icc_send_state(void) { int ret = 0; int mode = 0; u32 icc_channel_id = ICC_CHN_IFC << 16 | IFC_RECV_FUNC_ONOFF; mode = bsp_start_mode_get(); ret = bsp_icc_send(ICC_CPU_MODEM, icc_channel_id, (u8*)&mode, sizeof(mode)); if (ret != (int)sizeof(mode)) { pr_dbg("send len(%x) != expected len(%x)\n", ret, sizeof(mode)); } }
/***************************************************************************** * 函 数 名 : bsp_efuse_read * * 功能描述 : 按组读取EFUSE中的数据 * * 输入参数 : group 起始group * num 读取长度(word数,不超过512/4=128) * 输出参数 : pBuf EFUSE中的数据 * * 返 回 值 : * * 其它说明 : * *****************************************************************************/ int bsp_efuse_read(u32* pBuf, const u32 group, const u32 num) { int length = 0; u32 *buf = efuse_buf; u32 chan_id = ICC_CHN_IFC << 16 | IFC_RECV_FUNC_EFUSE; EFUSE_DATA_STRU msg; if((0 == num) || (group + num > EFUSE_MAX_SIZE) || (NULL == pBuf) || (num > EFUSE_MAX_ALLOW_SIZE)) { efuse_print_error(" parameter error, group=%d, num=%d, pBuf=0x%x.\n", group, num, pBuf); return EFUSE_ERROR; } msg.start = group; msg.len = num; msg.opt = (u32)EFUSE_READ; osl_sem_down(&efuse_queue_sem_id); length = bsp_icc_send(ICC_CPU_APP, chan_id, (unsigned char*)&msg, sizeof(EFUSE_DATA_STRU)); if((unsigned int)length != sizeof(EFUSE_DATA_STRU)) { osl_sem_up(&efuse_queue_sem_id); efuse_print_error("send len(%x) != expected len(%x).\n", length, sizeof(EFUSE_DATA_STRU)); return EFUSE_ERROR; } /* coverity[lock] */ osl_sem_down(&efuse_sem_id); if(0 != efuse_ret) { osl_sem_up(&efuse_queue_sem_id); efuse_print_error("efuse icc write is fail, err= %d.\n", efuse_ret); /* coverity[missing_unlock] */ return EFUSE_ERROR; } else { memcpy(pBuf, buf, EFUSE_GROUP_SIZE * num); } osl_sem_up(&efuse_queue_sem_id); /* coverity[missing_unlock] */ return EFUSE_OK; }
/* 该回调用于接收核不读数据,直接回确认信息给发送核 */ s32 icc_send_test_cb0_new(u32 channel_id , u32 len, void* context) { u8 confirm = ICC_CONF_MSG_TYPE1; u32 channel_idx = GET_CHN_ID(channel_id); u32 sub_chn_idx = GET_FUNC_ID(channel_id); u32 send_len = sizeof(confirm); icc_print_debug("enter: channel_id=0x%x\n", ((channel_idx << 16) | (sub_chn_idx + 1))); if((s32)send_len != bsp_icc_send(g_icc_dbg.send_cpu_id, ((channel_idx << 16) | (sub_chn_idx + 1)), &confirm, send_len)) { icc_print_error("send error!\n"); } return ICC_OK; }
/******************************************************************************* * 函 数 名 : cshell_udi_open_cb * * 功能描述 : USB插入通知回调 * * 输入参数 : 无 * * 输出参数 : 无 * * 返 回 值 : 无 * *******************************************************************************/ void cshell_udi_open_cb(void) { /*lint --e{550} */ cshell_ctx_t *cshell_ctx = &g_cshell_ctx; void* cshell_udi_handle ; int ret = 0; printk("A:cshell_udi_open_cb acm plugin: [0x%p]\n", cshell_ctx->cshell_acm_fd); /* 注意, cshell_acm_fd 是指针, 不是整形 */ if (cshell_ctx->cshell_acm_fd) { printk("A:cshell_udi_open_cb acm is already opened:[0x%p]\n", cshell_ctx->cshell_acm_fd); return; } cshell_udi_handle = bsp_acm_open(UDI_USB_ACM_SHELL); if (cshell_udi_handle == 0) { printk("A:cshell_udi_open_cb acm open fail: [0x%p]\n", cshell_udi_handle); return; } cshell_ctx->cshell_acm_fd = cshell_udi_handle; ret = bsp_acm_ioctl(cshell_ctx->cshell_acm_fd, ACM_IOCTL_SET_READ_CB, cshell_shell_recv_cb); if (CSHELL_OK != ret) { printk("A:cshell_udi_open_cb cb register fail: [0x%x]\n", ret); return; } printk("A:cshell_udi_open_cb cb register success: [0x%x],fd[0x%p]\n", ret, cshell_ctx->cshell_acm_fd); (void)cshell_set_bit(USB_CSHELL); if(g_cshell_ctx.ccshell_work_flg) { ret = (int)bsp_icc_send((u32)ICC_CPU_MODEM, (ICC_CHN_IFC << 16)|IFC_RECV_FUNC_CSHELL, &cshell_ctx->acshell_permit, 1); if(ret <= 0) { printk("A:fail to send open flag to c-core\n"); return; } }else{ printk("[ACSHELL] modem is being reset\n"); } }
/***************************************************************************** * 函 数 名 : socp_power_req_cb * * 功能描述 : powerctrl执行完上、下电请求后,回调 * * 输入参数 : 无 * * 输出参数 : 无 * * 返 回 值 : 释放成功与否的标识码 *****************************************************************************/ __ao_func s32 socp_power_req_cb(s32 data) { socp_vote_cnf_stru cnf_data; u32 chan_id; if(data == 0) { cnf_data.vote_rst = 1; } else { cnf_data.vote_rst = 0; } /* icc通道发送数据 */ chan_id = (ICC_CHN_MCORE_CCORE << 16) | MCORE_CCORE_FUNC_SOCP; (void)bsp_icc_send(ICC_CPU_MODEM, chan_id, (u8*)&cnf_data, sizeof(socp_vote_cnf_stru)); return BSP_OK; }
void cshell_send_data(char* data, int length) { SHELL_IO_CHAN *ptr_shell = &shell_io_channel; int size = 1024; int send_size; int sended_len = 0; while(data && length) { send_size = length < size ? length : size; sended_len = bsp_icc_send(ICC_CPU_APP, ptr_shell->icc_channel_id, (u8*)data, (u32)send_size); if (sended_len < 0) { break; } data += sended_len; length -= sended_len; taskDelay(5); } }
int send_cmd_ccore(char* func_name, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { char* cptr = (char*)&g_cshell_ctx.recv_cmd_str[0]; int ret = 0; if((0 == cshell_get_bit(AUART_CSHELL)) || !g_cshell_ctx.ccshell_work_flg || (0 == g_cshell_ctx.valid)) { printk("AUART_CSHELL %d ccshell_work_flg :%d\n", g_cshell_ctx.acshell_permit, g_cshell_ctx.ccshell_work_flg); return CSHELL_ERROR; } if((strlen(func_name) - 1) > (RECV_CMD_STR_LEN - 6 * 9 - 1 - 2)) { printk("[ACSHELL] func_name is too long\n"); return CSHELL_ERROR; } snprintf(cptr, RECV_CMD_STR_LEN, "%s 0x%X,0x%X,0x%X,0x%X,0x%X,0x%X\r\n", func_name + 1, arg1, arg2, arg3, arg4, arg5, arg6); ret = bsp_icc_send((u32)ICC_CPU_MODEM, (g_cshell_ctx.icc_channel_id << 16), (u8*)cptr, (u32)strlen(cptr)); cshell_log.auart_send_cmd_times += 1; return ret; }
int BSP_ICC_Write(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_send(ICC_SEND_CPU, channel_id, (u8*)pData, (u32)s32Size); }
/* 任务处理函数,读取通道里的数据 */ 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; }
/* * 发送消息 BSP_ERROR 发送失败;BSP_OK 发送成功 */ int balong_cpufreq_icc_send(struct cpufreq_msg *msg) { u32 channel_id = ICC_CHN_MCORE_CCORE << 16 | MCU_CCORE_CPUFREQ; s32 ret = 0; u32 time_value = 0; u32 msg_len = sizeof(struct cpufreq_msg); if (!g_cpufreq_lock_status_flag) { return BSP_ERROR; } ret = balong_check_msg(msg); if (BSP_ERROR == ret) { bsp_trace(BSP_LOG_LEVEL_DEBUG, BSP_MUDU_CPUFREQ,"msg is: msg_type:%d source:%d content:%d profile:%d\n", msg->msg_type, msg->source, msg->content, msg->profile); return BSP_OK; } if(g_lowpower_shared_addr) { time_value= bsp_get_slice_value(); writel(time_value, g_lowpower_shared_addr + 0x210); } debug_msg.msg_type = msg->msg_type; debug_msg.source = msg->source; debug_msg.content = msg->content; debug_msg.profile = msg->profile; cpufreq_pm_om_log(msg); ret = bsp_icc_send(ICC_CPU_MCU, channel_id, (u8 *)msg, msg_len); if((ret < 0) && (ret != BSP_ERR_ICC_CCORE_RESETTING)) { cpufreq_err("mcore return an ERROR please check m3 %d\n", ret); return BSP_ERROR; } return BSP_OK; }
/******************************************************************************* * FUNC NAME: * led_state_check_callback() - C核软timer回调函数 * Function : * Arguments * input : null * output : null * * Return : null * Decription : ************************************************************************/ void led_state_check_callback(void) { int ret = LED_ERROR; /* 获取上层状态 */ if (NULL != p_func_tled_state_get) { g_new_work_state = (unsigned char)((*p_func_tled_state_get)()); } else { return; } LED_TRACE(LED_DEBUG_LEVEL(INFO), "[%s]LED get new state success, new state %d\n", __FUNCTION__, g_new_work_state); /* 与当前状态进行比较,若不同,则更新当前状态并通知A核闪灯 */ if(g_cur_work_state != g_new_work_state) { ret = bsp_icc_send(ICC_CPU_APP, LED_ICC_CHN_ID, (unsigned char*)&g_new_work_state, sizeof(unsigned char)); if(ret != (int)sizeof(unsigned char)) { LED_TRACE(LED_DEBUG_LEVEL(ERROR), "[%s]icc send failed, new state %d, length %d\n", __FUNCTION__, g_new_work_state, ret); return; } LED_TRACE(LED_DEBUG_LEVEL(INFO), "[%s]icc send success, new state %d\n", __FUNCTION__, g_new_work_state); g_cur_work_state = g_new_work_state; } LED_TRACE(LED_DEBUG_LEVEL(INFO), "[%s]LED same state, skip\n", __FUNCTION__); bsp_softtimer_add(&led_softtimer); return; }
void socp_debug_sendCmd(char* cmd) { struct socp_debug_icc_stru icc_req; int ret; u32 channel_id = ICC_CHN_ACORE_CCORE_MIN <<16 | IFC_RECV_FUNC_SOCP_DEBUG; u32 cpu_id; #if defined(__KERNEL__) cpu_id = (u32)ICC_CPU_MODEM; #else cpu_id = (u32)ICC_CPU_APP; #endif Socp_Memset(icc_req.OpsCmd,0,sizeof(icc_req.OpsCmd)); Socp_Memcpy(icc_req.OpsCmd, cmd, strlen(cmd));/*lint !e666*/ socp_printf("enter here %s %d\n",__FUNCTION__,__LINE__); ret = bsp_icc_send(cpu_id,channel_id, (u8*)&icc_req,sizeof(icc_req)); if(ret != (int)sizeof(icc_req)) { socp_printf("bsp_icc_send failed! ret 0x%x\n",ret); } return; }
static s32 rfile_write(u32 fd ,void *ptr, u32 size) { s32 ret; struct bsp_rfile_write_req *pstReq; u32 ulLen; ulLen = sizeof(struct bsp_rfile_write_req) + size; pstReq = Rfile_Malloc(ulLen); if(!pstReq) { bsp_trace(BSP_LOG_LEVEL_DEBUG, BSP_MODU_RFILE, "%d.\n", __LINE__); return BSP_ERROR; } pstReq->opType = EN_RFILE_OP_WRITE; pstReq->pstlist = NULL; pstReq->fd = fd; pstReq->ulSize = size; memcpy(pstReq->aucData, ptr, size); ret = bsp_icc_send(ICC_CPU_APP, RFILE_MCORE_ICC_WR_CHAN, pstReq, ulLen); if (ulLen != ret) { bsp_trace(BSP_LOG_LEVEL_DEBUG, BSP_MODU_RFILE, "%d.\n", __LINE__); g_stRfileMain.ret = -1; } else { osSemaphoreWait(g_stRfileMain.semReq, osWaitForever); } Rfile_Free(pstReq); return g_stRfileMain.ret; }
/***************************************************************************** 函 数 名 : bsp_start_mode_get 功能描述 : 用于C核获取开机模式,通过核间调用, 启动的时候不允许获取 输入参数 : 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : *****************************************************************************/ int bsp_start_mode_get( void ) { int rt = 0; u32 channel_id = ICC_CHN_IFC << 16 | IFC_RECV_FUNC_ONOFF; DRV_START_MODE start_mode = DRV_START_MODE_NORMAL; stCtrlMsg msg = g_pwrctrl.curr; if(!g_pwrctrl.is_init) return start_mode; if (g_start_mode != (int)DRV_START_MODE_BUILT) return g_start_mode; msg.pwr_type = E_POWER_ON_MODE_GET; msg.mode = DRV_START_MODE_NORMAL; osl_sem_down(&(g_pwrctrl.pwr_sem)); rt = bsp_icc_send(ICC_CPU_APP, channel_id, (u8*)&msg, sizeof(stCtrlMsg)); //lint !e40 if(rt != (int)sizeof(stCtrlMsg)) { osl_sem_up(&(g_pwrctrl.pwr_sem)); bsp_trace(BSP_LOG_LEVEL_ERROR, BSP_MODU_ONOFF,"[onoff]onoff icc send error, rt=0x%x\n", rt); return start_mode; } /*coverity[lock] */ osl_sem_down(&g_sem_mode); start_mode = (DRV_START_MODE)g_start_mode; osl_sem_up(&(g_pwrctrl.pwr_sem)); /*coverity[missing_unlock] */ return start_mode; }