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;
}
/* 收对方核回过来的确认信息: 如果信息是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;
}
/*****************************************************************************
 函 数 名  : 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 ;
}
/*****************************************************************************
 函 数 名  : 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 ;
}
/*测试函数接口操作timer0*/
s32 hardtimer_test_case01(void)
{
   u32 i=0; 
   s32 ret = 0;
   my_timer.func =(timer_func) for_timer_test;
   my_timer.mode = TIMER_PERIOD_COUNT;
   my_timer.timeout = 32768;
   my_timer.timerId = i;
   my_timer.para = i;
   osl_sem_init(SEM_EMPTY,&sem);
   ret = bsp_hardtimer_alloc(&my_timer);
   if (OK != ret)
   	return ERROR;
   ret = bsp_hardtimer_enable(my_timer.timerId);
   if (OK != ret)
   	return ERROR;
   osl_sem_down(&sem);
   ret = bsp_hardtimer_free(i);
   if (OK != ret)
   {
	osl_sem_up(&sem);
	osl_sema_delete(&sem);
	return ERROR;
    }
   osl_sem_up(&sem);
   osl_sema_delete(&sem);
   return OK;
}
Beispiel #6
0
/*
* 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);
    }
}
u32 bsp_om_send_coder_src(u8 *send_data_virt, u32 send_len)
{
    SOCP_BUFFER_RW_STRU                 bd_buf = {0};
    u32                          ulBDNum;
    SOCP_BD_DATA_STRU                *p_bd_data;
    u32                          send_data_phy = 0;
    u32                         ret;

    osl_sem_down(&socp_opt_sem);

    /*  将用户虚拟地址转换成物理地址*/
    send_data_phy = bsp_om_virt_phy((u32)send_data_virt);

    bsp_socp_get_write_buff(g_bsp_om_socp_chan_info.en_src_chan_id, &bd_buf);

    /* 计算空闲BD的值 */
    ulBDNum = (bd_buf.u32Size + bd_buf.u32RbSize)  / sizeof(SOCP_BD_DATA_STRU);

    /* 判断是否还有空间 */
    if (1 >= ulBDNum)
    {
        bsp_om_debug(BSP_LOG_LEVEL_ERROR," get BD fail,ulBDNum = %d\n",ulBDNum);
        ret =  BSP_ERR_OMS_SOCP_GET_BD_NUM_ERR;
        goto fail;
    }

    /*SOCP给出是虚拟地址*/
    if(NULL == bd_buf.pBuffer )
    {
        bsp_om_debug(BSP_LOG_LEVEL_ERROR," get BD fail,pBuffer = NULL \n");
        ret =  BSP_ERR_OMS_SOCP_BD_ADDR_ERR;
        goto fail;
    }

    p_bd_data = (SOCP_BD_DATA_STRU *)(bd_buf.pBuffer);

    p_bd_data->pucData    = send_data_phy;
    p_bd_data->usMsgLen   = (BSP_U16)send_len;
    p_bd_data->enDataType = SOCP_BD_DATA;

    (void)cacheFlush(DATA_CACHE, bd_buf.pBuffer, sizeof(SOCP_BD_DATA_STRU));
    ret =  (u32)bsp_socp_write_done(g_bsp_om_socp_chan_info.en_src_chan_id, sizeof(SOCP_BD_DATA_STRU)) ;  /* 当前数据写入完毕 */

    if(ret != BSP_OK)
    {
        goto fail;
    }
    else
    {
        goto successful;
    }

fail:
    osl_sem_up(&socp_opt_sem);
    return ret;
