1
2
3
4
5
6#include <common.h>
7#include <command.h>
8#include <env.h>
9#include <fsl_validate.h>
10
11int do_esbc_halt(struct cmd_tbl *cmdtp, int flag, int argc,
12 char *const argv[])
13{
14 if (fsl_check_boot_mode_secure() == 0) {
15 printf("Boot Mode is Non-Secure. Not entering spin loop.\n");
16 return 0;
17 }
18
19 printf("Core is entering spin loop.\n");
20loop:
21 goto loop;
22
23 return 0;
24}
25
26#ifndef CONFIG_SPL_BUILD
27static int do_esbc_validate(struct cmd_tbl *cmdtp, int flag, int argc,
28 char *const argv[])
29{
30 char *hash_str = NULL;
31 uintptr_t haddr;
32 int ret;
33 uintptr_t img_addr = 0;
34 char buf[20];
35
36 if (argc < 2)
37 return cmd_usage(cmdtp);
38 else if (argc > 2)
39
40 hash_str = argv[2];
41
42
43 haddr = (uintptr_t)hextoul(argv[1], NULL);
44
45
46
47
48
49 ret = fsl_secboot_validate(haddr, hash_str, &img_addr);
50
51
52
53
54
55 sprintf(buf, "%lx", img_addr);
56 env_set("img_addr", buf);
57
58 if (ret)
59 return 1;
60
61 printf("esbc_validate command successful\n");
62 return 0;
63}
64
65
66static char esbc_validate_help_text[] =
67 "esbc_validate hdr_addr <hash_val> - Validates signature using\n"
68 " RSA verification\n"
69 " $hdr_addr Address of header of the image\n"
70 " to be validated.\n"
71 " $hash_val -Optional\n"
72 " It provides Hash of public/srk key to be\n"
73 " used to verify signature.\n";
74
75U_BOOT_CMD(
76 esbc_validate, 3, 0, do_esbc_validate,
77 "Validates signature on a given image using RSA verification",
78 esbc_validate_help_text
79);
80
81U_BOOT_CMD(
82 esbc_halt, 1, 0, do_esbc_halt,
83 "Put the core in spin loop (Secure Boot Only)",
84 ""
85);
86#endif
87