sdb.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * This is the official version 1.1 of sdb.h
  3. */
  4. #ifndef __SDB_H__
  5. #define __SDB_H__
  6. #ifdef __KERNEL__
  7. #include <linux/types.h>
  8. #else
  9. #include <stdint.h>
  10. #endif
  11. /*
  12. * All structures are 64 bytes long and are expected
  13. * to live in an array, one for each interconnect.
  14. * Most fields of the structures are shared among the
  15. * various types, and most-specific fields are at the
  16. * beginning (for alignment reasons, and to keep the
  17. * magic number at the head of the interconnect record
  18. */
  19. /* Product, 40 bytes at offset 24, 8-byte aligned
  20. *
  21. * device_id is vendor-assigned; version is device-specific,
  22. * date is hex (e.g 0x20120501), name is UTF-8, blank-filled
  23. * and not terminated with a 0 byte.
  24. */
  25. struct sdb_product {
  26. uint64_t vendor_id; /* 0x18..0x1f */
  27. uint32_t device_id; /* 0x20..0x23 */
  28. uint32_t version; /* 0x24..0x27 */
  29. uint32_t date; /* 0x28..0x2b */
  30. uint8_t name[19]; /* 0x2c..0x3e */
  31. uint8_t record_type; /* 0x3f */
  32. };
  33. /*
  34. * Component, 56 bytes at offset 8, 8-byte aligned
  35. *
  36. * The address range is first to last, inclusive
  37. * (for example 0x100000 - 0x10ffff)
  38. */
  39. struct sdb_component {
  40. uint64_t addr_first; /* 0x08..0x0f */
  41. uint64_t addr_last; /* 0x10..0x17 */
  42. struct sdb_product product; /* 0x18..0x3f */
  43. };
  44. /* Type of the SDB record */
  45. enum sdb_record_type {
  46. sdb_type_interconnect = 0x00,
  47. sdb_type_device = 0x01,
  48. sdb_type_bridge = 0x02,
  49. sdb_type_integration = 0x80,
  50. sdb_type_repo_url = 0x81,
  51. sdb_type_synthesis = 0x82,
  52. sdb_type_empty = 0xFF,
  53. };
  54. /* Type 0: interconnect (first of the array)
  55. *
  56. * sdb_records is the length of the table including this first
  57. * record, version is 1. The bus type is enumerated later.
  58. */
  59. #define SDB_MAGIC 0x5344422d /* "SDB-" */
  60. struct sdb_interconnect {
  61. uint32_t sdb_magic; /* 0x00-0x03 */
  62. uint16_t sdb_records; /* 0x04-0x05 */
  63. uint8_t sdb_version; /* 0x06 */
  64. uint8_t sdb_bus_type; /* 0x07 */
  65. struct sdb_component sdb_component; /* 0x08-0x3f */
  66. };
  67. /* Type 1: device
  68. *
  69. * class is 0 for "custom device", other values are
  70. * to be standardized; ABI version is for the driver,
  71. * bus-specific bits are defined by each bus (see below)
  72. */
  73. struct sdb_device {
  74. uint16_t abi_class; /* 0x00-0x01 */
  75. uint8_t abi_ver_major; /* 0x02 */
  76. uint8_t abi_ver_minor; /* 0x03 */
  77. uint32_t bus_specific; /* 0x04-0x07 */
  78. struct sdb_component sdb_component; /* 0x08-0x3f */
  79. };
  80. /* Type 2: bridge
  81. *
  82. * child is the address of the nested SDB table
  83. */
  84. struct sdb_bridge {
  85. uint64_t sdb_child; /* 0x00-0x07 */
  86. struct sdb_component sdb_component; /* 0x08-0x3f */
  87. };
  88. /* Type 0x80: integration
  89. *
  90. * all types with bit 7 set are meta-information, so
  91. * software can ignore the types it doesn't know. Here we
  92. * just provide product information for an aggregate device
  93. */
  94. struct sdb_integration {
  95. uint8_t reserved[24]; /* 0x00-0x17 */
  96. struct sdb_product product; /* 0x08-0x3f */
  97. };
  98. /* Type 0x81: Top module repository url
  99. *
  100. * again, an informative field that software can ignore
  101. */
  102. struct sdb_repo_url {
  103. uint8_t repo_url[63]; /* 0x00-0x3e */
  104. uint8_t record_type; /* 0x3f */
  105. };
  106. /* Type 0x82: Synthesis tool information
  107. *
  108. * this informative record
  109. */
  110. struct sdb_synthesis {
  111. uint8_t syn_name[16]; /* 0x00-0x0f */
  112. uint8_t commit_id[16]; /* 0x10-0x1f */
  113. uint8_t tool_name[8]; /* 0x20-0x27 */
  114. uint32_t tool_version; /* 0x28-0x2b */
  115. uint32_t date; /* 0x2c-0x2f */
  116. uint8_t user_name[15]; /* 0x30-0x3e */
  117. uint8_t record_type; /* 0x3f */
  118. };
  119. /* Type 0xff: empty
  120. *
  121. * this allows keeping empty slots during development,
  122. * so they can be filled later with minimal efforts and
  123. * no misleading description is ever shipped -- hopefully.
  124. * It can also be used to pad a table to a desired length.
  125. */
  126. struct sdb_empty {
  127. uint8_t reserved[63]; /* 0x00-0x3e */
  128. uint8_t record_type; /* 0x3f */
  129. };
  130. /* The type of bus, for bus-specific flags */
  131. enum sdb_bus_type {
  132. sdb_wishbone = 0x00,
  133. sdb_data = 0x01,
  134. };
  135. #define SDB_WB_WIDTH_MASK 0x0f
  136. #define SDB_WB_ACCESS8 0x01
  137. #define SDB_WB_ACCESS16 0x02
  138. #define SDB_WB_ACCESS32 0x04
  139. #define SDB_WB_ACCESS64 0x08
  140. #define SDB_WB_LITTLE_ENDIAN 0x80
  141. #define SDB_DATA_READ 0x04
  142. #define SDB_DATA_WRITE 0x02
  143. #define SDB_DATA_EXEC 0x01
  144. #endif /* __SDB_H__ */