sds.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef SDS_H
  7. #define SDS_H
  8. /* SDS Structure Identifier defines */
  9. /* AP CPU INFO defines */
  10. #define SDS_AP_CPU_INFO_STRUCT_ID 1
  11. #define SDS_AP_CPU_INFO_PRIMARY_CPUID_OFFSET 0x0
  12. #define SDS_AP_CPU_INFO_PRIMARY_CPUID_SIZE 0x4
  13. /* ROM Firmware Version defines */
  14. #define SDS_ROM_VERSION_STRUCT_ID 2
  15. #define SDS_ROM_VERSION_OFFSET 0x0
  16. #define SDS_ROM_VERSION_SIZE 0x4
  17. /* RAM Firmware version defines */
  18. #define SDS_RAM_VERSION_STRUCT_ID 3
  19. #define SDS_RAM_VERSION_OFFSET 0x0
  20. #define SDS_RAM_VERSION_SIZE 0x4
  21. /* Platform Identity defines */
  22. #define SDS_PLATFORM_IDENTITY_STRUCT_ID 4
  23. #define SDS_PLATFORM_IDENTITY_ID_OFFSET 0x0
  24. #define SDS_PLATFORM_IDENTITY_ID_SIZE 0x4
  25. #define SDS_PLATFORM_IDENTITY_ID_CONFIG_SHIFT 28
  26. #define SDS_PLATFORM_IDENTITY_ID_CONFIG_WIDTH 4
  27. #define SDS_PLATFORM_IDENTITY_ID_CONFIG_MASK \
  28. ((1 << SDS_PLATFORM_IDENTITY_ID_CONFIG_WIDTH) - 1)
  29. #define SDS_PLATFORM_IDENTITY_PLAT_TYPE_OFFSET 0x4
  30. #define SDS_PLATFORM_IDENTITY_PLAT_TYPE_SIZE 0x4
  31. /* Reset Syndrome defines */
  32. #define SDS_RESET_SYNDROME_STRUCT_ID 5
  33. #define SDS_RESET_SYNDROME_OFFSET 0
  34. #define SDS_RESET_SYNDROME_SIZE 4
  35. #define SDS_RESET_SYNDROME_POW_ON_RESET_BIT (1 << 0)
  36. #define SDS_RESET_SYNDROME_SCP_WD_RESET_BIT (1 << 1)
  37. #define SDS_RESET_SYNDROME_AP_WD_RESET_BIT (1 << 2)
  38. #define SDS_RESET_SYNDROME_SYS_RESET_REQ_BIT (1 << 3)
  39. #define SDS_RESET_SYNDROME_M3_LOCKUP_BIT (1 << 4)
  40. /* SCP Firmware Feature Availability defines */
  41. #define SDS_FEATURE_AVAIL_STRUCT_ID 6
  42. #define SDS_FEATURE_AVAIL_OFFSET 0
  43. #define SDS_FEATURE_AVAIL_SIZE 4
  44. #define SDS_FEATURE_AVAIL_SCP_RAM_READY_BIT (1 << 0)
  45. #define SDS_FEATURE_AVAIL_DMC_READY_BIT (1 << 1)
  46. #define SDS_FEATURE_AVAIL_MSG_IF_READY_BIT (1 << 2)
  47. /* SCP BL2 Image Metadata defines */
  48. #define SDS_SCP_IMG_STRUCT_ID 9
  49. #define SDS_SCP_IMG_FLAG_OFFSET 0
  50. #define SDS_SCP_IMG_FLAG_SIZE 4
  51. #define SDS_SCP_IMG_VALID_FLAG_BIT (1 << 0)
  52. #define SDS_SCP_IMG_ADDR_OFFSET 4
  53. #define SDS_SCP_IMG_ADDR_SIZE 4
  54. #define SDS_SCP_IMG_SIZE_OFFSET 8
  55. #define SDS_SCP_IMG_SIZE_SIZE 4
  56. /* SDS Driver Error Codes */
  57. #define SDS_OK 0
  58. #define SDS_ERR_FAIL -1
  59. #define SDS_ERR_INVALID_PARAMS -2
  60. #define SDS_ERR_STRUCT_NOT_FOUND -3
  61. #define SDS_ERR_STRUCT_NOT_FINALIZED -4
  62. #ifndef __ASSEMBLER__
  63. #include <stddef.h>
  64. #include <stdint.h>
  65. typedef enum {
  66. SDS_ACCESS_MODE_NON_CACHED,
  67. SDS_ACCESS_MODE_CACHED,
  68. } sds_access_mode_t;
  69. /*
  70. * The following structure describes a SDS memory region. Its items are used
  71. * to track and maintain the state of the memory region reserved for usage
  72. * by the SDS framework.
  73. *
  74. * The base address of the SDS memory region is platform specific. The
  75. * SDS description structure must already contain the address when it is
  76. * returned by the plat_sds_get_regions() platform API during SDS region
  77. * initialization.
  78. * The size of the SDS memory region is dynamically discovered during the
  79. * initialization of the region and written into the 'size' item of the
  80. * SDS description structure.
  81. */
  82. typedef struct {
  83. uintptr_t base; /* Pointer to the base of the SDS memory region */
  84. size_t size; /* Size of the SDS memory region in bytes */
  85. } sds_region_desc_t;
  86. /* API to get the platform specific SDS region description(s) */
  87. sds_region_desc_t *plat_sds_get_regions(unsigned int *region_count);
  88. int sds_init(unsigned int region_id);
  89. int sds_struct_exists(unsigned int region_id, unsigned int structure_id);
  90. int sds_struct_read(unsigned int region_id, uint32_t structure_id,
  91. unsigned int fld_off, void *data, size_t size, sds_access_mode_t mode);
  92. int sds_struct_write(unsigned int region_id, uint32_t structure_id,
  93. unsigned int fld_off, void *data, size_t size, sds_access_mode_t mode);
  94. #endif /*__ASSEMBLER__ */
  95. #endif /* SDS_H */