blob: d3206000e92da3790488dca434da3e57224d3d1d [file] [log] [blame]
/*
* Copyright (c) 2018 MediaTek Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <errno.h>
#include <fit.h>
#include <kernel/vm.h>
#include <lib/bio.h>
#include <lib/mempool.h>
#include <libfdt.h>
#include <platform.h>
#include <string.h>
#include <sys/types.h>
#include <trace.h>
#include "avb.h"
#include "blxboot_ab.h"
#include "blxboot_plat.h"
#include "imageinfo.h"
#if ENABLE_ANDROID_BOOTIMG_SUPPORT
#include <lib/android_bootimg.h>
#include <lib/boot_info.h>
#endif
#define LOCAL_TRACE 0
/* BL33 load and entry point address */
#define CFG_BL33_LOAD_EP_ADDR (BL33_ADDR)
/* ramdisk args to be appended to kernel command line */
#define MAX_RAMDISK_ARG_LEN (45)
#define RAMDISK_ARG_STR_FMT "initrd=0x%lx,0x%x"
extern __WEAK paddr_t kvaddr_to_paddr(void *ptr);
/* forward declaration */
static int load_avb_image(const char *part_name,
struct imageinfo_t *img);
static int load_builtin_bl33_image(const char *part_name,
struct imageinfo_t *img);
static int load_fit_image(const char *part_name,
struct imageinfo_t *img);
static int load_android_image(const char *part_name,
struct imageinfo_t *img);
static int load_dtbo_image(const char *part_name,
struct imageinfo_t *img);
static int load_scpsys_image(const char *part_name,
struct imageinfo_t *img);
static int load_scpdata_image(const char *part_name,
struct imageinfo_t *img);
static int load_scpcfg_image(const char *part_name,
struct imageinfo_t *img);
#if ENABLE_MODEM_LOAD
static int load_md_image(const char *part_name,
struct imageinfo_t *img);
#endif
#if ENABLE_HSM_OS_LOAD
static int load_hsm_os_image(const char *part_name,
struct imageinfo_t *img);
#endif
struct image_load_data tzimg = {
.part_name = TZ_PART_NAME,
.recovery_part_name = RECOVERY_TZ_PART_NAME,
.membdev_name = "download:tz",
.has_slot = (TZ_HAS_SLOT != 0),
};
struct image_load_data bl33img = {
.part_name = BL33_PART_NAME,
.recovery_part_name = RECOVERY_BL33_PART_NAME,
.membdev_name = "download:bl33",
.has_slot = (BL33_HAS_SLOT != 0),
};
#if ENABLE_SLAVE_CPU_LOAD
struct image_load_data scpuimg = {
.part_name = SLAVE_CPU_PART_NAME,
.recovery_part_name = RECOVERY_SLAVE_CPU_PART_NAME,
.membdev_name = "download:scpu",
.has_slot = (SLAVE_CPU_HAS_SLOT != 0),
};
#endif
struct image_load_data bootimg = {
.part_name = BOOT_PART_NAME,
.recovery_part_name = RECOVERY_BOOT_PART_NAME,
.membdev_name = "download:boot",
.has_slot = (BOOT_HAS_SLOT != 0),
};
struct image_load_data dtboimg = {
.part_name = DTBO_PART_NAME,
.has_slot = (DTBO_HAS_SLOT != 0),
};
struct image_load_data vpdimg = {
#if defined(VPD_PART_NAME)
.part_name = VPD_PART_NAME,
#endif
#if defined(RECOVERY_VPD_PART_NAME)
.recovery_part_name = RECOVERY_VPD_PART_NAME,
#endif
.membdev_name = "download:vpd",
.has_slot = (VPD_HAS_SLOT != 0),
};
#if ENABLE_SCP_LOAD
struct image_load_data scpsysimg = {
.part_name = SCPSYS_PART_NAME,
.recovery_part_name = RECOVERY_SCPSYS_PART_NAME,
.membdev_name = "download:scpsys",
.has_slot = (SCPSYS_HAS_SLOT != 0),
};
#endif
#if ENABLE_SCP_AUX_LOAD
struct image_load_data scpdataimg = {
.part_name = SCPDATA_PART_NAME,
.recovery_part_name = RECOVERY_SCPDATA_PART_NAME,
.membdev_name = "download:scpdata",
.has_slot = (SCPDATA_HAS_SLOT != 0),
};
struct image_load_data scpcfgimg = {
.part_name = SCPCFG_PART_NAME,
.recovery_part_name = RECOVERY_SCPCFG_PART_NAME,
.buf = (void *)SCP_CFG_VA,
.has_slot = (SCPCFG_HAS_SLOT != 0),
};
#endif
#if ENABLE_SPM_FW_LOAD
struct image_load_data spmfwimg = {
.part_name = SPM_PART_NAME,
.recovery_part_name = SPM_PART_NAME,
.membdev_name = "download:spmfw",
.has_slot = (SPMFW_HAS_SLOT != 0),
};
#endif
#if ENABLE_MODEM_LOAD
struct image_load_data mdimg = {
.part_name = MD_PART_NAME,
.membdev_name = "download:md",
.buf = (void *)MD_ADDR,
.has_slot = (MD_HAS_SLOT != 0),
};
#endif
#if ENABLE_HSM_OS_LOAD
struct image_load_data hsm_os_img = {
.part_name = HSM_OS_PART_NAME,
.membdev_name = "download:hsmos",
.buf = (void *)HSM_OS_ADDR,
.has_slot = (HSM_OS_HAS_SLOT != 0),
};
#endif
struct imageinfo_t imagelist[] = {
#if ENABLE_SCP_AUX_LOAD
{
.type = IMGTYPE_SCPDATA,
.load = load_scpdata_image,
.imgdata = &scpdataimg,
},
{
.type = IMGTYPE_SCPCFG,
.load = load_scpcfg_image,
.imgdata = &scpcfgimg,
},
#endif
#if ENABLE_SCP_LOAD
{
.type = IMGTYPE_SCPSYS,
.load = load_scpsys_image,
.imgdata = &scpsysimg,
},
#endif
#if ENABLE_TZ_LOAD
{
.type = IMGTYPE_TZ,
.load = load_fit_image,
.imgdata = &tzimg,
},
#endif /* ENABLE_TZ_LOAD */
#if ENABLE_BL33_LOAD
{
#if ENABLE_BUILTIN_BL33
.type = IMGTYPE_BUILTIN_BL33,
.load = load_builtin_bl33_image,
#else
.type = IMGTYPE_BL33,
.load = load_fit_image,
#endif
.imgdata = &bl33img,
},
#endif /* ENABLE_BL33_LOAD */
#if ENABLE_SLAVE_CPU_LOAD
{
.type = IMGTYPE_SLAVE_CPU,
.load = load_fit_image,
.imgdata = &scpuimg,
},
#endif /* ENABLE_DSP_LOAD */
#if ENABLE_KERNEL_LOAD
{
.type = IMGTYPE_KERNEL,
#if defined(AVB_VERIFY_KERNEL)
.load = load_avb_image,
#else
#if ENABLE_ANDROID_BOOTIMG_SUPPORT
.load = load_android_image,
#else
.load = load_fit_image,
#endif
#endif
.imgdata = &bootimg,
},
{
.type = IMGTYPE_VPD,
.load = load_dtbo_image,
.imgdata = &vpdimg,
},
{
.type = IMGTYPE_DTBO,
.load = load_dtbo_image,
.imgdata = &dtboimg,
},
#endif /* ENABLE_KERNEL_LOAD */
#if ENABLE_SPM_FW_LOAD
{
.type = IMGTYPE_SPM,
.load = load_fit_image,
.imgdata = &spmfwimg,
},
#endif /* ENABLE_SPM_FW_LOAD */
#if ENABLE_MODEM_LOAD
{
.type = IMGTYPE_MODEM,
.load = load_md_image,
.imgdata = &mdimg,
},
#endif
#if ENABLE_HSM_OS_LOAD
{
.type = IMGTYPE_HSM_OS,
.load = load_hsm_os_image,
.imgdata = &hsm_os_img,
},
#endif
{ .type = IMGTYPE_NONE } /* imagelist end marker */
};
static void append_cmdline_ramdisk_arg(addr_t ramdisk_addr, uint32_t ramdisk_sz)
{
char ramdisk_arg[MAX_RAMDISK_ARG_LEN];
memset(ramdisk_arg, 0x0, sizeof(ramdisk_arg));
snprintf(ramdisk_arg, MAX_RAMDISK_ARG_LEN, RAMDISK_ARG_STR_FMT,
ramdisk_addr, ramdisk_sz);
plat_fixup_append(ramdisk_arg);
}
static int fit_load_images(void *fit, struct image_load_data *fit_data,
bool need_verified)
{
addr_t load;
size_t load_size;
int ret;
/* TODO: decide verify policy with config. */
if (need_verified) {
dprintf(ALWAYS, "verify fit conf sig: %s\n", fit_data->part_name);
ret = fit_conf_verify_sig(NULL, fit);
if (ret < 0)
return ret;
}
ret = fit_load_image(NULL, "kernel", fit, NULL, NULL,
(paddr_t *)&fit_data->kernel_entry, need_verified);
if (ret && (ret != -ENOENT)) {
dprintf(CRITICAL, "%s load kernel failed\n", fit_data->part_name);
return ret;
}
ret = fit_load_image(NULL, "ramdisk", fit, &load, &load_size, NULL,
need_verified);
if (ret) {
if (ret != -ENOENT) {
dprintf(CRITICAL, "%s load ramdisk failed\n", fit_data->part_name);
return ret;
}
} else {
#if WITH_KERNEL_VM
load = kvaddr_to_paddr((void *)load);
#endif
append_cmdline_ramdisk_arg(load, load_size);
}
ret = fit_load_image(NULL, "fdt", fit, (addr_t *)&fit_data->dtb_load, NULL,
NULL, need_verified);
if (ret && (ret != -ENOENT)) {
fit_data->dtb_load = ERR_ADDR; /* [TODO] remove or assign it to NULL */
dprintf(CRITICAL, "%s load fdt failed\n", fit_data->part_name);
return ret;
}
ret = fit_load_image(NULL, "tee", fit, NULL, NULL,
(paddr_t *)&fit_data->trustedos_entry, need_verified);
if (ret && (ret != -ENOENT)) {
dprintf(CRITICAL, "%s load trustedos failed\n", fit_data->part_name);
return ret;
}
return 0;
}
#if ENABLE_ANDROID_BOOTIMG_SUPPORT
static int load_android_hdr_images(const void *part_data,
struct image_load_data *android_data)
{
int rc;
uint32_t ramdisk_target_addr, kernel_target_addr;
uint32_t ramdisk_sz, zimage_sz, dtb_sz;
uint64_t dtb_target_addr;
vaddr_t ramdisk_addr, kernel_addr, dtb_addr;
char android_dtb_param[] = "androidboot.dtb_idx=0";
load_bootinfo_bootimg_hdr((struct bootimg_hdr *)part_data);
set_bootimg_loaded((vaddr_t)part_data);
ramdisk_target_addr = get_ramdisk_target_addr();
ramdisk_addr = get_ramdisk_addr();
ramdisk_sz = get_ramdisk_real_sz();
kernel_target_addr = get_kernel_target_addr();
kernel_addr = get_kernel_addr();
zimage_sz = get_kernel_real_sz();
dtb_target_addr = get_dtb_target_addr();
dtb_addr = get_dtb_addr();
dtb_sz = get_dtb_size();
assert(ramdisk_target_addr != 0);
assert(ramdisk_addr != 0);
assert(kernel_target_addr != 0);
assert(kernel_addr != 0);
assert(dtb_target_addr != 0);
assert(dtb_addr != 0);
if(get_header_version() < BOOT_HEADER_VERSION_TWO) {
LTRACEF_LEVEL(CRITICAL,
"Android Image Header version is lower than v2\n");
return -EINVAL;
}
rc = android_processing_data("ramdisk", ramdisk_addr,
ramdisk_target_addr, ramdisk_sz);
if (rc != 0) {
LTRACEF_LEVEL(CRITICAL, "load %s failed\n", "ramdisk");
return -EINVAL;
}
append_cmdline_ramdisk_arg((addr_t)ramdisk_target_addr, ramdisk_sz);
rc = android_processing_data("kernel", kernel_addr,
kernel_target_addr, zimage_sz);
if (rc != 0) {
LTRACEF_LEVEL(CRITICAL, "load %s failed\n", "kernel");
return -EINVAL;
}
android_data->kernel_entry = kernel_target_addr;
rc = android_processing_data("dtb", dtb_addr,
dtb_target_addr, dtb_sz);
if (rc != 0) {
LTRACEF_LEVEL(CRITICAL, "load %s failed\n", "dtb");
return -EINVAL;
}
#if WITH_KERNEL_VM
dtb_target_addr = (vaddr_t)paddr_to_kvaddr(dtb_target_addr);
#endif
android_data->dtb_load = dtb_target_addr;
plat_fixup_append(android_dtb_param);
return 0;
}
#endif
static int load_avb_image(const char *part_name, struct imageinfo_t *img)
{
int ret;
size_t part_name_len;
struct image_load_data *imgdata;
char *raw_part_name;
const char *suffix;
AvbSlotVerifyResult verify_result;
AvbSlotVerifyData *verify_data;
if ((img == NULL) || (img->imgdata == NULL))
return -1;
imgdata = img->imgdata;
raw_part_name = strdup(part_name);
if (raw_part_name == NULL)
return -ENOMEM;
if (imgdata->has_slot) {
/* prepare partition name without ab suffix */
part_name_len = strlen(part_name);
suffix = get_suffix();
if (suffix && (part_name_len > strlen(suffix))) {
part_name_len -= strlen(suffix);
*(raw_part_name + part_name_len) = '\0';
}
}
ret = 0;
verify_result = android_verified_boot_2_0(raw_part_name, &verify_data);
if ((verify_result != AVB_SLOT_VERIFY_RESULT_OK) && !is_device_unlocked()) {
ret = -10;
goto exit;
}
void *part_data = get_partition_data(raw_part_name, verify_data);
if (part_data == NULL) {
ret = -11;
goto exit;
}
#if ENABLE_ANDROID_BOOTIMG_SUPPORT
if (img->type == IMGTYPE_KERNEL) {
ret = load_android_hdr_images(part_data, imgdata);
} else {
if (android_dtbo_check_header((const void *)part_data) == DTBO_RET_OK) {
/* android dtbo image without fit header */
imgdata->dtb_load = (ulong)part_data;
} else {
/* android dtbo image with fit header */
ret = fit_load_images(part_data, imgdata, false);
}
}
#else
ret = fit_load_images(part_data, imgdata, false);
#endif
if (ret) {
LTRACEF_LEVEL(CRITICAL, "load %s image failed\n", part_name);
ret = -21;
goto exit;
}
if (img->type == IMGTYPE_KERNEL)
plat_fixup_append(verify_data->cmdline);
exit:
if (raw_part_name)
free(raw_part_name);
return ret;
}
static int load_builtin_bl33_image(const char *part_name,
struct imageinfo_t *img)
{
uint32_t bl33[] = { 0xea000005, /* b BL33_32_ENTRY | ands x5, x0, x0 */
0x58000160, /* .word 0x58000160 | ldr x0, _X0 */
0x58000181, /* .word 0x58000181 | ldr x1, _X1 */
0x580001a2, /* .word 0x580001a2 | ldr x2, _X2 */
0x580001c3, /* .word 0x580001c3 | ldr x3, _X3 */
0x580001e4, /* .word 0x580001e4 | ldr x4, _X4 */
0xd61f0080, /* .word 0xd61f0080 | br x4 */
/* BL33_32_ENTRY: | */
0xe59f0030, /* ldr r0, _R0 | .word 0xe59f0030 */
0xe59f1030, /* ldr r1, _R1 | .word 0xe59f1030 */
0xe59f2004, /* ldr r2, _X0 | .word 0xe59f2004 */
0xe59ff020, /* ldr pc, _X4 | .word 0xe59ff020 */
0x00000000, /* .word 0x00000000 */
0x00000000, /* _X0: .word 0x00000000 */
0x00000000, /* .word 0x00000000 */
0x00000000, /* _X1: .word 0x00000000 */
0x00000000, /* .word 0x00000000 */
0x00000000, /* _X2: .word 0x00000000 */
0x00000000, /* .word 0x00000000 */
0x00000000, /* _X3: .word 0x00000000 */
0x00000000, /* .word 0x00000000 */
0x00000000, /* _X4: .word 0x00000000 */
0x00000000, /* _R0: .word 0x00000000 */
0x00000000, /* _R1: .word 0x00000000 */
0x00000000 /* .word 0x00000000 */
};
memcpy((void *)CFG_BL33_LOAD_EP_ADDR, bl33, sizeof(bl33));
img->imgdata->kernel_entry = kvaddr_to_paddr ?
kvaddr_to_paddr((void *)CFG_BL33_LOAD_EP_ADDR) : CFG_BL33_LOAD_EP_ADDR;
return 0;
}
static int load_fit_image(const char *part_name, struct imageinfo_t *img)
{
int err;
if ((err = fit_get_image(part_name, &img->imgdata->buf)) == 0) {
err = fit_load_images(img->imgdata->buf, img->imgdata, true);
}
return err;
}
#if ENABLE_ANDROID_BOOTIMG_SUPPORT
static int load_android_image(const char *part_name, struct imageinfo_t *img)
{
int err;
if ((err = android_get_image(part_name, &img->imgdata->buf)) == 0) {
err = load_android_hdr_images(img->imgdata->buf, img->imgdata);
}
return err;
}
#endif
static int load_android_dtbo_image(const char *part_name,
struct imageinfo_t *img, uint32_t size)
{
int ret;
/* android dtbo format */
LTRACEF("part_name(%s) in pure android dtbo format.\n", part_name);
#if defined(AVB_VERIFY_KERNEL)
ret = load_avb_image(part_name, img);
#else
bdev_t *bdev;
void *buf;
ssize_t read_bytes;
bdev = bio_open_by_label(part_name) ? : bio_open(part_name);
if (!bdev)
return -ENODEV;
ret = 0;
buf = mempool_alloc(size, MEMPOOL_ANY);
if (!buf) {
ret = -ENOMEM;
goto _err;
}
read_bytes = bio_read(bdev, buf, 0, size);
if (read_bytes < (ssize_t)size) {
LTRACEF("Read android dtbo image fail: read(0x%x), got(0x%zx)\n",
size, read_bytes);
mempool_free(buf);
ret = -EIO;
goto _err;
}
img->imgdata->dtb_load = (ulong)buf;
_err:
if (bdev)
bio_close(bdev);
#endif
return ret;
}
static int load_fdt_dtbo_image(const char *part_name, struct imageinfo_t *img)
{
int ret;
int noffset;
/* legacy fdt format dtbo or android dtbo format with FIT header */
ret = fit_get_image(part_name, &img->imgdata->buf);
if (ret != 0)
return ret;
/* check configuration node to know it's legacy dtbo or not */
noffset = fdt_path_offset(img->imgdata->buf, "/configurations");
if (noffset < 0) {
LTRACEF("part_name(%s) in legacy dtbo format\n", part_name);
img->imgdata->dtb_load = (ulong)img->imgdata->buf;
return 0;
}
LTRACEF("part_name(%s) in fit android dtbo format.\n", part_name);
/* we verifies android dtbo image in the same method with kernel */
#if defined(AVB_VERIFY_KERNEL)
if (img->type == IMGTYPE_DTBO) {
mempool_free(img->imgdata->buf);
img->imgdata->buf = NULL;
/* [TODO] load_avb_image() will waste time to load dtbo image again */
ret = load_avb_image(part_name, img);
} else {
ret = fit_load_images(img->imgdata->buf, img->imgdata, true);
}
#else
/* get android dtbo */
ret = fit_load_images(img->imgdata->buf, img->imgdata, true);
#endif
return ret;
}
static int load_dtbo_image(const char *part_name, struct imageinfo_t *img)
{
int ret;
uint32_t total_size;
ssize_t read_bytes;
void *buf;
bdev_t *bdev;
bdev = bio_open_by_label(part_name) ? : bio_open(part_name);
if (!bdev) {
LTRACEF("Partition [%s] is not exist.\n", part_name);
return -ENODEV;
}
ret = 0;
/* read 1 block to determine the dtbo image format */
buf = malloc(bdev->block_size);
if (!buf) {
ret = -ENOMEM;
goto _err;
}
memset(buf, 0, bdev->block_size);
read_bytes = bio_read(bdev, buf, 0, bdev->block_size);
if (read_bytes < (ssize_t)bdev->block_size) {
LTRACEF("bio_read offset: 0, size: %ld, got: %ld\n",
bdev->block_size, read_bytes);
ret = -EIO;
goto _err;
}
if (android_dtbo_check_header((const void *)buf) == DTBO_RET_OK) {
total_size = android_dtbo_total_size((const void *)buf);
if (load_android_dtbo_image(part_name, img, total_size) < 0)
ret = -EINVAL;
} else if (fdt_check_header((const void *)buf) == 0) {
if (load_fdt_dtbo_image(part_name, img) < 0)
ret = -EINVAL;
} else {
LTRACEF("Not valid dtbo image.\n");
ret = -ENOTSUP;
}
_err:
if (buf)
free(buf);
bio_close(bdev);
return ret;
}
static int load_scpsys_image(const char *part_name, struct imageinfo_t *img)
{
int err;
void *fit;
err = fit_get_image(part_name, &img->imgdata->buf);
if (err) {
LTRACEF("fit_get_image %s fail, err=%d\n", part_name, err);
return err;
}
fit = img->imgdata->buf;
dprintf(ALWAYS, "verify fit conf sig: %s\n", part_name);
err = fit_conf_verify_sig(NULL, fit);
if (err < 0)
return err;
err = fit_load_image(NULL, "kernel", fit, NULL, NULL, NULL, true);
if (err) {
LTRACEF("fit_load_image %s: sram fw fail, err=%d\n", part_name, err);
return err;
}
/* the dram part of scpsys image is an optional image, could be absent */
err = fit_load_image(NULL, "firmware", fit, NULL, NULL, NULL, true);
if (err && err != -ENOENT) {
LTRACEF("fit_load_image %s: dram fw fail, err=%d\n", part_name, err);
return err;
}
return 0;
}
static int load_scpdata_image(const char *part_name, struct imageinfo_t *img)
{
#define FIT_FASTLOGO_IMG_NODE_NAME "logo"
#define FIT_GUIDELINE_IMG_NODE_NAME "guideline"
#define FIT_WARNMSG_IMG_NODE_NAME "warnmsg"
#define FIT_CVBSIMG_IMG_NODE_NAME "cvbsimg"
int err;
void *fit;
err = fit_get_image(part_name, &img->imgdata->buf);
if (err) {
LTRACEF("fit_get_image %s fail, err=%d\n", part_name, err);
return err;
}
fit = img->imgdata->buf;
err = fit_load_loadable_image(fit, FIT_FASTLOGO_IMG_NODE_NAME, NULL);
if (err) {
LTRACEF("fit_load_loadable_image %s fail, err=%d\n",
FIT_FASTLOGO_IMG_NODE_NAME, err);
return err;
}
err = fit_load_loadable_image(fit, FIT_GUIDELINE_IMG_NODE_NAME, NULL);
if (err) {
LTRACEF("fit_load_loadable_image %s fail, err=%d\n",
FIT_GUIDELINE_IMG_NODE_NAME, err);
return err;
}
err = fit_load_loadable_image(fit, FIT_WARNMSG_IMG_NODE_NAME, NULL);
if (err) {
LTRACEF("fit_load_loadable_image %s fail, err=%d\n",
FIT_WARNMSG_IMG_NODE_NAME, err);
return err;
}
err = fit_load_loadable_image(fit, FIT_CVBSIMG_IMG_NODE_NAME, NULL);
if (err) {
LTRACEF("fit_load_loadable_image %s fail, err=%d\n",
FIT_CVBSIMG_IMG_NODE_NAME, err);
return err;
}
return 0;
}
/* [TODO] mvoe load_scpcfg_image to mt2712 platform layer to keep SCP_CFG_VA
* invisble to others */
static int load_scpcfg_image(const char *part_name, struct imageinfo_t *img)
{
int err;
ssize_t bytes_read;
bdev_t *bdev;
bdev = bio_open_by_label(part_name) ? : bio_open(part_name);
if (!bdev)
return -ENODEV;
err = 0;
bytes_read = bio_read(bdev, img->imgdata->buf, 0, bdev->total_size);
if (bytes_read < bdev->total_size)
err = -EIO;
bio_close(bdev);
return err;
}
#if ENABLE_MODEM_LOAD
extern int load_modem_image(const char *part_name);
static int load_md_image(const char *part_name, struct imageinfo_t *img)
{
return load_modem_image(part_name);
}
#endif
#if ENABLE_HSM_OS_LOAD
extern int load_hsm_os(const char *part_name);
static int load_hsm_os_image(const char *part_name, struct imageinfo_t *img)
{
return load_hsm_os(part_name);
}
#endif