fw_dynamic.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #ifndef __FW_DYNAMIC_H__
  10. #define __FW_DYNAMIC_H__
  11. #include <sbi/riscv_asm.h>
  12. /* clang-format off */
  13. /** Offset of magic member in fw_dynamic_info */
  14. #define FW_DYNAMIC_INFO_MAGIC_OFFSET (0 * __SIZEOF_POINTER__)
  15. /** Offset of version member in fw_dynamic_info */
  16. #define FW_DYNAMIC_INFO_VERSION_OFFSET (1 * __SIZEOF_POINTER__)
  17. /** Offset of next_addr member in fw_dynamic_info (version >= 1) */
  18. #define FW_DYNAMIC_INFO_NEXT_ADDR_OFFSET (2 * __SIZEOF_POINTER__)
  19. /** Offset of next_mode member in fw_dynamic_info (version >= 1) */
  20. #define FW_DYNAMIC_INFO_NEXT_MODE_OFFSET (3 * __SIZEOF_POINTER__)
  21. /** Offset of options member in fw_dynamic_info (version >= 1) */
  22. #define FW_DYNAMIC_INFO_OPTIONS_OFFSET (4 * __SIZEOF_POINTER__)
  23. /** Offset of boot_hart member in fw_dynamic_info (version >= 2) */
  24. #define FW_DYNAMIC_INFO_BOOT_HART_OFFSET (5 * __SIZEOF_POINTER__)
  25. /** Expected value of info magic ('OSBI' ascii string in hex) */
  26. #define FW_DYNAMIC_INFO_MAGIC_VALUE 0x4942534f
  27. /** Maximum supported info version */
  28. #define FW_DYNAMIC_INFO_VERSION_MAX 0x2
  29. /** Possible next mode values */
  30. #define FW_DYNAMIC_INFO_NEXT_MODE_U 0x0
  31. #define FW_DYNAMIC_INFO_NEXT_MODE_S 0x1
  32. #define FW_DYNAMIC_INFO_NEXT_MODE_M 0x3
  33. /* clang-format on */
  34. #ifndef __ASSEMBLER__
  35. #include <sbi/sbi_types.h>
  36. /** Representation dynamic info passed by previous booting stage */
  37. struct fw_dynamic_info {
  38. /** Info magic */
  39. unsigned long magic;
  40. /** Info version */
  41. unsigned long version;
  42. /** Next booting stage address */
  43. unsigned long next_addr;
  44. /** Next booting stage mode */
  45. unsigned long next_mode;
  46. /** Options for OpenSBI library */
  47. unsigned long options;
  48. /**
  49. * Preferred boot HART id
  50. *
  51. * It is possible that the previous booting stage uses same link
  52. * address as the FW_DYNAMIC firmware. In this case, the relocation
  53. * lottery mechanism can potentially overwrite the previous booting
  54. * stage while other HARTs are still running in the previous booting
  55. * stage leading to boot-time crash. To avoid this boot-time crash,
  56. * the previous booting stage can specify last HART that will jump
  57. * to the FW_DYNAMIC firmware as the preferred boot HART.
  58. *
  59. * To avoid specifying a preferred boot HART, the previous booting
  60. * stage can set it to -1UL which will force the FW_DYNAMIC firmware
  61. * to use the relocation lottery mechanism.
  62. */
  63. unsigned long boot_hart;
  64. } __packed;
  65. #endif
  66. #endif