2 * Copyright 2015 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <fsl_validate.h>
11 int do_esbc_halt(cmd_tbl_t *cmdtp, int flag, int argc,
14 if (fsl_check_boot_mode_secure() == 0) {
15 printf("Boot Mode is Non-Secure. Not entering spin loop.\n");
19 printf("Core is entering spin loop.\n");
26 static int do_esbc_validate(cmd_tbl_t *cmdtp, int flag, int argc,
29 char *hash_str = NULL;
32 uintptr_t img_addr = 0;
36 return cmd_usage(cmdtp);
38 /* Second arg - Optional - Hash Str*/
41 /* First argument - header address -32/64bit */
42 haddr = (uintptr_t)simple_strtoul(argv[1], NULL, 16);
44 /* With esbc_validate command, Image address must be
45 * part of header. So, the function is called
46 * by passing this argument as 0.
48 ret = fsl_secboot_validate(haddr, hash_str, &img_addr);
50 /* Need to set "img_addr" even if validation failure.
51 * Required when SB_EN in RCW set and non-fatal error
54 sprintf(buf, "%lx", img_addr);
55 setenv("img_addr", buf);
60 printf("esbc_validate command successful\n");
64 /***************************************************/
65 static char esbc_validate_help_text[] =
66 "esbc_validate hdr_addr <hash_val> - Validates signature using\n"
68 " $hdr_addr Address of header of the image\n"
70 " $hash_val -Optional\n"
71 " It provides Hash of public/srk key to be\n"
72 " used to verify signature.\n";
75 esbc_validate, 3, 0, do_esbc_validate,
76 "Validates signature on a given image using RSA verification",
77 esbc_validate_help_text
81 esbc_halt, 1, 0, do_esbc_halt,
82 "Put the core in spin loop (Secure Boot Only)",