| 1 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 2 | // File     : mapping_info.h | 
|---|
| 3 | // Date     : 01/04/2012 | 
|---|
| 4 | // Author   : alain greiner | 
|---|
| 5 | // Copyright (c) UPMC-LIP6 | 
|---|
| 6 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 7 | // The MAPPING_INFO data structure, used by the GIET_VM kernel contains: | 
|---|
| 8 | // | 
|---|
| 9 | // 1) a description of a clusterized hardware architecture. | 
|---|
| 10 | // The number of cluster is variable (can be one). The number of processors | 
|---|
| 11 | // per cluster is variable (can be one). The number of peripherals per cluser | 
|---|
| 12 | // and coprocessor per cluster is variable. The number of physical memory | 
|---|
| 13 | // banks per cluster is variable. | 
|---|
| 14 | // | 
|---|
| 15 | // 2/ a description of the applications (called vspaces) to be - statically - | 
|---|
| 16 | // launched on the platform. The number of parallel tasks per application is | 
|---|
| 17 | // variable (can be one). Multi-Writer/Multi-Reader communication channels | 
|---|
| 18 | // betwwen tasks are supported. Each vspace contains a variable number | 
|---|
| 19 | // of virtual segments (called vsegs). The number of virtual space can be one. | 
|---|
| 20 | // | 
|---|
| 21 | // 3/ the mapping directives: both tasks on processors, and software objects | 
|---|
| 22 | // (called vsegs) on the physical memory banks (called psegs). | 
|---|
| 23 | // | 
|---|
| 24 | // The mapping_info data structure is organised as the concatenation of | 
|---|
| 25 | // a fixed size header, and 11 variable size arrays: | 
|---|
| 26 | // | 
|---|
| 27 | // - mapping_cluster_t  cluster[] | 
|---|
| 28 | // - mapping_pseg_t     pseg[] | 
|---|
| 29 | // - mapping_vspace_t   vspace[] | 
|---|
| 30 | // - mapping_vseg_t     vseg[] | 
|---|
| 31 | // - mapping_task_t     task[] | 
|---|
| 32 | // - mapping_proc_t     proc[] | 
|---|
| 33 | // - mapping_irq_t      irq[] | 
|---|
| 34 | // - mapping_coproc_t   coproc[] | 
|---|
| 35 | // - mapping_cp_port_t  cp_port[] | 
|---|
| 36 | // - mapping_periph_t   periph[] | 
|---|
| 37 | // | 
|---|
| 38 | // It is intended to be stored in memory in the seg_boot_mapping segment. | 
|---|
| 39 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 40 |  | 
|---|
| 41 | #ifndef _MAPPING_INFO_H_ | 
|---|
| 42 | #define _MAPPING_INFO_H_ | 
|---|
| 43 |  | 
|---|
| 44 | #define MAPPING_HEADER_SIZE   sizeof(mapping_header_t) | 
|---|
| 45 | #define MAPPING_CLUSTER_SIZE  sizeof(mapping_cluster_t) | 
|---|
| 46 | #define MAPPING_VSPACE_SIZE   sizeof(mapping_vspace_t) | 
|---|
| 47 | #define MAPPING_VSEG_SIZE     sizeof(mapping_vseg_t) | 
|---|
| 48 | #define MAPPING_PSEG_SIZE     sizeof(mapping_pseg_t) | 
|---|
| 49 | #define MAPPING_TASK_SIZE     sizeof(mapping_task_t) | 
|---|
| 50 | #define MAPPING_PROC_SIZE     sizeof(mapping_proc_t) | 
|---|
| 51 | #define MAPPING_IRQ_SIZE      sizeof(mapping_irq_t) | 
|---|
| 52 | #define MAPPING_COPROC_SIZE   sizeof(mapping_coproc_t) | 
|---|
| 53 | #define MAPPING_CP_PORT_SIZE  sizeof(mapping_cp_port_t) | 
|---|
| 54 |  | 
|---|
| 55 | #define C_MODE_MASK  0b1000   // cacheable | 
|---|
| 56 | #define X_MODE_MASK  0b0100   // executable | 
|---|
| 57 | #define W_MODE_MASK  0b0010   // writable | 
|---|
| 58 | #define U_MODE_MASK  0b0001   // user access | 
|---|
| 59 |  | 
|---|
| 60 | #define IN_MAPPING_SIGNATURE    0xDACE2014 | 
|---|
| 61 | #define OUT_MAPPING_SIGNATURE   0xBABEF00D | 
|---|
| 62 |  | 
|---|
| 63 | typedef unsigned long long  paddr_t; | 
|---|
| 64 |  | 
|---|
| 65 | enum vsegType | 
|---|
| 66 | { | 
|---|
| 67 | VSEG_TYPE_ELF      = 0,  // loadable code/data object of elf files | 
|---|
| 68 | VSEG_TYPE_BLOB     = 1,  // loadable blob object | 
|---|
| 69 | VSEG_TYPE_PTAB     = 2,  // page table | 
|---|
| 70 | VSEG_TYPE_PERI     = 3,  // hardware component | 
|---|
| 71 | VSEG_TYPE_MWMR     = 4,  // MWMR channel | 
|---|
| 72 | VSEG_TYPE_LOCK     = 5,  // Lock | 
|---|
| 73 | VSEG_TYPE_BUFFER   = 6,  // Any "no initialization" objects (stacks...) | 
|---|
| 74 | VSEG_TYPE_BARRIER  = 7,  // Barrier | 
|---|
| 75 | VSEG_TYPE_CONST    = 8,  // Constant | 
|---|
| 76 | VSEG_TYPE_MEMSPACE = 9,  // Memspace (descriptor must be initialised) | 
|---|
| 77 | VSEG_TYPE_SCHED    = 10, // Array of schedulers (one per cluster) | 
|---|
| 78 | VSEG_TYPE_HEAP     = 11, // Heap   f schedulers (one per cluster) | 
|---|
| 79 | }; | 
|---|
| 80 |  | 
|---|
| 81 | enum irqType | 
|---|
| 82 | { | 
|---|
| 83 | IRQ_TYPE_HWI = 0,        // HARD in map.xml file | 
|---|
| 84 | IRQ_TYPE_WTI = 1,        // SOFT in map.xml file, | 
|---|
| 85 | IRQ_TYPE_PTI = 2,        // TIME in map.xml file, | 
|---|
| 86 | }; | 
|---|
| 87 |  | 
|---|
| 88 | enum psegType | 
|---|
| 89 | { | 
|---|
| 90 | PSEG_TYPE_RAM  = 0, | 
|---|
| 91 | PSEG_TYPE_ROM  = 1,      // deprecated => you should use PSEG_TYPE_PERI | 
|---|
| 92 | PSEG_TYPE_PERI = 2, | 
|---|
| 93 | }; | 
|---|
| 94 |  | 
|---|
| 95 | // The enum definitions for psegType and periphType must be kept | 
|---|
| 96 | // consistent with the definitions in the xml_driver.c file... | 
|---|
| 97 |  | 
|---|
| 98 | enum periphType | 
|---|
| 99 | { | 
|---|
| 100 | PERIPH_TYPE_CMA       = 0, | 
|---|
| 101 | PERIPH_TYPE_DMA       = 1, | 
|---|
| 102 | PERIPH_TYPE_FBF       = 2, | 
|---|
| 103 | PERIPH_TYPE_IOB       = 3, | 
|---|
| 104 | PERIPH_TYPE_IOC       = 4, | 
|---|
| 105 | PERIPH_TYPE_MMC       = 5, | 
|---|
| 106 | PERIPH_TYPE_MWR       = 6, | 
|---|
| 107 | PERIPH_TYPE_NIC       = 7, | 
|---|
| 108 | PERIPH_TYPE_ROM       = 8, | 
|---|
| 109 | PERIPH_TYPE_SIM       = 9, | 
|---|
| 110 | PERIPH_TYPE_TIM       = 10, | 
|---|
| 111 | PERIPH_TYPE_TTY       = 11, | 
|---|
| 112 | PERIPH_TYPE_XCU       = 12, | 
|---|
| 113 | PERIPH_TYPE_PIC       = 13, | 
|---|
| 114 | PERIPH_TYPE_DROM      = 14, | 
|---|
| 115 |  | 
|---|
| 116 | PERIPH_TYPE_MAX_VALUE = 15, | 
|---|
| 117 | }; | 
|---|
| 118 |  | 
|---|
| 119 | enum periphSubtype | 
|---|
| 120 | { | 
|---|
| 121 | PERIPH_SUBTYPE_BDV       = 0, | 
|---|
| 122 | PERIPH_SUBTYPE_HBA       = 1, | 
|---|
| 123 | PERIPH_SUBTYPE_SPI       = 2, | 
|---|
| 124 | PERIPH_SUBTYPE_NONE      = 3, | 
|---|
| 125 | }; | 
|---|
| 126 |  | 
|---|
| 127 | enum mwmrPortDirection | 
|---|
| 128 | { | 
|---|
| 129 | PORT_TO_COPROC   = 0, // status register | 
|---|
| 130 | PORT_FROM_COPROC = 1, // config register | 
|---|
| 131 | }; | 
|---|
| 132 |  | 
|---|
| 133 |  | 
|---|
| 134 | //////////////////////////////////////////////////////// | 
|---|
| 135 | typedef struct __attribute__((packed))  mapping_header_s | 
|---|
| 136 | { | 
|---|
| 137 | unsigned int signature;          // must contain IN_MAPPING_SIGNATURE | 
|---|
| 138 | unsigned int x_size;             // actual number of clusters in a row | 
|---|
| 139 | unsigned int y_size;             // actual number of clusters in a column | 
|---|
| 140 | unsigned int x_width;            // number of bits to encode x coordinate | 
|---|
| 141 | unsigned int y_width;            // number of bits to encode y coordinate | 
|---|
| 142 | unsigned int x_io;               // x coordinate for cluster_io_ext | 
|---|
| 143 | unsigned int y_io;               // y coordinate for cluster_io_ext | 
|---|
| 144 | unsigned int irq_per_proc;       // number of IRQ per processor | 
|---|
| 145 | unsigned int use_ram_disk;       // does not use IOC peripheral if non zero | 
|---|
| 146 | unsigned int globals;            // total number of global vsegs | 
|---|
| 147 | unsigned int vspaces;            // total number of virtual spaces | 
|---|
| 148 | unsigned int psegs;              // total number of physical segments | 
|---|
| 149 | unsigned int vsegs;              // total number of virtual segments | 
|---|
| 150 | unsigned int tasks;              // total number of tasks | 
|---|
| 151 | unsigned int procs;              // total number of procs | 
|---|
| 152 | unsigned int irqs;               // total number of irqs | 
|---|
| 153 | unsigned int coprocs;            // total number of coprocs | 
|---|
| 154 | unsigned int cp_ports;           // total number of cp_ports | 
|---|
| 155 | unsigned int periphs;            // total number of peripherals | 
|---|
| 156 | char name[32];                   // mapping name | 
|---|
| 157 | } mapping_header_t; | 
|---|
| 158 |  | 
|---|
| 159 |  | 
|---|
| 160 | ///////////////////////////////////////////////////////// | 
|---|
| 161 | typedef struct __attribute__((packed))  mapping_cluster_s | 
|---|
| 162 | { | 
|---|
| 163 | unsigned int    x;               // x coordinate | 
|---|
| 164 | unsigned int    y;               // y coordinate | 
|---|
| 165 |  | 
|---|
| 166 | unsigned int    psegs;           // number of psegs in cluster | 
|---|
| 167 | unsigned int    pseg_offset;     // global index of first pseg in psegs | 
|---|
| 168 |  | 
|---|
| 169 | unsigned int    procs;           // number of processors in cluster | 
|---|
| 170 | unsigned int    proc_offset;     // global index of first proc in procs | 
|---|
| 171 |  | 
|---|
| 172 | unsigned int    coprocs;         // number of coprocessors in cluster | 
|---|
| 173 | unsigned int    coproc_offset;   // global index of first coproc in coprocs | 
|---|
| 174 |  | 
|---|
| 175 | unsigned int    periphs;         // number of peripherals in cluster | 
|---|
| 176 | unsigned int    periph_offset;   // global index of first coproc in periphs | 
|---|
| 177 | } mapping_cluster_t; | 
|---|
| 178 |  | 
|---|
| 179 |  | 
|---|
| 180 | //////////////////////////////////////////////////////// | 
|---|
| 181 | typedef struct __attribute__((packed))  mapping_vspace_s | 
|---|
| 182 | { | 
|---|
| 183 | char            name[32];        // virtual space name | 
|---|
| 184 | unsigned int    start_vseg_id;   // vseg containing start vector index | 
|---|
| 185 | unsigned int    vsegs;           // number of vsegs in vspace | 
|---|
| 186 | unsigned int    tasks;           // number of tasks in vspace | 
|---|
| 187 | unsigned int    vseg_offset;     // global index of first vseg in vspace | 
|---|
| 188 | unsigned int    task_offset;     // global index of first task in vspace | 
|---|
| 189 | } mapping_vspace_t; | 
|---|
| 190 |  | 
|---|
| 191 |  | 
|---|
| 192 | ////////////////////////////////////////////////////// | 
|---|
| 193 | typedef struct __attribute__((packed))  mapping_vseg_s | 
|---|
| 194 | { | 
|---|
| 195 | char            name[32];        // vseg name (unique in vspace) | 
|---|
| 196 | char            binpath[64];     // path for the binary code (if required) | 
|---|
| 197 | unsigned int    vbase;           // base address in virtual space | 
|---|
| 198 | paddr_t         pbase;           // base address in physical space | 
|---|
| 199 | unsigned int    length;          // size (bytes) | 
|---|
| 200 | unsigned int    psegid;          // physical segment global index | 
|---|
| 201 | unsigned int    mode;            // C-X-W-U flags | 
|---|
| 202 | unsigned int    type;            // vseg type | 
|---|
| 203 | char            mapped;          // mapped if non zero | 
|---|
| 204 | char            ident;           // identity mapping if non zero | 
|---|
| 205 | char            local;           // only mapped in the local PTAB | 
|---|
| 206 | char            big;             // to be mapped in a big physical page | 
|---|
| 207 | } mapping_vseg_t; | 
|---|
| 208 |  | 
|---|
| 209 |  | 
|---|
| 210 | ////////////////////////////////////////////////////// | 
|---|
| 211 | typedef struct __attribute__((packed))  mapping_pseg_s | 
|---|
| 212 | { | 
|---|
| 213 | char            name[32];        // pseg name (unique in a cluster) | 
|---|
| 214 | paddr_t         base;            // base address in physical space | 
|---|
| 215 | paddr_t         length;          // size (bytes) | 
|---|
| 216 | unsigned int    type;            // RAM / PERI | 
|---|
| 217 | unsigned int    clusterid;       // global index in clusters set | 
|---|
| 218 | unsigned int    next_vseg;       // linked list of vsegs mapped on pseg | 
|---|
| 219 | } mapping_pseg_t; | 
|---|
| 220 |  | 
|---|
| 221 |  | 
|---|
| 222 | ////////////////////////////////////////////////////// | 
|---|
| 223 | typedef struct __attribute__((packed))  mapping_task_s | 
|---|
| 224 | { | 
|---|
| 225 | char            name[32];        // task name (unique in vspace) | 
|---|
| 226 | unsigned int    clusterid;       // global index in clusters set | 
|---|
| 227 | unsigned int    proclocid;       // processor local index (inside cluster) | 
|---|
| 228 | unsigned int    trdid;           // thread index in vspace | 
|---|
| 229 | unsigned int    stack_vseg_id;   // global index for vseg containing stack | 
|---|
| 230 | unsigned int    heap_vseg_id;    // global index for vseg containing heap | 
|---|
| 231 | unsigned int    startid;         // index in start_vector | 
|---|
| 232 | } mapping_task_t; | 
|---|
| 233 |  | 
|---|
| 234 |  | 
|---|
| 235 | ////////////////////////////////////////////////////// | 
|---|
| 236 | typedef struct __attribute__((packed))  mapping_proc_s | 
|---|
| 237 | { | 
|---|
| 238 | unsigned int    index;           // processor local index (in cluster) | 
|---|
| 239 | } mapping_proc_t; | 
|---|
| 240 |  | 
|---|
| 241 |  | 
|---|
| 242 | //////////////////////////////////////////////////////// | 
|---|
| 243 | typedef struct __attribute__((packed))  mapping_coproc_s | 
|---|
| 244 | { | 
|---|
| 245 | char            name[32];        // coprocessor name (probablement inutile AG) | 
|---|
| 246 | unsigned int    psegid;          // global pseg index | 
|---|
| 247 | unsigned int    ports;           // number of MWMR ports used by coprocessor | 
|---|
| 248 | unsigned int    port_offset;     // global index of first MWMR port | 
|---|
| 249 | } mapping_coproc_t; | 
|---|
| 250 |  | 
|---|
| 251 |  | 
|---|
| 252 | ///////////////////////////////////////////////////////// | 
|---|
| 253 | typedef struct __attribute__((packed))  mapping_cp_port_s | 
|---|
| 254 | { | 
|---|
| 255 | unsigned int    direction;       // TO_COPROC == 0 / FROM_COPROC == 1 | 
|---|
| 256 | unsigned int    vspaceid;        // index of the vspace containing MWMR channel | 
|---|
| 257 | unsigned int    mwmr_vseg_id;    // global index of vseg containing MWMR channel | 
|---|
| 258 | } mapping_cp_port_t; | 
|---|
| 259 |  | 
|---|
| 260 |  | 
|---|
| 261 | //////////////////////////////////////////////////////// | 
|---|
| 262 | typedef struct __attribute__((packed))  mapping_periph_s | 
|---|
| 263 | { | 
|---|
| 264 | unsigned int    type;            // legal values defined above | 
|---|
| 265 | unsigned int    subtype;         // periph specialization | 
|---|
| 266 | unsigned int    psegid;          // pseg index in cluster | 
|---|
| 267 | unsigned int    channels;        // number of channels | 
|---|
| 268 | unsigned int    arg;             // argument depending on peripheral type | 
|---|
| 269 | unsigned int    irqs;            // number of input IRQs (for XCU or PIC) | 
|---|
| 270 | unsigned int    irq_offset;      // index of first IRQ | 
|---|
| 271 | } mapping_periph_t; | 
|---|
| 272 |  | 
|---|
| 273 |  | 
|---|
| 274 | ///////////////////////////////////////////////////// | 
|---|
| 275 | typedef struct __attribute__((packed))  mapping_irq_s | 
|---|
| 276 | { | 
|---|
| 277 | unsigned int    srctype;         // source IRQ type (HWI / WTI / PTI) | 
|---|
| 278 | unsigned int    srcid;           // source IRQ index (for XCU/PIC component) | 
|---|
| 279 | unsigned int    isr;             // ISR type (defined in irq_handler.h) | 
|---|
| 280 | unsigned int    channel;         // channel index (for multi-channels ISR) | 
|---|
| 281 | unsigned int    dest_xy;         // destination cluster (set by GIET_VM) | 
|---|
| 282 | unsigned int    dest_id;         // destination port (set by GIET_VM) | 
|---|
| 283 | } mapping_irq_t; | 
|---|
| 284 |  | 
|---|
| 285 |  | 
|---|
| 286 | #endif | 
|---|
| 287 |  | 
|---|
| 288 | // Local Variables: | 
|---|
| 289 | // tab-width: 4 | 
|---|
| 290 | // c-basic-offset: 4 | 
|---|
| 291 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) | 
|---|
| 292 | // indent-tabs-mode: nil | 
|---|
| 293 | // End: | 
|---|
| 294 |  | 
|---|
| 295 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 | 
|---|
| 296 |  | 
|---|