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 | |
---|
51 | #include <hal_types.h> |
---|
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. |
---|
65 | * It must be consistent with values defined in files arch_class.py, and device.* |
---|
66 | ***************************************************************************************/ |
---|
67 | |
---|
68 | enum deviceTypes |
---|
69 | { |
---|
70 | DEV_TYPE_RAM_SCL = 0x00000000, |
---|
71 | DEV_TYPE_ROM_SCL = 0x00010000, |
---|
72 | DEV_TYPE_FBF_SCL = 0x00020000, |
---|
73 | DEV_TYPE_IOB_TSR = 0x00030000, |
---|
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, |
---|
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, |
---|
84 | DEV_TYPE_ICU_XCU = 0x000A0000, |
---|
85 | DEV_TYPE_PIC_TSR = 0x000B0000, |
---|
86 | }; |
---|
87 | |
---|
88 | /**************************************************************************************** |
---|
89 | * This structure defines the ARCHINFO header. |
---|
90 | * WARNING: the size of this structure (128 bytes) is used by the ALMOS-MKH bootloader. |
---|
91 | ***************************************************************************************/ |
---|
92 | |
---|
93 | typedef struct __attribute__((packed)) archinfo_header_s |
---|
94 | { |
---|
95 | uint32_t signature; // must contain ARCH_INFO_SIGNATURE |
---|
96 | uint32_t x_size; // number of clusters in a row |
---|
97 | uint32_t y_size; // number of clusters in a column |
---|
98 | uint32_t paddr_width; // number of bits for physical address |
---|
99 | uint32_t x_width; // number of bits for x coordinate |
---|
100 | uint32_t y_width; // number of bits for y coordinate |
---|
101 | uint32_t cores_max; // max number of cores per cluster |
---|
102 | uint32_t devices_max; // max number of devices per cluster |
---|
103 | |
---|
104 | uint32_t cores; // total number of cores |
---|
105 | uint32_t devices; // total number of devices |
---|
106 | uint32_t irqs; // total number of irqs |
---|
107 | uint32_t io_cxy; // io_cluster identifier |
---|
108 | uint32_t boot_cxy; // boot_cluster identifier |
---|
109 | uint32_t irqs_per_core; // number of IRQs per core |
---|
110 | uint32_t cache_line_size; // number of bytes |
---|
111 | uint32_t reserved; // reserved |
---|
112 | |
---|
113 | char name[64]; // architecture name |
---|
114 | } |
---|
115 | archinfo_header_t; |
---|
116 | |
---|
117 | |
---|
118 | /**************************************************************************************** |
---|
119 | * This structure defines the ARCHINFO cluster. |
---|
120 | ***************************************************************************************/ |
---|
121 | |
---|
122 | typedef struct __attribute__((packed)) archinfo_cluster_s |
---|
123 | { |
---|
124 | uint32_t cxy; // cluster identifier |
---|
125 | uint32_t cores; // number of cores in cluster |
---|
126 | uint32_t core_offset; // global index of first core in cluster |
---|
127 | uint32_t devices; // number of devices in cluster |
---|
128 | uint32_t device_offset; // global index of first device in cluster |
---|
129 | } |
---|
130 | archinfo_cluster_t; |
---|
131 | |
---|
132 | /**************************************************************************************** |
---|
133 | * This structure defines the ARCHINFO core descriptor. |
---|
134 | * WARNING: the size of this structure (8 bytes) is used by the ALMOS-MKH bootloader. |
---|
135 | ***************************************************************************************/ |
---|
136 | |
---|
137 | typedef struct __attribute__((packed)) archinfo_core_s |
---|
138 | { |
---|
139 | uint32_t gid; // core hardware identifier |
---|
140 | uint16_t cxy; // cluster identifier |
---|
141 | uint16_t lid; // core local index in cluster |
---|
142 | } |
---|
143 | archinfo_core_t; |
---|
144 | |
---|
145 | /**************************************************************************************** |
---|
146 | * This structure defines the ARCHINFO device descriptor. |
---|
147 | ***************************************************************************************/ |
---|
148 | |
---|
149 | typedef struct __attribute__((packed)) archinfo_device_s |
---|
150 | { |
---|
151 | uint64_t base; // base address in physical space |
---|
152 | uint64_t size; // channel size (bytes) |
---|
153 | uint32_t type; // supported values defined above |
---|
154 | uint32_t channels; // number of channels |
---|
155 | uint32_t arg0; // semantic depends on device type |
---|
156 | uint32_t arg1; // semantic depends on device type |
---|
157 | uint32_t arg2; // semantic depends on device type |
---|
158 | uint32_t arg3; // semantic depends on device type |
---|
159 | uint32_t irqs; // number of input IRQs (for ICU or PIC) |
---|
160 | uint32_t irq_offset; // global index of first IRQ |
---|
161 | } |
---|
162 | archinfo_device_t; |
---|
163 | |
---|
164 | /**************************************************************************************** |
---|
165 | * This structure defines the ARCHINFO input IRQs for XCU or PIC components. |
---|
166 | * It describes the hardware connection from one device output IRQ (identified |
---|
167 | * by the source device type, channel, and direction) to a PIC or XCU iput port. |
---|
168 | ***************************************************************************************/ |
---|
169 | |
---|
170 | typedef struct __attribute__((packed)) archinfo_irq_s |
---|
171 | { |
---|
172 | uint32_t dev_type; // source device type index |
---|
173 | uint8_t channel; // source device channel |
---|
174 | uint8_t is_rx; // source device direction |
---|
175 | uint8_t port; // input IRQ index (in XCU/PIC) |
---|
176 | uint8_t reserved; // padding |
---|
177 | } |
---|
178 | archinfo_irq_t; |
---|
179 | |
---|
180 | /**************************************************************************** |
---|
181 | * These functions allows the boot-loader to get to the starting address * |
---|
182 | * of various ARCHINFO tables. * |
---|
183 | ****************************************************************************/ |
---|
184 | |
---|
185 | inline archinfo_core_t* archinfo_get_core_base(archinfo_header_t* header) |
---|
186 | { |
---|
187 | return (archinfo_core_t*)((char*)header + |
---|
188 | ARCHINFO_HEADER_SIZE); |
---|
189 | } |
---|
190 | |
---|
191 | inline archinfo_cluster_t* archinfo_get_cluster_base(archinfo_header_t* header) |
---|
192 | { |
---|
193 | return (archinfo_cluster_t*)((char*)header + |
---|
194 | ARCHINFO_HEADER_SIZE + |
---|
195 | ARCHINFO_CORE_SIZE * header->cores); |
---|
196 | } |
---|
197 | |
---|
198 | inline archinfo_device_t* archinfo_get_device_base(archinfo_header_t* header) |
---|
199 | { |
---|
200 | return (archinfo_device_t*)((char*)header + |
---|
201 | ARCHINFO_HEADER_SIZE + |
---|
202 | ARCHINFO_CORE_SIZE * header->cores + |
---|
203 | ARCHINFO_CLUSTER_SIZE * header->x_size * |
---|
204 | header->y_size); |
---|
205 | } |
---|
206 | |
---|
207 | inline archinfo_irq_t* archinfo_get_irq_base(archinfo_header_t* header) |
---|
208 | { |
---|
209 | return (archinfo_irq_t*)((char*)header + |
---|
210 | ARCHINFO_HEADER_SIZE + |
---|
211 | ARCHINFO_CORE_SIZE * header->cores + |
---|
212 | ARCHINFO_CLUSTER_SIZE * header->x_size * |
---|
213 | header->y_size + |
---|
214 | ARCHINFO_DEVICE_SIZE * header->devices); |
---|
215 | } |
---|
216 | |
---|
217 | #endif /* _ARCHINFO_H_ */ |
---|