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