successful:
    osl_sem_up(&socp_opt_sem);
    return BSP_OK;
}
Beispiel #8
0
/*****************************************************************************
* 函 数 名  : 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;

}
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 bsp_icc_test_uninit(void)
{
	u32 i = 0;
	u32 channel_idx = 0;
	struct icc_channel *channel = NULL;
	struct icc_test_sub_channel *sub_channel = NULL;

	for(i = 0; i < ICC_VALIDE_CHN_NUM + 1; i++)
	{
		channel_idx = g_icc_init_info[i].real_channel_id;
		channel = g_icc_ctrl.channels[channel_idx];
		sub_channel =  &(g_icc_test.channels[i].sub_channels[0]);
		
		icc_safe_free(channel->rector);
		channel->func_size = g_icc_test.channels[channel_idx].func_size_bak;
		channel->rector = g_icc_test.channels[i].vec_bak;
		channel->fifo_recv->size = channel->fifo_send->size = g_icc_test.channels[i].fifo_size_bak;

		/* 分配的时候,子通道0的为buffer的起始地址 */
		icc_safe_free(sub_channel->wr_buf);
	}

	osl_sem_up(&g_icc_test.recv_task_sem);
	g_icc_test.recv_task_flag = 0;
	osl_sema_delete(&g_icc_test.recv_task_sem);

	return ICC_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;
}
/*****************************************************************************
 函数    : bsp_rffe_cfg_in_power_on
 功能    : 开机时mipi和线控配置
 输入    : 无
 输出    : 无
 返回     : mipi配置是否成功,0为成功,1为失败
*****************************************************************************/
int bsp_rffe_cfg_on_power_up(PWC_COMM_MODE_E mode, PWC_COMM_MODEM_E modem, PWC_COMM_CHANNEL_E chn)
{
    unsigned int  vote_bit = 0;
    unsigned int  first_on = 0;
    int           ret      = 0;

    vote_bit = RF_PWR_MODE_NUM*modem + mode;

    /*依赖fem的供电,所以使用其信号量*/
    osl_sem_down(&rf_pwr_sem[SEM_FEM]);

    first_on = !rffe_cfg.vote[chn];
    rffe_cfg.vote[chn] |= (u64)1 << vote_bit;
    if(first_on){
        ret  = balong_rf_config_by_mipi_modem_on((u32)chn);
        ret |= balong_rf_config_anten_poweron((u32)chn);

        rffe_cfg.true_pwron_cnt[chn]++;
        rffe_cfg.true_pwron_time_stamp[chn] = bsp_get_slice_value();
    }
    rffe_cfg.pwron_cnt[chn]++;
    rffe_cfg.pwron_time_stamp[chn] = bsp_get_slice_value();

    osl_sem_up(&rf_pwr_sem[SEM_FEM]);

    return ret;
}
 /*****************************************************************************
 * 函 数 名      : ipc_sem_int_handler
 *
 * 功能描述  : 信号量释放中断处理函数
 *
 * 输入参数  : 无
 * 输出参数  : 无
 *
 * 返 回 值      : 无
 *
 * 修改记录  :  2013年1月9日 lixiaojie
 *****************************************************************************/
