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