| 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). | 
|---|
| 20 | // | 
|---|
| 21 | // 3/ the mapping directives: both tasks on processors, and software objects  | 
|---|
| 22 | // (vobjs and vsegs) on the physical memory banks (called psegs). | 
|---|
| 23 | // and a variable number of tasks. The number of virtual space can be one. | 
|---|
| 24 | // | 
|---|
| 25 | // The mapping_info data structure is organised as the concatenation of | 
|---|
| 26 | // a fixed size header, and 11 variable size arrays: | 
|---|
| 27 | // | 
|---|
| 28 | // - mapping_cluster_t  cluster[]   | 
|---|
| 29 | // - mapping_pseg_t     pseg[]        | 
|---|
| 30 | // - mapping_vspace_t   vspace[]   | 
|---|
| 31 | // - mapping_vseg_t     vseg[]      | 
|---|
| 32 | // - mapping_vseg_t     vobj[]     | 
|---|
| 33 | // - mapping_task_t     task[]   | 
|---|
| 34 | // - mapping_proc_t     proc[]   | 
|---|
| 35 | // - mapping_irq_t      irq[]    | 
|---|
| 36 | // - mapping_coproc_t   coproc[] | 
|---|
| 37 | // - mapping_cp_port_t  cp_port[]  | 
|---|
| 38 | // - mapping_periph_t   periph[] | 
|---|
| 39 | // | 
|---|
| 40 | // It is intended to be stored in memory in the seg_boot_mapping segment.  | 
|---|
| 41 | //////////////////////////////////////////////////////////////////////////// | 
|---|
| 42 |  | 
|---|
| 43 | #ifndef _MAPPING_INFO_H_ | 
|---|
| 44 | #define _MAPPING_INFO_H_ | 
|---|
| 45 |  | 
|---|
| 46 | #define MAPPING_HEADER_SIZE   sizeof(mapping_header_t) | 
|---|
| 47 | #define MAPPING_CLUSTER_SIZE  sizeof(mapping_cluster_t) | 
|---|
| 48 | #define MAPPING_VSPACE_SIZE   sizeof(mapping_vspace_t) | 
|---|
| 49 | #define MAPPING_VSEG_SIZE     sizeof(mapping_vseg_t) | 
|---|
| 50 | #define MAPPING_VOBJ_SIZE     sizeof(mapping_vobj_t) | 
|---|
| 51 | #define MAPPING_PSEG_SIZE     sizeof(mapping_pseg_t) | 
|---|
| 52 | #define MAPPING_TASK_SIZE     sizeof(mapping_task_t) | 
|---|
| 53 | #define MAPPING_PROC_SIZE     sizeof(mapping_proc_t) | 
|---|
| 54 | #define MAPPING_IRQ_SIZE      sizeof(mapping_irq_t) | 
|---|
| 55 | #define MAPPING_COPROC_SIZE   sizeof(mapping_coproc_t) | 
|---|
| 56 | #define MAPPING_CP_PORT_SIZE  sizeof(mapping_cp_port_t) | 
|---|
| 57 |  | 
|---|
| 58 | #define C_MODE_MASK  0b1000   // cacheable | 
|---|
| 59 | #define X_MODE_MASK  0b0100   // executable | 
|---|
| 60 | #define W_MODE_MASK  0b0010   // writable | 
|---|
| 61 | #define U_MODE_MASK  0b0001   // user access | 
|---|
| 62 |  | 
|---|
| 63 | #define IN_MAPPING_SIGNATURE    0xDEADBEEF | 
|---|
| 64 | #define OUT_MAPPING_SIGNATURE   0xBABEF00D | 
|---|
| 65 |  | 
|---|
| 66 | typedef unsigned long long  paddr_t; | 
|---|
| 67 |  | 
|---|
| 68 | enum vobjType  | 
|---|
| 69 | { | 
|---|
| 70 |     VOBJ_TYPE_ELF      = 0,  // loadable code/data object of elf files | 
|---|
| 71 |     VOBJ_TYPE_BLOB     = 1,  // loadable blob object | 
|---|
| 72 |     VOBJ_TYPE_PTAB     = 2,  // page table  | 
|---|
| 73 |     VOBJ_TYPE_PERI     = 3,  // hardware component | 
|---|
| 74 |     VOBJ_TYPE_MWMR     = 4,  // MWMR channel | 
|---|
| 75 |     VOBJ_TYPE_LOCK     = 5,  // Lock | 
|---|
| 76 |     VOBJ_TYPE_BUFFER   = 6,  // Any "no initialization" objects (stacks...) | 
|---|
| 77 |     VOBJ_TYPE_BARRIER  = 7,  // Barrier | 
|---|
| 78 |     VOBJ_TYPE_CONST    = 8,  // Constant | 
|---|
| 79 |     VOBJ_TYPE_MEMSPACE = 9,  // Memspace (descriptor must be initialised) | 
|---|
| 80 |     VOBJ_TYPE_SCHED    = 10, // Array of schedulers (one per cluster) | 
|---|
| 81 |     VOBJ_TYPE_BOOT     = 11, // loader by the preloader | 
|---|
| 82 | }; | 
|---|
| 83 |  | 
|---|
| 84 | enum irqType | 
|---|
| 85 | { | 
|---|
| 86 |     IRQ_TYPE_HWI = 0,        // HARD in map.xml file | 
|---|
| 87 |     IRQ_TYPE_SWI = 1,        // SOFT in map.xml file, | 
|---|
| 88 |     IRQ_TYPE_PTI = 2,        // TIME in map.xml file, | 
|---|
| 89 | }; | 
|---|
| 90 |  | 
|---|
| 91 | enum psegType  | 
|---|
| 92 | { | 
|---|
| 93 |     PSEG_TYPE_RAM  = 0, | 
|---|
| 94 |     PSEG_TYPE_ROM  = 1,      // deprecated => you should use PSEG_TYPE_PERI   | 
|---|
| 95 |     PSEG_TYPE_PERI = 2, | 
|---|
| 96 | }; | 
|---|
| 97 |  | 
|---|
| 98 | // The enum definitions for psegType and periphType must be kept | 
|---|
| 99 | // consistent with the definitions in the xml_driver.c file... | 
|---|
| 100 |  | 
|---|
| 101 | enum periphType  | 
|---|
| 102 | { | 
|---|
| 103 |     PERIPH_TYPE_CMA       = 0, | 
|---|
| 104 |     PERIPH_TYPE_DMA       = 1, | 
|---|
| 105 |     PERIPH_TYPE_FBF       = 2, | 
|---|
| 106 |     PERIPH_TYPE_HBA       = 3, | 
|---|
| 107 |     PERIPH_TYPE_ICU       = 4, | 
|---|
| 108 |     PERIPH_TYPE_IOB       = 5, | 
|---|
| 109 |     PERIPH_TYPE_IOC       = 6, | 
|---|
| 110 |     PERIPH_TYPE_MMC       = 7, | 
|---|
| 111 |     PERIPH_TYPE_MWR       = 8, | 
|---|
| 112 |     PERIPH_TYPE_NIC       = 9, | 
|---|
| 113 |     PERIPH_TYPE_ROM       = 10, | 
|---|
| 114 |     PERIPH_TYPE_SIM       = 11, | 
|---|
| 115 |     PERIPH_TYPE_TIM       = 12, | 
|---|
| 116 |     PERIPH_TYPE_TTY       = 13, | 
|---|
| 117 |     PERIPH_TYPE_XCU       = 14, | 
|---|
| 118 |  | 
|---|
| 119 |     PERIPH_TYPE_MAX_VALUE = 15, | 
|---|
| 120 | }; | 
|---|
| 121 |  | 
|---|
| 122 | enum periphSubtype  | 
|---|
| 123 | { | 
|---|
| 124 |     PERIPH_SUBTYPE_BDV       = 0, | 
|---|
| 125 |     PERIPH_SUBTYPE_HBA       = 1, | 
|---|
| 126 |     PERIPH_SUBTYPE_SPI       = 2, | 
|---|
| 127 |  | 
|---|
| 128 |     PERIPH_SUBTYPE_MAX_VALUE = 3, | 
|---|
| 129 | }; | 
|---|
| 130 |  | 
|---|
| 131 | enum mwmrPortDirection  | 
|---|
| 132 | { | 
|---|
| 133 |     PORT_TO_COPROC   = 0, // status register | 
|---|
| 134 |     PORT_FROM_COPROC = 1, // config register | 
|---|
| 135 | }; | 
|---|
| 136 |  | 
|---|
| 137 |  | 
|---|
| 138 | //////////////////////////////////////////////////////// | 
|---|
| 139 | typedef struct __attribute__((packed))  mapping_header_s  | 
|---|
| 140 | { | 
|---|
| 141 |     unsigned int signature;          // must contain MAPPING_SIGNATURE | 
|---|
| 142 |     unsigned int x_size;             // actual number of clusters in a row | 
|---|
| 143 |     unsigned int y_size;             // actual number of clusters in a column | 
|---|
| 144 |     unsigned int x_width;            // number of bits to encode x coordinate  | 
|---|
| 145 |     unsigned int y_width;            // number of bits to encode y coordinate  | 
|---|
| 146 |     unsigned int globals;            // number of vsegs mapped in all vspaces | 
|---|
| 147 |     unsigned int vspaces;            // number of virtual spaces | 
|---|
| 148 |     unsigned int increment;          // vseg cluster increment for replicated periphs | 
|---|
| 149 |  | 
|---|
| 150 |     unsigned int cma_cluster;        // index of cluster containing CMA controler | 
|---|
| 151 |     unsigned int cma_cluster_bis;    // index of cluster containing second CMA controler | 
|---|
| 152 |  | 
|---|
| 153 |     unsigned int fbf_cluster;        // index of cluster containing FBF controler | 
|---|
| 154 |     unsigned int fbf_cluster_bis;    // index of cluster containing second FBF controler | 
|---|
| 155 |  | 
|---|
| 156 |     unsigned int hba_cluster;        // index of cluster containing HBA controler | 
|---|
| 157 |     unsigned int hba_cluster_bis;    // index of cluster containing second HBA controler | 
|---|
| 158 |  | 
|---|
| 159 |     unsigned int iob_cluster;        // index of cluster containing IOB controler | 
|---|
| 160 |     unsigned int iob_cluster_bis;    // index of cluster containing second IOB controler | 
|---|
| 161 |  | 
|---|
| 162 |     unsigned int ioc_cluster;        // index of cluster containing IOC controler | 
|---|
| 163 |     unsigned int ioc_cluster_bis;    // index of cluster containing second IOC controler | 
|---|
| 164 |  | 
|---|
| 165 |     unsigned int nic_cluster;        // index of cluster containing NIC controler | 
|---|
| 166 |     unsigned int nic_cluster_bis;    // index of cluster containing second NIC controler | 
|---|
| 167 |  | 
|---|
| 168 |     unsigned int rom_cluster;        // index of cluster containing ROM controler | 
|---|
| 169 |     unsigned int rom_cluster_bis;    // index of cluster containing second ROM controler | 
|---|
| 170 |  | 
|---|
| 171 |     unsigned int sim_cluster;        // index of cluster containing SIM controler | 
|---|
| 172 |     unsigned int sim_cluster_bis;    // index of cluster containing second SIM controler | 
|---|
| 173 |  | 
|---|
| 174 |     unsigned int tty_cluster;        // index of cluster containing TTY controler | 
|---|
| 175 |     unsigned int tty_cluster_bis;    // index of cluster containing second TTY controler | 
|---|
| 176 |  | 
|---|
| 177 |     unsigned int psegs;              // total number of physical segments (for all clusters) | 
|---|
| 178 |     unsigned int vsegs;              // total number of virtual segments (for all vspaces) | 
|---|
| 179 |     unsigned int vobjs;              // total number of virtual objects (for all vspaces) | 
|---|
| 180 |     unsigned int tasks;              // total number of tasks (for all vspaces) | 
|---|
| 181 |     unsigned int procs;              // total number of procs (for all clusters) | 
|---|
| 182 |     unsigned int irqs;               // total number of irqs (for all processors) | 
|---|
| 183 |     unsigned int coprocs;            // total number of coprocs (for all clusters) | 
|---|
| 184 |     unsigned int cp_ports;           // total number of cp_ports (for all coprocs) | 
|---|
| 185 |     unsigned int periphs;            // total number of peripherals (for all clusters) | 
|---|
| 186 |  | 
|---|
| 187 |     char name[32];                   // mapping name | 
|---|
| 188 | } mapping_header_t; | 
|---|
| 189 |  | 
|---|
| 190 |  | 
|---|
| 191 | ///////////////////////////////////////////////////////// | 
|---|
| 192 | typedef struct __attribute__((packed))  mapping_cluster_s  | 
|---|
| 193 | { | 
|---|
| 194 |     unsigned int    x;               // x coordinate | 
|---|
| 195 |     unsigned int    y;               // y coordinate | 
|---|
| 196 |  | 
|---|
| 197 |     unsigned int    psegs;           // number of psegs in cluster | 
|---|
| 198 |     unsigned int    pseg_offset;     // index of first pseg in pseg set | 
|---|
| 199 |  | 
|---|
| 200 |     unsigned int    procs;           // number of processors in cluster | 
|---|
| 201 |     unsigned int    proc_offset;     // index of first proc in proc set | 
|---|
| 202 |   | 
|---|
| 203 |     unsigned int    coprocs;         // number of coprocessors in cluster | 
|---|
| 204 |     unsigned int    coproc_offset;   // index of first coproc in coproc set | 
|---|
| 205 |  | 
|---|
| 206 |     unsigned int    periphs;         // number of peripherals in cluster | 
|---|
| 207 |     unsigned int    periph_offset;   // index of first coproc in coproc set | 
|---|
| 208 | } mapping_cluster_t; | 
|---|
| 209 |  | 
|---|
| 210 |  | 
|---|
| 211 | //////////////////////////////////////////////////////// | 
|---|
| 212 | typedef struct __attribute__((packed))  mapping_vspace_s  | 
|---|
| 213 | { | 
|---|
| 214 |     char            name[32];        // virtual space name | 
|---|
| 215 |     unsigned int    start_offset;    // offset of the vobj containing start vector | 
|---|
| 216 |     unsigned int    vsegs;           // number of vsegs in vspace | 
|---|
| 217 |     unsigned int    vobjs;           // number of vobjs in vspace | 
|---|
| 218 |     unsigned int    tasks;           // number of tasks in vspace | 
|---|
| 219 |     unsigned int    vseg_offset;     // index of first vseg in vspace  | 
|---|
| 220 |     unsigned int    vobj_offset;     // index of first vobjs in vspace | 
|---|
| 221 |     unsigned int    task_offset;     // index of first task in vspace | 
|---|
| 222 | } mapping_vspace_t; | 
|---|
| 223 |  | 
|---|
| 224 |  | 
|---|
| 225 | ////////////////////////////////////////////////////// | 
|---|
| 226 | typedef struct __attribute__((packed))  mapping_vseg_s  | 
|---|
| 227 | { | 
|---|
| 228 |     char            name[32];        // vseg name (unique in vspace) | 
|---|
| 229 |     unsigned int    vbase;           // base address in virtual space | 
|---|
| 230 |     paddr_t         pbase;           // base address in physical space | 
|---|
| 231 |     unsigned int    length;          // size (bytes) | 
|---|
| 232 |     unsigned int    psegid;          // physical segment global index | 
|---|
| 233 |     unsigned int    mode;            // C-X-W-U flags | 
|---|
| 234 |     unsigned int    vobjs;           // number of vobjs in vseg | 
|---|
| 235 |     unsigned int    vobj_offset;     // index of first vobj in vseg | 
|---|
| 236 |     unsigned int    next_vseg;       // linked list of vsegs mapped on pseg | 
|---|
| 237 |     char            mapped;          // mapped if non zero | 
|---|
| 238 |     char            ident;           // identity mapping if non zero | 
|---|
| 239 |     char            rsvd0;           // reserved  | 
|---|
| 240 |     char            rsvd1;           // reserved | 
|---|
| 241 | } mapping_vseg_t; | 
|---|
| 242 |  | 
|---|
| 243 |  | 
|---|
| 244 | ////////////////////////////////////////////////////// | 
|---|
| 245 | typedef struct __attribute__((packed))  mapping_pseg_s   | 
|---|
| 246 | { | 
|---|
| 247 |     char            name[32];        // pseg name (unique in a cluster) | 
|---|
| 248 |     paddr_t         base;            // base address in physical space | 
|---|
| 249 |     paddr_t         length;          // size (bytes) | 
|---|
| 250 |     unsigned int    type;            // RAM / PERI | 
|---|
| 251 |     unsigned int    clusterid;       // linear index in array of clusters | 
|---|
| 252 |     unsigned int    next_vseg;       // linked list of vsegs mapped on pseg | 
|---|
| 253 | } mapping_pseg_t; | 
|---|
| 254 |  | 
|---|
| 255 |  | 
|---|
| 256 | ////////////////////////////////////////////////////// | 
|---|
| 257 | typedef struct __attribute__((packed))  mapping_task_s  | 
|---|
| 258 | { | 
|---|
| 259 |     char            name[32];        // task name (unique in vspace) | 
|---|
| 260 |     unsigned int    clusterid;       // linear index in array of clusters | 
|---|
| 261 |     unsigned int    proclocid;       // processor local index (inside cluster) | 
|---|
| 262 |     unsigned int    trdid;           // thread index in vspace | 
|---|
| 263 |     unsigned int    stack_vobjid;    // stack vobj index in vspace | 
|---|
| 264 |     unsigned int    heap_vobjid;     // heap vobj index in vspace | 
|---|
| 265 |     unsigned int    startid;         // index in start_vector  | 
|---|
| 266 |     unsigned int    use_tty;         // TTY channel required (global) | 
|---|
| 267 |     unsigned int    use_nic;         // NIC channel required (global) | 
|---|
| 268 |     unsigned int    use_cma;         // CMA channel required (global) | 
|---|
| 269 |     unsigned int    use_hba;         // IOC channel required (global) | 
|---|
| 270 |     unsigned int    use_tim;         // user timer required (local) | 
|---|
| 271 | } mapping_task_t; | 
|---|
| 272 |  | 
|---|
| 273 |  | 
|---|
| 274 | ////////////////////////////////////////////////////// | 
|---|
| 275 | typedef struct __attribute__((packed))  mapping_vobj_s  | 
|---|
| 276 | { | 
|---|
| 277 |     char            name[32];        // vobj name (unique in a vspace) | 
|---|
| 278 |     char            binpath[64];     // path for the binary code ("*.elf") | 
|---|
| 279 |     unsigned int    type;            // type of vobj | 
|---|
| 280 |     unsigned int    length;          // size (bytes) | 
|---|
| 281 |     unsigned int    align;           // required alignement (logarithm of 2) | 
|---|
| 282 |     unsigned int    vaddr;           // virtual base addresse of the vobj | 
|---|
| 283 |     paddr_t         paddr;           // physical base addresse of the vobj | 
|---|
| 284 |     unsigned int    init;            // init value (used by barrier or mwmr channel) | 
|---|
| 285 | } mapping_vobj_t; | 
|---|
| 286 |  | 
|---|
| 287 |  | 
|---|
| 288 | ////////////////////////////////////////////////////// | 
|---|
| 289 | typedef struct __attribute__((packed))  mapping_proc_s  | 
|---|
| 290 | { | 
|---|
| 291 |     unsigned int    irqs;            // number of IRQs allocated to processor | 
|---|
| 292 |     unsigned int    irq_offset;      // index of first IRQ allocated to processor | 
|---|
| 293 | } mapping_proc_t; | 
|---|
| 294 |  | 
|---|
| 295 |  | 
|---|
| 296 | ///////////////////////////////////////////////////// | 
|---|
| 297 | typedef struct __attribute__((packed))  mapping_irq_s  | 
|---|
| 298 | { | 
|---|
| 299 |     unsigned int    type;            // HWI / SWI / PTI | 
|---|
| 300 |     unsigned int    icuid;           // IRQ Index for the ICU component | 
|---|
| 301 |     unsigned int    isr;             // ISR Index (defined in irq_handler.h) | 
|---|
| 302 |     unsigned int    channel;         // Channel Index (for multi-channels peripherals) | 
|---|
| 303 | } mapping_irq_t;  | 
|---|
| 304 |  | 
|---|
| 305 |  | 
|---|
| 306 | //////////////////////////////////////////////////////// | 
|---|
| 307 | typedef struct __attribute__((packed))  mapping_coproc_s  | 
|---|
| 308 | { | 
|---|
| 309 |     char            name[32];        // coprocessor name | 
|---|
| 310 |     unsigned int    psegid;          // global pseg index  | 
|---|
| 311 |     unsigned int    ports;           // number of MWMR ports used by coprocessor | 
|---|
| 312 |     unsigned int    port_offset;     // index of first MWMR port used by coprocessor | 
|---|
| 313 | } mapping_coproc_t; | 
|---|
| 314 |  | 
|---|
| 315 |  | 
|---|
| 316 | ///////////////////////////////////////////////////////// | 
|---|
| 317 | typedef struct __attribute__((packed))  mapping_cp_port_s  | 
|---|
| 318 | { | 
|---|
| 319 |     unsigned int    direction;       // TO_COPROC == 0 / FROM_COPROC == 1 | 
|---|
| 320 |     unsigned int    vspaceid;        // index of the vspace containing the MWMR channel | 
|---|
| 321 |     unsigned int    mwmr_vobjid;     // local index of the vobj containing the MWMR channel | 
|---|
| 322 | } mapping_cp_port_t; | 
|---|
| 323 |  | 
|---|
| 324 |  | 
|---|
| 325 | //////////////////////////////////////////////////////// | 
|---|
| 326 | typedef struct __attribute__((packed))  mapping_periph_s  | 
|---|
| 327 | { | 
|---|
| 328 |     unsigned int    type;          | 
|---|
| 329 |     unsigned int    subtype;         // periph specialization | 
|---|
| 330 |     unsigned int    psegid;          // pseg index in cluster | 
|---|
| 331 |     unsigned int    channels;        // number of channels | 
|---|
| 332 | } mapping_periph_t; | 
|---|
| 333 |  | 
|---|
| 334 |  | 
|---|
| 335 | #endif | 
|---|
| 336 |  | 
|---|
| 337 | // Local Variables: | 
|---|
| 338 | // tab-width: 4 | 
|---|
| 339 | // c-basic-offset: 4 | 
|---|
| 340 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) | 
|---|
| 341 | // indent-tabs-mode: nil | 
|---|
| 342 | // End: | 
|---|
| 343 |  | 
|---|
| 344 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 | 
|---|
| 345 |  | 
|---|