int read_spldata() { int size = CONFIG_SPL_LOAD_LEN; if(TRUE != Emmc_Read(PARTITION_BOOT1, 0, size/EMMC_SECTOR_SIZE, (uint8*)spl_data)){ debugf("vmjaluna nand read error \n"); return -1; } return 0; }
/** Function for reading user partition. */ PUBLIC int _boot_partition_read(block_dev_desc_t *dev, wchar_t* partition_name, u32 offsetsector, u32 size, u8* buf) { int ret =0; u32 left; u32 nsct; char *sctbuf=NULL; disk_partition_t info; if(NULL == buf){ debugf("%s:buf is NULL!\n", __func__); goto end; } nsct = size/EMMC_SECTOR_SIZE; left = size%EMMC_SECTOR_SIZE; if(get_partition_info_by_name(dev, partition_name, &info)){ debugf("get partition %s info failed!\n", w2c(partition_name)); goto end; } if(TRUE != Emmc_Read(PARTITION_USER, info.start+offsetsector, nsct, buf)) goto end; if(left){ sctbuf = malloc(EMMC_SECTOR_SIZE); if(NULL != sctbuf){ if(TRUE == Emmc_Read(PARTITION_USER, info.start+offsetsector+nsct, 1, sctbuf)){ memcpy(buf+(nsct*EMMC_SECTOR_SIZE), sctbuf, left); ret = 1; } free(sctbuf); } }else{ ret = 1; } end: debugf("%s: partition %s read %s!\n", __func__,w2c(partition_name),ret?"success":"failed"); return ret; }
int read_logoimg(char *bmp_img,size_t size) { block_dev_desc_t *p_block_dev = NULL; disk_partition_t info; p_block_dev = get_dev("mmc", 1); if(NULL == p_block_dev){ return -1; } if (!get_partition_info_by_name(p_block_dev, L"logo", &info)) { if(TRUE != Emmc_Read(PARTITION_USER, info.start, size/EMMC_SECTOR_SIZE, bmp_img)){ debugf("function: %s nand read error\n", __FUNCTION__); return -1; } } return 0; }
int get_recovery_message(struct recovery_message *out) { block_dev_desc_t *p_block_dev = NULL; disk_partition_t info; int size=8192; p_block_dev = get_dev("mmc", 1); if(NULL == p_block_dev){ return -1; } if (!get_partition_info(p_block_dev, PARTITION_MISC, &info)) { if(TRUE != Emmc_Read(PARTITION_USER, info.start, size/EMMC_SECTOR_SIZE, (void *)buf)){ printf("function: %s emcc read error\n", __FUNCTION__); return -1; } } memcpy(out, buf, sizeof(*out)); return 0; }