[258] | 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. |
---|
[522] | 10 | // The number of cluster is variable (can be one). |
---|
| 11 | // The number of processors per cluster is variable (can be zero). |
---|
| 12 | // The number of peripherals per cluster is variable (can be zero), |
---|
| 13 | // The number of physical memory bank per cluster is variable. |
---|
[258] | 14 | // |
---|
| 15 | // 2/ a description of the applications (called vspaces) to be - statically - |
---|
[709] | 16 | // mapped on the platform. The number of parallel threads per application is |
---|
[522] | 17 | // variable (can be one). Each vspace contains a variable number |
---|
| 18 | // of virtual segments (called vsegs). |
---|
[258] | 19 | // |
---|
[709] | 20 | // 3/ the mapping directives: both threads on processors, and software objects |
---|
| 21 | // (vsegs) on physical memory banks (psegs). |
---|
[258] | 22 | // |
---|
| 23 | // The mapping_info data structure is organised as the concatenation of |
---|
[522] | 24 | // a fixed size header, and 8 variable size arrays: |
---|
[258] | 25 | // |
---|
| 26 | // - mapping_cluster_t cluster[] |
---|
| 27 | // - mapping_pseg_t pseg[] |
---|
| 28 | // - mapping_vspace_t vspace[] |
---|
| 29 | // - mapping_vseg_t vseg[] |
---|
[709] | 30 | // - mapping_thread_t thread[] |
---|
[258] | 31 | // - mapping_proc_t proc[] |
---|
| 32 | // - mapping_irq_t irq[] |
---|
| 33 | // - mapping_periph_t periph[] |
---|
| 34 | // |
---|
| 35 | // It is intended to be stored in memory in the seg_boot_mapping segment. |
---|
| 36 | //////////////////////////////////////////////////////////////////////////// |
---|
| 37 | |
---|
| 38 | #ifndef _MAPPING_INFO_H_ |
---|
| 39 | #define _MAPPING_INFO_H_ |
---|
| 40 | |
---|
| 41 | #define MAPPING_HEADER_SIZE sizeof(mapping_header_t) |
---|
| 42 | #define MAPPING_CLUSTER_SIZE sizeof(mapping_cluster_t) |
---|
| 43 | #define MAPPING_VSPACE_SIZE sizeof(mapping_vspace_t) |
---|
| 44 | #define MAPPING_VSEG_SIZE sizeof(mapping_vseg_t) |
---|
| 45 | #define MAPPING_PSEG_SIZE sizeof(mapping_pseg_t) |
---|
[709] | 46 | #define MAPPING_THREAD_SIZE sizeof(mapping_thread_t) |
---|
[258] | 47 | #define MAPPING_PROC_SIZE sizeof(mapping_proc_t) |
---|
| 48 | #define MAPPING_IRQ_SIZE sizeof(mapping_irq_t) |
---|
[522] | 49 | #define MAPPING_PERIPH_SIZE sizeof(mapping_periph_t) |
---|
[258] | 50 | |
---|
| 51 | #define C_MODE_MASK 0b1000 // cacheable |
---|
| 52 | #define X_MODE_MASK 0b0100 // executable |
---|
| 53 | #define W_MODE_MASK 0b0010 // writable |
---|
| 54 | #define U_MODE_MASK 0b0001 // user access |
---|
| 55 | |
---|
[295] | 56 | #define IN_MAPPING_SIGNATURE 0xDACE2014 |
---|
[258] | 57 | #define OUT_MAPPING_SIGNATURE 0xBABEF00D |
---|
| 58 | |
---|
| 59 | typedef unsigned long long paddr_t; |
---|
| 60 | |
---|
[511] | 61 | enum vsegType |
---|
[258] | 62 | { |
---|
[511] | 63 | VSEG_TYPE_ELF = 0, // loadable code/data object of elf files |
---|
| 64 | VSEG_TYPE_BLOB = 1, // loadable blob object |
---|
| 65 | VSEG_TYPE_PTAB = 2, // page table |
---|
| 66 | VSEG_TYPE_PERI = 3, // hardware component |
---|
[548] | 67 | VSEG_TYPE_BUFFER = 4, // no initialization object (stacks...) |
---|
| 68 | VSEG_TYPE_SCHED = 5, // scheduler |
---|
| 69 | VSEG_TYPE_HEAP = 6, // heap |
---|
[763] | 70 | VSEG_TYPE_MMAP = 7, // mmap (dynamically mapped) |
---|
[258] | 71 | }; |
---|
| 72 | |
---|
| 73 | enum irqType |
---|
| 74 | { |
---|
| 75 | IRQ_TYPE_HWI = 0, // HARD in map.xml file |
---|
[295] | 76 | IRQ_TYPE_WTI = 1, // SOFT in map.xml file, |
---|
[258] | 77 | IRQ_TYPE_PTI = 2, // TIME in map.xml file, |
---|
| 78 | }; |
---|
| 79 | |
---|
[522] | 80 | |
---|
[258] | 81 | enum psegType |
---|
| 82 | { |
---|
| 83 | PSEG_TYPE_RAM = 0, |
---|
| 84 | PSEG_TYPE_PERI = 2, |
---|
| 85 | }; |
---|
| 86 | |
---|
| 87 | |
---|
[522] | 88 | //////////////////////////////////////////////////////////////////// |
---|
| 89 | // These enum must be coherent with the values in |
---|
| 90 | // xml_driver.c / xml_parser.c / mapping.py |
---|
| 91 | /////////////////////////////////////////////////////////////////// |
---|
| 92 | enum periphTypes |
---|
[258] | 93 | { |
---|
| 94 | PERIPH_TYPE_CMA = 0, |
---|
| 95 | PERIPH_TYPE_DMA = 1, |
---|
| 96 | PERIPH_TYPE_FBF = 2, |
---|
[439] | 97 | PERIPH_TYPE_IOB = 3, |
---|
| 98 | PERIPH_TYPE_IOC = 4, |
---|
| 99 | PERIPH_TYPE_MMC = 5, |
---|
| 100 | PERIPH_TYPE_MWR = 6, |
---|
| 101 | PERIPH_TYPE_NIC = 7, |
---|
| 102 | PERIPH_TYPE_ROM = 8, |
---|
| 103 | PERIPH_TYPE_SIM = 9, |
---|
| 104 | PERIPH_TYPE_TIM = 10, |
---|
| 105 | PERIPH_TYPE_TTY = 11, |
---|
| 106 | PERIPH_TYPE_XCU = 12, |
---|
| 107 | PERIPH_TYPE_PIC = 13, |
---|
[491] | 108 | PERIPH_TYPE_DROM = 14, |
---|
[258] | 109 | |
---|
[491] | 110 | PERIPH_TYPE_MAX_VALUE = 15, |
---|
[258] | 111 | }; |
---|
| 112 | |
---|
[522] | 113 | enum iocTypes |
---|
[289] | 114 | { |
---|
[566] | 115 | IOC_SUBTYPE_BDV = 0, |
---|
| 116 | IOC_SUBTYPE_HBA = 1, |
---|
| 117 | IOC_SUBTYPE_SDC = 2, |
---|
| 118 | IOC_SUBTYPE_SPI = 3, |
---|
[289] | 119 | }; |
---|
| 120 | |
---|
[522] | 121 | enum mwrTypes |
---|
[258] | 122 | { |
---|
[738] | 123 | MWR_SUBTYPE_CPY = 0, |
---|
| 124 | MWR_SUBTYPE_GCD = 1, |
---|
| 125 | MWR_SUBTYPE_DCT = 2, |
---|
[258] | 126 | }; |
---|
| 127 | |
---|
[522] | 128 | ////////////////////////////////////////////////////////// |
---|
| 129 | // This enum must be coherent with the values in |
---|
| 130 | // mwr_driver.h |
---|
| 131 | ////////////////////////////////////////////////////////// |
---|
| 132 | enum MwmrDmaModes |
---|
| 133 | { |
---|
| 134 | MODE_MWMR = 0, |
---|
| 135 | MODE_DMA_IRQ = 1, |
---|
| 136 | MODE_DMA_NO_IRQ = 2, |
---|
| 137 | }; |
---|
[258] | 138 | |
---|
| 139 | //////////////////////////////////////////////////////// |
---|
| 140 | typedef struct __attribute__((packed)) mapping_header_s |
---|
| 141 | { |
---|
[566] | 142 | unsigned int signature; // must contain IN_MAPPING_SIGNATURE |
---|
| 143 | unsigned int x_size; // actual number of clusters in a row |
---|
| 144 | unsigned int y_size; // actual number of clusters in a column |
---|
| 145 | unsigned int x_width; // number of bits to encode x coordinate |
---|
| 146 | unsigned int y_width; // number of bits to encode y coordinate |
---|
| 147 | unsigned int x_io; // x coordinate for cluster_io_ext |
---|
| 148 | unsigned int y_io; // y coordinate for cluster_io_ext |
---|
| 149 | unsigned int irq_per_proc; // number of IRQ per processor |
---|
| 150 | unsigned int use_ram_disk; // does not use IOC peripheral if non zero |
---|
| 151 | unsigned int globals; // total number of global vsegs |
---|
| 152 | unsigned int vspaces; // total number of virtual spaces |
---|
| 153 | unsigned int psegs; // total number of physical segments |
---|
| 154 | unsigned int vsegs; // total number of virtual segments |
---|
[709] | 155 | unsigned int threads; // total number of threads |
---|
[566] | 156 | unsigned int procs; // total number of processors |
---|
| 157 | unsigned int irqs; // total number of irqs |
---|
| 158 | unsigned int periphs; // total number of peripherals |
---|
[763] | 159 | unsigned int max_pt2; // max number of PT2s (computed in boot.c) |
---|
| 160 | unsigned int padding[14]; // reserved |
---|
[709] | 161 | char name[256]; // mapping name |
---|
[258] | 162 | } mapping_header_t; |
---|
| 163 | |
---|
| 164 | |
---|
| 165 | ///////////////////////////////////////////////////////// |
---|
| 166 | typedef struct __attribute__((packed)) mapping_cluster_s |
---|
| 167 | { |
---|
[263] | 168 | unsigned int x; // x coordinate |
---|
| 169 | unsigned int y; // y coordinate |
---|
| 170 | |
---|
[258] | 171 | unsigned int psegs; // number of psegs in cluster |
---|
[522] | 172 | unsigned int pseg_offset; // global index of first pseg in cluster |
---|
[258] | 173 | |
---|
| 174 | unsigned int procs; // number of processors in cluster |
---|
[522] | 175 | unsigned int proc_offset; // global index of first proc in cluster |
---|
[258] | 176 | |
---|
| 177 | unsigned int periphs; // number of peripherals in cluster |
---|
[522] | 178 | unsigned int periph_offset; // global index of first coproc in cluster |
---|
[258] | 179 | } mapping_cluster_t; |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | //////////////////////////////////////////////////////// |
---|
| 183 | typedef struct __attribute__((packed)) mapping_vspace_s |
---|
| 184 | { |
---|
| 185 | char name[32]; // virtual space name |
---|
[511] | 186 | unsigned int start_vseg_id; // vseg containing start vector index |
---|
[258] | 187 | unsigned int vsegs; // number of vsegs in vspace |
---|
[709] | 188 | unsigned int threads; // number of threads in vspace |
---|
[323] | 189 | unsigned int vseg_offset; // global index of first vseg in vspace |
---|
[709] | 190 | unsigned int thread_offset; // global index of first thread in vspace |
---|
[645] | 191 | unsigned int active; // always active if non zero |
---|
[258] | 192 | } mapping_vspace_t; |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | ////////////////////////////////////////////////////// |
---|
| 196 | typedef struct __attribute__((packed)) mapping_vseg_s |
---|
| 197 | { |
---|
| 198 | char name[32]; // vseg name (unique in vspace) |
---|
[511] | 199 | char binpath[64]; // path for the binary code (if required) |
---|
[258] | 200 | unsigned int vbase; // base address in virtual space |
---|
| 201 | paddr_t pbase; // base address in physical space |
---|
| 202 | unsigned int length; // size (bytes) |
---|
| 203 | unsigned int psegid; // physical segment global index |
---|
| 204 | unsigned int mode; // C-X-W-U flags |
---|
[511] | 205 | unsigned int type; // vseg type |
---|
[258] | 206 | char mapped; // mapped if non zero |
---|
| 207 | char ident; // identity mapping if non zero |
---|
[349] | 208 | char local; // only mapped in the local PTAB |
---|
[409] | 209 | char big; // to be mapped in a big physical page |
---|
[258] | 210 | } mapping_vseg_t; |
---|
| 211 | |
---|
| 212 | |
---|
| 213 | ////////////////////////////////////////////////////// |
---|
| 214 | typedef struct __attribute__((packed)) mapping_pseg_s |
---|
| 215 | { |
---|
| 216 | char name[32]; // pseg name (unique in a cluster) |
---|
| 217 | paddr_t base; // base address in physical space |
---|
| 218 | paddr_t length; // size (bytes) |
---|
| 219 | unsigned int type; // RAM / PERI |
---|
[323] | 220 | unsigned int clusterid; // global index in clusters set |
---|
[258] | 221 | unsigned int next_vseg; // linked list of vsegs mapped on pseg |
---|
| 222 | } mapping_pseg_t; |
---|
| 223 | |
---|
| 224 | |
---|
[709] | 225 | //////////////////////////////////////////////////////// |
---|
| 226 | typedef struct __attribute__((packed)) mapping_thread_s |
---|
[258] | 227 | { |
---|
[709] | 228 | char name[32]; // thread name (unique in vspace) |
---|
[323] | 229 | unsigned int clusterid; // global index in clusters set |
---|
[258] | 230 | unsigned int proclocid; // processor local index (inside cluster) |
---|
[709] | 231 | unsigned int is_main; // this thread is the application entry point |
---|
[511] | 232 | unsigned int stack_vseg_id; // global index for vseg containing stack |
---|
| 233 | unsigned int heap_vseg_id; // global index for vseg containing heap |
---|
[258] | 234 | unsigned int startid; // index in start_vector |
---|
[709] | 235 | unsigned int ltid; // thread index in scheduler (dynamically defined) |
---|
| 236 | } mapping_thread_t; |
---|
[258] | 237 | |
---|
| 238 | |
---|
| 239 | ////////////////////////////////////////////////////// |
---|
| 240 | typedef struct __attribute__((packed)) mapping_proc_s |
---|
| 241 | { |
---|
[295] | 242 | unsigned int index; // processor local index (in cluster) |
---|
[258] | 243 | } mapping_proc_t; |
---|
| 244 | |
---|
| 245 | |
---|
| 246 | //////////////////////////////////////////////////////// |
---|
| 247 | typedef struct __attribute__((packed)) mapping_periph_s |
---|
| 248 | { |
---|
[295] | 249 | unsigned int type; // legal values defined above |
---|
[289] | 250 | unsigned int subtype; // periph specialization |
---|
[258] | 251 | unsigned int psegid; // pseg index in cluster |
---|
| 252 | unsigned int channels; // number of channels |
---|
[522] | 253 | unsigned int arg0; // semantic depends on peripheral type |
---|
| 254 | unsigned int arg1; // semantic depends on peripheral type |
---|
| 255 | unsigned int arg2; // semantic depends on peripheral type |
---|
| 256 | unsigned int arg3; // semantic depends on peripheral type |
---|
[323] | 257 | unsigned int irqs; // number of input IRQs (for XCU or PIC) |
---|
| 258 | unsigned int irq_offset; // index of first IRQ |
---|
[258] | 259 | } mapping_periph_t; |
---|
| 260 | |
---|
| 261 | |
---|
[295] | 262 | ///////////////////////////////////////////////////// |
---|
| 263 | typedef struct __attribute__((packed)) mapping_irq_s |
---|
| 264 | { |
---|
| 265 | unsigned int srctype; // source IRQ type (HWI / WTI / PTI) |
---|
[531] | 266 | unsigned int srcid; // source IRQ index (for XCU/PIC) |
---|
[295] | 267 | unsigned int isr; // ISR type (defined in irq_handler.h) |
---|
[323] | 268 | unsigned int channel; // channel index (for multi-channels ISR) |
---|
| 269 | unsigned int dest_xy; // destination cluster (set by GIET_VM) |
---|
| 270 | unsigned int dest_id; // destination port (set by GIET_VM) |
---|
[295] | 271 | } mapping_irq_t; |
---|
| 272 | |
---|
| 273 | |
---|
[258] | 274 | #endif |
---|
| 275 | |
---|
| 276 | // Local Variables: |
---|
| 277 | // tab-width: 4 |
---|
| 278 | // c-basic-offset: 4 |
---|
| 279 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 280 | // indent-tabs-mode: nil |
---|
| 281 | // End: |
---|
| 282 | |
---|
| 283 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 284 | |
---|