opensbi.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: BSD-2-Clause */
  2. /*
  3. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  4. *
  5. * Based on include/sbi/{fw_dynamic.h,sbi_scratch.h} from the OpenSBI project.
  6. */
  7. #ifndef OPENSBI_H
  8. #define OPENSBI_H
  9. /** Expected value of info magic ('OSBI' ascii string in hex) */
  10. #define FW_DYNAMIC_INFO_MAGIC_VALUE 0x4942534f
  11. /** Maximum supported info version */
  12. #define FW_DYNAMIC_INFO_VERSION 0x2
  13. /** Possible next mode values */
  14. #define FW_DYNAMIC_INFO_NEXT_MODE_U 0x0
  15. #define FW_DYNAMIC_INFO_NEXT_MODE_S 0x1
  16. #define FW_DYNAMIC_INFO_NEXT_MODE_M 0x3
  17. enum sbi_scratch_options {
  18. /** Disable prints during boot */
  19. SBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),
  20. };
  21. /** Representation dynamic info passed by previous booting stage */
  22. struct fw_dynamic_info {
  23. /** Info magic */
  24. unsigned long magic;
  25. /** Info version */
  26. unsigned long version;
  27. /** Next booting stage address */
  28. unsigned long next_addr;
  29. /** Next booting stage mode */
  30. unsigned long next_mode;
  31. /** Options for OpenSBI library */
  32. unsigned long options;
  33. /**
  34. * Preferred boot HART id
  35. *
  36. * It is possible that the previous booting stage uses same link
  37. * address as the FW_DYNAMIC firmware. In this case, the relocation
  38. * lottery mechanism can potentially overwrite the previous booting
  39. * stage while other HARTs are still running in the previous booting
  40. * stage leading to boot-time crash. To avoid this boot-time crash,
  41. * the previous booting stage can specify last HART that will jump
  42. * to the FW_DYNAMIC firmware as the preferred boot HART.
  43. *
  44. * To avoid specifying a preferred boot HART, the previous booting
  45. * stage can set it to -1UL which will force the FW_DYNAMIC firmware
  46. * to use the relocation lottery mechanism.
  47. */
  48. unsigned long boot_hart;
  49. } __packed;
  50. #endif