예제 #1
0
u32 nv_readEx(u32 modem_id,u32 itemid,u32 offset,u8* pdata,u32 datalen)
{
    u32 ret = NV_ERROR;
    struct nv_file_list_info_stru file_info = {0};
    struct nv_ref_data_info_stru  ref_info  = {0};

    if((NULL == pdata)||(0 == datalen))
    {
        ret = BSP_ERR_NV_INVALID_PARAM;
        goto nv_readEx_err;
    }

    ret = nv_search_byid(itemid,(u8*)NV_GLOBAL_CTRL_INFO_ADDR,&ref_info,&file_info);
    if(ret)
    {
        goto nv_readEx_err;
    }

    if((offset + datalen) > ref_info.nv_len)
    {
        ret = BSP_ERR_NV_ITEM_LEN_ERR;
        goto nv_readEx_err;
    }
    if(modem_id <= ref_info.modem_num)
    {
        ref_info.nv_off += (modem_id - NV_USIMM_CARD_1)*ref_info.nv_len;
    }
    else
    {
        ret = BSP_ERR_NV_INVALID_PARAM;
        goto nv_readEx_err;
    }

    ret = nv_read_from_mem(pdata, datalen,file_info.file_id,ref_info.nv_off+offset);
    if(ret)
    {
        goto nv_readEx_err;
    }

    return NV_OK;
nv_readEx_err:
    return ret;
}
예제 #2
0
u32 nv_readEx(u32 modem_id,u32 itemid,u32 offset,u8* pdata,u32 datalen)
{
    u32 ret = NV_ERROR;
    struct nv_file_list_info_stru file_info = {0};
    struct nv_ref_data_info_stru  ref_info  = {0};

    nv_debug(NV_FUN_READ_EX,0,itemid,modem_id,datalen);

    if((NULL == pdata)||(0 == datalen))
    {
        nv_debug(NV_FUN_READ_EX,1,itemid,0,0);
        ret = BSP_ERR_NV_INVALID_PARAM;
        /*lint -save -e801*/
        goto nv_readEx_err;
        /*lint -restore*/
    }

    /*lint -save -e826*/
    ret = nv_search_byid(itemid,(u8*)NV_GLOBAL_CTRL_INFO_ADDR,&ref_info,&file_info);
    /*lint -restore +e826*/
    if(ret)
    {
        nv_debug(NV_FUN_READ_EX,2,itemid,ret,0);
        return BSP_ERR_NV_NO_THIS_ID;
    }

    if((offset + datalen) > ref_info.nv_len)
    {
        ret = BSP_ERR_NV_ITEM_LEN_ERR;
        nv_debug(NV_FUN_READ_EX,4,offset,datalen,ref_info.nv_len);
        /*lint -save -e801*/
        goto nv_readEx_err;
        /*lint -restore*/
    }
    if(modem_id <= ref_info.modem_num)
    {
        ref_info.nv_off += (modem_id - NV_USIMM_CARD_1)*ref_info.nv_len;
    }
    else
    {
#if (FEATURE_OFF == FEATURE_MULTI_MODEM)
        ret = BSP_ERR_NV_INVALID_PARAM;
        nv_debug(NV_FUN_READ_EX,5,ret,itemid,modem_id);
        /*lint -save -e801*/
        goto nv_readEx_err;
        /*lint -restore*/
#endif
    }

    ret = nv_read_from_mem(pdata,datalen,file_info.file_id,ref_info.nv_off+offset);
    if(ret)
    {
        nv_debug(NV_FUN_READ_EX,6,offset,datalen,ref_info.nv_len);
        /*lint -save -e801*/
        goto nv_readEx_err;
        /*lint -restore*/
    }
    /*lint -save -e578 -e530 -e718 -e746 -e628 -e515 -e516*/
    nv_debug_trace(pdata,datalen);/*lint !e628*/
    /*lint -restore*/

    return NV_OK;
nv_readEx_err:
    /*lint -save -e515 -e516*/
    printf_nv("\n[%s]:[0x%x]:[%d]\n",__FUNCTION__,itemid,modem_id);
    /*lint -restore*/
    nv_help(NV_FUN_READ_EX);
    return ret;
}