config_fsl_chain_trust.h 2.8 KB

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