コード例 #1
0
/*
 *get file info in back ,default,nvdload
 */
u32 nv_sec_file_info_init(const s8* name,struct nv_file_info_stru* sec_info)
{
    u32 ret = NV_ERROR;
    u32 file_len = 0;
    struct nv_file_info_stru info;
    struct nv_ctrl_file_info_stru ctrl_info;
    u8* file_info;

    /*first: read nv ctrl file*/
    ret = (u32)bsp_nand_read((char*)name,0,&ctrl_info,sizeof(ctrl_info),NULL);
    if(NAND_OK != ret)
    {
        printf("[%s]:patrition name %s,get file magic fail ret 0x%x,\n",__func__,name,ret);
        return ret;
    }

    /*second :check magic num in file head*/
    if(ctrl_info.magicnum != NV_CTRL_FILE_MAGIC_NUM)
    {
        printf("[%s]:enter this way  1111! %s\n",__func__,name);
        return NV_OK;
    }

    /*third: read all nv ctrl file*/
    file_info = (u8*)nv_malloc(ctrl_info.file_size+1);
    if(NULL == file_info)
    {
        printf("[%s]:enter this way  2222! %s\n",__func__,name);
        return BSP_ERR_NV_MALLOC_FAIL;
    }
    ret = (u32)bsp_nand_read((char*)name,sizeof(struct nv_ctrl_file_info_stru),file_info,ctrl_info.file_size,NULL);
    if(NAND_OK != ret)
    {
        printf("[%s]:enter this way 3333! %s\n",__func__,name);
        goto init_end;
    }

    /*fourth: count nv file len base the ctrl file info*/
    ret = nv_get_bin_crc_file_len(&ctrl_info,(struct nv_file_list_info_stru*)file_info,&file_len);
    if(ret)
    {
        printf("[%s]:enter this way 4444! %s\n",__func__,name);
        goto init_end;
    }

    info.len       = file_len;
    info.magic_num = NV_FILE_EXIST;
    info.off       = 0;


    memcpy(sec_info,&info,sizeof(info));
init_end:
    nv_free(file_info);
    return NV_OK;
}
コード例 #2
0
bool get_sc_file_back_state(void)
{
    struct sc_file_packet_info_struct sc_file;
    int ret;
    int i;

    /*标志文件存在返回false*/
    if(!BSP_access((char*)SC_FILE_BACKUP_FLAG,0)){
        printk("%s is exist!\n",SC_FILE_BACKUP_FLAG);
        return false;
    }

    ret = bsp_nand_read((char*)SC_BACKUP_SEC_NAME,SC_BACKUP_SEC_OFFSET,&sc_file,sizeof(sc_file),NULL);
    if(ret){
        printk("%s bsp_nand_read err ret :0x%x!\n",__func__,ret);
        return false;
    }

    if(sc_file.magic_num != SC_FILE_PACKET_MAGIC){
        printk(" %s magic num is invalid!\n",__func__);
        return false;
    }

    for(i= 0;i<SC_FILE_NUM;i++)
    {
        if(sc_file.file_info[i].magic_num != SC_FILE_EXIST_MAGIC){
            printk("%d  file is not exist !\n",i);
            return false;
        }
    }

    return true;
}
コード例 #3
0
s32 nv_modify_upgrade_flag(bool flag)
{
    struct nv_dload_packet_head_stru nv_dload;
    s32 ret;
    u32 old_magic;
    u32 new_magic;

    ret = bsp_nand_read((char*)NV_DLOAD_SEC_NAME,0,&nv_dload,sizeof(nv_dload),NULL);
    if(ret)
    {
        return ret;
    }
/*lint -save -e731*/
    if(true == flag)
    {
        old_magic = NV_DLOAD_INVALID_FLAG;
        new_magic = NV_FILE_EXIST;
    }
    else
    {
        new_magic = NV_DLOAD_INVALID_FLAG;
        old_magic = NV_FILE_EXIST;
    }
/*lint -restore*/
    nv_dload.nv_bin.magic_num = (nv_dload.nv_bin.magic_num == old_magic) ? new_magic : nv_dload.nv_bin.magic_num;
    ret = bsp_nand_write((char*)NV_DLOAD_SEC_NAME,0,&nv_dload,sizeof(nv_dload));
    if(ret)
    {
        return ret;
    }

    return 0;
}
コード例 #4
0
/*lint -save -e813*/
int sc_file_restore(void)
{
    int i;
    int ret;
    struct sc_file_packet_info_struct sc_file;


    if(false == get_sc_file_back_state()){
        return -1;
    }

    ret = bsp_nand_read((char*)SC_BACKUP_SEC_NAME,SC_BACKUP_SEC_OFFSET,&sc_file,sizeof(sc_file),NULL);
    if(ret){
        printk("%s bsp_nand_read err ret :0x%x!\n",__func__,ret);
        return ret;
    }

    for(i=0;i<SC_FILE_NUM;i++)
    {
        ret = sc_file_restore_from_factory(&sc_file.file_info[i]);
        if(ret){
            return ret;
        }
    }
    return 0;
}
コード例 #5
0
ファイル: loadm.c プロジェクト: samm-git/e3372h-vendor-src
int his_modem_load_vxworks(char *part_name)
{
    int ret = 0;
    int offset = 0;
    int skip_len = 0;
    u32 image_total_length = 0;
    void *image_load_addr = 0;

    struct image_head head;

    hi_trace(HI_INFO, ">>loading:%s.....\r\n", part_name);

    ret = bsp_nand_read(part_name, (FSZ)0, &head, sizeof(struct image_head) , &skip_len);
    if (NAND_OK != ret)
    {
        hi_trace(HI_ERR, "fail to read vxworks image head, error code 0x%x\r\n", ret);
        return NAND_ERROR;
    }

    if (memcmp(head.image_name, CCORE_IMAGE_NAME, sizeof(CCORE_IMAGE_NAME)))
    {
        hi_trace(HI_ERR, "vxworks image error!!.\r\n");
        return NAND_ERROR;
    }

    offset += sizeof(struct image_head) + skip_len;
    image_total_length = (u32)head.image_length;

    image_load_addr = (void*)g_ccore_entry;

    ret = bsp_nand_read(part_name, offset, image_load_addr, image_total_length, &skip_len);
    if(NAND_OK != ret)
    {
        hi_trace(HI_ERR, "fail to read vxworks image, error code 0x%x\r\n", ret);
        goto exit;
    }

    hi_trace(HI_INFO, ">>load vxworks ok, entey %#x, length %#x\r\n", head.load_addr, head.image_length);

exit:

    return ret;
}
コード例 #6
0
/************************************************************************************************
*
*	Function:		load_modem_dsp_to_secos
*	Description:	read modem_dsp of specified image from emmc to sec os
*	Calls:		
*			load_data_to_secos
*			bsp_nand_read
*
*	Data Accessed:	session
*	Data Updated:
*
*	Parameters:
*	
*	Return:
*			@u32
*					SEC_OK:      success
*					SEC_ERROR:      failure
*
*************************************************************************************************/	
static s32 load_modem_dsp_to_secos(TEEC_Session *session)
{	
	u32 skip_len = 0;
	u32 offset = 0;
	/* coverity[var_decl] */
	struct image_head head;  
	s32 ret = SEC_ERROR;	 

	/* clean ok flag */
    writel(0, (void*)SHM_MEM_DSP_FLAG_ADDR);
	
    ret = bsp_nand_read(PTN_MODEM_DSP_NAME, (FSZ)0, &head, sizeof(struct image_head), &skip_len);
    if (NAND_OK != ret)
    {
        sec_print_err("fail to read modem dsp image head, error code 0x%x\r\n", ret);
        return SEC_ERROR;
    }

	/* coverity[uninit_use_in_call] */
	if (memcmp(head.image_name, DSP_IMAGE_NAME, sizeof(DSP_IMAGE_NAME)))
    {
        sec_print_err("DSP image error!!.\r\n");
        return SEC_ERROR;
    }

    trans_data.image_length = DDR_TLPHY_IMAGE_SIZE;
	trans_data.image_addr = DDR_TLPHY_IMAGE_ADDR;
	
 	offset += LPHY_BBE16_MUTI_IMAGE_OFFSET + sizeof(struct image_head) + skip_len;
	ret = load_data_to_secos(session, PTN_MODEM_DSP_NAME, offset, trans_data.image_length, &skip_len);
	if(SEC_ERROR == ret)
	{
		sec_print_err("load dsp fail!\n");
		return ret;
	}

	trans_data.image_length = MODEM_TDS_SIZE;
	trans_data.image_addr = DDR_LPHY_SDR_ADDR + MODEM_DSP_SIZE + MODEM_TDS_SIZE;
	
 	offset += LPHY_BBE16_MUTI_IMAGE_SIZE + skip_len;
	ret = load_data_to_secos(session, PTN_MODEM_DSP_NAME, offset, trans_data.image_length, &skip_len);
	if(SEC_ERROR == ret)
	{
		sec_print_err("load TDS fail!\n");
		return ret;
	}

	/* set the ok flag of dsp image */
    writel(DSP_IMAGE_STATE_OK, (void*)SHM_MEM_DSP_FLAG_ADDR);

    return SEC_OK;
}
コード例 #7
0
/************************************************************************************************
*
*	Function:		load_VRL_to_secos
*	Description:	read vrl of specified image from emmc
*	Calls:		
*			bsp_trans_to_os
*			bsp_nand_read
*
*	Data Accessed:	No
*	Data Updated:
*
*	Parameters:
*	
*	Return:
*			@u32
*					SEC_OK:      success
*					SEC_ERROR:      failure
*
*************************************************************************************************/
static s32 load_VRL_to_secos(TEEC_Session *session)
{
	unsigned read_bytes;
	s32 ret;

	read_bytes = SECBOOT_VRL_SIZE;
	
	ret = bsp_nand_read(PTN_VRL_P_NAME, SECBOOT_MODEM_VRL_OFFSET * SECBOOT_VRL_SIZE, (void *)g_vrl_P, read_bytes, NULL);
	if (NAND_OK != ret) 
	{
		sec_print_err("%s: can't make ptn for vrl!\n", __func__);
		return SEC_ERROR;
	}

	ret = bsp_nand_read(PTN_VRL_M_NAME, SECBOOT_MODEM_VRL_OFFSET * SECBOOT_VRL_SIZE, (void *)g_vrl_M, read_bytes, NULL);
	if (NAND_OK != ret) 
	{
		sec_print_err("%s: can't make ptn for vrl_backup!\n", __func__);
		return SEC_ERROR;
	}	

	/* compare the data read from vrl and vrl_back, if not equ, we restore primary vrl to backup vrl */
	if (memcmp((void *)g_vrl_P, (void *)g_vrl_M, SECBOOT_VRL_SIZE)) {
		sec_print_err("%s: memcmp data error!\n", __func__);
		return SEC_ERROR;		
	}

	/* trans the vrl to secure os. */
	ret = bsp_trans_to_os(session,SECBOOT_CMD_ID_COPY_VRL,(void *)g_vrl_P,0,SECBOOT_VRL_SIZE);
	if (SEC_ERROR == ret)
	{
		sec_print_err("modem image trans to os is failed, error code 0x%x\r\n", ret);
		return SEC_ERROR;
	}
	
	return SEC_OK;
}
コード例 #8
0
static s32 load_modem_head(void)
{	
	u32 skip_len = 0;
	u32 g_ccore_entry = 0;
	u32 image_load_addr = 0;
	/* coverity[var_decl] */
	struct image_head head;  
	s32 ret = SEC_ERROR;	 

    ret = bsp_nand_read(PTN_MODEM_NAME, (FSZ)0, &head, sizeof(struct image_head) , &skip_len);
    if (NAND_OK != ret)
    {
        sec_print_err("fail to read modem image head, error code 0x%x\r\n", ret);
        return SEC_ERROR;
    }

	/* coverity[uninit_use_in_call] */
	if (memcmp(head.image_name, CCORE_IMAGE_NAME, sizeof(CCORE_IMAGE_NAME)))
    {
        sec_print_err("vxworks image error!!.\r\n");
        return SEC_ERROR;
    }

    /* coverity[uninit_use] */
	g_ccore_entry = head.load_addr;
	
    /* coverity[uninit_use] */
    trans_data.image_length = (u32)head.image_length + 2*IDIO_LEN + OEM_CA_LEN + sizeof(struct image_head);

	/* coverity[uninit_use] */
    if (head.is_compressed)
    {
        image_load_addr = g_ccore_entry - (MCORE_TEXT_START_ADDR - DDR_MCORE_ADDR)
            + DDR_MCORE_SIZE - trans_data.image_length;
    }
    else
    {
        image_load_addr = g_ccore_entry;
    }

	if(trans_data.image_length % 64)
	{
		trans_data.image_length = trans_data.image_length + (64 - trans_data.image_length % 64);
	}
	
	trans_data.image_addr = image_load_addr - sizeof(struct image_head);

    return SEC_OK;
}
コード例 #9
0
/*
 * 读nand接口
 * mtd      :   mtd device
 * off      :   loggic offset in this file,need
 * len      :   data len write to flash ,len <= mtd->erasesize
 * ptr      :   the data need to write
 */
