Пример #1
0
static int itp_load_ipl(block_dev_desc_t *block_dev)
{
	u32 offset;
	u32 size;
	u32 loadaddr;
	u32 returnvalue;
	int ab8500_cutid;

	debug("itp_load_ipl\n");

	/* Check if IPL partition is present */
	if (get_entry_info_toc(block_dev, ITP_TOC_IPL_NAME, &offset,
			       &size, &loadaddr)) {
		printf("itp_load_ipl: ipl toc entry not present\n");
		return 1;
	}

	/* Get CutID */
	ab8500_cutid = ab8500_read(AB8500_MISC, AB8500_REV_REG);

	returnvalue = sec_bridge_call_secure_service((u32)ISSWAPI_SECURE_LOAD,
						SEC_ROM_FORCE_CLEAN_MASK,
						IPL_ITEM_ID,
						ab8500_cutid);
	if (returnvalue != SEC_ROM_RET_OK) {
		printf("itp_load_ipl: ISSWAPI_SECURE_LOAD: %d\n",
			returnvalue);
		return 1;
	}

	return 0;
}
Пример #2
0
/*
 * itp_load_itp - Loads itp.
 * If itp is loaded ok it will be executed and u-boot execution will stop
 */
int itp_load_itp(block_dev_desc_t *block_dev)
{
	u32 offset;
	u32 size;
	u32 loadaddress;

	debug("\nitp_load_itp\n");

	if (toc_load_toc_entry(block_dev, CONFIG_ITP_TOC_ITP_NAME, 0, 0, 0))
		return 1;

	if (get_entry_info_toc(block_dev, CONFIG_ITP_TOC_ITP_NAME, &offset,
			       &size, &loadaddress))
		return 1;

	((void(*)(void))loadaddress)(); /* U-boot execution will end here */

	return 1; /* Should not get here */
}
Пример #3
0
static int itp_load_toc_entry(block_dev_desc_t *block_dev,
			      const char *partname,
			      int verify_signature,
			      u32 *loadaddress)
{
	u32 n;
	u32 offset;
	u32 size;
#if defined(CONFIG_SECURE_KERNEL_BOOT)
	u32 real_loadaddr = 0;
	u32 size_in_bytes = 0;
#endif

	debug("itp_load_toc_entry: Loading %s\n", partname);

	if (get_entry_info_toc(block_dev, partname, &offset,
			       &size, loadaddress)) {
		HREF_PRINTF("itp_load_toc_entry: %s not present\n", partname);
		return 1;
	}

#if defined(CONFIG_SECURE_KERNEL_BOOT)
	if (verify_signature) {
		size_in_bytes = size;
		real_loadaddr = *loadaddress;
		/*
		 * We might need an offset, since ISSW doesn't support
		 * address 0.
		 */
		if (*loadaddress == 0)
			*loadaddress = *loadaddress + block_dev->blksz;
	}
#else
	if (verify_signature) {
		debug("itp_load_toc_entry: secure boot disabled so verify signature has no effect\n");
	}
#endif

	size = (size / block_dev->blksz) +
	       ((size % block_dev->blksz) ? 1 : 0);

	n = block_dev->block_read(block_dev->dev,
				  offset / block_dev->blksz,
				  size,
				  (void *) *loadaddress);

	if (n != size) {
		printf("itp_load_toc_entry: Failed to load %s!\n", partname);
		return 1;
	}

#if defined(CONFIG_SECURE_KERNEL_BOOT)
	if (verify_signature) {
		debug("itp_load_toc_entry: Verifying image...\n");

		if (sec_bridge_verify_itp_image(loadaddress)) {
			printf("itp_load_toc_entry: Failed to verify image %s!\n", partname);
			return 1;
		}

		if (real_loadaddr != *loadaddress) {
			/*
			 * Loadaddr is moved, need to move it back to ensure
			 * binary is not put out of order...
			 */
			memmove((void *)(real_loadaddr), (void*)*loadaddress, size_in_bytes);
			*loadaddress = real_loadaddr;
		}
	}

#endif

	return 0;
}