summaryrefslogtreecommitdiff
path: root/board/xilinx/zynqmp/cmds.c
diff options
context:
space:
mode:
authorVipul Kumar <vipul.kumar@xilinx.com>2018-07-11 15:18:28 +0530
committerMichal Simek <michal.simek@xilinx.com>2018-07-19 10:49:55 +0200
commit8c258e6245cb8510359db4e3769098dc53079351 (patch)
treeb9943f7cb2b334fb37ecfe5833ff4cb53eb5c0ff /board/xilinx/zynqmp/cmds.c
parent10441ec9224d0d269dc512819a32c0785a6338d3 (diff)
arm64: zynqmp: Changed zynqmp command to handle subcommands with U_BOOT_CMD_MKENT
This patch changed zynqmp command to handle subcommands with U_BOOT_CMD_MKENT. Signed-off-by: Vipul Kumar <vipul.kumar@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'board/xilinx/zynqmp/cmds.c')
-rw-r--r--board/xilinx/zynqmp/cmds.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c
index d914653238..1f6a5dee1f 100644
--- a/board/xilinx/zynqmp/cmds.c
+++ b/board/xilinx/zynqmp/cmds.c
@@ -9,24 +9,37 @@
#include <asm/arch/sys_proto.h>
#include <asm/io.h>
-static int zynqmp_verify_secure(u8 *key_ptr, u8 *src_ptr, u32 len)
+static int do_zynqmp_verify_secure(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
{
+ u64 src_addr, addr;
+ u32 len, src_lo, src_hi;
+ u8 *key_ptr = NULL;
int ret;
- u32 src_lo, src_hi;
u32 key_lo = 0;
u32 key_hi = 0;
u32 ret_payload[PAYLOAD_ARG_CNT];
- u64 addr;
- if ((ulong)src_ptr != ALIGN((ulong)src_ptr,
- CONFIG_SYS_CACHELINE_SIZE)) {
- printf("Failed: source address not aligned:%p\n", src_ptr);
+ if (argc < 4)
+ return CMD_RET_USAGE;
+
+ src_addr = simple_strtoull(argv[2], NULL, 16);
+ len = simple_strtoul(argv[3], NULL, 16);
+
+ if (argc == 5)
+ key_ptr = (uint8_t *)(uintptr_t)simple_strtoull(argv[4],
+ NULL, 16);
+
+ if ((ulong)src_addr != ALIGN((ulong)src_addr,
+ CONFIG_SYS_CACHELINE_SIZE)) {
+ printf("Failed: source address not aligned:%lx\n",
+ (ulong)src_addr);
return -EINVAL;
}
- src_lo = lower_32_bits((ulong)src_ptr);
- src_hi = upper_32_bits((ulong)src_ptr);
- flush_dcache_range((ulong)src_ptr, (ulong)(src_ptr + len));
+ src_lo = lower_32_bits((ulong)src_addr);
+ src_hi = upper_32_bits((ulong)src_addr);
+ flush_dcache_range((ulong)src_addr, (ulong)(src_addr + len));
if (key_ptr) {
key_lo = lower_32_bits((ulong)key_ptr);
@@ -48,6 +61,10 @@ static int zynqmp_verify_secure(u8 *key_ptr, u8 *src_ptr, u32 len)
return ret;
}
+static cmd_tbl_t cmd_zynqmp_sub[] = {
+ U_BOOT_CMD_MKENT(secure, 5, 0, do_zynqmp_verify_secure, "", ""),
+};
+
/**
* do_zynqmp - Handle the "zynqmp" command-line command
* @cmdtp: Command data struct pointer
@@ -62,30 +79,18 @@ static int zynqmp_verify_secure(u8 *key_ptr, u8 *src_ptr, u32 len)
static int do_zynqmp(cmd_tbl_t *cmdtp, int flag, int argc,
char *const argv[])
{
- u64 src_addr;
- u32 len;
- u8 *key_ptr = NULL;
- u8 *src_ptr;
- int ret;
+ cmd_tbl_t *c;
- if (argc > 5 || argc < 4 || strncmp(argv[1], "secure", 6))
+ if (argc < 2)
return CMD_RET_USAGE;
- src_addr = simple_strtoull(argv[2], NULL, 16);
-
- len = simple_strtoul(argv[3], NULL, 16);
-
- if (argc > 4)
- key_ptr = (uint8_t *)(uintptr_t)simple_strtoull(argv[4],
- NULL, 16);
-
- src_ptr = (uint8_t *)(uintptr_t)src_addr;
+ c = find_cmd_tbl(argv[1], &cmd_zynqmp_sub[0],
+ ARRAY_SIZE(cmd_zynqmp_sub));
- ret = zynqmp_verify_secure(key_ptr, src_ptr, len);
- if (ret)
- return CMD_RET_FAILURE;
-
- return CMD_RET_SUCCESS;
+ if (c)
+ return c->cmd(c, flag, argc, argv);
+ else
+ return CMD_RET_USAGE;
}
/***************************************************/
@@ -99,6 +104,6 @@ static char zynqmp_help_text[] =
U_BOOT_CMD(
zynqmp, 5, 1, do_zynqmp,
- "Verify and load secure images",
+ "ZynqMP sub-system",
zynqmp_help_text
)