u32 nv_mtd_read(struct nv_emmc_file_header_stru* fd,FSZ off,u32 len,u8* ptr)
{
    u32 ret;
    u32 offset = 0;    /*传进来的偏移相对于文件头的逻辑偏移*/
    struct mtd_info* mtd = fd->mtd;

    ret = nv_sec_off_count(fd,off,&offset);
    if(ret != NAND_OK)
    {
        return ret;
    }
    ret = (u32)bsp_nand_read((char*)mtd->name,offset,ptr,len,NULL);

    return ret;
}
コード例 #10
0
u32 nv_dload_file_info_init(void)
{
    u32 ret = NV_ERROR;
    struct nv_dload_packet_head_stru nv_dload;

    /*first read file packet head*/
    ret = (u32)bsp_nand_read((char*)NV_DLOAD_SEC_NAME,0,&nv_dload,sizeof(nv_dload),NULL);
    if(ret)
    {
        printf("[%s]:ret 0x%x,\n",__func__,ret);
        return ret;
    }
    memcpy(&g_emmc_info.nv_dload,&nv_dload,sizeof(nv_dload));
    return NV_OK;
}
コード例 #11
0
/*获取升级包数据有效性
 *true :有效 false: 无效
 */
bool nv_get_upgrade_flag(void)
{
    struct nv_dload_packet_head_stru nv_dload;
    s32 ret;

    ret = bsp_nand_read((char*)NV_DLOAD_SEC_NAME,0,&nv_dload,sizeof(nv_dload),NULL);
    if(ret)
    {
        return false;
    }

    if(nv_dload.nv_bin.magic_num == NV_FILE_EXIST)
    {
        return true;
    }
    return false;
}
コード例 #12
0
int sc_file_restore_from_factory(struct sc_file_info* file_info)
{
    int ret;
    void* fp = NULL;
    void* buf = NULL;
    unsigned int off = SC_BACKUP_SEC_OFFSET +(unsigned int)file_info->off;



    buf = (void*)kmalloc((unsigned int)(file_info->len),GFP_KERNEL);
    if(!buf)
        return 1;

    ret = bsp_nand_read((char*)SC_BACKUP_SEC_NAME,off,buf,(unsigned int)(file_info->len),NULL);
    if(ret){
        printk("%s : off = 0x%x,len = 0x%x\n",__func__,off,file_info->len);
        kfree(buf);
        return 2;
    }

    fp = BSP_fopen(file_info->path,"wb+");
    if(!fp){
        printk("open %s fail !\n",file_info->path);
        kfree(buf);
        return 3;
    }

    ret = BSP_fwrite(buf,1,(unsigned int)(file_info->len),fp);
    kfree(buf);
    BSP_fclose(fp);

    if(ret != file_info->len){
        printk("write %s fail,ret :0x%x,len :0x%x\n",__func__,ret,file_info->len);
        BSP_remove(file_info->path);
        return 4;
    }

    return 0;
}
u32 nv_dload_file_info_init(void)
{
    u32 ret = NV_ERROR;
    struct nv_dload_packet_head_stru nv_dload;
    u32 total_len;
    u32 i = 0;

    g_sec_info.nv_dload[0] = 0;
    /*first read file packet head*/
    ret = (u32)bsp_nand_read((char*)NV_DLOAD_SEC_NAME,0,&nv_dload,sizeof(nv_dload),NULL);
    if(ret)
    {
        printf("[%s]:ret 0x%x,\n",__func__,ret);
        return ret;
    }
    /*second count file total len*/
    total_len = sizeof(nv_dload);
    total_len += ((nv_dload.nv_bin.magic_num == NV_FILE_EXIST)?nv_dload.nv_bin.len:0);
    for(i=0;i<2;i++)/*双卡双待有双份xml数据*/
    {
        /* coverity[uninit_use] */
        total_len += ((nv_dload.xnv_xml[i].magic_num == NV_FILE_EXIST)?nv_dload.xnv_xml[i].len:0);
        /* coverity[uninit_use] */
        total_len += ((nv_dload.cust_xml[i].magic_num == NV_FILE_EXIST)?nv_dload.cust_xml[i].len:0);
        /* coverity[uninit_use] */
        total_len += ((nv_dload.xnv_map[i].magic_num == NV_FILE_EXIST)?nv_dload.xnv_map[i].len:0);
    }

    ret = nv_count_file_sec_info((const s8*)NV_DLOAD_SEC_NAME,total_len,g_sec_info.nv_dload);
    if(ret)
    {
        printf("[%s] ret : 0x%x\n",__func__,ret);
        return NV_ERROR;
    }
    memcpy(&g_flash_info.nv_dload,&nv_dload,sizeof(nv_dload));
    return NV_OK;
}
コード例 #14
0
ファイル: loadm.c プロジェクト: samm-git/e3372h-vendor-src
int his_modem_load_vxworks(char *part_name)
{
    int ret = 0;
    int offset = 0;
    int skip_len = 0;
    u32 image_total_length = 0;
    void *image_load_addr = 0;
    decompress_fn inflate_fn = NULL;

    struct image_head head;

    hi_trace(HI_INFO, ">>loading:%s.....\r\n", part_name);

    ret = bsp_nand_read(part_name, (FSZ)0, &head, sizeof(struct image_head) , &skip_len);
    if (NAND_OK != ret)
    {
        hi_trace(HI_ERR, "fail to read vxworks image head, error code 0x%x\r\n", ret);
        return NAND_ERROR;
    }

    /*coverity[uninit_use_in_call] */
    if (memcmp(head.image_name, CCORE_IMAGE_NAME, sizeof(CCORE_IMAGE_NAME)))
    {
        hi_trace(HI_ERR, "vxworks image error!!.\r\n");
        return NAND_ERROR;
    }

    /*coverity[uninit_use] */
    if (head.image_length + 2*IDIO_LEN + OEM_CA_LEN > PRODUCT_CFG_FLASH_CCORE_LEN)
    {
        hi_trace(HI_ERR, "loadsize is incorrect, 0x%x!\r\n",
            head.image_length + 2*IDIO_LEN + OEM_CA_LEN);
        return NAND_ERROR;
    }

    /*coverity[uninit_use_in_call] */
    g_ccore_entry = (u32)ioremap_cached(head.load_addr, DDR_MCORE_SIZE - (MCORE_TEXT_START_ADDR - DDR_MCORE_ADDR));
    if(!g_ccore_entry)
    {
        hi_trace(HI_ERR, "ioremap failed.\r\n");
        return NAND_ERROR;
    }

    offset += sizeof(struct image_head) + skip_len;
    image_total_length = (u32)head.image_length + 2*IDIO_LEN + OEM_CA_LEN;

    /*coverity[uninit_use] */
    if (head.is_compressed)
    {
        image_load_addr = (void*)g_ccore_entry - (MCORE_TEXT_START_ADDR - DDR_MCORE_ADDR)
            + DDR_MCORE_SIZE - image_total_length;
    }
    else
    {
        image_load_addr = (void*)g_ccore_entry;
    }

    ret = bsp_nand_read(part_name, offset, image_load_addr, image_total_length, &skip_len);
    if(NAND_OK != ret)
    {
        hi_trace(HI_ERR, "fail to read vxworks image, error code 0x%x\r\n", ret);
        goto exit;
    }

    ret = bsp_sec_check((u32)image_load_addr, head.image_length);
    if (ret)
    {
        hi_trace(HI_ERR, "fail to check vxworks image, error code 0x%x\r\n", ret);
        goto exit;
    }

    if (head.is_compressed)
    {
        hi_trace(HI_INFO, ">>start to decompress vxworks image ...\r\n");
        inflate_fn = decompress_method((const unsigned char *)image_load_addr, 2, NULL);
        if (inflate_fn)
        {
            ret = inflate_fn((unsigned char*)image_load_addr,
                head.image_length, NULL, NULL, (unsigned char*)g_ccore_entry,
                NULL, (void(*)(char*))printk);
            if (ret)
            {
                hi_trace(HI_ERR, "fail to decompress vxworks image, error code 0x%x\r\n", ret);
                goto exit;
            }
        }
        else
        {
            hi_trace(HI_ERR, "fail to get decompress method\r\n");
            goto exit;
        }
    }

    /* flush cache */
    __dma_single_cpu_to_dev_noverify((const void *)g_ccore_entry,
                     DDR_MCORE_SIZE - (MCORE_TEXT_START_ADDR - DDR_MCORE_ADDR),
                     CACHE_DMA_TO_DEVICE);

    hi_trace(HI_INFO, ">>load vxworks ok, entey %#x, length %#x\r\n", head.load_addr, head.image_length);

exit:
    iounmap((void volatile *)g_ccore_entry);

    return ret;
}
コード例 #15
0
/*
* Function   : sc_restore
* 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_restore(s8 *pdata, u32 len)
{
    s32 sc_fp       = 0;
    s32 rlen        = 0;
    s32 wlen        = 0;
    u32 sc_mtd_len  = 0;
    struct mtd_info* mtd;

    mtd = get_mtd_device_nm((char*)SC_BACKUP_SEC_NAME);
    if (IS_ERR(mtd))
    {
        sc_error_printf("get mtd device err! %s\n",mtd);
        return BSP_ERR_READ_MTD_FAIL;
    }
    sc_mtd_len = mtd->size;
    put_mtd_device(mtd);
    
    if((sc_mtd_len < SC_MTD_PTABLE_OFFSET) || (len >= SC_MTD_PTABLE_OFFSET))
    {
        sc_error_printf("mtd length err! size 0x%x\n",mtd->size);
        return BSP_ERR_READ_LGTH_FAIL;
    }

    rlen = bsp_nand_read((char*)SC_BACKUP_SEC_NAME, (sc_mtd_len - SC_MTD_PTABLE_OFFSET), pdata, len, NULL);
    if(rlen != BSP_OK)
    {
        sc_error_printf("mtd length err! read_ret 0x%x, len is 0x%x\n",rlen,len);
        return BSP_ERR_SC_READ_FILE_FAIL;
    }
    else
    {
        sc_debug_printf("mtd length read ok len is 0x%x\n",rlen);
    }

    /* write to file */
    sc_fp = bsp_open((char*)SC_PACKET_TRANS_FILE,(RFILE_CREAT|RFILE_RDWR),0660);
    if(!sc_fp)
    {   
        sc_error_printf("bsp_open error, chanid :0x%x sc_fp :0x%x\n",SC_ICC_CHAN_ID,sc_fp);
        return BSP_ERR_SC_NO_FILE;
    }
    else
    {
        sc_debug_printf("bsp_open ok, file is 0x%x!\n",sc_fp);
    }

    /* write to file */
    wlen = bsp_write(sc_fp, pdata, len);
    if(wlen != len)
    {
        sc_error_printf("bsp_write error, chanid :0x%x wlen :0x%x, len : 0x%x\n",SC_ICC_CHAN_ID,wlen,len);
        bsp_close(sc_fp);
        return BSP_ERR_SC_WRITE_FILE_FAIL;
    }
    else
    {
        sc_debug_printf("bsp_write ok,wlen is 0x%x",wlen);
    }

    bsp_close(sc_fp);

    return SC_OK;
}
void show_flash_info(void)
{
    struct nv_dload_packet_head_stru nv_dload;
    struct nv_ctrl_file_info_stru ctrl_info;
    u8* file_info;
    s32 ret = -1 ;
    u32 i = 0;

    printf("\n******************sys info*********************\n");
    printf("\n************sys nv info in mem**************\n");
    ret = bsp_nand_read((char*)NV_DLOAD_SEC_NAME,0,&ctrl_info,sizeof(ctrl_info),NULL);
    if(ret)
        return;
     /* coverity[uninit_use] */
    if(ctrl_info.magicnum != NV_CTRL_FILE_MAGIC_NUM)
    {
        ctrl_info.file_size = 144;
    }
    /* coverity[uninit_use] */
    file_info = (u8*)nv_malloc(ctrl_info.file_size+1);
    if(NULL == file_info)
    {
        return;
    }
    ret = bsp_nand_read((char*)NV_DLOAD_SEC_NAME,sizeof(ctrl_info),file_info,ctrl_info.file_size,NULL);
    if(ret){
        nv_free(file_info);
        return;
    }
    printf("\n********sys mem info*******\n");
    printf("nv   :flag 0x%x,off 0x%x,len 0x%x\n",g_flash_info.sys_nv.magic_num,\
        g_flash_info.sys_nv.off,g_flash_info.sys_nv.len);
    printf("\n************sys info in nand**************\n");
    /* coverity[uninit_use_in_call] */
    printf("magic :0x%x,file num: %d,nv num :0x%x,modem num :%d\n",\
        ctrl_info.magicnum,ctrl_info.file_num,ctrl_info.ref_count,ctrl_info.modem_num);

    for(i= 0;i<NV_BIN_FILE_BLOCK_NUM;i++)
        printf("nv img file %d block off :0x%x\n",i,g_sec_info.sys_nv[i]);

    printf("\n******************dload info*******************\n");
    ret = bsp_nand_read((char*)NV_DLOAD_SEC_NAME,0,&nv_dload,sizeof(nv_dload),NULL);
    if(ret){
        nv_free(file_info);
        return;
    }
    printf("\n********dload mem info*******\n");
    printf("nv   : flag 0x%x,len 0x%x,off 0x%x\n",g_flash_info.nv_dload.nv_bin.magic_num,\
        g_flash_info.nv_dload.nv_bin.len,g_flash_info.nv_dload.nv_bin.off);
    printf("xnv1 : flag 0x%x,len 0x%x,off 0x%x\n",g_flash_info.nv_dload.xnv_xml[0].magic_num,\
        g_flash_info.nv_dload.xnv_xml[0].len,g_flash_info.nv_dload.xnv_xml[0].off);
    printf("cust1: flag 0x%x,len 0x%x,off 0x%x\n",g_flash_info.nv_dload.cust_xml[0].magic_num,\
        g_flash_info.nv_dload.cust_xml[0].len,g_flash_info.nv_dload.cust_xml[0].off);

    printf("xnv2 : flag 0x%x,len 0x%x,off 0x%x\n",g_flash_info.nv_dload.xnv_xml[1].magic_num,\
        g_flash_info.nv_dload.xnv_xml[1].len,g_flash_info.nv_dload.xnv_xml[1].off);
    printf("cust2: flag 0x%x,len 0x%x,off 0x%x\n",g_flash_info.nv_dload.cust_xml[1].magic_num,\
        g_flash_info.nv_dload.cust_xml[1].len,g_flash_info.nv_dload.cust_xml[1].off);
    printf("xnv map1: flag 0x%x,len 0x%x,off 0x%x\n",g_flash_info.nv_dload.xnv_map[0].magic_num,\
        g_flash_info.nv_dload.xnv_map[0].len,g_flash_info.nv_dload.xnv_map[0].off);
    printf("xnv map2: flag 0x%x,len 0x%x,off 0x%x\n",g_flash_info.nv_dload.xnv_map[1].magic_num,\
        g_flash_info.nv_dload.xnv_map[1].len,g_flash_info.nv_dload.xnv_map[1].off);
    printf("\n********dload mtd info*******\n");
    printf("nv   : flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.nv_bin.magic_num,\
        nv_dload.nv_bin.len,nv_dload.nv_bin.off);
    /* coverity[uninit_use] */
    printf("xnv1 : flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.xnv_xml[0].magic_num,\
        nv_dload.xnv_xml[0].len,nv_dload.xnv_xml[0].off);
     /* coverity[uninit_use] */
    printf("cust1: flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.cust_xml[0].magic_num,\
        nv_dload.cust_xml[0].len,nv_dload.cust_xml[0].off);

    printf("xnv2 : flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.xnv_xml[1].magic_num,\
        nv_dload.xnv_xml[1].len,nv_dload.xnv_xml[1].off);
    printf("cust2: flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.cust_xml[1].magic_num,\
        nv_dload.cust_xml[1].len,nv_dload.cust_xml[1].off);
     /* coverity[uninit_use] */
    printf("xnv map1: flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.xnv_map[0].magic_num,\
        nv_dload.xnv_map[0].len,nv_dload.xnv_map[0].off);
    printf("xnv map2: flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.xnv_map[1].magic_num,\
        nv_dload.xnv_map[1].len,nv_dload.xnv_map[1].off);

    for(i= 0;i<NV_DLOAD_FILE_BLOCK_NUM;i++)
        printf("nv dload file %d block off :0x%x\n",i,g_sec_info.nv_dload[i]);

    printf("\n******************backup info******************\n");
    printf("\n********backup mem info******\n");
    printf("backup flag: 0x%x, len : 0x%x, off:0x%x\n",g_flash_info.bak_sec.magic_num,\
        g_flash_info.bak_sec.len,g_flash_info.bak_sec.off);
    printf("\n********backup mtd info******\n");
    ret = bsp_nand_read((char*)NV_BACK_SEC_NAME,0,&ctrl_info,sizeof(ctrl_info),NULL);
    if(ret){
        nv_free(file_info);
        return;
    }
    if(ctrl_info.magicnum != NV_CTRL_FILE_MAGIC_NUM)
    {
        ctrl_info.file_size = 144;
    }
    ret = bsp_nand_read((char*)NV_BACK_SEC_NAME,sizeof(ctrl_info),file_info,ctrl_info.file_size,NULL);
    if(ret){
        nv_free(file_info);
        return;
    }
    printf("magic :0x%x,file num: %d,nv num :0x%x,modem num :%d\n",\
        ctrl_info.magicnum,ctrl_info.file_num,ctrl_info.ref_count,ctrl_info.modem_num);
    for(i= 0;i<NV_BIN_FILE_BLOCK_NUM;i++)
        printf("nv back file %d block off :0x%x\n",i,g_sec_info.nv_bak[i]);

    printf("\n******************default info*****************\n");
    printf("\n********default mem info*****\n");
    printf("default flag: 0x%x, len : 0x%x, off:0x%x\n",g_flash_info.def_sec.magic_num,\
        g_flash_info.def_sec.len,g_flash_info.def_sec.off);

    printf("\n********default mtd info*****\n");
    ret = bsp_nand_read((char*)NV_DEF_SEC_NAME,0,&ctrl_info,sizeof(ctrl_info),NULL);
    if(ret){
        nv_free(file_info);
        return;
    }
    if(ctrl_info.magicnum != NV_CTRL_FILE_MAGIC_NUM)
    {
        ctrl_info.file_size = 144;
    }
    ret = bsp_nand_read((char*)NV_DEF_SEC_NAME,sizeof(ctrl_info),file_info,ctrl_info.file_size,NULL);
    if(ret){
        nv_free(file_info);
        return;
    }
    printf("magic :0x%x,file num: %d,nv num :0x%x,modem num :%d\n",\
        ctrl_info.magicnum,ctrl_info.file_num,ctrl_info.ref_count,ctrl_info.modem_num);
    for(i= 0;i<NV_BIN_FILE_BLOCK_NUM;i++)
        printf("nv default file %d block off :0x%x\n",i,g_sec_info.nv_default[i]);
    nv_free(file_info);
}
コード例 #17
0
void show_emmc_info(void)
{
    struct nv_dload_packet_head_stru nv_dload;
    struct nv_ctrl_file_info_stru ctrl_info;
    u8* file_info;
    s32 ret = -1 ;

    printf("\n******************img info*********************\n");
    ret = bsp_nand_read((char*)NV_SYS_SEC_NAME,0,&ctrl_info,sizeof(ctrl_info),NULL);
    if(ret)
        return;
    if(ctrl_info.magicnum != NV_CTRL_FILE_MAGIC_NUM)
    {
        ctrl_info.file_size = 144;
    }
    file_info = (u8*)nv_malloc(ctrl_info.file_size+1);
    if(NULL == file_info)
    {
        return;
    }
    ret = bsp_nand_read((char*)NV_SYS_SEC_NAME,sizeof(ctrl_info),file_info,ctrl_info.file_size,NULL);
    if(ret)
        return;
    printf("\n********sys mem info*******\n");
    printf("nv   :flag 0x%x,off 0x%x,len 0x%x\n",g_emmc_info.sys_nv.magic_num,\
        g_emmc_info.sys_nv.off,g_emmc_info.sys_nv.len);
    printf("\n************sys info in nand**************\n");
    printf("magic :0x%x,file num: %d,nv num :0x%x,modem num :%d\n",\
        ctrl_info.magicnum,ctrl_info.file_num,ctrl_info.ref_count,ctrl_info.modem_num);

    printf("\n******************dload info*******************\n");
    ret = bsp_nand_read((char*)NV_DLOAD_SEC_NAME,0,&nv_dload,sizeof(nv_dload),NULL);
    if(ret)
        return;
    printf("\n********dload mem info*******\n");
    printf("nv   : flag 0x%x,len 0x%x,off 0x%x\n",g_emmc_info.nv_dload.nv_bin.magic_num,\
        g_emmc_info.nv_dload.nv_bin.len,g_emmc_info.nv_dload.nv_bin.off);
    printf("xnv1 : flag 0x%x,len 0x%x,off 0x%x\n",g_emmc_info.nv_dload.xnv_xml[0].magic_num,\
        g_emmc_info.nv_dload.xnv_xml[0].len,g_emmc_info.nv_dload.xnv_xml[0].off);
    printf("cust1: flag 0x%x,len 0x%x,off 0x%x\n",g_emmc_info.nv_dload.cust_xml[0].magic_num,\
        g_emmc_info.nv_dload.cust_xml[0].len,g_emmc_info.nv_dload.cust_xml[0].off);

    printf("xnv2 : flag 0x%x,len 0x%x,off 0x%x\n",g_emmc_info.nv_dload.xnv_xml[1].magic_num,\
        g_emmc_info.nv_dload.xnv_xml[1].len,g_emmc_info.nv_dload.xnv_xml[1].off);
    printf("cust2: flag 0x%x,len 0x%x,off 0x%x\n",g_emmc_info.nv_dload.cust_xml[1].magic_num,\
        g_emmc_info.nv_dload.cust_xml[1].len,g_emmc_info.nv_dload.cust_xml[1].off);
    printf("xnv map1: flag 0x%x,len 0x%x,off 0x%x\n",g_emmc_info.nv_dload.xnv_map[0].magic_num,\
        g_emmc_info.nv_dload.xnv_map[0].len,g_emmc_info.nv_dload.xnv_map[0].off);
    printf("xnv map2: flag 0x%x,len 0x%x,off 0x%x\n",g_emmc_info.nv_dload.xnv_map[1].magic_num,\
        g_emmc_info.nv_dload.xnv_map[1].len,g_emmc_info.nv_dload.xnv_map[1].off);
    printf("\n********dload mtd info*******\n");
    printf("nv   : flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.nv_bin.magic_num,\
        nv_dload.nv_bin.len,nv_dload.nv_bin.off);
    printf("xnv1 : flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.xnv_xml[0].magic_num,\
        nv_dload.xnv_xml[0].len,nv_dload.xnv_xml[0].off);
    printf("cust1: flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.cust_xml[0].magic_num,\
        nv_dload.cust_xml[0].len,nv_dload.cust_xml[0].off);

    printf("xnv2 : flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.xnv_xml[1].magic_num,\
        nv_dload.xnv_xml[1].len,nv_dload.xnv_xml[1].off);
    printf("cust2: flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.cust_xml[1].magic_num,\
        nv_dload.cust_xml[1].len,nv_dload.cust_xml[1].off);

    printf("xnv map1: flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.xnv_map[0].magic_num,\
        nv_dload.xnv_map[0].len,nv_dload.xnv_map[0].off);
    printf("xnv map2: flag 0x%x,len 0x%x,off 0x%x\n",nv_dload.xnv_map[1].magic_num,\
        nv_dload.xnv_map[1].len,nv_dload.xnv_map[1].off);

    printf("\n******************backup info******************\n");
    printf("\n********backup mem info******\n");
    printf("backup flag: 0x%x, len : 0x%x, off:0x%x\n",g_emmc_info.bak_sec.magic_num,\
        g_emmc_info.bak_sec.len,g_emmc_info.bak_sec.off);
    printf("\n********backup mtd info******\n");
    ret = bsp_nand_read((char*)NV_BACK_SEC_NAME,0,&ctrl_info,sizeof(ctrl_info),NULL);
    if(ret)
        return;
    if(ctrl_info.magicnum != NV_CTRL_FILE_MAGIC_NUM)
    {
        ctrl_info.file_size = 144;
    }
    ret = bsp_nand_read((char*)NV_BACK_SEC_NAME,sizeof(ctrl_info),file_info,ctrl_info.file_size,NULL);
    if(ret)
        return;
    printf("magic :0x%x,file num: %d,nv num :0x%x,modem num :%d\n",\
        ctrl_info.magicnum,ctrl_info.file_num,ctrl_info.ref_count,ctrl_info.modem_num);

    printf("\n******************default info*****************\n");
    printf("\n********default mem info*****\n");
    printf("default flag: 0x%x, len : 0x%x, off:0x%x\n",g_emmc_info.def_sec.magic_num,\
        g_emmc_info.def_sec.len,g_emmc_info.def_sec.off);

    printf("\n********default mtd info*****\n");
    ret = bsp_nand_read((char*)NV_DEF_SEC_NAME,0,&ctrl_info,sizeof(ctrl_info),NULL);
    if(ret)
        return;
    if(ctrl_info.magicnum != NV_CTRL_FILE_MAGIC_NUM)
    {
        ctrl_info.file_size = 144;
    }
    ret = bsp_nand_read((char*)NV_DEF_SEC_NAME,sizeof(ctrl_info),file_info,ctrl_info.file_size,NULL);
    if(ret)
        return;
    printf("magic :0x%x,file num: %d,nv num :0x%x,modem num :%d\n",\
        ctrl_info.magicnum,ctrl_info.file_num,ctrl_info.ref_count,ctrl_info.modem_num);


    nv_free(file_info);
}
コード例 #18
0
/******************************************************************************
Function:	    load_data_to_secos
Description:	从指定偏移开始传送指定大小的镜像
Input:		
			part_name   - 要发送镜像的名称
			offset      - 偏移地址 
		    sizeToRead	- 输入参数,要写入的镜像的bytes大小

Output:		    none
Return:		    SEC_OK: OK  SEC_ERROR: ERROR码
******************************************************************************/
static s32 load_data_to_secos(TEEC_Session *session, char* part_name, u32 offset, u32 sizeToRead, u32 * skip_len)
{
	u32 read_bytes;
	u32 end_bytes;
	u32 copy_bytes;
	u32 timers;
	u32 i;
	s32 ret = SEC_ERROR;

	/*split the size to be read to each 64K bytes.*/
	timers = sizeToRead / SECBOOT_BUFLEN;	
	if (sizeToRead % SECBOOT_BUFLEN)		
	timers = timers + 1;

	end_bytes = sizeToRead;
	
	/*call flash_read each time to read to memDst.*/
	for (i = 0; i < timers; i++) 
	{		
		if (end_bytes >= SECBOOT_BUFLEN)
			read_bytes = SECBOOT_BUFLEN;
		else
			read_bytes = end_bytes;
		
		if (bsp_nand_read(part_name, offset + i * SECBOOT_BUFLEN, (void *)SECBOOT_BUFFER, read_bytes, skip_len)) {
			sec_print_err("%s: err: flash_read\n", __func__);
			return SEC_ERROR;
		}

		if (end_bytes >= SECBOOT_BUFLEN) {
			if (SECBOOT_BUFLEN != read_bytes) {
				sec_print_err("%s: err: SECBOOT_BUFLEN:%d != read_bytes:%d\r\n", __func__, SECBOOT_BUFLEN, read_bytes);
				return SEC_ERROR;
			}
			copy_bytes = SECBOOT_BUFLEN;
		} else {
			if (end_bytes > read_bytes) {
				sec_print_err("%s: err: end_bytes:%d!= read_bytes:%d\r\n", __func__, end_bytes, read_bytes);
				return SEC_ERROR;
			}
			copy_bytes = end_bytes;
		}		

		ret = bsp_trans_to_os(session, SECBOOT_CMD_ID_COPY_DATA, (void *)(SECBOOT_BUFFER),
			                                            (i * SECBOOT_BUFLEN), copy_bytes);	
		if (SEC_ERROR == ret)
		{
			sec_print_err("modem image trans to os is failed, error code 0x%x\r\n", ret);
			return SEC_ERROR;
		}

		end_bytes -= copy_bytes;
	}
	
	if (0 != end_bytes) {
		sec_print_err("%s: end_bytes = 0x%x\n", __func__, end_bytes);
		return SEC_ERROR;
	}
	
	return SEC_OK;
/*lint --e{818}*/
}