2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-02-27 04:15:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Freescale Semiconductor, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2015-02-27 04:15:35 +00:00
|
|
|
#include <fsl_validate.h>
|
|
|
|
|
2016-03-23 10:54:44 +00:00
|
|
|
int do_esbc_halt(cmd_tbl_t *cmdtp, int flag, int argc,
|
2015-03-10 08:38:50 +00:00
|
|
|
char * const argv[])
|
|
|
|
{
|
2016-01-22 11:07:28 +00:00
|
|
|
if (fsl_check_boot_mode_secure() == 0) {
|
|
|
|
printf("Boot Mode is Non-Secure. Not entering spin loop.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-10 08:38:50 +00:00
|
|
|
printf("Core is entering spin loop.\n");
|
|
|
|
loop:
|
|
|
|
goto loop;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-03 13:57:50 +00:00
|
|
|
#ifndef CONFIG_SPL_BUILD
|
2015-02-27 04:15:35 +00:00
|
|
|
static int do_esbc_validate(cmd_tbl_t *cmdtp, int flag, int argc,
|
|
|
|
char * const argv[])
|
|
|
|
{
|
2015-12-08 08:44:12 +00:00
|
|
|
char *hash_str = NULL;
|
2015-12-08 08:44:15 +00:00
|
|
|
uintptr_t haddr;
|
2015-12-08 08:44:12 +00:00
|
|
|
int ret;
|
2016-03-23 10:54:45 +00:00
|
|
|
uintptr_t img_addr = 0;
|
|
|
|
char buf[20];
|
2015-12-08 08:44:12 +00:00
|
|
|
|
2015-02-27 04:15:35 +00:00
|
|
|
if (argc < 2)
|
|
|
|
return cmd_usage(cmdtp);
|
2015-12-08 08:44:12 +00:00
|
|
|
else if (argc > 2)
|
|
|
|
/* Second arg - Optional - Hash Str*/
|
|
|
|
hash_str = argv[2];
|
|
|
|
|
|
|
|
/* First argument - header address -32/64bit */
|
2015-12-08 08:44:15 +00:00
|
|
|
haddr = (uintptr_t)simple_strtoul(argv[1], NULL, 16);
|
2015-02-27 04:15:35 +00:00
|
|
|
|
2015-12-08 08:44:15 +00:00
|
|
|
/* With esbc_validate command, Image address must be
|
|
|
|
* part of header. So, the function is called
|
|
|
|
* by passing this argument as 0.
|
|
|
|
*/
|
2016-03-23 10:54:45 +00:00
|
|
|
ret = fsl_secboot_validate(haddr, hash_str, &img_addr);
|
|
|
|
|
|
|
|
/* Need to set "img_addr" even if validation failure.
|
|
|
|
* Required when SB_EN in RCW set and non-fatal error
|
|
|
|
* to continue U-Boot
|
|
|
|
*/
|
|
|
|
sprintf(buf, "%lx", img_addr);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("img_addr", buf);
|
2016-03-23 10:54:45 +00:00
|
|
|
|
2015-12-08 08:44:12 +00:00
|
|
|
if (ret)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
printf("esbc_validate command successful\n");
|
|
|
|
return 0;
|
2015-02-27 04:15:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************/
|
|
|
|
static char esbc_validate_help_text[] =
|
|
|
|
"esbc_validate hdr_addr <hash_val> - Validates signature using\n"
|
|
|
|
" RSA verification\n"
|
|
|
|
" $hdr_addr Address of header of the image\n"
|
|
|
|
" to be validated.\n"
|
|
|
|
" $hash_val -Optional\n"
|
|
|
|
" It provides Hash of public/srk key to be\n"
|
|
|
|
" used to verify signature.\n";
|
|
|
|
|
|
|
|
U_BOOT_CMD(
|
|
|
|
esbc_validate, 3, 0, do_esbc_validate,
|
|
|
|
"Validates signature on a given image using RSA verification",
|
|
|
|
esbc_validate_help_text
|
|
|
|
);
|
2015-03-10 08:38:50 +00:00
|
|
|
|
|
|
|
U_BOOT_CMD(
|
|
|
|
esbc_halt, 1, 0, do_esbc_halt,
|
2016-01-22 11:07:28 +00:00
|
|
|
"Put the core in spin loop (Secure Boot Only)",
|
2015-03-10 08:38:50 +00:00
|
|
|
""
|
|
|
|
);
|
2018-01-03 13:57:50 +00:00
|
|
|
#endif
|