gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
Aneesh Bansal | 4310470 | 2016-01-22 16:37:24 +0530 | [diff] [blame] | 7 | #ifndef __CONFIG_FSL_CHAIN_TRUST_H |
| 8 | #define __CONFIG_FSL_CHAIN_TRUST_H |
gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 9 | |
Aneesh Bansal | 4310470 | 2016-01-22 16:37:24 +0530 | [diff] [blame] | 10 | #ifdef CONFIG_CHAIN_OF_TRUST |
| 11 | |
gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 12 | #ifndef CONFIG_EXTRA_ENV |
| 13 | #define CONFIG_EXTRA_ENV "" |
| 14 | #endif |
| 15 | |
| 16 | /* |
| 17 | * Control should not reach back to uboot after validation of images |
| 18 | * for secure boot flow and therefore bootscript should have |
| 19 | * the bootm command. If control reaches back to uboot anyhow |
| 20 | * after validating images, core should just spin. |
| 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * Define the key hash for boot script here if public/private key pair used to |
| 25 | * sign bootscript are different from the SRK hash put in the fuse |
| 26 | * Example of defining KEY_HASH is |
| 27 | * #define CONFIG_BOOTSCRIPT_KEY_HASH \ |
| 28 | * "41066b564c6ffcef40ccbc1e0a5d0d519604000c785d97bbefd25e4d288d1c8b" |
| 29 | */ |
| 30 | |
Sam Protsenko | bd7bffe | 2017-08-14 20:22:17 +0300 | [diff] [blame] | 31 | #ifdef CONFIG_USE_BOOTARGS |
Saksham Jain | 2548469 | 2016-03-23 16:24:43 +0530 | [diff] [blame] | 32 | #define CONFIG_SET_BOOTARGS "setenv bootargs \'" CONFIG_BOOTARGS" \';" |
| 33 | #else |
| 34 | #define CONFIG_SET_BOOTARGS "setenv bootargs \'root=/dev/ram " \ |
| 35 | "rw console=ttyS0,115200 ramdisk_size=600000\';" |
| 36 | #endif |
| 37 | |
| 38 | |
gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 39 | #ifdef CONFIG_BOOTSCRIPT_KEY_HASH |
| 40 | #define CONFIG_SECBOOT \ |
| 41 | "setenv bs_hdraddr " __stringify(CONFIG_BOOTSCRIPT_HDR_ADDR)";" \ |
Saksham Jain | 2548469 | 2016-03-23 16:24:43 +0530 | [diff] [blame] | 42 | CONFIG_SET_BOOTARGS \ |
gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 43 | CONFIG_EXTRA_ENV \ |
| 44 | "esbc_validate $bs_hdraddr " \ |
| 45 | __stringify(CONFIG_BOOTSCRIPT_KEY_HASH)";" \ |
| 46 | "source $img_addr;" \ |
| 47 | "esbc_halt\0" |
| 48 | #else |
| 49 | #define CONFIG_SECBOOT \ |
| 50 | "setenv bs_hdraddr " __stringify(CONFIG_BOOTSCRIPT_HDR_ADDR)";" \ |
Saksham Jain | 2548469 | 2016-03-23 16:24:43 +0530 | [diff] [blame] | 51 | CONFIG_SET_BOOTARGS \ |
gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 52 | CONFIG_EXTRA_ENV \ |
| 53 | "esbc_validate $bs_hdraddr;" \ |
| 54 | "source $img_addr;" \ |
| 55 | "esbc_halt\0" |
| 56 | #endif |
| 57 | |
Aneesh Bansal | b69061d | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 58 | #ifdef CONFIG_BOOTSCRIPT_COPY_RAM |
| 59 | #define CONFIG_BS_COPY_ENV \ |
| 60 | "setenv bs_hdr_ram " __stringify(CONFIG_BS_HDR_ADDR_RAM)";" \ |
Sumit Garg | 4564283 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 61 | "setenv bs_hdr_device " __stringify(CONFIG_BS_HDR_ADDR_DEVICE)";" \ |
Aneesh Bansal | b69061d | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 62 | "setenv bs_hdr_size " __stringify(CONFIG_BS_HDR_SIZE)";" \ |
| 63 | "setenv bs_ram " __stringify(CONFIG_BS_ADDR_RAM)";" \ |
Sumit Garg | 4564283 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 64 | "setenv bs_device " __stringify(CONFIG_BS_ADDR_DEVICE)";" \ |
Aneesh Bansal | b69061d | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 65 | "setenv bs_size " __stringify(CONFIG_BS_SIZE)";" |
| 66 | |
Saksham Jain | 503eab9 | 2016-03-23 16:24:37 +0530 | [diff] [blame] | 67 | /* For secure boot flow, default environment used will be used */ |
Ruchika Gupta | ba68875 | 2017-04-17 18:07:18 +0530 | [diff] [blame] | 68 | #if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_NAND_BOOT) || \ |
| 69 | defined(CONFIG_SD_BOOT) |
| 70 | #if defined(CONFIG_RAMBOOT_NAND) || defined(CONFIG_NAND_BOOT) |
Aneesh Bansal | b69061d | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 71 | #define CONFIG_BS_COPY_CMD \ |
Sumit Garg | 4564283 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 72 | "nand read $bs_hdr_ram $bs_hdr_device $bs_hdr_size ;" \ |
| 73 | "nand read $bs_ram $bs_device $bs_size ;" |
Sumit Garg | 4564283 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 74 | #elif defined(CONFIG_SD_BOOT) |
| 75 | #define CONFIG_BS_COPY_CMD \ |
| 76 | "mmc read $bs_hdr_ram $bs_hdr_device $bs_hdr_size ;" \ |
| 77 | "mmc read $bs_ram $bs_device $bs_size ;" |
Ruchika Gupta | ba68875 | 2017-04-17 18:07:18 +0530 | [diff] [blame] | 78 | #endif |
| 79 | #else |
Saksham Jain | 503eab9 | 2016-03-23 16:24:37 +0530 | [diff] [blame] | 80 | #define CONFIG_BS_COPY_CMD \ |
Sumit Garg | 4564283 | 2016-06-14 13:52:39 -0400 | [diff] [blame] | 81 | "cp.b $bs_hdr_device $bs_hdr_ram $bs_hdr_size ;" \ |
| 82 | "cp.b $bs_device $bs_ram $bs_size ;" |
gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 83 | #endif |
Saksham Jain | 503eab9 | 2016-03-23 16:24:37 +0530 | [diff] [blame] | 84 | #endif /* CONFIG_BOOTSCRIPT_COPY_RAM */ |
gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 85 | |
Aneesh Bansal | b69061d | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 86 | #ifndef CONFIG_BS_COPY_ENV |
| 87 | #define CONFIG_BS_COPY_ENV |
| 88 | #endif |
| 89 | |
| 90 | #ifndef CONFIG_BS_COPY_CMD |
| 91 | #define CONFIG_BS_COPY_CMD |
| 92 | #endif |
| 93 | |
Aneesh Bansal | 4310470 | 2016-01-22 16:37:24 +0530 | [diff] [blame] | 94 | #define CONFIG_CHAIN_BOOT_CMD CONFIG_BS_COPY_ENV \ |
Aneesh Bansal | b69061d | 2015-06-16 10:36:43 +0530 | [diff] [blame] | 95 | CONFIG_BS_COPY_CMD \ |
| 96 | CONFIG_SECBOOT |
gaurav rana | f79323c | 2015-03-10 14:08:50 +0530 | [diff] [blame] | 97 | |
| 98 | #endif |
| 99 | #endif |