[1] | 1 | /* |
---|
| 2 | * archinfo.h - Hardware Architecture Information structures |
---|
| 3 | * |
---|
| 4 | * Author Alain Greiner (2016) |
---|
| 5 | * |
---|
| 6 | * Copyright (c) UPMC Sorbonne Universites |
---|
| 7 | * |
---|
| 8 | * This file is part of ALMOS-MKH. |
---|
| 9 | * |
---|
| 10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
| 11 | * under the terms of the GNU General Public License as published by |
---|
| 12 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 13 | * |
---|
| 14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 17 | * General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
| 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #ifndef _ARCHINFO_H_ |
---|
| 25 | #define _ARCHINFO_H_ |
---|
| 26 | |
---|
| 27 | /**************************************************************************************** |
---|
| 28 | * The ARCHINFO data structure describes a generic manycore hardware architecture: |
---|
| 29 | * - The number of cluster is variable (can be one). |
---|
| 30 | * - The cluster topology is variable (2D mesh or vector) |
---|
| 31 | * - The number of cores per cluster is variable (can be zero). |
---|
| 32 | * - The number of addressable component per cluster is variable. |
---|
| 33 | * - The size of the physical memory bank per cluster is variable. |
---|
| 34 | * An adressable device componentcan can be a physical memory bank or a peripheral. |
---|
| 35 | * Each cluster cover a fixed size segment in physical address space. |
---|
| 36 | * |
---|
| 37 | * It is loaded from the block device by the ALMOS-MKH bootloader as a BLOB. |
---|
| 38 | * The ARCHINFO structure has a three levels hierarchical organisation: |
---|
| 39 | * - the architecture contains a variable number of clusters. |
---|
| 40 | * - each cluster contains a variable number of cores and a variable number of devices. |
---|
| 41 | * - some device contains a variable number of input IRQs. |
---|
| 42 | |
---|
| 43 | * The BLOB is organised as the concatenation of a fixed size header, |
---|
| 44 | * and 4 variable size arrays of fixed size objects in the following order: |
---|
| 45 | * 1 : archinfo_core_t core[] |
---|
| 46 | * 2 : archinfo_cluster_t cluster[] |
---|
| 47 | * 3 : archinfo_device_t device[] |
---|
| 48 | * 4 : archinfo_irq_t irq[] |
---|
| 49 | ***************************************************************************************/ |
---|
| 50 | |
---|
[457] | 51 | #include <hal_kernel_types.h> |
---|
[1] | 52 | |
---|
| 53 | #define ARCHINFO_HEADER_SIZE sizeof(archinfo_header_t) |
---|
| 54 | #define ARCHINFO_CLUSTER_SIZE sizeof(archinfo_cluster_t) |
---|
| 55 | #define ARCHINFO_CORE_SIZE sizeof(archinfo_core_t) |
---|
| 56 | #define ARCHINFO_IRQ_SIZE sizeof(archinfo_irq_t) |
---|
| 57 | #define ARCHINFO_DEVICE_SIZE sizeof(archinfo_device_t) |
---|
| 58 | |
---|
| 59 | #define ARCHINFO_SIGNATURE 0xBABE2016 |
---|
| 60 | |
---|
| 61 | /**************************************************************************************** |
---|
| 62 | * This enum defines the supported device types. |
---|
| 63 | * The 16 MSB bits define the functionnal type. |
---|
| 64 | * The 16 LSB bits define the implementation type. |
---|
[571] | 65 | * It must be consistent with values defined in file arch_class.py |
---|
[1] | 66 | ***************************************************************************************/ |
---|
| 67 | |
---|
[571] | 68 | enum device_types_e |
---|
[1] | 69 | { |
---|
[6] | 70 | DEV_TYPE_RAM_SCL = 0x00000000, |
---|
| 71 | DEV_TYPE_ROM_SCL = 0x00010000, |
---|
| 72 | DEV_TYPE_FBF_SCL = 0x00020000, |
---|
| 73 | DEV_TYPE_IOB_TSR = 0x00030000, |
---|
[1] | 74 | DEV_TYPE_IOC_BDV = 0x00040000, |
---|
| 75 | DEV_TYPE_IOC_HBA = 0x00040001, |
---|
| 76 | DEV_TYPE_IOC_SDC = 0x00040002, |
---|
| 77 | DEV_TYPE_IOC_SPI = 0x00040003, |
---|
| 78 | DEV_TYPE_IOC_RDK = 0x00040004, |
---|
[6] | 79 | DEV_TYPE_MMC_TSR = 0x00050000, |
---|
| 80 | DEV_TYPE_DMA_SCL = 0x00060000, |
---|
| 81 | DEV_TYPE_NIC_CBF = 0x00070000, |
---|
| 82 | DEV_TYPE_TIM_SCL = 0x00080000, |
---|
| 83 | DEV_TYPE_TXT_TTY = 0x00090000, |
---|
[571] | 84 | DEV_TYPE_TXT_MTY = 0x00090001, |
---|
[6] | 85 | DEV_TYPE_ICU_XCU = 0x000A0000, |
---|
| 86 | DEV_TYPE_PIC_TSR = 0x000B0000, |
---|
[571] | 87 | }; |
---|
[1] | 88 | |
---|
| 89 | /**************************************************************************************** |
---|
| 90 | * This structure defines the ARCHINFO header. |
---|
| 91 | * WARNING: the size of this structure (128 bytes) is used by the ALMOS-MKH bootloader. |
---|
| 92 | ***************************************************************************************/ |
---|
| 93 | |
---|
| 94 | typedef struct __attribute__((packed)) archinfo_header_s |
---|
| 95 | { |
---|
| 96 | uint32_t signature; // must contain ARCH_INFO_SIGNATURE |
---|
| 97 | uint32_t x_size; // number of clusters in a row |
---|
| 98 | uint32_t y_size; // number of clusters in a column |
---|
| 99 | uint32_t paddr_width; // number of bits for physical address |
---|
| 100 | uint32_t x_width; // number of bits for x coordinate |
---|
| 101 | uint32_t y_width; // number of bits for y coordinate |
---|
| 102 | uint32_t cores_max; // max number of cores per cluster |
---|
| 103 | uint32_t devices_max; // max number of devices per cluster |
---|
| 104 | |
---|
| 105 | uint32_t cores; // total number of cores |
---|
| 106 | uint32_t devices; // total number of devices |
---|
| 107 | uint32_t irqs; // total number of irqs |
---|
| 108 | uint32_t io_cxy; // io_cluster identifier |
---|
| 109 | uint32_t boot_cxy; // boot_cluster identifier |
---|
| 110 | uint32_t irqs_per_core; // number of IRQs per core |
---|
| 111 | uint32_t cache_line_size; // number of bytes |
---|
| 112 | uint32_t reserved; // reserved |
---|
| 113 | |
---|
| 114 | char name[64]; // architecture name |
---|
| 115 | } |
---|
| 116 | archinfo_header_t; |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | /**************************************************************************************** |
---|
| 120 | * This structure defines the ARCHINFO cluster. |
---|
| 121 | ***************************************************************************************/ |
---|
| 122 | |
---|
| 123 | typedef struct __attribute__((packed)) archinfo_cluster_s |
---|
| 124 | { |
---|
| 125 | uint32_t cxy; // cluster identifier |
---|
| 126 | uint32_t cores; // number of cores in cluster |
---|
| 127 | uint32_t core_offset; // global index of first core in cluster |
---|
| 128 | uint32_t devices; // number of devices in cluster |
---|
| 129 | uint32_t device_offset; // global index of first device in cluster |
---|
| 130 | } |
---|
| 131 | archinfo_cluster_t; |
---|
| 132 | |
---|
| 133 | /**************************************************************************************** |
---|
| 134 | * This structure defines the ARCHINFO core descriptor. |
---|
| 135 | * WARNING: the size of this structure (8 bytes) is used by the ALMOS-MKH bootloader. |
---|
| 136 | ***************************************************************************************/ |
---|
| 137 | |
---|
| 138 | typedef struct __attribute__((packed)) archinfo_core_s |
---|
| 139 | { |
---|
| 140 | uint32_t gid; // core hardware identifier |
---|
[6] | 141 | uint16_t cxy; // cluster identifier |
---|
[1] | 142 | uint16_t lid; // core local index in cluster |
---|
| 143 | } |
---|
| 144 | archinfo_core_t; |
---|
| 145 | |
---|
| 146 | /**************************************************************************************** |
---|
| 147 | * This structure defines the ARCHINFO device descriptor. |
---|
| 148 | ***************************************************************************************/ |
---|
| 149 | |
---|
| 150 | typedef struct __attribute__((packed)) archinfo_device_s |
---|
| 151 | { |
---|
[6] | 152 | uint64_t base; // base address in physical space |
---|
| 153 | uint64_t size; // channel size (bytes) |
---|
[1] | 154 | uint32_t type; // supported values defined above |
---|
| 155 | uint32_t channels; // number of channels |
---|
| 156 | uint32_t arg0; // semantic depends on device type |
---|
| 157 | uint32_t arg1; // semantic depends on device type |
---|
| 158 | uint32_t arg2; // semantic depends on device type |
---|
| 159 | uint32_t arg3; // semantic depends on device type |
---|
[6] | 160 | uint32_t irqs; // number of input IRQs (for ICU or PIC) |
---|
[1] | 161 | uint32_t irq_offset; // global index of first IRQ |
---|
| 162 | } |
---|
| 163 | archinfo_device_t; |
---|
| 164 | |
---|
| 165 | /**************************************************************************************** |
---|
| 166 | * This structure defines the ARCHINFO input IRQs for XCU or PIC components. |
---|
| 167 | * It describes the hardware connection from one device output IRQ (identified |
---|
| 168 | * by the source device type, channel, and direction) to a PIC or XCU iput port. |
---|
| 169 | ***************************************************************************************/ |
---|
| 170 | |
---|
| 171 | typedef struct __attribute__((packed)) archinfo_irq_s |
---|
| 172 | { |
---|
| 173 | uint32_t dev_type; // source device type index |
---|
| 174 | uint8_t channel; // source device channel |
---|
| 175 | uint8_t is_rx; // source device direction |
---|
| 176 | uint8_t port; // input IRQ index (in XCU/PIC) |
---|
| 177 | uint8_t reserved; // padding |
---|
| 178 | } |
---|
| 179 | archinfo_irq_t; |
---|
| 180 | |
---|
| 181 | /**************************************************************************** |
---|
| 182 | * These functions allows the boot-loader to get to the starting address * |
---|
| 183 | * of various ARCHINFO tables. * |
---|
| 184 | ****************************************************************************/ |
---|
| 185 | |
---|
| 186 | inline archinfo_core_t* archinfo_get_core_base(archinfo_header_t* header) |
---|
| 187 | { |
---|
| 188 | return (archinfo_core_t*)((char*)header + |
---|
| 189 | ARCHINFO_HEADER_SIZE); |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | inline archinfo_cluster_t* archinfo_get_cluster_base(archinfo_header_t* header) |
---|
| 193 | { |
---|
| 194 | return (archinfo_cluster_t*)((char*)header + |
---|
| 195 | ARCHINFO_HEADER_SIZE + |
---|
| 196 | ARCHINFO_CORE_SIZE * header->cores); |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | inline archinfo_device_t* archinfo_get_device_base(archinfo_header_t* header) |
---|
| 200 | { |
---|
| 201 | return (archinfo_device_t*)((char*)header + |
---|
| 202 | ARCHINFO_HEADER_SIZE + |
---|
| 203 | ARCHINFO_CORE_SIZE * header->cores + |
---|
| 204 | ARCHINFO_CLUSTER_SIZE * header->x_size * |
---|
| 205 | header->y_size); |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | inline archinfo_irq_t* archinfo_get_irq_base(archinfo_header_t* header) |
---|
| 209 | { |
---|
| 210 | return (archinfo_irq_t*)((char*)header + |
---|
| 211 | ARCHINFO_HEADER_SIZE + |
---|
| 212 | ARCHINFO_CORE_SIZE * header->cores + |
---|
| 213 | ARCHINFO_CLUSTER_SIZE * header->x_size * |
---|
| 214 | header->y_size + |
---|
| 215 | ARCHINFO_DEVICE_SIZE * header->devices); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | #endif /* _ARCHINFO_H_ */ |
---|