source: trunk/tools/arch_info/arch_info.h @ 534

Last change on this file since 534 was 534, checked in by nicolas.van.phan@…, 3 years ago

Add mtty driver.

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