OSL_IRQ_FUNC(static irqreturn_t,ipc_sem_int_handler,irq,arg)
{
	u32 u32IntStat = 0,u32HsCtrl=0,u32SNum=0, i = 32;
	u32IntStat = readl(ipc_ctrl.ipc_base[IPCM_NS]+BSP_IPC_SEM_INT_STAT(ipc_ctrl.core_num));
	u32SNum = ffSLsb(u32IntStat);
	if( u32SNum != 0)
	{
		do
		{
			 /*如果有信号量释放中断,清除该中断*/
			writel((u32)1<<--u32SNum, ipc_ctrl.ipc_base[IPCM_NS]+BSP_IPC_SEM_INT_CLR(ipc_ctrl.core_num));
			u32HsCtrl = readl(ipc_ctrl.ipc_base[IPCM_NS] + BSP_IPC_HS_CTRL(ipc_ctrl.core_num, u32SNum));
			if (0 == u32HsCtrl)
			{
				osl_sem_up(&(ipc_ctrl.sem_ipc_task[u32SNum]));
			}
			else
			{
				ipc_debug.u32SemTakeFailTimes[u32SNum]++;
			}
			u32IntStat = readl(ipc_ctrl.ipc_base[IPCM_NS]+BSP_IPC_SEM_INT_STAT(ipc_ctrl.core_num));
			u32SNum = ffSLsb(u32IntStat);
			i--;
		}while((u32SNum != 0) && (i  > 0));
	}
	else
	{
		return  IRQ_NONE;
	}
	return  IRQ_HANDLED;
}
s32 reset_prepare(enum MODEM_ACTION action)
{
	unsigned long flags = 0;
	u32 current_action = (u32)action;
	u32 global_action = g_modem_reset_ctrl.modem_action;

	if (current_action == global_action)
	{
		return RESET_OK;
	}
	else if ((u32)MODEM_NORMAL != global_action)
	{
		reset_print_err("action(%d) is doing, abundon action(%d)\n", global_action, action);
		return RESET_ERROR;
	}

	g_reset_debug.main_stage = 0;

	wake_lock(&(g_modem_reset_ctrl.wake_lock));
	reset_print_debug("(%d) wake_lock\n", ++g_reset_debug.main_stage);

	spin_lock_irqsave(&g_modem_reset_ctrl.action_lock, flags);
	g_modem_reset_ctrl.modem_action = action;
	spin_unlock_irqrestore(&g_modem_reset_ctrl.action_lock, flags);

	if ((MODEM_POWER_OFF ==  current_action) || (MODEM_RESET ==  current_action))
	{
		ccore_ipc_disable();
	}
	osl_sem_up(&(g_modem_reset_ctrl.task_sem));

	return RESET_OK;
}
s32 nv_emmc_close(FILE* fp)
{

    struct nv_emmc_file_header_stru* fd = (struct nv_emmc_file_header_stru*)fp;

    nv_file_debug(NV_FILE_CLOSE_API,0,0,0,0);

    if((NULL == fd)||(fd->fp != fd))
    {
        nv_file_debug(NV_FILE_CLOSE_API,1,0,0,0);
        return BSP_ERR_NV_INVALID_PARAM;
    }

    put_mtd_device(fd->mtd);
    osl_sem_up(&fd->file_sem);

    fd->fp = NULL;
    fd->seek = 0;
    fd->length = 0;
    fd->off = 0;
    fd->ops --;
    fd->mtd = NULL;
    if(fd->ops != 0)
    {
        nv_file_debug(NV_FILE_CLOSE_API,2,fd->ops,0,0);
        return BSP_ERR_NV_CLOSE_FILE_FAIL;
    }


    return NV_OK;
}
int socp_debug_icc_msg_callback(u32 chanid ,u32 len,void* pdata)
{
    u32 channel_id = ICC_CHN_ACORE_CCORE_MIN <<16 | IFC_RECV_FUNC_SOCP_DEBUG;
    if(channel_id != chanid)
        return 0;

    socp_printf("enter here %s  %d\n",__FUNCTION__,__LINE__);

    osl_sem_up(&g_stSocpDebugCtrl.task_sem);
    return 0;
}
Beispiel #17
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;
}
/*****************************************************************************
 函数    : bsp_fem_power_up
 功能    : RF 上电打桩
 输入    : 无
 输出    : 无
 返回    : rf电源开关状态
*****************************************************************************/
int bsp_fem_power_up(PWC_COMM_MODE_E mode, PWC_COMM_MODEM_E modem, PWC_COMM_CHANNEL_E chn)
{
    int ret = 0;

    osl_sem_down(&rf_pwr_sem[SEM_FEM]);

    ret = balong_fem_power_on(mode, modem, chn);

    osl_sem_up(&rf_pwr_sem[SEM_FEM]);

    return ret;
}
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 ;
}
int bsp_om_buf_sem_give(void)
{
    if(g_bsp_om_socp_chan_info.init_state== BSP_OM_SOCP_CHAN_INIT_SUCC)
    {
        osl_sem_up(&om_buf_sem);
    }
    else
    {
        return -1;
    }

    return BSP_OK;
}
/*
* Function   : sc_icc_msg_proc
* 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    : 
*/
s32 sc_icc_msg_proc(u32 chanid, u32 len, void* pdata)
{ 
    if(chanid != SC_ICC_CHAN_ID)
    {
        sc_error_printf(" sc icc channel error :0x%x\n",chanid);
        return BSP_ERR_SC_ICC_READ;
    }

    osl_sem_up(&g_sc_stat.sc_tsk_sem);

    sc_debug_printf("recv from ccore ok!\n");

    return SC_OK;
}
/*****************************************************************************
 函 数 名  : 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;
}
static s32 icc_test_recv_check(u32 channel_idx, u32 sub_chn_idx, u32 *cnt, u32 total_cnt)
{	
	if(ICC_TEST_SEND_CNT == g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx].success_cnt)
	{
		(*cnt)++;
		if(total_cnt == (*cnt))
		{
			osl_sem_up(&g_icc_test.multi_send_confirm_sem); /*lint !e40 !e516*/
			return ICC_OK;
		}
	}

	icc_task_delay(20);

	return ICC_ERR;
}
int bsp_fem_power_down(PWC_COMM_MODE_E mode, PWC_COMM_MODEM_E modem, PWC_COMM_CHANNEL_E chn)
{
    int ret        = 0;

    osl_sem_down(&rf_pwr_sem[SEM_FEM]);

    ret = balong_fem_power_off(mode, modem, chn);
    if(ret){
        rf_print_error("rfic power down faild\n");
        ret = RFFE_ERROR;
    }

    osl_sem_up(&rf_pwr_sem[SEM_FEM]);

    return ret;
}
/*****************************************************************************
 函 数 名  : uart_send
 功能描述  : uart send
 输入参数  : UART_HW_PORT* uart_port
             BSP_U8 *pbuf
             BSP_U32 size
 输出参数  : 无
 返 回 值  : BSP_S32
*****************************************************************************/
int dual_modem_send_bytes(UART_PORT* uart_port,u8* pbuf,u32 size)
{
	u8 * pu8Buffer = NULL;
	u32  regval = 0;
	
    pu8Buffer = pbuf;
 
    osl_sem_down(&uart_port->send_mutex);	
	
	g_dm_dump_info->send_mutex_cnt++;
	g_dm_dump_info->tx_cur_size = size;
	g_dm_dump_info->tx_total_size += size;

	g_dm_dump_info->send_time_stamp = bsp_get_slice_value();
	if(g_dm_dump_info->tx_cur_offset + 4 > DUAL_DUMP_TX_BUFF_SIZE)
	{
		g_dm_dump_info->tx_cur_offset = 0;
	}
	(void)memcpy_s((void *)(g_dm_dump_info->tx_dump_addr + g_dm_dump_info->tx_cur_offset), sizeof(u32), 
		(void *)&g_dm_dump_info->send_time_stamp, sizeof(u32));
	g_dm_dump_info->tx_cur_offset += 4;

	if(g_dual_modem_ctrl.log_flag == 1)
	{	
		dm_debug_print("TxCurSize %d,TxTotalSize %d\n",g_dm_dump_info->tx_cur_size,g_dm_dump_info->tx_total_size);
		(void)dm_print_info(pu8Buffer ,size);	/* lint !e532 */
	}	
	while(size)
	{
		regval = readl(uart_port->base_addr+ UART_REGOFFSET_FR);
		if(0 == (regval & UART_FR_TX_FIFO_FULL))
    	{
			writel(*pu8Buffer, uart_port->base_addr + UART_REGOFFSET_THR);
			(void)memcpy_s((void *)(g_dm_dump_info->tx_dump_addr + g_dm_dump_info->tx_cur_offset), 1, (void *)pu8Buffer, 1);
			g_dm_dump_info->tx_cur_offset++;
			if(g_dm_dump_info->tx_cur_offset > DUAL_DUMP_TX_BUFF_SIZE)
			{
				g_dm_dump_info->tx_cur_offset = 0;
			}
			pu8Buffer++;
			size--;
      	}
	}
	
	osl_sem_up(&uart_port->send_mutex);
	return 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;
}
MAILBOX_LOCAL int mailbox_ipc_process(
                struct mb_vx_work  *work,
                struct mb_vx_proc  *proc,
                unsigned int channel_id,
                unsigned int proc_id)
{
    unsigned int is_find = MAILBOX_FALSE;

    while (work) {
        /*从邮箱工作队列中找到对应的邮箱,设置标志位并释放信号量通知处理任务*/
        if (channel_id  == work->channel_id) {
            if ((proc_id > MAILBOX_VXWORKS_PROC_STYLE_TASK_RESERVED) && (proc_id < MAILBOX_VXWORKS_PROC_STYLE_TASK_BUTT)) {
                is_find = MAILBOX_TRUE;

                /*设置任务邮箱工作队列链表中此邮箱的数据标志位*/
                work->data_flag = MAILBOX_TRUE;
 #ifdef MAILBOX_OPEN_MNTN
                mailbox_record_sche_send(work->mb_priv);
 #endif
                /*释放信号量,通知任务*/
                osl_sem_up(&proc->sema);
            } else if (MAILBOX_VXWORKS_PROC_STYLE_INT_NORMAL == proc_id) {
                 /*中断处理方式,在中断中直接处理邮箱数据*/
                if (work->cb) {
                    is_find = MAILBOX_TRUE;

                    if (MAILBOX_OK !=  work->cb(work->channel_id)) {
                         (void)mailbox_logerro_p1(MAILBOX_ERR_VXWORKS_CALLBACK_ERRO, work->channel_id);
                    }
                } else {
                     (void)mailbox_logerro_p1(MAILBOX_ERR_VXWORKS_CALLBACK_NOT_FIND, work->channel_id);
                }
            } else {
                is_find = MAILBOX_FALSE;
            }

        }
        work = work->next;
    }

    return (int)is_find;
}
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;
}
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;
}
/*****************************************************************************
 函 数 名  : 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;
}