config_fsl_chain_trust.h 2.9 KB

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