From: Siva Durga Prasad Paladugu Date: Wed, 9 Dec 2015 13:16:44 +0000 (+0530) Subject: fpga: zynqpl: Extend the zynqaes command X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=735480e6db9ef0e00b79b5c9041e50b8044a8e56;p=thirdparty%2Fu-boot.git fpga: zynqpl: Extend the zynqaes command Extend the zynqaes command to have separate commands for encrypted bitstream load support. This patch adds two new commands "zynqaes load" and "zynqaes loadp" to load encrypted full and partial bitstreams respectively. The full bistream load which was supported earlier using "zynqaes" command is now deprcated and same can be done using "zynqaes load" command. Signed-off-by: Siva Durga Prasad Paladugu Signed-off-by: Michal Simek --- diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c index 16a795d84ed..9d598f4bfb0 100644 --- a/drivers/fpga/zynqpl.c +++ b/drivers/fpga/zynqpl.c @@ -541,25 +541,47 @@ static int do_zynq_decrypt_image(cmd_tbl_t *cmdtp, int flag, int argc, u32 dstlen; u8 imgtype = BIT_NONE; int status; + u8 i = 1; - if (argc < 5) + if (argc < 4 && argc > 5) goto usage; - srcaddr = simple_strtoul(argv[1], &endp, 16); - if (*argv[1] == 0 || *endp != 0) - return -1; - srclen = simple_strtoul(argv[2], &endp, 16); - if (*argv[2] == 0 || *endp != 0) - return -1; - dstaddr = simple_strtoul(argv[3], &endp, 16); - if (*argv[3] == 0 || *endp != 0) - return -1; - dstlen = simple_strtoul(argv[4], &endp, 16); - if (*argv[4] == 0 || *endp != 0) - return -1; + if (argc == 4) { + if (!strcmp("load", argv[i])) + imgtype = BIT_FULL; + else if (!strcmp("loadp", argv[i])) + imgtype = BIT_PARTIAL; + else + goto usage; + i++; + } + + srcaddr = simple_strtoul(argv[i], &endp, 16); + if (*argv[i++] == 0 || *endp != 0) + goto usage; + srclen = simple_strtoul(argv[i], &endp, 16); + if (*argv[i++] == 0 || *endp != 0) + goto usage; + if (argc == 4) { + dstaddr = 0xFFFFFFFF; + dstlen = srclen; + } else { + dstaddr = simple_strtoul(argv[i], &endp, 16); + if (*argv[i++] == 0 || *endp != 0) + goto usage; + dstlen = simple_strtoul(argv[i], &endp, 16); + if (*argv[i++] == 0 || *endp != 0) + goto usage; + } - if (dstaddr == 0xFFFFFFFF) - imgtype = BIT_FULL; + /* + * If the image is not bitstream but destination address is + * 0xFFFFFFFF + */ + if (imgtype == BIT_NONE && dstaddr == 0xFFFFFFFF) { + printf("ERR:use zynqaes load/loadp encrypted bitstream\n"); + goto usage; + } status = zynq_decrypt_load(srcaddr, srclen, dstaddr, dstlen, imgtype); if (status != 0) @@ -573,11 +595,17 @@ usage: #ifdef CONFIG_SYS_LONGHELP static char zynqaes_help_text[] = -"zynqaes -\n" +"zynqaes [operation type] -\n" "Decrypts the encrypted image present in source address\n" "and places the decrypted image at destination address\n" -"The destination address should be 0xFFFFFFFF for loading\n" -"the encrypted bitstreams\n"; +"zynqaes operations:\n" +" zynqaes \n" +" zynqaes load \n" +" zynqaes loadp \n" +"if operation type is load or loadp, it loads the encrypted\n" +"full or partial bitstream on to PL respectively. If no valid\n" +"operation type specified then it loads decrypted image back\n" +"to memory and it doesnt support loading PL bistsream\n"; #endif U_BOOT_CMD(