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