fw_dynamic.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_LONG__)
  15. /** Offset of version member in fw_dynamic_info */
  16. #define FW_DYNAMIC_INFO_VERSION_OFFSET (1 * __SIZEOF_LONG__)
  17. /** Offset of next_addr member in fw_dynamic_info (version >= 1) */
  18. #define FW_DYNAMIC_INFO_NEXT_ADDR_OFFSET (2 * __SIZEOF_LONG__)
  19. /** Offset of next_mode member in fw_dynamic_info (version >= 1) */
  20. #define FW_DYNAMIC_INFO_NEXT_MODE_OFFSET (3 * __SIZEOF_LONG__)
  21. /** Offset of options member in fw_dynamic_info (version >= 1) */
  22. #define FW_DYNAMIC_INFO_OPTIONS_OFFSET (4 * __SIZEOF_LONG__)
  23. /** Offset of boot_hart member in fw_dynamic_info (version >= 2) */
  24. #define FW_DYNAMIC_INFO_BOOT_HART_OFFSET (5 * __SIZEOF_LONG__)
  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_2 0x2
  29. #define FW_DYNAMIC_INFO_VERSION_MAX FW_DYNAMIC_INFO_VERSION_2
  30. /** Possible next mode values */
  31. #define FW_DYNAMIC_INFO_NEXT_MODE_U 0x0
  32. #define FW_DYNAMIC_INFO_NEXT_MODE_S 0x1
  33. #define FW_DYNAMIC_INFO_NEXT_MODE_M 0x3
  34. /* clang-format on */
  35. #ifndef __ASSEMBLER__
  36. #include <sbi/sbi_types.h>
  37. /** Representation dynamic info passed by previous booting stage */
  38. struct fw_dynamic_info {
  39. /** Info magic */
  40. unsigned long magic;
  41. /** Info version */
  42. unsigned long version;
  43. /** Next booting stage address */
  44. unsigned long next_addr;
  45. /** Next booting stage mode */
  46. unsigned long next_mode;
  47. /** Options for OpenSBI library */
  48. unsigned long options;
  49. /**
  50. * Preferred boot HART id
  51. *
  52. * It is possible that the previous booting stage uses same link
  53. * address as the FW_DYNAMIC firmware. In this case, the relocation
  54. * lottery mechanism can potentially overwrite the previous booting
  55. * stage while other HARTs are still running in the previous booting
  56. * stage leading to boot-time crash. To avoid this boot-time crash,
  57. * the previous booting stage can specify last HART that will jump
  58. * to the FW_DYNAMIC firmware as the preferred boot HART.
  59. *
  60. * To avoid specifying a preferred boot HART, the previous booting
  61. * stage can set it to -1UL which will force the FW_DYNAMIC firmware
  62. * to use the relocation lottery mechanism.
  63. */
  64. unsigned long boot_hart;
  65. } __packed;
  66. #endif
  67. #endif