| [158] | 1 | /////////////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 2 | // File     : xml_parser.c | 
|---|
| [181] | 3 | // Date     : 14/04/2012 | 
|---|
| [158] | 4 | // Author   : alain greiner | 
|---|
|  | 5 | // Copyright (c) UPMC-LIP6 | 
|---|
|  | 6 | /////////////////////////////////////////////////////////////////////////////////////// | 
|---|
| [217] | 7 | // This program translate a "map.xml" source file to a binary file "map.bin" that | 
|---|
|  | 8 | // can be directly loaded in the boot ROM and used by the GIET-VM operating system. | 
|---|
|  | 9 | // | 
|---|
|  | 10 | // This map.xml file contains : | 
|---|
|  | 11 | // 1) the multi-cluster/multi-processors hardware architecture description | 
|---|
|  | 12 | // 2) the various multi-threaded software applications | 
|---|
|  | 13 | // 3) the mapping directives bor both the tasks and the virtual segments. | 
|---|
|  | 14 | // The corresponding C structures are defined in the "mapping_info.h" file. | 
|---|
|  | 15 | // | 
|---|
|  | 16 | // This program also generates the "hard_config.h" and the "giet_vsegs.ld" files, | 
|---|
|  | 17 | // required  to compile the GIET-VM code. | 
|---|
| [158] | 18 | /////////////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 19 |  | 
|---|
|  | 20 | #include  <stdlib.h> | 
|---|
|  | 21 | #include  <fcntl.h> | 
|---|
| [162] | 22 | #include  <sys/types.h> | 
|---|
|  | 23 | #include  <sys/stat.h> | 
|---|
| [158] | 24 | #include  <unistd.h> | 
|---|
|  | 25 | #include  <stdio.h> | 
|---|
|  | 26 | #include  <string.h> | 
|---|
| [181] | 27 | #include  <assert.h> | 
|---|
| [158] | 28 | #include  <libxml/xmlreader.h> | 
|---|
|  | 29 | #include  <mapping_info.h> | 
|---|
| [189] | 30 | #include  <irq_handler.h> | 
|---|
| [158] | 31 |  | 
|---|
| [228] | 32 | #define MAX_CLUSTERS   1024 | 
|---|
|  | 33 | #define MAX_PSEGS      4096 | 
|---|
|  | 34 | #define MAX_VSPACES    1024 | 
|---|
|  | 35 | #define MAX_TASKS      4096 | 
|---|
|  | 36 | #define MAX_MWMRS      4096 | 
|---|
|  | 37 | #define MAX_VSEGS      4096 | 
|---|
|  | 38 | #define MAX_VOBJS      8192 | 
|---|
|  | 39 | #define MAX_PROCS      1024 | 
|---|
|  | 40 | #define MAX_IRQS       8192 | 
|---|
|  | 41 | #define MAX_COPROCS    4096 | 
|---|
|  | 42 | #define MAX_CP_PORTS   8192 | 
|---|
|  | 43 | #define MAX_PERIPHS    8192 | 
|---|
| [158] | 44 |  | 
|---|
| [228] | 45 | #define XML_PARSER_DEBUG  0 | 
|---|
| [158] | 46 |  | 
|---|
|  | 47 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| [228] | 48 | //     global variables used to store and index the data structures | 
|---|
| [158] | 49 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 50 |  | 
|---|
| [238] | 51 | mapping_header_t *   header; | 
|---|
|  | 52 | mapping_cluster_t *  cluster[MAX_CLUSTERS];  // cluster array | 
|---|
|  | 53 | mapping_pseg_t *     pseg[MAX_PSEGS];        // pseg array | 
|---|
|  | 54 | mapping_vspace_t *   vspace[MAX_VSPACES];    // vspace array | 
|---|
|  | 55 | mapping_vseg_t *     vseg[MAX_VSEGS];        // vseg array | 
|---|
|  | 56 | mapping_vobj_t *     vobj[MAX_VOBJS];        // vobj array | 
|---|
|  | 57 | mapping_task_t *     task[MAX_TASKS];        // task array | 
|---|
|  | 58 | mapping_proc_t *     proc[MAX_PROCS];        // proc array | 
|---|
|  | 59 | mapping_irq_t *      irq[MAX_IRQS];          // irq array | 
|---|
|  | 60 | mapping_coproc_t *   coproc[MAX_COPROCS];    // coproc array | 
|---|
|  | 61 | mapping_cp_port_t *  cp_port[MAX_CP_PORTS];  // coproc port array | 
|---|
|  | 62 | mapping_periph_t *   periph[MAX_PERIPHS];    // peripheral array | 
|---|
| [158] | 63 |  | 
|---|
| [189] | 64 | // Index for the various arrays | 
|---|
| [181] | 65 |  | 
|---|
| [228] | 66 | unsigned int cluster_index  = 0; | 
|---|
|  | 67 | unsigned int vspace_index = 0; | 
|---|
|  | 68 | unsigned int global_index = 0; | 
|---|
|  | 69 | unsigned int pseg_index = 0; | 
|---|
| [181] | 70 |  | 
|---|
| [228] | 71 | unsigned int proc_index = 0; | 
|---|
|  | 72 | unsigned int proc_loc_index = 0; | 
|---|
| [181] | 73 |  | 
|---|
| [228] | 74 | unsigned int irq_index = 0; | 
|---|
|  | 75 | unsigned int irq_loc_index  = 0; | 
|---|
| [181] | 76 |  | 
|---|
| [228] | 77 | unsigned int coproc_index = 0; | 
|---|
|  | 78 | unsigned int coproc_loc_index = 0; | 
|---|
| [181] | 79 |  | 
|---|
| [228] | 80 | unsigned int cp_port_index = 0; | 
|---|
|  | 81 | unsigned int cp_port_loc_index = 0; | 
|---|
| [181] | 82 |  | 
|---|
| [228] | 83 | unsigned int periph_index = 0; | 
|---|
|  | 84 | unsigned int periph_loc_index = 0; | 
|---|
| [181] | 85 |  | 
|---|
| [228] | 86 | unsigned int vseg_index = 0; | 
|---|
|  | 87 | unsigned int vseg_loc_index = 0; | 
|---|
| [189] | 88 |  | 
|---|
| [228] | 89 | unsigned int task_index = 0; | 
|---|
|  | 90 | unsigned int task_loc_index = 0; | 
|---|
| [189] | 91 |  | 
|---|
| [228] | 92 | unsigned int vobj_index = 0; | 
|---|
|  | 93 | unsigned int vobj_loc_index = 0; | 
|---|
|  | 94 | unsigned int vobj_count = 0; | 
|---|
| [165] | 95 |  | 
|---|
| [215] | 96 |  | 
|---|
| [238] | 97 | ////////////////////////////// | 
|---|
|  | 98 | // for replicated peripheral | 
|---|
|  | 99 | ////////////////////////////// | 
|---|
| [215] | 100 | char found_timer = 0; | 
|---|
| [249] | 101 | char found_icu   = 0; | 
|---|
|  | 102 | char found_dma   = 0; | 
|---|
|  | 103 | char found_mmc   = 0; | 
|---|
| [215] | 104 |  | 
|---|
|  | 105 |  | 
|---|
| [238] | 106 | //////////////////////////////////////////////////////////////////// | 
|---|
|  | 107 | // These variables are used to generate the hard_config.h file | 
|---|
|  | 108 | //////////////////////////////////////////////////////////////////// | 
|---|
| [232] | 109 |  | 
|---|
| [238] | 110 | unsigned int cluster_y        = 0; // number of clusters in a column | 
|---|
|  | 111 | unsigned int cluster_x        = 0; // number of clusters in a row | 
|---|
|  | 112 | unsigned int nb_proc_max      = 0; // max number of processors per cluster | 
|---|
|  | 113 | unsigned int nb_tasks_max     = 0; // max number of tasks (for all vspaces) | 
|---|
| [215] | 114 |  | 
|---|
| [238] | 115 | unsigned int tim_channels     = 0; // max number of user timers per cluster | 
|---|
|  | 116 | unsigned int dma_channels     = 0; // max number of DMA channels per cluster | 
|---|
| [215] | 117 |  | 
|---|
| [238] | 118 | unsigned int tty_channels     = 0; // total number of terminals in first TTY | 
|---|
|  | 119 | unsigned int ioc_channels     = 0; // total number of channels in first IOC | 
|---|
|  | 120 | unsigned int nic_channels     = 0; // total number of channels in first NIC | 
|---|
|  | 121 | unsigned int cma_channels     = 0; // total number of channels in first CMA | 
|---|
| [215] | 122 |  | 
|---|
| [249] | 123 | unsigned int use_iob          = 0; // using IOB component | 
|---|
| [238] | 124 | unsigned int use_xicu         = 0; // using XICU (not ICU) | 
|---|
| [215] | 125 |  | 
|---|
|  | 126 |  | 
|---|
| [238] | 127 | //////////////////////////////////////////////////////////////// | 
|---|
|  | 128 | // These variables are used to generate the giet_vseg.ld file | 
|---|
|  | 129 | //////////////////////////////////////////////////////////////// | 
|---|
| [215] | 130 |  | 
|---|
| [238] | 131 | unsigned int periph_vbase_array[PERIPH_TYPE_MAX_VALUE] | 
|---|
|  | 132 | = { [0 ... (PERIPH_TYPE_MAX_VALUE - 1)] = 0xFFFFFFFF }; | 
|---|
| [215] | 133 |  | 
|---|
|  | 134 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [189] | 135 | // This arrray is useful to build a temporary list of vobj references. | 
|---|
|  | 136 | // The struct vobj_ref_s is formed by a vspace_name and a vobj_name. | 
|---|
|  | 137 | // This array is used to set the attribute vobj_id of a cp_port | 
|---|
|  | 138 | // once all the vspace have been parsed. | 
|---|
| [215] | 139 | ///////////////////////////////////////////////////////////////////// | 
|---|
| [238] | 140 | typedef struct vobj_ref_s | 
|---|
|  | 141 | { | 
|---|
| [189] | 142 | char vspace_name[32]; | 
|---|
|  | 143 | char vobj_name[32]; | 
|---|
| [228] | 144 | } vobj_ref_t; | 
|---|
| [189] | 145 |  | 
|---|
| [228] | 146 | vobj_ref_t * cp_port_vobj_ref[MAX_CP_PORTS]; | 
|---|
| [189] | 147 |  | 
|---|
|  | 148 |  | 
|---|
| [158] | 149 | ////////////////////////////////////////////////// | 
|---|
| [238] | 150 | unsigned int getIntValue( xmlTextReaderPtr reader, | 
|---|
|  | 151 | const char * attributeName, | 
|---|
|  | 152 | unsigned int * ok) | 
|---|
|  | 153 | { | 
|---|
| [228] | 154 | unsigned int value = 0; | 
|---|
|  | 155 | unsigned int i; | 
|---|
|  | 156 | char c; | 
|---|
| [158] | 157 |  | 
|---|
| [238] | 158 | char * string = (char *) xmlTextReaderGetAttribute(reader, | 
|---|
|  | 159 | (const xmlChar *) attributeName); | 
|---|
| [158] | 160 |  | 
|---|
| [238] | 161 | if (string == NULL) | 
|---|
|  | 162 | { | 
|---|
| [228] | 163 | // missing argument | 
|---|
| [158] | 164 | *ok = 0; | 
|---|
|  | 165 | return 0; | 
|---|
|  | 166 | } | 
|---|
| [238] | 167 | else | 
|---|
|  | 168 | { | 
|---|
|  | 169 | if ((string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X'))) | 
|---|
|  | 170 | { | 
|---|
| [228] | 171 | // Hexa | 
|---|
| [238] | 172 | for (i = 2 ; (string[i] != 0) && (i < 10) ; i++) | 
|---|
|  | 173 | { | 
|---|
| [158] | 174 | c = string[i]; | 
|---|
| [228] | 175 | if      ((c >= '0') && (c <= '9')) { value = (value << 4) + string[i] - 48; } | 
|---|
|  | 176 | else if ((c >= 'a') && (c <= 'f')) { value = (value << 4) + string[i] - 87; } | 
|---|
|  | 177 | else if ((c >= 'A') && (c <= 'F')) { value = (value << 4) + string[i] - 55; } | 
|---|
| [238] | 178 | else | 
|---|
|  | 179 | { | 
|---|
| [158] | 180 | *ok = 0; | 
|---|
|  | 181 | return 0; | 
|---|
|  | 182 | } | 
|---|
|  | 183 | } | 
|---|
|  | 184 | } | 
|---|
| [238] | 185 | else | 
|---|
|  | 186 | { | 
|---|
| [228] | 187 | // Decimal | 
|---|
| [238] | 188 | for (i = 0; (string[i] != 0) && (i < 9); i++) | 
|---|
|  | 189 | { | 
|---|
| [158] | 190 | c = string[i]; | 
|---|
| [228] | 191 | if ((c >= '0') && (c <= '9')) value = (value * 10) + string[i] - 48; | 
|---|
| [238] | 192 | else | 
|---|
|  | 193 | { | 
|---|
| [158] | 194 | *ok = 0; | 
|---|
|  | 195 | return 0; | 
|---|
|  | 196 | } | 
|---|
|  | 197 | } | 
|---|
|  | 198 | } | 
|---|
|  | 199 | *ok = 1; | 
|---|
|  | 200 | return value; | 
|---|
|  | 201 | } | 
|---|
|  | 202 | } // end getIntValue() | 
|---|
|  | 203 |  | 
|---|
| [238] | 204 | //////////////////////////////////////////////// | 
|---|
|  | 205 | paddr_t getPaddrValue( xmlTextReaderPtr reader, | 
|---|
|  | 206 | const char * attributeName, | 
|---|
|  | 207 | unsigned int * ok) | 
|---|
|  | 208 | { | 
|---|
|  | 209 | paddr_t value = 0; | 
|---|
|  | 210 | unsigned int i; | 
|---|
|  | 211 | char c; | 
|---|
| [228] | 212 |  | 
|---|
| [238] | 213 | char * string = (char *) xmlTextReaderGetAttribute(reader, | 
|---|
|  | 214 | (const xmlChar *) attributeName); | 
|---|
| [158] | 215 |  | 
|---|
| [238] | 216 | if (string == NULL) | 
|---|
|  | 217 | { | 
|---|
|  | 218 | // missing argument | 
|---|
|  | 219 | *ok = 0; | 
|---|
|  | 220 | return 0; | 
|---|
|  | 221 | } | 
|---|
|  | 222 | else | 
|---|
|  | 223 | { | 
|---|
|  | 224 | if ((string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X'))) | 
|---|
|  | 225 | { | 
|---|
|  | 226 | // Hexa | 
|---|
|  | 227 | for (i = 2 ; (string[i] != 0) && (i < 18) ; i++) | 
|---|
|  | 228 | { | 
|---|
|  | 229 | c = string[i]; | 
|---|
|  | 230 | if      ((c >= '0') && (c <= '9')) { value = (value << 4) + string[i] - 48; } | 
|---|
|  | 231 | else if ((c >= 'a') && (c <= 'f')) { value = (value << 4) + string[i] - 87; } | 
|---|
|  | 232 | else if ((c >= 'A') && (c <= 'F')) { value = (value << 4) + string[i] - 55; } | 
|---|
|  | 233 | else | 
|---|
|  | 234 | { | 
|---|
|  | 235 | *ok = 0; | 
|---|
|  | 236 | return 0; | 
|---|
|  | 237 | } | 
|---|
|  | 238 | } | 
|---|
|  | 239 | } | 
|---|
|  | 240 | else | 
|---|
|  | 241 | { | 
|---|
|  | 242 | // Decimal not supported for paddr_t | 
|---|
|  | 243 | *ok = 0; | 
|---|
|  | 244 | return 0; | 
|---|
|  | 245 | } | 
|---|
|  | 246 | *ok = 1; | 
|---|
|  | 247 | return value; | 
|---|
|  | 248 | } | 
|---|
|  | 249 | } // end getPaddrValue() | 
|---|
| [228] | 250 |  | 
|---|
| [238] | 251 | //////////////////////////////////////////////// | 
|---|
|  | 252 | char * getStringValue( xmlTextReaderPtr reader, | 
|---|
|  | 253 | const char * attributeName, | 
|---|
|  | 254 | unsigned int * ok ) | 
|---|
|  | 255 | { | 
|---|
|  | 256 | char * string = (char *) xmlTextReaderGetAttribute(reader, | 
|---|
|  | 257 | (const xmlChar *) attributeName); | 
|---|
|  | 258 |  | 
|---|
|  | 259 |  | 
|---|
|  | 260 | if (string == NULL) | 
|---|
|  | 261 | { | 
|---|
| [228] | 262 | // missing argument | 
|---|
| [158] | 263 | *ok = 0; | 
|---|
|  | 264 | return NULL; | 
|---|
|  | 265 | } | 
|---|
| [238] | 266 | else | 
|---|
|  | 267 | { | 
|---|
| [215] | 268 | //we read only string smaller than 32 byte | 
|---|
| [238] | 269 | if (strlen(string) > 32) | 
|---|
|  | 270 | { | 
|---|
| [215] | 271 | printf("[XML ERROR] all strings must be less than 32 bytes\n"); | 
|---|
|  | 272 | exit(1); | 
|---|
|  | 273 | } | 
|---|
|  | 274 |  | 
|---|
| [158] | 275 | *ok = 1; | 
|---|
|  | 276 | return string; | 
|---|
|  | 277 | } | 
|---|
|  | 278 | } // end getStringValue() | 
|---|
|  | 279 |  | 
|---|
| [238] | 280 | /////////////////////////////////////////////////////// | 
|---|
|  | 281 | void set_periph_vbase_array( unsigned int vseg_index ) | 
|---|
|  | 282 | { | 
|---|
|  | 283 | unsigned int vbase  = vseg[vseg_index]->vbase;  // peripheral vbase address | 
|---|
|  | 284 | unsigned int psegid = vseg[vseg_index]->psegid; // pseg global index | 
|---|
|  | 285 | unsigned int type;                              // peripheral type | 
|---|
|  | 286 | unsigned int periph_id; | 
|---|
| [228] | 287 |  | 
|---|
| [238] | 288 | for ( periph_id = 0 ; periph_id < header->periphs ; periph_id++) | 
|---|
|  | 289 | { | 
|---|
|  | 290 | if( periph[periph_id]->psegid == psegid ) | 
|---|
|  | 291 | { | 
|---|
|  | 292 | type = periph[periph_id]->type; | 
|---|
|  | 293 | if ( periph_vbase_array[type] == 0xFFFFFFFF ) | 
|---|
|  | 294 | periph_vbase_array[type] = vbase; | 
|---|
|  | 295 | } | 
|---|
|  | 296 | } | 
|---|
|  | 297 | }  // end set_periph_vbase_array() | 
|---|
|  | 298 |  | 
|---|
|  | 299 | //////////////////////////////////////////////////////// | 
|---|
|  | 300 | int getPsegId(unsigned int cluster_id, char * pseg_name) | 
|---|
|  | 301 | { | 
|---|
| [158] | 302 | unsigned int pseg_id; | 
|---|
| [181] | 303 | unsigned int pseg_min = cluster[cluster_id]->pseg_offset; | 
|---|
|  | 304 | unsigned int pseg_max = pseg_min + cluster[cluster_id]->psegs; | 
|---|
| [158] | 305 |  | 
|---|
| [238] | 306 | for (pseg_id = pseg_min; pseg_id < pseg_max; pseg_id++) | 
|---|
|  | 307 | { | 
|---|
|  | 308 | if (strcmp(pseg[pseg_id]->name, pseg_name) == 0) | 
|---|
|  | 309 | { | 
|---|
| [215] | 310 | return pseg_id; | 
|---|
|  | 311 | } | 
|---|
| [158] | 312 | } | 
|---|
|  | 313 | return -1; | 
|---|
|  | 314 | } | 
|---|
|  | 315 |  | 
|---|
| [238] | 316 | /////////////////////////////////// | 
|---|
|  | 317 | int getVspaceId(char * vspace_name) | 
|---|
|  | 318 | { | 
|---|
| [181] | 319 | unsigned int vspace_id; | 
|---|
|  | 320 |  | 
|---|
| [238] | 321 | for (vspace_id = 0; vspace_id < vspace_index; vspace_id++) | 
|---|
|  | 322 | { | 
|---|
|  | 323 | if (strcmp(vspace[vspace_id]->name, vspace_name) == 0) | 
|---|
|  | 324 | { | 
|---|
| [181] | 325 | return vspace_id; | 
|---|
|  | 326 | } | 
|---|
|  | 327 | } | 
|---|
|  | 328 | return -1; | 
|---|
|  | 329 | } | 
|---|
|  | 330 |  | 
|---|
| [238] | 331 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 332 | int getVobjLocId(unsigned int vspace_id, char * vobj_name, unsigned int vspace_max) | 
|---|
|  | 333 | { | 
|---|
| [160] | 334 | unsigned int vobj_id; | 
|---|
|  | 335 | unsigned int vobj_min = vspace[vspace_id]->vobj_offset; | 
|---|
| [181] | 336 | unsigned int vobj_max = vobj_min + vspace_max; | 
|---|
| [158] | 337 |  | 
|---|
| [228] | 338 | for (vobj_id = vobj_min; vobj_id < vobj_max; vobj_id++) { | 
|---|
|  | 339 | if (strcmp(vobj[vobj_id]->name, vobj_name) == 0) { | 
|---|
|  | 340 | return (vobj_id - vobj_min); | 
|---|
| [160] | 341 | } | 
|---|
| [158] | 342 | } | 
|---|
|  | 343 | return -1; | 
|---|
|  | 344 | } | 
|---|
|  | 345 |  | 
|---|
| [228] | 346 |  | 
|---|
| [181] | 347 | ///////////////////////////////////////// | 
|---|
| [238] | 348 | void taskNode(xmlTextReaderPtr reader) | 
|---|
|  | 349 | { | 
|---|
| [228] | 350 | unsigned int ok; | 
|---|
|  | 351 | unsigned int value; | 
|---|
|  | 352 | char * str; | 
|---|
| [181] | 353 |  | 
|---|
| [238] | 354 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } | 
|---|
| [181] | 355 |  | 
|---|
| [238] | 356 | if (task_index >= MAX_TASKS) | 
|---|
|  | 357 | { | 
|---|
| [158] | 358 | printf("[XML ERROR] The number of tasks is larger than %d\n", MAX_TASKS); | 
|---|
|  | 359 | } | 
|---|
|  | 360 |  | 
|---|
|  | 361 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 362 | printf("   task %d\n", task_loc_index); | 
|---|
| [158] | 363 | #endif | 
|---|
|  | 364 |  | 
|---|
| [228] | 365 | task[task_index] = (mapping_task_t *) malloc(sizeof(mapping_task_t)); | 
|---|
| [158] | 366 |  | 
|---|
|  | 367 | ////////// get name attribute | 
|---|
|  | 368 | str = getStringValue(reader, "name", &ok); | 
|---|
| [238] | 369 | if (ok) | 
|---|
|  | 370 | { | 
|---|
| [158] | 371 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 372 | printf("      name = %s\n", str); | 
|---|
| [158] | 373 | #endif | 
|---|
|  | 374 | strncpy( task[task_index]->name, str, 31 ); | 
|---|
|  | 375 | } | 
|---|
| [238] | 376 | else | 
|---|
|  | 377 | { | 
|---|
| [158] | 378 | printf("[XML ERROR] illegal or missing <name> attribute for task (%d,%d)\n", | 
|---|
| [228] | 379 | vspace_index, task_loc_index); | 
|---|
| [158] | 380 | exit(1); | 
|---|
|  | 381 | } | 
|---|
|  | 382 |  | 
|---|
|  | 383 | ///////// get clusterid attribute | 
|---|
| [228] | 384 | value = getIntValue(reader, "clusterid", &ok); | 
|---|
| [238] | 385 | if (ok) | 
|---|
|  | 386 | { | 
|---|
| [158] | 387 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 388 | printf("      clusterid = %x\n", value); | 
|---|
| [158] | 389 | #endif | 
|---|
| [238] | 390 | if (value >= header->clusters) | 
|---|
|  | 391 | { | 
|---|
| [165] | 392 | printf("[XML ERROR] <clusterid> too large for task (%d,%d)\n", | 
|---|
| [228] | 393 | vspace_index, task_loc_index); | 
|---|
| [165] | 394 | exit(1); | 
|---|
|  | 395 | } | 
|---|
| [158] | 396 | task[task_index]->clusterid = value; | 
|---|
|  | 397 | } | 
|---|
| [238] | 398 | else | 
|---|
|  | 399 | { | 
|---|
| [158] | 400 | printf("[XML ERROR] illegal or missing <clusterid> attribute for task (%d,%d)\n", | 
|---|
| [228] | 401 | vspace_index, task_loc_index); | 
|---|
| [158] | 402 | exit(1); | 
|---|
|  | 403 | } | 
|---|
|  | 404 |  | 
|---|
|  | 405 | ////////// get proclocid attribute | 
|---|
| [228] | 406 | value = getIntValue(reader, "proclocid", &ok); | 
|---|
| [238] | 407 | if (ok) | 
|---|
|  | 408 | { | 
|---|
| [158] | 409 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 410 | printf("      proclocid = %x\n", value); | 
|---|
| [158] | 411 | #endif | 
|---|
| [238] | 412 | if (value >= cluster[task[task_index]->clusterid]->procs) | 
|---|
|  | 413 | { | 
|---|
| [165] | 414 | printf("[XML ERROR] <proclocid> too large for task (%d,%d)\n", | 
|---|
| [228] | 415 | vspace_index, task_loc_index); | 
|---|
| [165] | 416 | exit(1); | 
|---|
|  | 417 | } | 
|---|
| [158] | 418 | task[task_index]->proclocid = value; | 
|---|
|  | 419 | } | 
|---|
| [238] | 420 | else | 
|---|
|  | 421 | { | 
|---|
| [158] | 422 | printf("[XML ERROR] illegal or missing <locprocid> attribute for task (%d,%d)\n", | 
|---|
|  | 423 | vspace_index, task_loc_index); | 
|---|
|  | 424 | exit(1); | 
|---|
|  | 425 | } | 
|---|
|  | 426 |  | 
|---|
|  | 427 | ////////// get stackname attribute | 
|---|
|  | 428 | str = getStringValue(reader, "stackname" , &ok); | 
|---|
| [238] | 429 | if (ok) | 
|---|
|  | 430 | { | 
|---|
| [228] | 431 | int index = getVobjLocId(vspace_index, str , vobj_loc_index); | 
|---|
| [238] | 432 | if (index >= 0) | 
|---|
|  | 433 | { | 
|---|
| [158] | 434 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 435 | printf("      stackname = %s\n", str); | 
|---|
|  | 436 | printf("      stackid   = %d\n", index); | 
|---|
| [158] | 437 | #endif | 
|---|
| [232] | 438 | task[task_index]->stack_vobjid = index; | 
|---|
| [158] | 439 | } | 
|---|
| [238] | 440 | else | 
|---|
|  | 441 | { | 
|---|
| [165] | 442 | printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", | 
|---|
|  | 443 | vspace_index, task_loc_index); | 
|---|
| [158] | 444 | exit(1); | 
|---|
|  | 445 | } | 
|---|
|  | 446 | } | 
|---|
| [238] | 447 | else | 
|---|
|  | 448 | { | 
|---|
| [165] | 449 | printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", | 
|---|
| [158] | 450 | vspace_index, task_loc_index); | 
|---|
|  | 451 | exit(1); | 
|---|
|  | 452 | } | 
|---|
|  | 453 |  | 
|---|
| [232] | 454 | ////////// get heap attribute | 
|---|
|  | 455 | str = getStringValue(reader, "heapname", &ok); | 
|---|
| [238] | 456 | if (ok) | 
|---|
|  | 457 | { | 
|---|
| [232] | 458 | int index = getVobjLocId(vspace_index, str, vobj_loc_index); | 
|---|
| [238] | 459 | if (index >= 0) | 
|---|
|  | 460 | { | 
|---|
| [232] | 461 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 462 | printf("      heapname = %s\n", str); | 
|---|
|  | 463 | printf("      heapid   = %d\n", index); | 
|---|
| [232] | 464 | #endif | 
|---|
|  | 465 | task[task_index]->heap_vobjid = index; | 
|---|
|  | 466 | } | 
|---|
| [238] | 467 | else | 
|---|
|  | 468 | { | 
|---|
|  | 469 | printf("[XML ERROR] illegal or missing <heapname> for task (%d,%d)\n", | 
|---|
|  | 470 | vspace_index, task_loc_index); | 
|---|
| [232] | 471 | exit(1); | 
|---|
|  | 472 | } | 
|---|
|  | 473 | } | 
|---|
| [238] | 474 | else | 
|---|
|  | 475 | { | 
|---|
| [232] | 476 | task[task_index]->heap_vobjid = -1; | 
|---|
|  | 477 | } | 
|---|
|  | 478 |  | 
|---|
|  | 479 |  | 
|---|
| [158] | 480 | ////////// get startid  attribute | 
|---|
| [228] | 481 | value = getIntValue(reader, "startid", &ok); | 
|---|
| [238] | 482 | if (ok) | 
|---|
|  | 483 | { | 
|---|
| [158] | 484 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 485 | printf("      startid = %x\n", value); | 
|---|
| [158] | 486 | #endif | 
|---|
|  | 487 | task[task_index]->startid = value; | 
|---|
|  | 488 | } | 
|---|
| [238] | 489 | else | 
|---|
|  | 490 | { | 
|---|
| [158] | 491 | printf("[XML ERROR] illegal or missing <startid> attribute for task (%d,%d)\n", | 
|---|
|  | 492 | vspace_index, task_loc_index); | 
|---|
|  | 493 | exit(1); | 
|---|
|  | 494 | } | 
|---|
|  | 495 |  | 
|---|
| [189] | 496 | /////////// get usetty  attribute (optionnal : 0 if missing) | 
|---|
| [228] | 497 | value = getIntValue(reader, "usetty", &ok); | 
|---|
| [158] | 498 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 499 | printf("      usetty = %x\n", value); | 
|---|
| [158] | 500 | #endif | 
|---|
| [238] | 501 | task[task_index]->use_tty = (ok)? value : 0; | 
|---|
| [165] | 502 |  | 
|---|
| [189] | 503 | /////////// get usenic  attribute (optionnal : 0 if missing) | 
|---|
| [228] | 504 | value = getIntValue(reader, "usenic", &ok); | 
|---|
| [165] | 505 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 506 | printf("      usenic = %x\n", value); | 
|---|
| [165] | 507 | #endif | 
|---|
| [238] | 508 | task[task_index]->use_nic = (ok)? value : 0; | 
|---|
| [158] | 509 |  | 
|---|
| [238] | 510 | /////////// get usetim attribute (optionnal : 0 if missing) | 
|---|
|  | 511 | value = getIntValue(reader, "usetim", &ok); | 
|---|
| [189] | 512 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 513 | printf("      usetim = %x\n", value); | 
|---|
| [189] | 514 | #endif | 
|---|
| [238] | 515 | task[task_index]->use_tim = (ok)? value : 0; | 
|---|
| [189] | 516 |  | 
|---|
| [238] | 517 | /////////// get usedma  attribute (optionnal : 0 if missing) | 
|---|
|  | 518 | value = getIntValue(reader, "usedma", &ok); | 
|---|
| [189] | 519 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 520 | printf("      usedma = %x\n", value); | 
|---|
| [189] | 521 | #endif | 
|---|
| [238] | 522 | task[task_index]->use_dma = (ok)? value : 0; | 
|---|
| [189] | 523 |  | 
|---|
| [238] | 524 | /////////// get useioc  attribute (optionnal : 0 if missing) | 
|---|
|  | 525 | value = getIntValue(reader, "useioc", &ok); | 
|---|
|  | 526 | #if XML_PARSER_DEBUG | 
|---|
|  | 527 | printf("      useioc = %x\n", value); | 
|---|
|  | 528 | #endif | 
|---|
|  | 529 | task[task_index]->use_ioc = (ok)? value : 0; | 
|---|
|  | 530 |  | 
|---|
|  | 531 | /////////// get usecma  attribute (optionnal : 0 if missing) | 
|---|
|  | 532 | value = getIntValue(reader, "usecma", &ok); | 
|---|
|  | 533 | #if XML_PARSER_DEBUG | 
|---|
|  | 534 | printf("      usecma = %x\n", value); | 
|---|
|  | 535 | #endif | 
|---|
|  | 536 | task[task_index]->use_cma = (ok)? value : 0; | 
|---|
|  | 537 |  | 
|---|
| [158] | 538 | task_index++; | 
|---|
|  | 539 | task_loc_index++; | 
|---|
|  | 540 | } // end taskNode() | 
|---|
|  | 541 |  | 
|---|
| [228] | 542 |  | 
|---|
| [238] | 543 | ////////////////////////////////////// | 
|---|
|  | 544 | void vobjNode(xmlTextReaderPtr reader) | 
|---|
|  | 545 | { | 
|---|
| [228] | 546 | unsigned int ok; | 
|---|
|  | 547 | unsigned int value; | 
|---|
|  | 548 | char * str; | 
|---|
| [160] | 549 |  | 
|---|
| [238] | 550 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } | 
|---|
| [160] | 551 |  | 
|---|
| [238] | 552 | if (vobj_index >= MAX_VOBJS) | 
|---|
|  | 553 | { | 
|---|
|  | 554 | printf("[XML ERROR] The number of vobjs is larger than %d\n", MAX_VOBJS); | 
|---|
| [160] | 555 | exit(1); | 
|---|
|  | 556 | } | 
|---|
|  | 557 |  | 
|---|
|  | 558 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 559 | printf("      vobj %d\n", vobj_loc_index); | 
|---|
| [160] | 560 | #endif | 
|---|
|  | 561 |  | 
|---|
| [228] | 562 | vobj[vobj_index] = (mapping_vobj_t *) malloc(sizeof(mapping_vobj_t)); | 
|---|
| [160] | 563 |  | 
|---|
|  | 564 | ///////// get name attribute | 
|---|
|  | 565 | str = getStringValue(reader, "name", &ok); | 
|---|
| [238] | 566 | if (ok) | 
|---|
|  | 567 | { | 
|---|
| [160] | 568 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 569 | printf("        name = %s\n", str); | 
|---|
| [160] | 570 | #endif | 
|---|
| [228] | 571 | strncpy(vobj[vobj_index]->name, str, 31); | 
|---|
| [160] | 572 | } | 
|---|
| [238] | 573 | else | 
|---|
|  | 574 | { | 
|---|
| [160] | 575 | printf("[XML ERROR] illegal or missing <name> attribute for vobj (%d,%d)\n", | 
|---|
|  | 576 | vseg_index, vobj_loc_index); | 
|---|
|  | 577 | exit(1); | 
|---|
|  | 578 | } | 
|---|
|  | 579 |  | 
|---|
| [165] | 580 | //////// get type attribute | 
|---|
| [182] | 581 | str = getStringValue(reader, "type", &ok); | 
|---|
| [160] | 582 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 583 | printf("        type = %s\n", str); | 
|---|
| [160] | 584 | #endif | 
|---|
| [238] | 585 | if (ok && (strcmp(str, "ELF") == 0)) | 
|---|
|  | 586 | { | 
|---|
| [165] | 587 | vobj[vobj_index]->type = VOBJ_TYPE_ELF; | 
|---|
|  | 588 |  | 
|---|
| [238] | 589 | assert( (vobj_count == 0) && "[XML ERROR] an ELF vobj must be alone in a vseg"); | 
|---|
| [160] | 590 | } | 
|---|
| [238] | 591 | else if (ok && (strcmp(str, "PERI")     == 0)) | 
|---|
|  | 592 | { | 
|---|
|  | 593 | vobj[vobj_index]->type = VOBJ_TYPE_PERI; | 
|---|
|  | 594 |  | 
|---|
|  | 595 | assert( (vobj_count == 0) && "[XML ERROR] a PERI vobj must be alone in a vseg"); | 
|---|
|  | 596 |  | 
|---|
|  | 597 | // fill the peripheral base address array | 
|---|
|  | 598 | set_periph_vbase_array( vseg_index ); | 
|---|
|  | 599 | } | 
|---|
|  | 600 | else if (ok && (strcmp(str, "BLOB")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BLOB;     } | 
|---|
|  | 601 | else if (ok && (strcmp(str, "PTAB")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_PTAB;     } | 
|---|
|  | 602 | else if (ok && (strcmp(str, "MWMR")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MWMR;     } | 
|---|
|  | 603 | else if (ok && (strcmp(str, "LOCK")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_LOCK;     } | 
|---|
|  | 604 | else if (ok && (strcmp(str, "BUFFER")   == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BUFFER;   } | 
|---|
|  | 605 | else if (ok && (strcmp(str, "BARRIER")  == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BARRIER;  } | 
|---|
|  | 606 | else if (ok && (strcmp(str, "CONST")    == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_CONST;    } | 
|---|
| [228] | 607 | else if (ok && (strcmp(str, "MEMSPACE") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MEMSPACE; } | 
|---|
| [238] | 608 | else if (ok && (strcmp(str, "SCHED")    == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_SCHED;    } | 
|---|
|  | 609 | else | 
|---|
|  | 610 | { | 
|---|
| [160] | 611 | printf("[XML ERROR] illegal or missing <type> attribute for vobj (%d,%d)\n", | 
|---|
| [165] | 612 | vspace_index, vobj_loc_index); | 
|---|
| [160] | 613 | exit(1); | 
|---|
|  | 614 | } | 
|---|
|  | 615 |  | 
|---|
| [165] | 616 | ////////// get length attribute | 
|---|
| [228] | 617 | value = getIntValue(reader, "length", &ok); | 
|---|
|  | 618 | if (ok) { | 
|---|
| [160] | 619 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 620 | printf("        length = %d\n", value); | 
|---|
| [160] | 621 | #endif | 
|---|
|  | 622 | vobj[vobj_index]->length = value; | 
|---|
|  | 623 | } | 
|---|
| [228] | 624 | else { | 
|---|
| [165] | 625 | printf("[XML ERROR] illegal or missing <length> attribute for vobj (%d,%d)\n", | 
|---|
|  | 626 | vspace_index, vobj_loc_index); | 
|---|
|  | 627 | exit(1); | 
|---|
| [160] | 628 | } | 
|---|
|  | 629 |  | 
|---|
| [165] | 630 | ////////// get align attribute (optional : 0 if missing) | 
|---|
| [228] | 631 | value = getIntValue(reader, "align", &ok); | 
|---|
|  | 632 | if (ok) { | 
|---|
| [160] | 633 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 634 | printf("        align = %d\n", value); | 
|---|
| [160] | 635 | #endif | 
|---|
|  | 636 | vobj[vobj_index]->align = value; | 
|---|
|  | 637 | } | 
|---|
| [228] | 638 | else { | 
|---|
| [160] | 639 | vobj[vobj_index]->align = 0; | 
|---|
|  | 640 | } | 
|---|
|  | 641 |  | 
|---|
| [165] | 642 | ////////// get binpath attribute (optional : '\0' if missing) | 
|---|
| [160] | 643 | str = getStringValue(reader, "binpath", &ok); | 
|---|
| [228] | 644 | if (ok) { | 
|---|
| [160] | 645 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 646 | printf("        binpath = %s\n", str); | 
|---|
| [160] | 647 | #endif | 
|---|
|  | 648 | strncpy(vobj[vobj_index]->binpath, str, 63); | 
|---|
|  | 649 | } | 
|---|
| [228] | 650 | else { | 
|---|
| [160] | 651 | vobj[vobj_index]->binpath[0] = '\0'; | 
|---|
|  | 652 | } | 
|---|
| [228] | 653 |  | 
|---|
| [175] | 654 | ////////// get init attribute (mandatory for mwmr and barrier) | 
|---|
| [228] | 655 | value = getIntValue(reader, "init", &ok); | 
|---|
| [238] | 656 | if (ok) | 
|---|
|  | 657 | { | 
|---|
| [165] | 658 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 659 | printf("        init  = %d\n", value); | 
|---|
| [165] | 660 | #endif | 
|---|
|  | 661 | vobj[vobj_index]->init = value; | 
|---|
|  | 662 | } | 
|---|
| [238] | 663 | else | 
|---|
|  | 664 | { | 
|---|
| [228] | 665 | if ((vobj[vobj_index]->type == VOBJ_TYPE_MWMR) || | 
|---|
| [238] | 666 | (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) || | 
|---|
|  | 667 | (vobj[vobj_index]->type == VOBJ_TYPE_CONST)) | 
|---|
|  | 668 | { | 
|---|
| [181] | 669 | printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d). \ | 
|---|
| [238] | 670 | All MWMR or BARRIER or CONST vobj must have a init value \n", | 
|---|
| [181] | 671 | vspace_index, vobj_loc_index); | 
|---|
| [175] | 672 | exit(1); | 
|---|
|  | 673 | } | 
|---|
| [181] | 674 | vobj[vobj_index]->init = 0; | 
|---|
| [165] | 675 | } | 
|---|
|  | 676 |  | 
|---|
| [160] | 677 | vobj_index++; | 
|---|
| [165] | 678 | vobj_count++; | 
|---|
| [160] | 679 | vobj_loc_index++; | 
|---|
| [165] | 680 | } // end vobjNode() | 
|---|
| [160] | 681 |  | 
|---|
| [228] | 682 |  | 
|---|
| [238] | 683 | ////////////////////////////////////// | 
|---|
|  | 684 | void vsegNode(xmlTextReaderPtr reader) | 
|---|
|  | 685 | { | 
|---|
| [228] | 686 | unsigned int ok; | 
|---|
|  | 687 | unsigned int value; | 
|---|
|  | 688 | char * str; | 
|---|
| [158] | 689 |  | 
|---|
| [228] | 690 | vobj_count = 0; | 
|---|
| [165] | 691 |  | 
|---|
| [238] | 692 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } | 
|---|
| [158] | 693 |  | 
|---|
| [238] | 694 | if (vseg_index >= MAX_VSEGS) | 
|---|
|  | 695 | { | 
|---|
| [158] | 696 | printf("[XML ERROR] The number of vsegs is larger than %d\n", MAX_VSEGS); | 
|---|
|  | 697 | exit(1); | 
|---|
|  | 698 | } | 
|---|
|  | 699 |  | 
|---|
|  | 700 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 701 | printf("    vseg %d\n", vseg_loc_index); | 
|---|
| [158] | 702 | #endif | 
|---|
|  | 703 |  | 
|---|
| [228] | 704 | vseg[vseg_index] = (mapping_vseg_t *) malloc(sizeof(mapping_vseg_t)); | 
|---|
|  | 705 |  | 
|---|
| [160] | 706 | ////////// set vobj_offset attributes | 
|---|
|  | 707 | vseg[vseg_index]->vobj_offset = vobj_index; | 
|---|
| [238] | 708 |  | 
|---|
| [160] | 709 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 710 | printf("      vobj_offset = %d\n", vobj_index); | 
|---|
| [160] | 711 | #endif | 
|---|
| [158] | 712 |  | 
|---|
|  | 713 | ///////// get name attribute | 
|---|
|  | 714 | str = getStringValue(reader, "name", &ok); | 
|---|
| [238] | 715 | if (ok) | 
|---|
|  | 716 | { | 
|---|
| [158] | 717 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 718 | printf("      name = %s\n", str); | 
|---|
| [158] | 719 | #endif | 
|---|
|  | 720 | strncpy( vseg[vseg_index]->name, str, 31); | 
|---|
|  | 721 | } | 
|---|
| [238] | 722 | else | 
|---|
|  | 723 | { | 
|---|
| [158] | 724 | printf("[XML ERROR] illegal or missing <name> attribute for vseg (%d,%d)\n", | 
|---|
|  | 725 | vspace_index, vseg_loc_index); | 
|---|
|  | 726 | exit(1); | 
|---|
|  | 727 | } | 
|---|
|  | 728 |  | 
|---|
| [203] | 729 | ////////// get ident attribute (optional : 0 if missing) | 
|---|
| [228] | 730 | value = getIntValue(reader, "ident", &ok); | 
|---|
| [238] | 731 | if (ok) | 
|---|
|  | 732 | { | 
|---|
| [203] | 733 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 734 | printf("      ident = %d\n", value); | 
|---|
| [203] | 735 | #endif | 
|---|
|  | 736 | vseg[vseg_index]->ident = value; | 
|---|
|  | 737 | } | 
|---|
| [238] | 738 | else | 
|---|
|  | 739 | { | 
|---|
| [203] | 740 | vseg[vseg_index]->ident = 0; | 
|---|
|  | 741 | } | 
|---|
|  | 742 |  | 
|---|
| [158] | 743 | /////////// get vbase attribute | 
|---|
| [228] | 744 | value = getIntValue(reader, "vbase", &ok); | 
|---|
| [238] | 745 | if (ok) | 
|---|
|  | 746 | { | 
|---|
| [158] | 747 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 748 | printf("      vbase = 0x%x\n", value); | 
|---|
| [158] | 749 | #endif | 
|---|
|  | 750 | vseg[vseg_index]->vbase = value; | 
|---|
|  | 751 | } | 
|---|
| [238] | 752 | else | 
|---|
|  | 753 | { | 
|---|
| [158] | 754 | printf("[XML ERROR] illegal or missing <vbase> attribute for vseg (%d,%d)\n", | 
|---|
|  | 755 | vspace_index, vseg_loc_index); | 
|---|
|  | 756 | exit(1); | 
|---|
|  | 757 | } | 
|---|
|  | 758 |  | 
|---|
| [181] | 759 | ////////// get clusterid and psegname attributes | 
|---|
| [228] | 760 | value = getIntValue(reader, "clusterid", &ok); | 
|---|
| [238] | 761 | if (ok == 0) | 
|---|
|  | 762 | { | 
|---|
| [181] | 763 | printf("[XML ERROR] illegal or missing <clusterid> for vseg %d\n", | 
|---|
| [228] | 764 | vseg_loc_index); | 
|---|
| [181] | 765 | exit(1); | 
|---|
|  | 766 | } | 
|---|
| [228] | 767 | str = getStringValue(reader, "psegname", &ok); | 
|---|
| [238] | 768 | if (ok == 0) | 
|---|
|  | 769 | { | 
|---|
| [181] | 770 | printf("[XML ERROR] illegal or missing <psegname> for vseg %d\n", | 
|---|
| [228] | 771 | vseg_loc_index); | 
|---|
| [181] | 772 | exit(1); | 
|---|
|  | 773 | } | 
|---|
|  | 774 |  | 
|---|
|  | 775 | /////////// set psegid field | 
|---|
| [228] | 776 | int index = getPsegId(value, str); | 
|---|
| [238] | 777 | if (index >= 0) | 
|---|
|  | 778 | { | 
|---|
| [181] | 779 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 780 | printf("      clusterid = %d\n", value); | 
|---|
|  | 781 | printf("      psegname  = %s\n", str); | 
|---|
|  | 782 | printf("      psegid    = %d\n", index); | 
|---|
| [181] | 783 | #endif | 
|---|
|  | 784 | vseg[vseg_index]->psegid = index; | 
|---|
|  | 785 | } | 
|---|
| [238] | 786 | else | 
|---|
|  | 787 | { | 
|---|
| [181] | 788 | printf("[XML ERROR] pseg not found for vseg %d / clusterid = %d / psegname = %s\n", | 
|---|
| [228] | 789 | vseg_loc_index, value, str ); | 
|---|
| [181] | 790 | exit(1); | 
|---|
|  | 791 | } | 
|---|
|  | 792 |  | 
|---|
| [165] | 793 | //////// get mode attribute | 
|---|
| [228] | 794 | str = getStringValue(reader, "mode", &ok); | 
|---|
| [158] | 795 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 796 | printf("      mode = %s\n", str); | 
|---|
| [158] | 797 | #endif | 
|---|
| [228] | 798 | if      (ok && (strcmp(str, "CXWU") == 0)) { vseg[vseg_index]->mode = 0xF; } | 
|---|
|  | 799 | else if (ok && (strcmp(str, "CXW_") == 0)) { vseg[vseg_index]->mode = 0xE; } | 
|---|
|  | 800 | else if (ok && (strcmp(str, "CX_U") == 0)) { vseg[vseg_index]->mode = 0xD; } | 
|---|
|  | 801 | else if (ok && (strcmp(str, "CX__") == 0)) { vseg[vseg_index]->mode = 0xC; } | 
|---|
|  | 802 | else if (ok && (strcmp(str, "C_WU") == 0)) { vseg[vseg_index]->mode = 0xB; } | 
|---|
|  | 803 | else if (ok && (strcmp(str, "C_W_") == 0)) { vseg[vseg_index]->mode = 0xA; } | 
|---|
|  | 804 | else if (ok && (strcmp(str, "C__U") == 0)) { vseg[vseg_index]->mode = 0x9; } | 
|---|
|  | 805 | else if (ok && (strcmp(str, "C___") == 0)) { vseg[vseg_index]->mode = 0x8; } | 
|---|
|  | 806 | else if (ok && (strcmp(str, "_XWU") == 0)) { vseg[vseg_index]->mode = 0x7; } | 
|---|
|  | 807 | else if (ok && (strcmp(str, "_XW_") == 0)) { vseg[vseg_index]->mode = 0x6; } | 
|---|
|  | 808 | else if (ok && (strcmp(str, "_X_U") == 0)) { vseg[vseg_index]->mode = 0x5; } | 
|---|
|  | 809 | else if (ok && (strcmp(str, "_X__") == 0)) { vseg[vseg_index]->mode = 0x4; } | 
|---|
|  | 810 | else if (ok && (strcmp(str, "__WU") == 0)) { vseg[vseg_index]->mode = 0x3; } | 
|---|
|  | 811 | else if (ok && (strcmp(str, "__W_") == 0)) { vseg[vseg_index]->mode = 0x2; } | 
|---|
|  | 812 | else if (ok && (strcmp(str, "___U") == 0)) { vseg[vseg_index]->mode = 0x1; } | 
|---|
|  | 813 | else if (ok && (strcmp(str, "____") == 0)) { vseg[vseg_index]->mode = 0x0; } | 
|---|
|  | 814 | else { | 
|---|
| [158] | 815 | printf("[XML ERROR] illegal or missing <mode> attribute for vseg (%d,%d)\n", | 
|---|
|  | 816 | vspace_index, vseg_loc_index); | 
|---|
|  | 817 | exit(1); | 
|---|
|  | 818 | } | 
|---|
| [228] | 819 |  | 
|---|
| [181] | 820 | ////////// get vobjs in vseg | 
|---|
|  | 821 | int status = xmlTextReaderRead(reader); | 
|---|
| [228] | 822 | while (status == 1) { | 
|---|
|  | 823 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [160] | 824 |  | 
|---|
| [238] | 825 | if      (strcmp(tag, "vobj")     == 0 ) { vobjNode(reader); } | 
|---|
| [228] | 826 | else if (strcmp(tag, "#text"  )  == 0 ) { } | 
|---|
|  | 827 | else if (strcmp(tag, "#comment") == 0 ) { } | 
|---|
| [238] | 828 | else if (strcmp(tag, "vseg")     == 0 ) | 
|---|
|  | 829 | { | 
|---|
| [165] | 830 | vseg[vseg_index]->vobjs = vobj_count; | 
|---|
| [160] | 831 | vseg_index++; | 
|---|
|  | 832 | vseg_loc_index++; | 
|---|
|  | 833 | return; | 
|---|
|  | 834 | } | 
|---|
| [228] | 835 | else { | 
|---|
|  | 836 | printf("[XML ERROR] Unknown tag %s", tag); | 
|---|
| [160] | 837 | exit(1); | 
|---|
|  | 838 | } | 
|---|
| [228] | 839 | status = xmlTextReaderRead (reader); | 
|---|
| [160] | 840 | } | 
|---|
| [158] | 841 | } // end vsegNode() | 
|---|
|  | 842 |  | 
|---|
| [228] | 843 |  | 
|---|
| [158] | 844 | ////////////////////////////////////////// | 
|---|
| [228] | 845 | void vspaceNode(xmlTextReaderPtr reader) { | 
|---|
|  | 846 | char * str; | 
|---|
|  | 847 | unsigned int ok; | 
|---|
| [232] | 848 | unsigned int nb_task_vspace = 0; | 
|---|
| [165] | 849 |  | 
|---|
|  | 850 | vobj_loc_index = 0; | 
|---|
| [228] | 851 | vseg_loc_index = 0; | 
|---|
|  | 852 | task_loc_index = 0; | 
|---|
| [158] | 853 |  | 
|---|
| [228] | 854 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 855 | return; | 
|---|
|  | 856 | } | 
|---|
| [158] | 857 |  | 
|---|
|  | 858 | // checking source file consistency | 
|---|
| [228] | 859 | if (vspace_index >= header->vspaces) { | 
|---|
| [158] | 860 | printf("[XML ERROR] The vspace index is too large : %d\n", | 
|---|
| [228] | 861 | vspace_index); | 
|---|
| [158] | 862 | exit(1); | 
|---|
|  | 863 | } | 
|---|
|  | 864 |  | 
|---|
|  | 865 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 866 | printf("\n  vspace %d\n", vspace_index); | 
|---|
| [158] | 867 | #endif | 
|---|
|  | 868 |  | 
|---|
| [228] | 869 | vspace[vspace_index] = (mapping_vspace_t *) malloc(sizeof(mapping_vspace_t)); | 
|---|
| [158] | 870 |  | 
|---|
|  | 871 | ////////// get name attribute | 
|---|
|  | 872 | str = getStringValue(reader, "name", &ok); | 
|---|
| [228] | 873 | if (ok) { | 
|---|
| [158] | 874 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 875 | printf("  name = %s\n", str); | 
|---|
| [158] | 876 | #endif | 
|---|
|  | 877 | strncpy(vspace[vspace_index]->name, str, 31); | 
|---|
|  | 878 | } | 
|---|
| [228] | 879 | else { | 
|---|
| [165] | 880 | printf("[XML ERROR] illegal or missing <name> attribute for vspace %d\n", | 
|---|
| [228] | 881 | vspace_index); | 
|---|
| [158] | 882 | exit(1); | 
|---|
|  | 883 | } | 
|---|
|  | 884 |  | 
|---|
| [165] | 885 | ////////// set vseg_offset and task_offset attributes | 
|---|
|  | 886 | vspace[vspace_index]->vseg_offset = vseg_index; | 
|---|
|  | 887 | vspace[vspace_index]->vobj_offset = vobj_index; | 
|---|
|  | 888 | vspace[vspace_index]->task_offset = task_index; | 
|---|
| [228] | 889 |  | 
|---|
| [158] | 890 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 891 | printf("  vseg_offset = %d\n", vseg_index); | 
|---|
|  | 892 | printf("  vobj_offset = %d\n", vobj_index); | 
|---|
|  | 893 | printf("  task_offset = %d\n", task_index); | 
|---|
| [158] | 894 | #endif | 
|---|
|  | 895 |  | 
|---|
| [165] | 896 | ////////// get startname attribute | 
|---|
|  | 897 | str = getStringValue(reader, "startname", &ok); | 
|---|
| [228] | 898 | if (ok) { | 
|---|
| [165] | 899 | //used after parsing the vobjs | 
|---|
| [158] | 900 | } | 
|---|
| [228] | 901 | else { | 
|---|
| [203] | 902 | printf("[XML ERROR] illegal or missing <startname> attribute for vspace %s\n", | 
|---|
| [228] | 903 | vspace[vspace_index]->name); | 
|---|
| [158] | 904 | exit(1); | 
|---|
|  | 905 | } | 
|---|
|  | 906 |  | 
|---|
| [181] | 907 | int status = xmlTextReaderRead(reader); | 
|---|
| [228] | 908 | while (status == 1) { | 
|---|
|  | 909 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [158] | 910 |  | 
|---|
| [230] | 911 | if (strcmp(tag, "vseg") == 0) { | 
|---|
| [228] | 912 | vsegNode(reader); | 
|---|
|  | 913 | } | 
|---|
| [230] | 914 | else if (strcmp(tag, "task") == 0) { | 
|---|
| [228] | 915 | taskNode(reader); | 
|---|
| [232] | 916 | nb_task_vspace++; | 
|---|
| [228] | 917 | } | 
|---|
| [230] | 918 | else if (strcmp(tag, "#text")    == 0) { } | 
|---|
|  | 919 | else if (strcmp(tag, "#comment") == 0) { } | 
|---|
|  | 920 | else if (strcmp(tag, "vspace")   == 0) { | 
|---|
| [181] | 921 | vspace[vspace_index]->vobjs = vobj_loc_index; | 
|---|
| [160] | 922 | vspace[vspace_index]->tasks = task_loc_index ; | 
|---|
|  | 923 | vspace[vspace_index]->vsegs = vseg_loc_index ; | 
|---|
| [165] | 924 |  | 
|---|
|  | 925 | // get index of the vobj containing the start vector | 
|---|
| [228] | 926 | int index = getVobjLocId(vspace_index, str , vobj_loc_index); | 
|---|
|  | 927 | if (index == -1) { | 
|---|
| [203] | 928 | printf("[XML ERROR] vobj containing start vector not found in vspace %s\n", | 
|---|
|  | 929 | vspace[vspace_index]->name); | 
|---|
| [160] | 930 | exit(-1); | 
|---|
| [158] | 931 | } | 
|---|
| [228] | 932 | else { | 
|---|
| [165] | 933 | vspace[vspace_index]->start_offset = index; | 
|---|
|  | 934 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 935 | printf("      startname = %s\n", str); | 
|---|
|  | 936 | printf("      startid   = %d\n", index); | 
|---|
|  | 937 | printf("  end vspace %d\n\n", vspace_index); | 
|---|
| [165] | 938 | #endif | 
|---|
|  | 939 | } | 
|---|
| [160] | 940 |  | 
|---|
| [165] | 941 | // checking startid values for all tasks in vspace | 
|---|
|  | 942 | int task_id; | 
|---|
|  | 943 | int task_min = vspace[vspace_index]->task_offset; | 
|---|
|  | 944 | int task_max = task_min + vspace[vspace_index]->tasks; | 
|---|
| [228] | 945 | for (task_id = task_min; task_id < task_max; task_id++) { | 
|---|
|  | 946 | if (task[task_id]->startid >= vspace[vspace_index]->tasks) { | 
|---|
| [165] | 947 | printf("[XML ERROR] <startid> too large for task (%d,%d)\n", | 
|---|
| [228] | 948 | vspace_index, task_id ); | 
|---|
| [165] | 949 | exit(1); | 
|---|
|  | 950 | } | 
|---|
|  | 951 | } | 
|---|
|  | 952 |  | 
|---|
| [232] | 953 | nb_tasks_max += nb_task_vspace; | 
|---|
| [160] | 954 | vspace_index++; | 
|---|
|  | 955 | return; | 
|---|
| [158] | 956 | } | 
|---|
| [228] | 957 | else { | 
|---|
|  | 958 | printf("[XML ERROR] Unknown tag %s", tag); | 
|---|
| [158] | 959 | exit(1); | 
|---|
|  | 960 | } | 
|---|
| [228] | 961 | status = xmlTextReaderRead(reader); | 
|---|
| [158] | 962 | } | 
|---|
|  | 963 | } // end vspaceNode() | 
|---|
|  | 964 |  | 
|---|
| [228] | 965 |  | 
|---|
| [215] | 966 | /////////////////////////////////////////// | 
|---|
| [228] | 967 | void cpPortNode(xmlTextReaderPtr reader) { | 
|---|
|  | 968 | char * str; | 
|---|
|  | 969 | unsigned int ok; | 
|---|
| [215] | 970 |  | 
|---|
| [228] | 971 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 972 | return; | 
|---|
|  | 973 | } | 
|---|
| [215] | 974 |  | 
|---|
| [228] | 975 | if (cp_port_index >= MAX_CP_PORTS) { | 
|---|
| [215] | 976 | printf("[XML ERROR] The number of ports (for coprocs) is larger than %d\n", MAX_CP_PORTS); | 
|---|
|  | 977 | } | 
|---|
|  | 978 |  | 
|---|
|  | 979 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 980 | printf("\n  port %d\n", cp_port_index); | 
|---|
| [215] | 981 | #endif | 
|---|
|  | 982 |  | 
|---|
| [228] | 983 | cp_port[cp_port_index] = (mapping_cp_port_t *) malloc(sizeof(mapping_cp_port_t)); | 
|---|
|  | 984 | cp_port_vobj_ref[cp_port_index] = (vobj_ref_t *) malloc(sizeof(vobj_ref_t)); | 
|---|
| [215] | 985 |  | 
|---|
|  | 986 |  | 
|---|
| [228] | 987 |  | 
|---|
| [215] | 988 | ///////// get direction attribute | 
|---|
| [228] | 989 | str = getStringValue(reader, "direction", &ok); | 
|---|
|  | 990 | if (ok) { | 
|---|
| [215] | 991 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 992 | printf("      direction = %s\n", str); | 
|---|
| [215] | 993 | #endif | 
|---|
| [228] | 994 | if (strcmp(str, "TO_COPROC")   ==  0) { | 
|---|
|  | 995 | cp_port[cp_port_index]->direction = PORT_TO_COPROC; | 
|---|
|  | 996 | } | 
|---|
|  | 997 | else if (strcmp(str, "FROM_COPROC") ==  0) { | 
|---|
|  | 998 | cp_port[cp_port_index]->direction = PORT_FROM_COPROC; | 
|---|
|  | 999 | } | 
|---|
|  | 1000 | else { | 
|---|
| [215] | 1001 | printf("[XML ERROR] illegal <direction> for cp_port %d in cluster %d\n", | 
|---|
| [228] | 1002 | cp_port_index, cluster_index); | 
|---|
| [215] | 1003 | exit(1); | 
|---|
|  | 1004 | } | 
|---|
|  | 1005 | } | 
|---|
| [228] | 1006 | else { | 
|---|
| [215] | 1007 | printf("[XML ERROR] missing <direction> for cp_port %d in cluster %d\n", | 
|---|
| [228] | 1008 | cp_port_index, cluster_index); | 
|---|
| [215] | 1009 | exit(1); | 
|---|
|  | 1010 | } | 
|---|
| [228] | 1011 |  | 
|---|
| [215] | 1012 | /////////// get vspacename attribute | 
|---|
| [228] | 1013 | str = getStringValue(reader, "vspacename", &ok); | 
|---|
| [215] | 1014 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1015 | printf("      vspacename = %s\n", str); | 
|---|
| [215] | 1016 | #endif | 
|---|
| [228] | 1017 | if (ok) { | 
|---|
| [215] | 1018 | strncpy(cp_port_vobj_ref[cp_port_index]->vspace_name, str, 31); | 
|---|
|  | 1019 | } | 
|---|
| [228] | 1020 | else { | 
|---|
| [215] | 1021 | printf("[XML ERROR] missing <vspacename> for cp_port %d in cluster %d\n", | 
|---|
| [228] | 1022 | cp_port_index, cluster_index); | 
|---|
| [215] | 1023 | exit(1); | 
|---|
|  | 1024 | } | 
|---|
|  | 1025 |  | 
|---|
|  | 1026 | /////////// get vobjname attribute | 
|---|
| [228] | 1027 | str = getStringValue(reader, "vobjname", &ok); | 
|---|
| [215] | 1028 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1029 | printf("      vobjname = %s\n", str); | 
|---|
| [215] | 1030 | #endif | 
|---|
| [228] | 1031 | if (ok) { | 
|---|
| [215] | 1032 | strncpy(cp_port_vobj_ref[cp_port_index]->vobj_name, str, 31); | 
|---|
|  | 1033 | } | 
|---|
| [228] | 1034 | else { | 
|---|
| [215] | 1035 | printf("[XML ERROR] missing <vobjname> for cp_port %d in cluster %d\n", | 
|---|
| [228] | 1036 | cp_port_index, cluster_index); | 
|---|
| [215] | 1037 | exit(1); | 
|---|
|  | 1038 | } | 
|---|
| [228] | 1039 |  | 
|---|
| [215] | 1040 | cp_port_index++; | 
|---|
|  | 1041 | cp_port_loc_index++; | 
|---|
|  | 1042 |  | 
|---|
|  | 1043 | } // end cpPortNode() | 
|---|
|  | 1044 |  | 
|---|
| [228] | 1045 |  | 
|---|
| [238] | 1046 | //////////////////////////////////////// | 
|---|
|  | 1047 | void periphNode(xmlTextReaderPtr reader) | 
|---|
|  | 1048 | { | 
|---|
| [228] | 1049 | char * str; | 
|---|
|  | 1050 | unsigned int value; | 
|---|
|  | 1051 | unsigned int ok; | 
|---|
| [215] | 1052 |  | 
|---|
| [238] | 1053 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } | 
|---|
| [215] | 1054 |  | 
|---|
| [238] | 1055 | if (periph_index >= MAX_PERIPHS) | 
|---|
|  | 1056 | { | 
|---|
| [215] | 1057 | printf("[XML ERROR] The number of periphs is larger than %d\n", MAX_PERIPHS); | 
|---|
|  | 1058 | } | 
|---|
|  | 1059 |  | 
|---|
|  | 1060 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1061 | printf("\n  periph %d\n", periph_index); | 
|---|
| [215] | 1062 | #endif | 
|---|
|  | 1063 |  | 
|---|
| [228] | 1064 | periph[periph_index] = (mapping_periph_t *) malloc(sizeof(mapping_periph_t)); | 
|---|
| [215] | 1065 |  | 
|---|
|  | 1066 | ///////// get channels attribute (optionnal : 1 if missing) | 
|---|
| [228] | 1067 | value = getIntValue(reader, "channels", &ok); | 
|---|
| [238] | 1068 | if (ok) | 
|---|
|  | 1069 | { | 
|---|
| [215] | 1070 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1071 | printf("      channels = %d\n", value); | 
|---|
| [215] | 1072 | #endif | 
|---|
|  | 1073 | periph[periph_index]->channels = value; | 
|---|
|  | 1074 | } | 
|---|
| [238] | 1075 | else | 
|---|
|  | 1076 | { | 
|---|
| [215] | 1077 | periph[periph_index]->channels = 1; | 
|---|
|  | 1078 | } | 
|---|
|  | 1079 |  | 
|---|
|  | 1080 | /////////// get psegname attribute | 
|---|
| [228] | 1081 | str = getStringValue(reader, "psegname", &ok); | 
|---|
| [238] | 1082 | if (ok == 0) | 
|---|
|  | 1083 | { | 
|---|
| [215] | 1084 | printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", | 
|---|
| [228] | 1085 | coproc_index, cluster_index); | 
|---|
| [215] | 1086 | exit(1); | 
|---|
|  | 1087 | } | 
|---|
|  | 1088 |  | 
|---|
|  | 1089 | /////////// set psegid attribute | 
|---|
| [228] | 1090 | int index = getPsegId(cluster_index, str); | 
|---|
| [238] | 1091 | if (index >= 0) | 
|---|
|  | 1092 | { | 
|---|
| [215] | 1093 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1094 | printf("      clusterid = %d\n", cluster_index); | 
|---|
|  | 1095 | printf("      psegname  = %s\n", str); | 
|---|
|  | 1096 | printf("      psegid    = %d\n", index); | 
|---|
| [215] | 1097 | #endif | 
|---|
|  | 1098 | periph[periph_index]->psegid = index; | 
|---|
|  | 1099 | assert(pseg[index]->type == PSEG_TYPE_PERI && | 
|---|
| [228] | 1100 | "peripheral psegname attribute must refer to a pseg of type PERI" ); | 
|---|
| [215] | 1101 | } | 
|---|
| [238] | 1102 | else | 
|---|
|  | 1103 | { | 
|---|
| [215] | 1104 | printf("[XML ERROR] pseg not found for periph %d / clusterid = %d / psegname = %s\n", | 
|---|
| [228] | 1105 | periph_loc_index, cluster_index, str ); | 
|---|
| [215] | 1106 | exit(1); | 
|---|
|  | 1107 | } | 
|---|
|  | 1108 |  | 
|---|
|  | 1109 | /////////// get type attribute | 
|---|
| [228] | 1110 | str = getStringValue(reader, "type", &ok); | 
|---|
| [238] | 1111 | if (ok) | 
|---|
|  | 1112 | { | 
|---|
| [215] | 1113 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1114 | printf("      type     = %s\n", str); | 
|---|
| [215] | 1115 | #endif | 
|---|
|  | 1116 | unsigned int error = 0; | 
|---|
| [228] | 1117 |  | 
|---|
| [238] | 1118 | // The TTY, IOC, NIC, FBF, CMA and IOB peripherals are not replicated in all clusters | 
|---|
|  | 1119 | // but can be replicated in two different clusters for fault tolerance | 
|---|
|  | 1120 | // In case of replication, the number of channels must be the same | 
|---|
|  | 1121 | if (strcmp(str, "IOC") == 0) | 
|---|
|  | 1122 | { | 
|---|
| [215] | 1123 | periph[periph_index]->type = PERIPH_TYPE_IOC; | 
|---|
| [238] | 1124 | if (header->ioc_cluster == 0xFFFFFFFF) | 
|---|
|  | 1125 | { | 
|---|
|  | 1126 | header->ioc_cluster  = cluster_index; | 
|---|
|  | 1127 | ioc_channels = periph[periph_index]->channels; | 
|---|
| [228] | 1128 | } | 
|---|
| [238] | 1129 | else if (header->ioc_cluster_bis == 0xFFFFFFFF) | 
|---|
|  | 1130 | { | 
|---|
|  | 1131 | header->ioc_cluster_bis = cluster_index; | 
|---|
|  | 1132 | } | 
|---|
|  | 1133 | else | 
|---|
|  | 1134 | { | 
|---|
| [228] | 1135 | error = 1; | 
|---|
|  | 1136 | } | 
|---|
| [215] | 1137 | } | 
|---|
| [238] | 1138 | else if (strcmp(str, "TTY") == 0) | 
|---|
|  | 1139 | { | 
|---|
| [215] | 1140 | periph[periph_index]->type = PERIPH_TYPE_TTY; | 
|---|
| [238] | 1141 | if (header->tty_cluster == 0xFFFFFFFF) | 
|---|
|  | 1142 | { | 
|---|
|  | 1143 | header->tty_cluster = cluster_index; | 
|---|
|  | 1144 | tty_channels = periph[periph_index]->channels; | 
|---|
| [228] | 1145 | } | 
|---|
| [238] | 1146 | else if (header->tty_cluster_bis == 0xFFFFFFFF) | 
|---|
|  | 1147 | { | 
|---|
|  | 1148 | header->tty_cluster_bis = cluster_index; | 
|---|
|  | 1149 | } | 
|---|
|  | 1150 | else | 
|---|
|  | 1151 | { | 
|---|
| [228] | 1152 | error = 1; | 
|---|
|  | 1153 | } | 
|---|
| [215] | 1154 | } | 
|---|
| [238] | 1155 | else if (strcmp(str, "FBF") == 0) | 
|---|
|  | 1156 | { | 
|---|
| [215] | 1157 | periph[periph_index]->type = PERIPH_TYPE_FBF; | 
|---|
| [238] | 1158 | if (header->fbf_cluster == 0xFFFFFFFF) | 
|---|
|  | 1159 | { | 
|---|
|  | 1160 | header->fbf_cluster = cluster_index; | 
|---|
| [228] | 1161 | } | 
|---|
| [238] | 1162 | else if (header->fbf_cluster_bis == 0xFFFFFFFF) | 
|---|
|  | 1163 | { | 
|---|
|  | 1164 | header->fbf_cluster_bis = cluster_index; | 
|---|
|  | 1165 | } | 
|---|
|  | 1166 | else | 
|---|
|  | 1167 | { | 
|---|
| [228] | 1168 | error = 1; | 
|---|
|  | 1169 | } | 
|---|
| [215] | 1170 | } | 
|---|
| [238] | 1171 | else if (strcmp(str, "NIC") == 0) | 
|---|
|  | 1172 | { | 
|---|
| [215] | 1173 | periph[periph_index]->type = PERIPH_TYPE_NIC; | 
|---|
| [238] | 1174 | if (header->nic_cluster == 0xFFFFFFFF) | 
|---|
|  | 1175 | { | 
|---|
|  | 1176 | header->nic_cluster = cluster_index; | 
|---|
|  | 1177 | nic_channels = periph[periph_index]->channels; | 
|---|
| [228] | 1178 | } | 
|---|
| [238] | 1179 | else if (header->nic_cluster_bis == 0xFFFFFFFF) | 
|---|
|  | 1180 | { | 
|---|
|  | 1181 | header->nic_cluster_bis = cluster_index; | 
|---|
|  | 1182 | } | 
|---|
|  | 1183 | else | 
|---|
|  | 1184 | { | 
|---|
| [228] | 1185 | error = 1; | 
|---|
|  | 1186 | } | 
|---|
| [215] | 1187 | } | 
|---|
| [238] | 1188 | else if (strcmp(str, "CMA") == 0) | 
|---|
|  | 1189 | { | 
|---|
|  | 1190 | periph[periph_index]->type = PERIPH_TYPE_CMA; | 
|---|
|  | 1191 | if (header->cma_cluster == 0xFFFFFFFF) | 
|---|
|  | 1192 | { | 
|---|
|  | 1193 | header->cma_cluster = cluster_index; | 
|---|
|  | 1194 | cma_channels = periph[periph_index]->channels; | 
|---|
|  | 1195 | } | 
|---|
|  | 1196 | else if (header->nic_cluster_bis == 0xFFFFFFFF) | 
|---|
|  | 1197 | { | 
|---|
|  | 1198 | header->cma_cluster_bis = cluster_index; | 
|---|
|  | 1199 | } | 
|---|
|  | 1200 | else | 
|---|
|  | 1201 | { | 
|---|
|  | 1202 | error = 1; | 
|---|
|  | 1203 | } | 
|---|
|  | 1204 | } | 
|---|
|  | 1205 | else if (strcmp(str, "IOB") == 0) | 
|---|
|  | 1206 | { | 
|---|
| [215] | 1207 | periph[periph_index]->type = PERIPH_TYPE_IOB; | 
|---|
| [249] | 1208 | use_iob = 1; | 
|---|
| [238] | 1209 | if (header->iob_cluster == 0xFFFFFFFF) | 
|---|
|  | 1210 | { | 
|---|
|  | 1211 | header->iob_cluster = cluster_index; | 
|---|
|  | 1212 | } | 
|---|
|  | 1213 | else if (header->iob_cluster_bis == 0xFFFFFFFF) | 
|---|
|  | 1214 | { | 
|---|
|  | 1215 | header->iob_cluster_bis = cluster_index; | 
|---|
|  | 1216 | } | 
|---|
|  | 1217 | else | 
|---|
|  | 1218 | { | 
|---|
| [228] | 1219 | error = 1; | 
|---|
|  | 1220 | } | 
|---|
| [215] | 1221 | } | 
|---|
| [249] | 1222 | // The TIM, ICU, XICU, DMA, MEMC peripherals are replicated in all clusters | 
|---|
| [238] | 1223 | // but only one component per cluster | 
|---|
|  | 1224 | else if (strcmp(str, "TIM") == 0 ) | 
|---|
|  | 1225 | { | 
|---|
| [215] | 1226 | periph[periph_index]->type = PERIPH_TYPE_TIM; | 
|---|
| [238] | 1227 | if (found_timer || use_xicu)  error = 1; | 
|---|
| [215] | 1228 | found_timer = 1; | 
|---|
| [238] | 1229 | if (tim_channels < periph[periph_index]->channels) | 
|---|
|  | 1230 | { | 
|---|
|  | 1231 | tim_channels = periph[periph_index]->channels; | 
|---|
| [228] | 1232 | } | 
|---|
| [215] | 1233 | } | 
|---|
| [238] | 1234 | else if (strcmp(str, "ICU") == 0) | 
|---|
|  | 1235 | { | 
|---|
| [215] | 1236 | periph[periph_index]->type = PERIPH_TYPE_ICU; | 
|---|
| [238] | 1237 | if (found_icu)  error = 1; | 
|---|
| [215] | 1238 | found_icu = 1; | 
|---|
|  | 1239 | } | 
|---|
| [238] | 1240 | else if (strcmp(str, "XICU") == 0) | 
|---|
|  | 1241 | { | 
|---|
|  | 1242 | periph[periph_index]->type = PERIPH_TYPE_ICU; | 
|---|
|  | 1243 | if (found_icu || found_timer)  error = 1; | 
|---|
|  | 1244 | found_icu = 1; | 
|---|
|  | 1245 | if (tim_channels == 0) | 
|---|
|  | 1246 | { | 
|---|
|  | 1247 | tim_channels = 32; | 
|---|
| [228] | 1248 | } | 
|---|
| [238] | 1249 | use_xicu = 1; | 
|---|
| [215] | 1250 | } | 
|---|
| [238] | 1251 | else if (strcmp(str, "DMA") == 0) | 
|---|
|  | 1252 | { | 
|---|
| [215] | 1253 | periph[periph_index]->type = PERIPH_TYPE_DMA; | 
|---|
| [238] | 1254 | if (found_dma)  error = 1; | 
|---|
| [215] | 1255 | found_dma = 1; | 
|---|
| [238] | 1256 | if (dma_channels < periph[periph_index]->channels) | 
|---|
|  | 1257 | dma_channels = periph[periph_index]->channels; | 
|---|
| [215] | 1258 | } | 
|---|
| [249] | 1259 | else if (strcmp(str, "MMC") == 0) | 
|---|
|  | 1260 | { | 
|---|
|  | 1261 | periph[periph_index]->type = PERIPH_TYPE_MMC; | 
|---|
|  | 1262 | if (found_mmc)  error = 1; | 
|---|
|  | 1263 | found_mmc = 1; | 
|---|
|  | 1264 | if ( periph[periph_index]->channels != 1 ) error = 1; | 
|---|
|  | 1265 | } | 
|---|
| [238] | 1266 | else | 
|---|
|  | 1267 | { | 
|---|
| [215] | 1268 | printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n", | 
|---|
| [228] | 1269 | periph_loc_index, cluster_index); | 
|---|
| [215] | 1270 | exit(1); | 
|---|
|  | 1271 | } | 
|---|
|  | 1272 |  | 
|---|
| [238] | 1273 | if (error) | 
|---|
|  | 1274 | { | 
|---|
| [215] | 1275 | printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n", | 
|---|
| [228] | 1276 | periph_loc_index, cluster_index); | 
|---|
| [215] | 1277 | exit(1); | 
|---|
|  | 1278 | } | 
|---|
|  | 1279 | } | 
|---|
| [238] | 1280 | else | 
|---|
|  | 1281 | { | 
|---|
| [215] | 1282 | printf("[XML ERROR] missing <type> for peripheral  %d in cluster %d\n", | 
|---|
| [228] | 1283 | periph_loc_index, cluster_index); | 
|---|
| [215] | 1284 | exit(1); | 
|---|
|  | 1285 | } | 
|---|
|  | 1286 |  | 
|---|
|  | 1287 | periph_index++; | 
|---|
|  | 1288 | periph_loc_index++; | 
|---|
|  | 1289 | cluster[cluster_index]->periphs++; | 
|---|
|  | 1290 |  | 
|---|
|  | 1291 | } // end periphNode | 
|---|
|  | 1292 |  | 
|---|
| [228] | 1293 |  | 
|---|
| [215] | 1294 | ///////////////////////////////////////// | 
|---|
| [228] | 1295 | void coprocNode(xmlTextReaderPtr reader) { | 
|---|
|  | 1296 | char * str; | 
|---|
|  | 1297 | unsigned int ok; | 
|---|
| [215] | 1298 |  | 
|---|
|  | 1299 | cp_port_loc_index = 0; | 
|---|
|  | 1300 |  | 
|---|
| [228] | 1301 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 1302 | return; | 
|---|
|  | 1303 | } | 
|---|
| [215] | 1304 |  | 
|---|
| [228] | 1305 | if (coproc_index >= MAX_COPROCS) { | 
|---|
| [215] | 1306 | printf("[XML ERROR] The number of coprocs is larger than %d\n", MAX_COPROCS); | 
|---|
|  | 1307 | } | 
|---|
|  | 1308 |  | 
|---|
|  | 1309 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1310 | printf("\n  coproc %d\n", coproc_index); | 
|---|
| [215] | 1311 | #endif | 
|---|
|  | 1312 |  | 
|---|
| [228] | 1313 | coproc[coproc_index] = (mapping_coproc_t *) malloc(sizeof(mapping_coproc_t)); | 
|---|
| [215] | 1314 |  | 
|---|
|  | 1315 | /////////// get name attribute | 
|---|
| [228] | 1316 | str = getStringValue(reader, "name", &ok); | 
|---|
|  | 1317 | if (ok) { | 
|---|
| [215] | 1318 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1319 | printf("      name = %s\n", str); | 
|---|
| [215] | 1320 | #endif | 
|---|
|  | 1321 | strncpy(coproc[coproc_index]->name, str, 31); | 
|---|
|  | 1322 | } | 
|---|
| [228] | 1323 | else { | 
|---|
| [215] | 1324 | printf("[XML ERROR] illegal or missing <name> for coproc %d in cluster %d\n", | 
|---|
| [228] | 1325 | coproc_index, cluster_index); | 
|---|
| [215] | 1326 | exit(1); | 
|---|
|  | 1327 | } | 
|---|
|  | 1328 |  | 
|---|
|  | 1329 | /////////// get psegname attribute | 
|---|
| [228] | 1330 | str = getStringValue(reader, "psegname", &ok); | 
|---|
|  | 1331 | if (ok == 0) { | 
|---|
| [215] | 1332 | printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", | 
|---|
| [228] | 1333 | coproc_index, cluster_index); | 
|---|
| [215] | 1334 | exit(1); | 
|---|
|  | 1335 | } | 
|---|
|  | 1336 |  | 
|---|
|  | 1337 | /////////// set psegid attribute | 
|---|
| [228] | 1338 | int index = getPsegId(cluster_index, str); | 
|---|
|  | 1339 | if (index >= 0) { | 
|---|
| [215] | 1340 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1341 | printf("      clusterid = %d\n", cluster_index); | 
|---|
|  | 1342 | printf("      psegname  = %s\n", str); | 
|---|
|  | 1343 | printf("      psegid    = %d\n", index); | 
|---|
| [215] | 1344 | #endif | 
|---|
|  | 1345 | coproc[coproc_index]->psegid = index; | 
|---|
|  | 1346 | assert(pseg[index]->type == PSEG_TYPE_PERI && "coproc psegname attribute must refer to a pseg of type PERI" ); | 
|---|
|  | 1347 | } | 
|---|
| [228] | 1348 | else { | 
|---|
| [215] | 1349 | printf("[XML ERROR] pseg not found for coproc %d / clusterid = %d / psegname = %s\n", | 
|---|
| [228] | 1350 | coproc_index, cluster_index, str ); | 
|---|
| [215] | 1351 | exit(1); | 
|---|
|  | 1352 | } | 
|---|
|  | 1353 |  | 
|---|
|  | 1354 | ////////// set port_offset | 
|---|
|  | 1355 | coproc[coproc_index]->port_offset = cp_port_index; | 
|---|
|  | 1356 |  | 
|---|
|  | 1357 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1358 | printf("      port_offset = %d\n", cp_port_index); | 
|---|
| [215] | 1359 | #endif | 
|---|
|  | 1360 |  | 
|---|
|  | 1361 | int status = xmlTextReaderRead(reader); | 
|---|
| [228] | 1362 | while (status == 1) { | 
|---|
|  | 1363 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [215] | 1364 |  | 
|---|
| [228] | 1365 | if (strcmp(tag, "port") == 0 ) { | 
|---|
|  | 1366 | cpPortNode(reader); | 
|---|
|  | 1367 | } | 
|---|
|  | 1368 | else if (strcmp(tag, "#text")    == 0 ) { } | 
|---|
|  | 1369 | else if (strcmp(tag, "#comment") == 0 ) { } | 
|---|
|  | 1370 | else if (strcmp(tag, "coproc") == 0 ) { | 
|---|
| [215] | 1371 | coproc[coproc_index]->ports = cp_port_loc_index; | 
|---|
|  | 1372 | cluster[cluster_index]->coprocs++; | 
|---|
|  | 1373 | coproc_loc_index++; | 
|---|
|  | 1374 | coproc_index++; | 
|---|
|  | 1375 | return; | 
|---|
|  | 1376 | } | 
|---|
| [228] | 1377 | else { | 
|---|
|  | 1378 | printf("[XML ERROR] Unknown tag %s", tag); | 
|---|
| [215] | 1379 | exit(1); | 
|---|
|  | 1380 | } | 
|---|
| [228] | 1381 | status = xmlTextReaderRead(reader); | 
|---|
| [215] | 1382 | } | 
|---|
|  | 1383 | } // end coprocNode() | 
|---|
|  | 1384 |  | 
|---|
| [228] | 1385 |  | 
|---|
| [215] | 1386 | /////////////////////////////////////// | 
|---|
| [228] | 1387 | void irqNode(xmlTextReaderPtr reader) { | 
|---|
|  | 1388 | unsigned int ok; | 
|---|
|  | 1389 | unsigned int value; | 
|---|
|  | 1390 | char * str; | 
|---|
| [215] | 1391 |  | 
|---|
| [228] | 1392 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 1393 | return; | 
|---|
|  | 1394 | } | 
|---|
| [215] | 1395 |  | 
|---|
| [228] | 1396 | if (irq_index >= MAX_IRQS) { | 
|---|
| [215] | 1397 | printf("[XML ERROR] The number of irqs is larger than %d\n", MAX_IRQS); | 
|---|
|  | 1398 | } | 
|---|
|  | 1399 |  | 
|---|
|  | 1400 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1401 | printf("     irq %d\n", irq_loc_index); | 
|---|
| [215] | 1402 | #endif | 
|---|
|  | 1403 |  | 
|---|
| [228] | 1404 | irq[irq_index] = (mapping_irq_t *) malloc(sizeof(mapping_irq_t)); | 
|---|
| [215] | 1405 |  | 
|---|
|  | 1406 | ///////// get type attribute | 
|---|
| [228] | 1407 | str = getStringValue(reader, "type", &ok); | 
|---|
|  | 1408 | if (ok) { | 
|---|
| [215] | 1409 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1410 | printf("        type    = %s\n", str); | 
|---|
| [215] | 1411 | #endif | 
|---|
| [228] | 1412 | if (strcmp(str, "HARD") == 0 ) { | 
|---|
|  | 1413 | irq[irq_index]->type = 0; | 
|---|
|  | 1414 | } | 
|---|
| [231] | 1415 | else { | 
|---|
| [228] | 1416 | irq[irq_index]->type = 1; | 
|---|
|  | 1417 | } | 
|---|
| [231] | 1418 | } | 
|---|
| [228] | 1419 | else { | 
|---|
| [215] | 1420 | printf("[XML ERROR] missing IRQ <type> for processor %d in cluster %d\n", | 
|---|
| [228] | 1421 | cluster_index, proc_loc_index); | 
|---|
| [215] | 1422 | exit(1); | 
|---|
|  | 1423 | } | 
|---|
|  | 1424 |  | 
|---|
|  | 1425 | ///////// get icuid attribute | 
|---|
|  | 1426 | value = getIntValue(reader, "icuid", &ok); | 
|---|
| [228] | 1427 | if (ok) { | 
|---|
| [215] | 1428 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1429 | printf("        icuid   = %d\n", value); | 
|---|
| [215] | 1430 | #endif | 
|---|
|  | 1431 | irq[irq_index]->icuid = value; | 
|---|
| [228] | 1432 | if (value >= 32) { | 
|---|
| [215] | 1433 | printf("[XML ERROR] IRQ <icuid> too large for processor %d in cluster %d\n", | 
|---|
| [228] | 1434 | cluster_index, proc_loc_index); | 
|---|
| [215] | 1435 | exit(1); | 
|---|
|  | 1436 | } | 
|---|
|  | 1437 | } | 
|---|
| [228] | 1438 | else { | 
|---|
| [215] | 1439 | printf("[XML ERROR] missing IRQ <icuid> for processor %d in cluster %d\n", | 
|---|
| [228] | 1440 | cluster_index, proc_loc_index); | 
|---|
| [215] | 1441 | exit(1); | 
|---|
|  | 1442 | } | 
|---|
|  | 1443 |  | 
|---|
|  | 1444 | ///////// get isr attribute | 
|---|
| [228] | 1445 | str = getStringValue(reader, "isr", &ok); | 
|---|
|  | 1446 | if (ok) { | 
|---|
| [215] | 1447 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1448 | printf("        isr     = %s\n", str); | 
|---|
| [215] | 1449 | #endif | 
|---|
| [228] | 1450 | if      (strcmp(str, "ISR_SWITCH" ) == 0) { irq[irq_index]->isr = ISR_SWITCH; } | 
|---|
|  | 1451 | else if (strcmp(str, "ISR_IOC"    ) == 0) { irq[irq_index]->isr = ISR_IOC; } | 
|---|
|  | 1452 | else if (strcmp(str, "ISR_DMA"    ) == 0) { irq[irq_index]->isr = ISR_DMA; } | 
|---|
|  | 1453 | else if (strcmp(str, "ISR_TTY"    ) == 0) { irq[irq_index]->isr = ISR_TTY; } | 
|---|
|  | 1454 | else if (strcmp(str, "ISR_TIMER"  ) == 0) { irq[irq_index]->isr = ISR_TIMER; } | 
|---|
|  | 1455 | else { | 
|---|
| [215] | 1456 | printf("[XML ERROR] illegal IRQ <isr> for processor %d in cluster %d\n", | 
|---|
| [228] | 1457 | cluster_index, proc_loc_index); | 
|---|
| [215] | 1458 | exit(1); | 
|---|
|  | 1459 | } | 
|---|
|  | 1460 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1461 | printf("        isrnum  = %d\n", irq[irq_index]->isr); | 
|---|
| [215] | 1462 | #endif | 
|---|
|  | 1463 | } | 
|---|
| [228] | 1464 | else { | 
|---|
| [215] | 1465 | printf("[XML ERROR] missing IRQ <isr> for processor %d in cluster %d\n", | 
|---|
| [228] | 1466 | cluster_index, proc_loc_index); | 
|---|
| [215] | 1467 | exit(1); | 
|---|
|  | 1468 | } | 
|---|
|  | 1469 |  | 
|---|
|  | 1470 | ///////// get channel attribute (optionnal : 0 if missing) | 
|---|
|  | 1471 | value = getIntValue(reader, "channel", &ok); | 
|---|
| [228] | 1472 | if (ok) { | 
|---|
| [215] | 1473 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1474 | printf("        channel = %d\n", value); | 
|---|
| [215] | 1475 | #endif | 
|---|
|  | 1476 | irq[irq_index]->channel = value; | 
|---|
|  | 1477 | } | 
|---|
| [228] | 1478 | else { | 
|---|
| [215] | 1479 | irq[irq_index]->channel = 0; | 
|---|
|  | 1480 | } | 
|---|
|  | 1481 |  | 
|---|
|  | 1482 | irq_index++; | 
|---|
|  | 1483 | irq_loc_index++; | 
|---|
|  | 1484 |  | 
|---|
|  | 1485 | } // end irqNode | 
|---|
|  | 1486 |  | 
|---|
| [228] | 1487 |  | 
|---|
| [215] | 1488 | ///////////////////////////////////////// | 
|---|
| [228] | 1489 | void procNode(xmlTextReaderPtr reader) { | 
|---|
|  | 1490 | unsigned int ok; | 
|---|
|  | 1491 | unsigned int value; | 
|---|
| [215] | 1492 |  | 
|---|
|  | 1493 | irq_loc_index = 0; | 
|---|
|  | 1494 |  | 
|---|
| [228] | 1495 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 1496 | return; | 
|---|
|  | 1497 | } | 
|---|
| [215] | 1498 |  | 
|---|
| [228] | 1499 | if (proc_index >= MAX_PROCS) { | 
|---|
| [215] | 1500 | printf("[XML ERROR] The number of procs is larger than %d\n", MAX_PROCS); | 
|---|
|  | 1501 | } | 
|---|
|  | 1502 |  | 
|---|
|  | 1503 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1504 | printf("\n  proc %d\n", proc_index); | 
|---|
| [215] | 1505 | #endif | 
|---|
|  | 1506 |  | 
|---|
| [228] | 1507 | proc[proc_index] = (mapping_proc_t *) malloc(sizeof(mapping_proc_t)); | 
|---|
| [215] | 1508 |  | 
|---|
|  | 1509 |  | 
|---|
|  | 1510 | /////////// get index attribute (optional) | 
|---|
| [228] | 1511 | value = getIntValue(reader, "index", &ok); | 
|---|
|  | 1512 | if (ok && (value != proc_loc_index)) { | 
|---|
|  | 1513 | printf("[XML ERROR] wrong proc index / expected value is %d", | 
|---|
| [215] | 1514 | proc_loc_index); | 
|---|
| [228] | 1515 | exit(1); | 
|---|
| [215] | 1516 | } | 
|---|
|  | 1517 |  | 
|---|
|  | 1518 | ////////// set irq_offset attribute | 
|---|
|  | 1519 | proc[proc_index]->irq_offset = irq_index; | 
|---|
|  | 1520 |  | 
|---|
|  | 1521 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1522 | printf("    irq_offset = %d\n", irq_index); | 
|---|
| [215] | 1523 | #endif | 
|---|
|  | 1524 |  | 
|---|
|  | 1525 | int status = xmlTextReaderRead(reader); | 
|---|
| [228] | 1526 | while (status == 1) { | 
|---|
|  | 1527 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [215] | 1528 |  | 
|---|
| [228] | 1529 | if (strcmp(tag, "irq") == 0) { | 
|---|
|  | 1530 | irqNode(reader); | 
|---|
|  | 1531 | } | 
|---|
|  | 1532 | else if (strcmp(tag, "#text")    == 0) { } | 
|---|
|  | 1533 | else if (strcmp(tag, "#comment") == 0) { } | 
|---|
|  | 1534 | else if (strcmp(tag, "proc")     == 0) { | 
|---|
| [215] | 1535 | proc[proc_index]->irqs = irq_loc_index; | 
|---|
|  | 1536 | cluster[cluster_index]->procs++; | 
|---|
|  | 1537 | proc_loc_index++; | 
|---|
|  | 1538 | proc_index++; | 
|---|
|  | 1539 | return; | 
|---|
|  | 1540 | } | 
|---|
| [228] | 1541 | else { | 
|---|
|  | 1542 | printf("[XML ERROR] Unknown tag %s", tag); | 
|---|
| [215] | 1543 | exit(1); | 
|---|
|  | 1544 | } | 
|---|
| [228] | 1545 | status = xmlTextReaderRead(reader); | 
|---|
| [215] | 1546 | } | 
|---|
|  | 1547 | } // end procNode() | 
|---|
|  | 1548 |  | 
|---|
|  | 1549 |  | 
|---|
| [158] | 1550 | ////////////////////////////////////////// | 
|---|
| [228] | 1551 | void psegNode(xmlTextReaderPtr reader) { | 
|---|
|  | 1552 | unsigned int ok; | 
|---|
| [238] | 1553 | paddr_t      ll_value; | 
|---|
| [228] | 1554 | char * str; | 
|---|
| [158] | 1555 |  | 
|---|
| [228] | 1556 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 1557 | return; | 
|---|
|  | 1558 | } | 
|---|
| [158] | 1559 |  | 
|---|
| [228] | 1560 | if (pseg_index >= MAX_PSEGS) { | 
|---|
| [158] | 1561 | printf("[XML ERROR] The number of psegs is larger than %d\n", MAX_PSEGS); | 
|---|
|  | 1562 | exit(1); | 
|---|
|  | 1563 | } | 
|---|
|  | 1564 |  | 
|---|
|  | 1565 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1566 | printf("    pseg %d\n", pseg_index); | 
|---|
| [158] | 1567 | #endif | 
|---|
|  | 1568 |  | 
|---|
| [228] | 1569 | pseg[pseg_index] = (mapping_pseg_t *) malloc(sizeof(mapping_pseg_t)); | 
|---|
| [158] | 1570 |  | 
|---|
| [181] | 1571 | /////// get name attribute | 
|---|
| [228] | 1572 | str = getStringValue(reader, "name", &ok); | 
|---|
| [158] | 1573 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1574 | printf("      name = %s\n", str); | 
|---|
| [158] | 1575 | #endif | 
|---|
| [228] | 1576 | if (ok) { | 
|---|
| [158] | 1577 | strncpy(pseg[pseg_index]->name, str, 31); | 
|---|
|  | 1578 | } | 
|---|
| [228] | 1579 | else { | 
|---|
| [181] | 1580 | printf("[XML ERROR] illegal or missing <name> for pseg %d in cluster %d\n", | 
|---|
| [228] | 1581 | pseg_index, cluster_index); | 
|---|
| [158] | 1582 | exit(1); | 
|---|
|  | 1583 | } | 
|---|
|  | 1584 |  | 
|---|
| [181] | 1585 | //////// get type attribute | 
|---|
|  | 1586 | str = getStringValue(reader, "type", &ok); | 
|---|
|  | 1587 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1588 | printf("      type = %s\n", str); | 
|---|
| [181] | 1589 | #endif | 
|---|
| [228] | 1590 | if      (ok && (strcmp(str, "RAM" ) == 0)) { pseg[pseg_index]->type = PSEG_TYPE_RAM; } | 
|---|
|  | 1591 | else if (ok && (strcmp(str, "ROM" ) == 0)) { pseg[pseg_index]->type = PSEG_TYPE_ROM; } | 
|---|
|  | 1592 | else if (ok && (strcmp(str, "PERI") == 0)) { pseg[pseg_index]->type = PSEG_TYPE_PERI; } | 
|---|
|  | 1593 | else { | 
|---|
| [181] | 1594 | printf("[XML ERROR] illegal or missing <type> for pseg %s in cluster %d\n", | 
|---|
| [228] | 1595 | pseg[pseg_index]->name, cluster_index); | 
|---|
| [181] | 1596 | exit(1); | 
|---|
|  | 1597 | } | 
|---|
|  | 1598 |  | 
|---|
|  | 1599 | //////// get base attribute | 
|---|
| [238] | 1600 | ll_value = getPaddrValue(reader, "base", &ok); | 
|---|
| [158] | 1601 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 1602 | printf("      base = 0x%llx\n", ll_value); | 
|---|
| [158] | 1603 | #endif | 
|---|
| [228] | 1604 | if (ok) { | 
|---|
| [238] | 1605 | pseg[pseg_index]->base = ll_value; | 
|---|
| [158] | 1606 | } | 
|---|
| [228] | 1607 | else { | 
|---|
| [181] | 1608 | printf("[XML ERROR] illegal or missing <base> for pseg %s in cluster %d\n", | 
|---|
| [228] | 1609 | pseg[pseg_index]->name, cluster_index); | 
|---|
| [158] | 1610 | exit(1); | 
|---|
|  | 1611 | } | 
|---|
|  | 1612 |  | 
|---|
| [181] | 1613 | //////// get length attribute | 
|---|
| [238] | 1614 | ll_value = getPaddrValue(reader, "length", &ok); | 
|---|
| [158] | 1615 | #if XML_PARSER_DEBUG | 
|---|
| [238] | 1616 | printf("      length = 0x%llx\n", ll_value); | 
|---|
| [158] | 1617 | #endif | 
|---|
| [228] | 1618 | if (ok) { | 
|---|
| [238] | 1619 | pseg[pseg_index]->length = ll_value; | 
|---|
| [158] | 1620 | } | 
|---|
| [228] | 1621 | else { | 
|---|
| [181] | 1622 | printf("[XML ERROR] illegal or missing <length> for pseg %s in cluster %d\n", | 
|---|
| [228] | 1623 | pseg[pseg_index]->name, cluster_index); | 
|---|
| [158] | 1624 | exit(1); | 
|---|
|  | 1625 | } | 
|---|
|  | 1626 |  | 
|---|
| [181] | 1627 | //////// set cluster attribute | 
|---|
|  | 1628 | pseg[pseg_index]->cluster = cluster_index; | 
|---|
|  | 1629 |  | 
|---|
| [158] | 1630 | pseg_index++; | 
|---|
| [181] | 1631 | cluster[cluster_index]->psegs++; | 
|---|
| [158] | 1632 | } // end psegNode() | 
|---|
|  | 1633 |  | 
|---|
| [228] | 1634 |  | 
|---|
| [238] | 1635 | ///////////////////////////////////////// | 
|---|
|  | 1636 | void clusterNode(xmlTextReaderPtr reader) | 
|---|
|  | 1637 | { | 
|---|
| [158] | 1638 | unsigned int ok; | 
|---|
|  | 1639 | unsigned int value; | 
|---|
|  | 1640 |  | 
|---|
| [228] | 1641 | cluster[cluster_index] = (mapping_cluster_t *) malloc(sizeof(mapping_cluster_t)); | 
|---|
|  | 1642 |  | 
|---|
| [215] | 1643 | //initialise all variables | 
|---|
|  | 1644 | //they will be incremented by *Node() functions | 
|---|
|  | 1645 | //FIXME: calloc? | 
|---|
|  | 1646 | cluster[cluster_index]->psegs = 0; | 
|---|
|  | 1647 | cluster[cluster_index]->procs = 0; | 
|---|
|  | 1648 | cluster[cluster_index]->coprocs = 0; | 
|---|
|  | 1649 | cluster[cluster_index]->periphs = 0; | 
|---|
|  | 1650 |  | 
|---|
|  | 1651 |  | 
|---|
|  | 1652 | //initialise global variables | 
|---|
|  | 1653 | //TODO: delete those three | 
|---|
| [181] | 1654 | proc_loc_index = 0; | 
|---|
|  | 1655 | coproc_loc_index = 0; | 
|---|
| [189] | 1656 | periph_loc_index = 0; | 
|---|
| [181] | 1657 |  | 
|---|
| [215] | 1658 | // for replicated periph | 
|---|
|  | 1659 | found_timer = 0; | 
|---|
| [249] | 1660 | found_icu   = 0; | 
|---|
|  | 1661 | found_dma   = 0; | 
|---|
|  | 1662 | found_mmc   = 0; | 
|---|
| [215] | 1663 |  | 
|---|
| [228] | 1664 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 1665 | return; | 
|---|
|  | 1666 | } | 
|---|
| [158] | 1667 |  | 
|---|
|  | 1668 | // checking source file consistency | 
|---|
| [228] | 1669 | if (cluster_index >= header->clusters) { | 
|---|
| [158] | 1670 | printf("[XML ERROR] The cluster index is too large : %d\n", cluster_index); | 
|---|
|  | 1671 | exit(1); | 
|---|
|  | 1672 | } | 
|---|
|  | 1673 |  | 
|---|
|  | 1674 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1675 | printf("  cluster %d\n", cluster_index); | 
|---|
| [158] | 1676 | #endif | 
|---|
|  | 1677 |  | 
|---|
|  | 1678 |  | 
|---|
| [189] | 1679 | /////////// check cluster index attribute (optional) | 
|---|
| [228] | 1680 | value = getIntValue(reader, "index", &ok); | 
|---|
|  | 1681 | if (ok && (value != cluster_index)) { | 
|---|
|  | 1682 | printf("[XML ERROR] wrong cluster index / expected value is %d", | 
|---|
| [158] | 1683 | cluster_index); | 
|---|
| [228] | 1684 | exit(1); | 
|---|
| [158] | 1685 | } | 
|---|
|  | 1686 |  | 
|---|
| [189] | 1687 | ////////// set offsets | 
|---|
| [228] | 1688 | cluster[cluster_index]->pseg_offset = pseg_index; | 
|---|
|  | 1689 | cluster[cluster_index]->proc_offset = proc_index; | 
|---|
| [189] | 1690 | cluster[cluster_index]->coproc_offset = coproc_index; | 
|---|
|  | 1691 | cluster[cluster_index]->periph_offset = periph_index; | 
|---|
| [181] | 1692 |  | 
|---|
| [158] | 1693 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1694 | printf("    pseg_offset   = %d\n", pseg_index); | 
|---|
|  | 1695 | printf("    proc_offset   = %d\n", proc_index); | 
|---|
|  | 1696 | printf("    coproc_offset = %d\n", coproc_index); | 
|---|
|  | 1697 | printf("    periph_offset = %d\n", coproc_index); | 
|---|
| [158] | 1698 | #endif | 
|---|
| [181] | 1699 |  | 
|---|
| [189] | 1700 | ////////// get psegs, procs, coprocs and periphs | 
|---|
| [181] | 1701 | int status = xmlTextReaderRead(reader); | 
|---|
|  | 1702 |  | 
|---|
| [238] | 1703 | while (status == 1) | 
|---|
|  | 1704 | { | 
|---|
| [228] | 1705 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [181] | 1706 |  | 
|---|
| [228] | 1707 | if      (strcmp(tag, "pseg")     == 0) psegNode(reader); | 
|---|
|  | 1708 | else if (strcmp(tag, "proc")     == 0) procNode(reader); | 
|---|
|  | 1709 | else if (strcmp(tag, "coproc")   == 0) coprocNode(reader); | 
|---|
|  | 1710 | else if (strcmp(tag, "periph")   == 0) periphNode(reader); | 
|---|
|  | 1711 | else if (strcmp(tag, "#text")    == 0) { } | 
|---|
|  | 1712 | else if (strcmp(tag, "#comment") == 0) { } | 
|---|
| [238] | 1713 | else if (strcmp(tag, "cluster")  == 0) | 
|---|
|  | 1714 | { | 
|---|
| [189] | 1715 |  | 
|---|
| [238] | 1716 | ////////////////// peripherals checks ///////////////////////// | 
|---|
|  | 1717 | if ((found_timer  && use_xicu) || (!found_timer  && !use_xicu)) | 
|---|
|  | 1718 | { | 
|---|
| [215] | 1719 | printf("[XML ERROR] illegal or missing timer peripheral in cluster %d\n", cluster_index); | 
|---|
|  | 1720 | exit(1); | 
|---|
|  | 1721 | } | 
|---|
|  | 1722 |  | 
|---|
| [238] | 1723 | if (!found_icu) | 
|---|
|  | 1724 | { | 
|---|
| [215] | 1725 | printf("[XML ERROR] illegal or missing icu peripheral in cluster %d\n", cluster_index); | 
|---|
|  | 1726 | exit(1); | 
|---|
|  | 1727 | } | 
|---|
|  | 1728 |  | 
|---|
| [238] | 1729 | if (!found_dma) | 
|---|
|  | 1730 | { | 
|---|
| [215] | 1731 | printf("[XML ERROR] illegal or missing dma peripheral in cluster %d\n", cluster_index); | 
|---|
|  | 1732 | exit(1); | 
|---|
|  | 1733 | } | 
|---|
|  | 1734 |  | 
|---|
|  | 1735 |  | 
|---|
| [238] | 1736 | if (nb_proc_max < cluster[cluster_index]->procs) | 
|---|
|  | 1737 | { | 
|---|
| [215] | 1738 | nb_proc_max = cluster[cluster_index]->procs; | 
|---|
| [228] | 1739 | } | 
|---|
| [215] | 1740 |  | 
|---|
| [181] | 1741 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1742 | printf("    psegs   = %d\n", cluster[cluster_index]->psegs); | 
|---|
|  | 1743 | printf("    procs   = %d\n", cluster[cluster_index]->procs); | 
|---|
|  | 1744 | printf("    coprocs = %d\n", cluster[cluster_index]->coprocs); | 
|---|
|  | 1745 | printf("    periphs = %d\n", cluster[cluster_index]->periphs); | 
|---|
|  | 1746 | printf("    end cluster %d\n", cluster_index); | 
|---|
| [181] | 1747 | #endif | 
|---|
|  | 1748 | cluster_index++; | 
|---|
|  | 1749 | return; | 
|---|
|  | 1750 | } | 
|---|
|  | 1751 | status = xmlTextReaderRead(reader); | 
|---|
| [158] | 1752 | } | 
|---|
|  | 1753 | } // end clusterNode() | 
|---|
|  | 1754 |  | 
|---|
| [228] | 1755 |  | 
|---|
| [158] | 1756 | ////////////////////////////////////////////// | 
|---|
| [238] | 1757 | void clusterSetNode(xmlTextReaderPtr reader) | 
|---|
|  | 1758 | { | 
|---|
|  | 1759 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } | 
|---|
| [158] | 1760 |  | 
|---|
|  | 1761 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1762 | printf("\n  clusters set\n"); | 
|---|
| [158] | 1763 | #endif | 
|---|
|  | 1764 |  | 
|---|
| [181] | 1765 | int status = xmlTextReaderRead(reader); | 
|---|
| [238] | 1766 | while (status == 1) | 
|---|
|  | 1767 | { | 
|---|
| [228] | 1768 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [158] | 1769 |  | 
|---|
| [238] | 1770 | if      (strcmp(tag, "cluster")    == 0) { clusterNode(reader); } | 
|---|
| [228] | 1771 | else if (strcmp(tag, "#text")      == 0) { } | 
|---|
|  | 1772 | else if (strcmp(tag, "#comment")   == 0) { } | 
|---|
| [238] | 1773 | else if (strcmp(tag, "clusterset") == 0) | 
|---|
|  | 1774 | { | 
|---|
| [158] | 1775 | // checking source file consistency | 
|---|
| [238] | 1776 | if (cluster_index != header->clusters) | 
|---|
|  | 1777 | { | 
|---|
| [158] | 1778 | printf("[XML ERROR] Wrong number of clusters\n"); | 
|---|
|  | 1779 | exit(1); | 
|---|
|  | 1780 | } | 
|---|
| [215] | 1781 |  | 
|---|
| [238] | 1782 | // At least one TTY terminal for system boot | 
|---|
|  | 1783 | if (header->tty_cluster == 0xFFFFFFFF) | 
|---|
|  | 1784 | { | 
|---|
| [215] | 1785 | printf("[XML ERROR] illegal or missing tty peripheral"); | 
|---|
|  | 1786 | exit(1); | 
|---|
|  | 1787 | } | 
|---|
|  | 1788 |  | 
|---|
| [181] | 1789 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1790 | printf("  end cluster set\n\n"); | 
|---|
| [181] | 1791 | #endif | 
|---|
| [228] | 1792 | header->psegs = pseg_index; | 
|---|
|  | 1793 | header->procs = proc_index; | 
|---|
|  | 1794 | header->irqs = irq_index; | 
|---|
|  | 1795 | header->coprocs = coproc_index; | 
|---|
| [215] | 1796 | header->cp_ports = cp_port_index; | 
|---|
| [238] | 1797 | header->periphs = periph_index; | 
|---|
| [215] | 1798 | return; | 
|---|
| [158] | 1799 | } | 
|---|
| [228] | 1800 | else { | 
|---|
| [158] | 1801 | printf("[XML ERROR] Unknown tag in clusterset node : %s",tag); | 
|---|
|  | 1802 | exit(1); | 
|---|
|  | 1803 | } | 
|---|
| [181] | 1804 | status = xmlTextReaderRead(reader); | 
|---|
| [158] | 1805 | } | 
|---|
|  | 1806 | } // end clusterSetNode() | 
|---|
|  | 1807 |  | 
|---|
| [228] | 1808 |  | 
|---|
| [158] | 1809 | ///////////////////////////////////////////// | 
|---|
| [228] | 1810 | void globalSetNode(xmlTextReaderPtr reader) { | 
|---|
|  | 1811 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 1812 | return; | 
|---|
|  | 1813 | } | 
|---|
| [158] | 1814 |  | 
|---|
|  | 1815 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1816 | printf("  globals set\n"); | 
|---|
| [158] | 1817 | #endif | 
|---|
|  | 1818 |  | 
|---|
| [181] | 1819 | int status = xmlTextReaderRead(reader); | 
|---|
| [238] | 1820 | while (status == 1) | 
|---|
|  | 1821 | { | 
|---|
| [228] | 1822 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [158] | 1823 |  | 
|---|
| [238] | 1824 | if      (strcmp(tag, "vseg")      == 0) { vsegNode(reader); } | 
|---|
| [228] | 1825 | else if (strcmp(tag, "#text")     == 0) { } | 
|---|
|  | 1826 | else if (strcmp(tag, "#comment")  == 0) { } | 
|---|
|  | 1827 | else if (strcmp(tag, "globalset") == 0) { | 
|---|
| [181] | 1828 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1829 | printf("  end global set\n\n"); | 
|---|
| [181] | 1830 | #endif | 
|---|
| [204] | 1831 | header->globals = vseg_index; | 
|---|
|  | 1832 | vseg_loc_index = 0; | 
|---|
|  | 1833 | return; | 
|---|
| [158] | 1834 | } | 
|---|
| [228] | 1835 | else { | 
|---|
| [158] | 1836 | printf("[XML ERROR] Unknown tag in globalset node : %s",tag); | 
|---|
|  | 1837 | exit(1); | 
|---|
|  | 1838 | } | 
|---|
| [228] | 1839 | status = xmlTextReaderRead(reader); | 
|---|
| [158] | 1840 | } | 
|---|
|  | 1841 | } // end globalSetNode() | 
|---|
|  | 1842 |  | 
|---|
| [228] | 1843 |  | 
|---|
| [158] | 1844 | ///////////////////////////////////////////// | 
|---|
| [228] | 1845 | void vspaceSetNode(xmlTextReaderPtr reader) { | 
|---|
|  | 1846 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { | 
|---|
|  | 1847 | return; | 
|---|
|  | 1848 | } | 
|---|
| [158] | 1849 |  | 
|---|
|  | 1850 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1851 | printf("\n  vspaces set\n"); | 
|---|
| [158] | 1852 | #endif | 
|---|
|  | 1853 |  | 
|---|
|  | 1854 | int status = xmlTextReaderRead ( reader ); | 
|---|
| [228] | 1855 | while (status == 1) { | 
|---|
|  | 1856 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [158] | 1857 |  | 
|---|
| [228] | 1858 | if (strcmp(tag, "vspace") == 0) { | 
|---|
|  | 1859 | vspaceNode(reader); | 
|---|
|  | 1860 | } | 
|---|
|  | 1861 | else if (strcmp(tag, "#text"    ) == 0 ) { } | 
|---|
|  | 1862 | else if (strcmp(tag, "#comment" ) == 0 ) { } | 
|---|
|  | 1863 | else if (strcmp(tag, "vspaceset") == 0 ) { | 
|---|
| [158] | 1864 | // checking source file consistency | 
|---|
| [228] | 1865 | if (vspace_index != header->vspaces) { | 
|---|
| [158] | 1866 | printf("[XML ERROR] Wrong number of vspaces\n"); | 
|---|
|  | 1867 | exit(1); | 
|---|
|  | 1868 | } | 
|---|
| [228] | 1869 | else { | 
|---|
| [158] | 1870 | header->vsegs = vseg_index; | 
|---|
| [160] | 1871 | header->vobjs = vobj_index; | 
|---|
| [158] | 1872 | header->tasks = task_index; | 
|---|
|  | 1873 | return; | 
|---|
|  | 1874 | } | 
|---|
|  | 1875 | } | 
|---|
| [228] | 1876 | else { | 
|---|
| [158] | 1877 | printf("[XML ERROR] Unknown tag in vspaceset node : %s",tag); | 
|---|
|  | 1878 | exit(1); | 
|---|
|  | 1879 | } | 
|---|
| [228] | 1880 | status = xmlTextReaderRead(reader); | 
|---|
| [158] | 1881 | } | 
|---|
|  | 1882 | } // end globalSetNode() | 
|---|
|  | 1883 |  | 
|---|
| [228] | 1884 |  | 
|---|
| [158] | 1885 | ////////////////////////////////////////// | 
|---|
| [238] | 1886 | void headerNode(xmlTextReaderPtr reader) | 
|---|
|  | 1887 | { | 
|---|
| [228] | 1888 | char * name; | 
|---|
|  | 1889 | unsigned int value; | 
|---|
|  | 1890 | unsigned int ok; | 
|---|
| [158] | 1891 |  | 
|---|
| [238] | 1892 | if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } | 
|---|
| [158] | 1893 |  | 
|---|
|  | 1894 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1895 | printf("mapping_info\n"); | 
|---|
| [158] | 1896 | #endif | 
|---|
|  | 1897 |  | 
|---|
| [228] | 1898 | header = (mapping_header_t *) malloc(sizeof(mapping_header_t)); | 
|---|
| [158] | 1899 |  | 
|---|
| [165] | 1900 | ////////// get name attribute | 
|---|
| [158] | 1901 | name = getStringValue(reader, "name", &ok); | 
|---|
| [228] | 1902 | if (ok) { | 
|---|
| [158] | 1903 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1904 | printf("  name = %s\n", name); | 
|---|
| [158] | 1905 | #endif | 
|---|
| [228] | 1906 | strncpy( header->name, name, 31); | 
|---|
|  | 1907 | } | 
|---|
|  | 1908 | else { | 
|---|
| [158] | 1909 | printf("[XML ERROR] illegal or missing <name> attribute in header\n"); | 
|---|
|  | 1910 | exit(1); | 
|---|
|  | 1911 | } | 
|---|
|  | 1912 |  | 
|---|
| [215] | 1913 | /////////// get cluster_x attribute | 
|---|
|  | 1914 | cluster_x = getIntValue(reader, "cluster_x", &ok); | 
|---|
| [228] | 1915 | if (ok) { | 
|---|
| [158] | 1916 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1917 | printf("  cluster_x = %d\n", cluster_x); | 
|---|
| [158] | 1918 | #endif | 
|---|
| [215] | 1919 | header->cluster_x = cluster_x; | 
|---|
| [158] | 1920 | } | 
|---|
| [228] | 1921 | else { | 
|---|
| [215] | 1922 | printf("[XML ERROR] illegal or missing <cluster_x> attribute in header\n"); | 
|---|
| [158] | 1923 | exit(1); | 
|---|
|  | 1924 | } | 
|---|
|  | 1925 |  | 
|---|
| [215] | 1926 | /////////// get cluster_y attribute | 
|---|
|  | 1927 | cluster_y = getIntValue(reader, "cluster_y", &ok); | 
|---|
| [228] | 1928 | if (ok) { | 
|---|
| [215] | 1929 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1930 | printf("  cluster_y = %d\n", cluster_y); | 
|---|
| [215] | 1931 | #endif | 
|---|
|  | 1932 | header->cluster_y = cluster_y; | 
|---|
|  | 1933 | } | 
|---|
| [228] | 1934 | else { | 
|---|
| [215] | 1935 | printf("[XML ERROR] illegal or missing <cluster_y> attribute in header\n"); | 
|---|
|  | 1936 | exit(1); | 
|---|
|  | 1937 | } | 
|---|
|  | 1938 |  | 
|---|
|  | 1939 | //check the number of cluster | 
|---|
| [228] | 1940 | value = cluster_x * cluster_y; | 
|---|
|  | 1941 | if (value >= MAX_CLUSTERS) { | 
|---|
| [215] | 1942 | printf("[XML ERROR] The number of clusters is larger than %d\n", MAX_CLUSTERS); | 
|---|
|  | 1943 | exit(1); | 
|---|
|  | 1944 | } | 
|---|
| [228] | 1945 |  | 
|---|
| [215] | 1946 | header->clusters  = value; | 
|---|
|  | 1947 |  | 
|---|
|  | 1948 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1949 | printf("  clusters = %d\n", value); | 
|---|
| [215] | 1950 | #endif | 
|---|
|  | 1951 |  | 
|---|
| [165] | 1952 | ///////// get vspaces attribute | 
|---|
| [158] | 1953 | value = getIntValue(reader, "vspaces", &ok); | 
|---|
| [228] | 1954 | if (ok) { | 
|---|
|  | 1955 | if (value >= MAX_VSPACES) { | 
|---|
| [158] | 1956 | printf("[XML ERROR] The number of vspaces is larger than %d\n", MAX_VSPACES); | 
|---|
|  | 1957 | exit(1); | 
|---|
|  | 1958 | } | 
|---|
|  | 1959 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1960 | printf("  vspaces = %d\n", value); | 
|---|
| [158] | 1961 | #endif | 
|---|
| [228] | 1962 | header->vspaces  = value; | 
|---|
| [158] | 1963 | } | 
|---|
| [228] | 1964 | else { | 
|---|
| [158] | 1965 | printf("[XML ERROR] illegal or missing <vspaces> attribute in mapping\n"); | 
|---|
|  | 1966 | exit(1); | 
|---|
|  | 1967 | } | 
|---|
|  | 1968 |  | 
|---|
| [238] | 1969 | //////// initialise non replicated peripherals cluster index | 
|---|
|  | 1970 | header->tty_cluster = 0xFFFFFFFF; | 
|---|
|  | 1971 | header->nic_cluster = 0xFFFFFFFF; | 
|---|
|  | 1972 | header->ioc_cluster = 0xFFFFFFFF; | 
|---|
|  | 1973 | header->fbf_cluster = 0xFFFFFFFF; | 
|---|
|  | 1974 | header->cma_cluster = 0xFFFFFFFF; | 
|---|
|  | 1975 | header->iob_cluster = 0xFFFFFFFF; | 
|---|
|  | 1976 | header->tty_cluster_bis = 0xFFFFFFFF; | 
|---|
|  | 1977 | header->nic_cluster_bis = 0xFFFFFFFF; | 
|---|
|  | 1978 | header->ioc_cluster_bis = 0xFFFFFFFF; | 
|---|
|  | 1979 | header->fbf_cluster_bis = 0xFFFFFFFF; | 
|---|
|  | 1980 | header->cma_cluster_bis = 0xFFFFFFFF; | 
|---|
|  | 1981 | header->iob_cluster_bis = 0xFFFFFFFF; | 
|---|
| [189] | 1982 |  | 
|---|
|  | 1983 | ///////// set signature | 
|---|
| [158] | 1984 | header->signature = IN_MAPPING_SIGNATURE; | 
|---|
|  | 1985 |  | 
|---|
| [181] | 1986 | int status = xmlTextReaderRead(reader); | 
|---|
| [228] | 1987 | while (status == 1) { | 
|---|
|  | 1988 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [158] | 1989 |  | 
|---|
| [228] | 1990 | if (strcmp(tag, "clusterset") == 0) { | 
|---|
|  | 1991 | clusterSetNode(reader); | 
|---|
|  | 1992 | } | 
|---|
|  | 1993 | else if (strcmp(tag, "globalset")    == 0) { globalSetNode(reader); } | 
|---|
|  | 1994 | else if (strcmp(tag, "vspaceset")    == 0) { vspaceSetNode(reader); } | 
|---|
|  | 1995 | else if (strcmp(tag, "#text")        == 0) { } | 
|---|
|  | 1996 | else if (strcmp(tag, "#comment")     == 0) { } | 
|---|
|  | 1997 | else if (strcmp(tag, "mapping_info") == 0) { | 
|---|
| [158] | 1998 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 1999 | printf("end mapping_info\n"); | 
|---|
| [158] | 2000 | #endif | 
|---|
|  | 2001 | return; | 
|---|
|  | 2002 | } | 
|---|
| [228] | 2003 | else { | 
|---|
| [174] | 2004 | printf("[XML ERROR] Unknown tag in header node : %s\n",tag); | 
|---|
| [158] | 2005 | exit(1); | 
|---|
|  | 2006 | } | 
|---|
| [181] | 2007 | status = xmlTextReaderRead(reader); | 
|---|
| [158] | 2008 | } | 
|---|
|  | 2009 | } // end headerNode() | 
|---|
| [228] | 2010 |  | 
|---|
|  | 2011 |  | 
|---|
| [189] | 2012 | /////////////////////////////////////// | 
|---|
| [228] | 2013 | void BuildTable(int fdout, const char * type, unsigned int nb_elem, | 
|---|
|  | 2014 | unsigned int elem_size, char ** table) { | 
|---|
| [181] | 2015 | unsigned int i; | 
|---|
|  | 2016 | // write element | 
|---|
| [228] | 2017 | for (i = 0; i < nb_elem; i++) { | 
|---|
|  | 2018 | if (elem_size != write(fdout, table[i], elem_size)) { | 
|---|
| [215] | 2019 | printf("function %s: %s(%d) write  error \n", __FUNCTION__, type, i); | 
|---|
|  | 2020 | exit(1); | 
|---|
|  | 2021 | } | 
|---|
|  | 2022 |  | 
|---|
| [181] | 2023 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 2024 | printf("Building binary: writing %s %d\n", type, i); | 
|---|
| [181] | 2025 | #endif | 
|---|
| [215] | 2026 | } | 
|---|
|  | 2027 | } | 
|---|
| [158] | 2028 |  | 
|---|
| [215] | 2029 |  | 
|---|
| [228] | 2030 | int open_file(const char * file_path) { | 
|---|
|  | 2031 |  | 
|---|
| [215] | 2032 | //open file | 
|---|
| [228] | 2033 | int fdout = open( file_path, (O_CREAT | O_RDWR), (S_IWUSR | S_IRUSR) ); | 
|---|
|  | 2034 | if (fdout < 0) { | 
|---|
| [215] | 2035 | perror("open"); | 
|---|
|  | 2036 | exit(1); | 
|---|
| [181] | 2037 | } | 
|---|
| [215] | 2038 |  | 
|---|
| [228] | 2039 | //reinitialise the file | 
|---|
|  | 2040 | if (ftruncate(fdout, 0)) { | 
|---|
|  | 2041 | perror("truncate"); | 
|---|
|  | 2042 | exit(1); | 
|---|
|  | 2043 | } | 
|---|
| [215] | 2044 |  | 
|---|
| [228] | 2045 | //#if XML_PARSER_DEBUG | 
|---|
|  | 2046 | printf("%s\n", file_path); | 
|---|
|  | 2047 | //#endif | 
|---|
|  | 2048 |  | 
|---|
| [215] | 2049 | return fdout; | 
|---|
| [181] | 2050 | } | 
|---|
|  | 2051 |  | 
|---|
| [215] | 2052 |  | 
|---|
| [158] | 2053 | /////////////////////////// | 
|---|
| [228] | 2054 | void buildBin(const char * file_path) { | 
|---|
|  | 2055 | unsigned int length; | 
|---|
| [158] | 2056 |  | 
|---|
| [215] | 2057 | int fdout = open_file(file_path); | 
|---|
|  | 2058 |  | 
|---|
| [158] | 2059 | // write header to binary file | 
|---|
| [228] | 2060 | length = write(fdout, (char *) header, sizeof(mapping_header_t)); | 
|---|
|  | 2061 | if (length != sizeof(mapping_header_t)) { | 
|---|
| [181] | 2062 | printf("write header error : length = %d \n", length); | 
|---|
| [158] | 2063 | exit(1); | 
|---|
|  | 2064 | } | 
|---|
|  | 2065 |  | 
|---|
|  | 2066 | // write clusters | 
|---|
| [228] | 2067 | BuildTable(fdout, "cluster", cluster_index, sizeof(mapping_cluster_t), (char **) cluster); | 
|---|
| [158] | 2068 | // write psegs | 
|---|
| [228] | 2069 | BuildTable(fdout, "pseg", pseg_index, sizeof(mapping_pseg_t), (char **) pseg); | 
|---|
| [158] | 2070 | // write vspaces | 
|---|
| [228] | 2071 | BuildTable(fdout, "vspace", vspace_index, sizeof(mapping_vspace_t), (char **) vspace); | 
|---|
| [158] | 2072 | // write vsegs | 
|---|
| [228] | 2073 | BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char **) vseg); | 
|---|
| [160] | 2074 | // write vobjs | 
|---|
| [228] | 2075 | BuildTable(fdout, "vobj", vobj_index, sizeof(mapping_vobj_t), (char **) vobj); | 
|---|
| [189] | 2076 | // write tasks array | 
|---|
| [228] | 2077 | BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char **) task); | 
|---|
| [189] | 2078 | //building procs array | 
|---|
| [228] | 2079 | BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char **) proc); | 
|---|
| [189] | 2080 | //building irqs array | 
|---|
| [228] | 2081 | BuildTable(fdout, "irq", irq_index, sizeof(mapping_irq_t), (char **) irq); | 
|---|
| [189] | 2082 | //building coprocs array | 
|---|
| [228] | 2083 | BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char **) coproc); | 
|---|
| [189] | 2084 | //building cp_ports array | 
|---|
| [228] | 2085 | BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_cp_port_t),(char **) cp_port); | 
|---|
| [189] | 2086 | //building periphs array | 
|---|
| [228] | 2087 | BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char **) periph); | 
|---|
|  | 2088 |  | 
|---|
| [215] | 2089 | close(fdout); | 
|---|
| [181] | 2090 |  | 
|---|
|  | 2091 | } // end buildBin() | 
|---|
|  | 2092 |  | 
|---|
| [228] | 2093 |  | 
|---|
| [189] | 2094 | /////////////////////////////////////////////////////////////////////// | 
|---|
|  | 2095 | // this function set the value the vobj_id fiels of all cp_ports | 
|---|
|  | 2096 | /////////////////////////////////////////////////////////////////////// | 
|---|
| [238] | 2097 | void prepareBuild() | 
|---|
|  | 2098 | { | 
|---|
| [181] | 2099 | unsigned int i; | 
|---|
| [200] | 2100 | //asign for all cp_ports the correct vspaceid and vobjid | 
|---|
| [228] | 2101 | for (i = 0; i < cp_port_index; i++) { | 
|---|
|  | 2102 | int vspace_id = getVspaceId(cp_port_vobj_ref[i]->vspace_name); | 
|---|
|  | 2103 | if (vspace_id < 0) { | 
|---|
|  | 2104 | printf("[XML ERROR] illegal  <vspacename> for cp_port %d,\n", i); | 
|---|
| [181] | 2105 | exit(1); | 
|---|
|  | 2106 | } | 
|---|
|  | 2107 | cp_port[i]->vspaceid = vspace_id; | 
|---|
| [189] | 2108 |  | 
|---|
| [228] | 2109 | int vobj_id = getVobjLocId(vspace_id, cp_port_vobj_ref[i]->vobj_name, vspace[vspace_id]->vobjs); | 
|---|
|  | 2110 | if (vobj_id >= 0) { | 
|---|
|  | 2111 |  | 
|---|
| [158] | 2112 | #if XML_PARSER_DEBUG | 
|---|
| [228] | 2113 | printf("\ncp_port = %d\n", i); | 
|---|
|  | 2114 | printf("      vspace_name  = %s\n", cp_port_vobj_ref[i]->vspace_name); | 
|---|
|  | 2115 | printf("      vobj_name    = %s\n", cp_port_vobj_ref[i]->vobj_name); | 
|---|
|  | 2116 | printf("      vobj_index   = %d\n", vobj_id); | 
|---|
| [158] | 2117 | #endif | 
|---|
| [232] | 2118 | cp_port[i]->mwmr_vobjid = vobj_id; | 
|---|
| [189] | 2119 |  | 
|---|
|  | 2120 | assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR) | 
|---|
| [228] | 2121 | && "coproc ports have to refer to a vobj of type MWMR"); | 
|---|
| [181] | 2122 | } | 
|---|
| [228] | 2123 | else { | 
|---|
|  | 2124 | printf("[XML ERROR] illegal  <vobjname> for cp_port %d,\n", i); | 
|---|
| [158] | 2125 | exit(1); | 
|---|
|  | 2126 | } | 
|---|
|  | 2127 | } | 
|---|
| [181] | 2128 | } | 
|---|
| [158] | 2129 |  | 
|---|
| [217] | 2130 | ////////////////////////////////////////// | 
|---|
| [238] | 2131 | void file_write(int fdout, char * towrite) | 
|---|
|  | 2132 | { | 
|---|
| [215] | 2133 | unsigned int size = strlen(towrite); | 
|---|
| [238] | 2134 | if (size != write(fdout, towrite, size)) | 
|---|
|  | 2135 | { | 
|---|
| [215] | 2136 | printf("file_write error"); | 
|---|
|  | 2137 | exit(1); | 
|---|
|  | 2138 | } | 
|---|
|  | 2139 | } | 
|---|
|  | 2140 |  | 
|---|
| [217] | 2141 | ////////////////////////////////////////////////// | 
|---|
| [238] | 2142 | void def_int_write(int fdout, char * def, int num) | 
|---|
|  | 2143 | { | 
|---|
| [228] | 2144 | char  buf[64]; | 
|---|
| [215] | 2145 | sprintf(buf, "#define\t %s  %d\n", def, num); | 
|---|
|  | 2146 | file_write(fdout, buf); | 
|---|
|  | 2147 | } | 
|---|
|  | 2148 |  | 
|---|
| [238] | 2149 | ////////////////////////////////////////////////// | 
|---|
|  | 2150 | void def_hex_write(int fdout, char * def, int num) | 
|---|
|  | 2151 | { | 
|---|
| [228] | 2152 | char  buf[64]; | 
|---|
| [215] | 2153 | sprintf(buf, "#define\t %s  0x%x\n", def, num); | 
|---|
|  | 2154 | file_write(fdout, buf); | 
|---|
|  | 2155 | } | 
|---|
|  | 2156 |  | 
|---|
| [238] | 2157 | /////////////////////////////////// | 
|---|
|  | 2158 | void  genHd(const char * file_path) | 
|---|
|  | 2159 | { | 
|---|
| [215] | 2160 | int fdout = open_file(file_path); | 
|---|
|  | 2161 |  | 
|---|
| [238] | 2162 | char * prol   = "/* Generated from the mapping_info file */\n\n"; | 
|---|
|  | 2163 | char * ifdef  = "#ifndef _HD_CONFIG_H\n#define _HD_CONFIG_H\n\n"; | 
|---|
|  | 2164 | char * epil   = "\n#endif //_HD_CONFIG_H"; | 
|---|
|  | 2165 |  | 
|---|
| [215] | 2166 | file_write(fdout, prol); | 
|---|
| [238] | 2167 | file_write(fdout, ifdef); | 
|---|
| [215] | 2168 |  | 
|---|
| [238] | 2169 | def_int_write(fdout, "CLUSTER_X         ", cluster_x); | 
|---|
|  | 2170 | def_int_write(fdout, "CLUSTER_Y         ", cluster_y); | 
|---|
|  | 2171 | def_int_write(fdout, "NB_CLUSTERS       ", cluster_index); | 
|---|
|  | 2172 | def_int_write(fdout, "NB_PROCS_MAX      ", nb_proc_max); | 
|---|
|  | 2173 | def_int_write(fdout, "NB_TASKS_MAX      ", nb_tasks_max); | 
|---|
| [228] | 2174 |  | 
|---|
| [215] | 2175 | file_write(fdout, "\n"); | 
|---|
|  | 2176 |  | 
|---|
| [238] | 2177 | def_int_write(fdout, "NB_TIM_CHANNELS   ", tim_channels); | 
|---|
|  | 2178 | def_int_write(fdout, "NB_DMA_CHANNELS   ", dma_channels); | 
|---|
|  | 2179 |  | 
|---|
|  | 2180 | file_write(fdout, "\n"); | 
|---|
|  | 2181 |  | 
|---|
|  | 2182 | def_int_write(fdout, "NB_TTY_CHANNELS   ", tty_channels); | 
|---|
|  | 2183 | def_int_write(fdout, "NB_IOC_CHANNELS   ", ioc_channels); | 
|---|
|  | 2184 | def_int_write(fdout, "NB_NIC_CHANNELS   ", nic_channels); | 
|---|
|  | 2185 | def_int_write(fdout, "NB_CMA_CHANNELS   ", cma_channels); | 
|---|
|  | 2186 |  | 
|---|
|  | 2187 | file_write(fdout, "\n"); | 
|---|
|  | 2188 |  | 
|---|
|  | 2189 | def_int_write(fdout, "USE_XICU          ", use_xicu); | 
|---|
| [249] | 2190 | def_int_write(fdout, "USE_IOB           ", use_iob); | 
|---|
| [238] | 2191 |  | 
|---|
| [215] | 2192 | file_write(fdout, epil); | 
|---|
|  | 2193 |  | 
|---|
|  | 2194 | close(fdout); | 
|---|
|  | 2195 | } | 
|---|
|  | 2196 |  | 
|---|
| [217] | 2197 | //////////////////////////////////////////////////////// | 
|---|
| [238] | 2198 | void ld_write(int fdout, char * seg, unsigned int addr) | 
|---|
|  | 2199 | { | 
|---|
| [228] | 2200 | char buf[64]; | 
|---|
| [215] | 2201 | sprintf(buf, "%s = 0x%x;\n", seg, addr); | 
|---|
|  | 2202 | file_write(fdout, buf); | 
|---|
|  | 2203 | } | 
|---|
|  | 2204 |  | 
|---|
| [238] | 2205 | ////////////////////////////////// | 
|---|
|  | 2206 | void genLd(const char * file_path) | 
|---|
|  | 2207 | { | 
|---|
|  | 2208 | int          fdout = open_file(file_path); | 
|---|
|  | 2209 | unsigned int count = 0; | 
|---|
|  | 2210 | unsigned int vseg_id; | 
|---|
| [228] | 2211 |  | 
|---|
|  | 2212 | char * prol = "/* Generated from the mapping_info file */\n\n"; | 
|---|
| [215] | 2213 | file_write(fdout, prol); | 
|---|
|  | 2214 |  | 
|---|
| [238] | 2215 | // boot and kernel segments | 
|---|
|  | 2216 | for (vseg_id = 0 ; vseg_id < header->vsegs ; vseg_id++) | 
|---|
|  | 2217 | { | 
|---|
|  | 2218 | if ( strcmp(vseg[vseg_id]->name, "seg_boot_code") == 0 ) | 
|---|
|  | 2219 | { | 
|---|
|  | 2220 | ld_write(fdout, "seg_boot_code_base      ",  vseg[vseg_id]->vbase); | 
|---|
|  | 2221 | count++; | 
|---|
|  | 2222 | } | 
|---|
| [245] | 2223 | else if ( strcmp(vseg[vseg_id]->name, "seg_boot_data") == 0 ) | 
|---|
|  | 2224 | { | 
|---|
|  | 2225 | ld_write(fdout, "seg_boot_data_base      ",  vseg[vseg_id]->vbase); | 
|---|
|  | 2226 | count++; | 
|---|
|  | 2227 | } | 
|---|
| [238] | 2228 | else if ( strcmp(vseg[vseg_id]->name, "seg_boot_stack") == 0 ) | 
|---|
|  | 2229 | { | 
|---|
|  | 2230 | ld_write(fdout, "seg_boot_stack_base     ",  vseg[vseg_id]->vbase); | 
|---|
|  | 2231 | count++; | 
|---|
|  | 2232 | } | 
|---|
|  | 2233 | else if ( strcmp(vseg[vseg_id]->name, "seg_boot_mapping") == 0 ) | 
|---|
|  | 2234 | { | 
|---|
|  | 2235 | ld_write(fdout, "seg_mapping_base        ",  vseg[vseg_id]->vbase); | 
|---|
|  | 2236 | count++; | 
|---|
|  | 2237 | } | 
|---|
|  | 2238 | else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_code") == 0 ) | 
|---|
|  | 2239 | { | 
|---|
|  | 2240 | ld_write(fdout, "seg_kernel_code_base    ",  vseg[vseg_id]->vbase); | 
|---|
|  | 2241 | count++; | 
|---|
|  | 2242 | } | 
|---|
|  | 2243 | else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_data") == 0 ) | 
|---|
|  | 2244 | { | 
|---|
|  | 2245 | ld_write(fdout, "seg_kernel_data_base    ",  vseg[vseg_id]->vbase); | 
|---|
|  | 2246 | count++; | 
|---|
|  | 2247 | } | 
|---|
|  | 2248 | else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_uncdata") == 0 ) | 
|---|
|  | 2249 | { | 
|---|
|  | 2250 | ld_write(fdout, "seg_kernel_uncdata_base ",  vseg[vseg_id]->vbase); | 
|---|
|  | 2251 | count++; | 
|---|
|  | 2252 | } | 
|---|
|  | 2253 | else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_init") == 0 ) | 
|---|
|  | 2254 | { | 
|---|
|  | 2255 | ld_write(fdout, "seg_kernel_init_base    ",  vseg[vseg_id]->vbase); | 
|---|
|  | 2256 | count++; | 
|---|
|  | 2257 | } | 
|---|
|  | 2258 | } | 
|---|
| [245] | 2259 | if ( count != 8 ) | 
|---|
| [238] | 2260 | { | 
|---|
|  | 2261 | printf ("[XML ERROR] Missing Boot or Kernel vseg : only %d\n", count); | 
|---|
|  | 2262 | printf ("Mandatory segments are :\n"); | 
|---|
|  | 2263 | printf (" - seg_boot_code\n"); | 
|---|
| [245] | 2264 | printf (" - seg_boot_data\n"); | 
|---|
| [238] | 2265 | printf (" - seg_boot_stack\n"); | 
|---|
|  | 2266 | printf (" - seg_boot_mapping\n"); | 
|---|
|  | 2267 | printf (" - seg_kernel_code\n"); | 
|---|
|  | 2268 | printf (" - seg_kernel_data\n"); | 
|---|
|  | 2269 | printf (" - seg_kernel_uncdata\n"); | 
|---|
|  | 2270 | printf (" - seg_kernel_init\n"); | 
|---|
|  | 2271 | } | 
|---|
| [215] | 2272 |  | 
|---|
| [238] | 2273 | file_write(fdout, "\n"); | 
|---|
| [215] | 2274 |  | 
|---|
| [238] | 2275 | // non replicated peripherals | 
|---|
| [249] | 2276 | ld_write(fdout, "seg_cma_base            ",   periph_vbase_array[PERIPH_TYPE_CMA]); | 
|---|
| [238] | 2277 | ld_write(fdout, "seg_ioc_base            ",   periph_vbase_array[PERIPH_TYPE_IOC]); | 
|---|
| [249] | 2278 | ld_write(fdout, "seg_tty_base            ",   periph_vbase_array[PERIPH_TYPE_TTY]); | 
|---|
|  | 2279 | ld_write(fdout, "seg_fbf_base            ",   periph_vbase_array[PERIPH_TYPE_FBF]); | 
|---|
| [238] | 2280 | ld_write(fdout, "seg_nic_base            ",   periph_vbase_array[PERIPH_TYPE_NIC]); | 
|---|
| [249] | 2281 | ld_write(fdout, "seg_iob_base            ",   periph_vbase_array[PERIPH_TYPE_IOB]); | 
|---|
| [238] | 2282 | ld_write(fdout, "seg_gcd_base            ",   periph_vbase_array[PERIPH_TYPE_GCD]); | 
|---|
| [215] | 2283 |  | 
|---|
| [238] | 2284 | file_write(fdout, "\n"); | 
|---|
|  | 2285 |  | 
|---|
|  | 2286 | // replicated peripherals | 
|---|
|  | 2287 | ld_write(fdout, "seg_icu_base            ",   periph_vbase_array[PERIPH_TYPE_ICU]); | 
|---|
| [249] | 2288 | ld_write(fdout, "seg_tim_base            ",   periph_vbase_array[PERIPH_TYPE_TIM]); | 
|---|
| [238] | 2289 | ld_write(fdout, "seg_dma_base            ",   periph_vbase_array[PERIPH_TYPE_DMA]); | 
|---|
| [249] | 2290 | ld_write(fdout, "seg_mmc_base            ",   periph_vbase_array[PERIPH_TYPE_MMC]); | 
|---|
| [238] | 2291 |  | 
|---|
| [215] | 2292 | close(fdout); | 
|---|
|  | 2293 | } | 
|---|
|  | 2294 |  | 
|---|
| [238] | 2295 | ////////////////////////////////////////////////////// | 
|---|
|  | 2296 | char * buildPath(const char * path, const char * name) | 
|---|
|  | 2297 | { | 
|---|
| [222] | 2298 | char * res = calloc(strlen(path) + strlen(name) + 1, 1); | 
|---|
| [215] | 2299 | strcat(res, path); | 
|---|
|  | 2300 | strcat(res, "/"); | 
|---|
|  | 2301 | strcat(res, name); | 
|---|
|  | 2302 | return res; | 
|---|
|  | 2303 | } | 
|---|
|  | 2304 |  | 
|---|
| [228] | 2305 |  | 
|---|
| [238] | 2306 | ////////////////////////////////// | 
|---|
|  | 2307 | int main(int argc, char * argv[]) | 
|---|
|  | 2308 | { | 
|---|
| [228] | 2309 | if (argc < 3) { | 
|---|
| [215] | 2310 | printf("Usage: xml2bin <input_file_path> <output_path>\n"); | 
|---|
| [158] | 2311 | return 1; | 
|---|
|  | 2312 | } | 
|---|
|  | 2313 |  | 
|---|
| [215] | 2314 | struct stat dir_st; | 
|---|
| [228] | 2315 | if (stat( argv[2], &dir_st)) { | 
|---|
| [215] | 2316 | perror("bad path"); | 
|---|
| [158] | 2317 | exit(1); | 
|---|
|  | 2318 | } | 
|---|
| [215] | 2319 |  | 
|---|
| [228] | 2320 | if ((dir_st.st_mode & S_IFDIR) == 0) { | 
|---|
| [215] | 2321 | printf("path is not a dir: %s", argv[2] ); | 
|---|
|  | 2322 | exit(1); | 
|---|
|  | 2323 | } | 
|---|
|  | 2324 |  | 
|---|
|  | 2325 |  | 
|---|
| [228] | 2326 | char * map_path = buildPath(argv[2], "map.bin"); | 
|---|
|  | 2327 | char * ld_path = buildPath(argv[2], "giet_vsegs.ld"); | 
|---|
|  | 2328 | char * hd_path = buildPath(argv[2], "hard_config.h"); | 
|---|
|  | 2329 |  | 
|---|
| [158] | 2330 | LIBXML_TEST_VERSION; | 
|---|
|  | 2331 |  | 
|---|
| [181] | 2332 | int status; | 
|---|
| [228] | 2333 | xmlTextReaderPtr reader = xmlReaderForFile(argv[1], NULL, 0); | 
|---|
| [158] | 2334 |  | 
|---|
| [228] | 2335 | if (reader != NULL) { | 
|---|
|  | 2336 | status = xmlTextReaderRead (reader); | 
|---|
|  | 2337 | while (status == 1) { | 
|---|
|  | 2338 | const char * tag = (const char *) xmlTextReaderConstName(reader); | 
|---|
| [181] | 2339 |  | 
|---|
| [228] | 2340 | if (strcmp(tag, "mapping_info") == 0) { | 
|---|
|  | 2341 | headerNode(reader); | 
|---|
| [181] | 2342 | prepareBuild(); | 
|---|
| [228] | 2343 | buildBin(map_path); | 
|---|
| [215] | 2344 | genHd(hd_path); | 
|---|
|  | 2345 | genLd(ld_path); | 
|---|
| [158] | 2346 | } | 
|---|
| [228] | 2347 | else { | 
|---|
| [158] | 2348 | printf("[XML ERROR] Wrong file type: \"%s\"\n", argv[1]); | 
|---|
|  | 2349 | return 1; | 
|---|
|  | 2350 | } | 
|---|
| [228] | 2351 | status = xmlTextReaderRead(reader); | 
|---|
| [158] | 2352 | } | 
|---|
| [228] | 2353 | xmlFreeTextReader(reader); | 
|---|
| [158] | 2354 |  | 
|---|
| [228] | 2355 | if (status != 0) { | 
|---|
| [158] | 2356 | printf("[XML ERROR] Wrong Syntax in \"%s\" file\n", argv[1]); | 
|---|
|  | 2357 | return 1; | 
|---|
|  | 2358 | } | 
|---|
|  | 2359 | } | 
|---|
|  | 2360 | return 0; | 
|---|
|  | 2361 | } // end main() | 
|---|
| [222] | 2362 |  | 
|---|
|  | 2363 |  | 
|---|
| [228] | 2364 | // Local Variables: | 
|---|
|  | 2365 | // tab-width: 4 | 
|---|
|  | 2366 | // c-basic-offset: 4 | 
|---|
|  | 2367 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) | 
|---|
|  | 2368 | // indent-tabs-mode: nil | 
|---|
|  | 2369 | // End: | 
|---|
|  | 2370 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 | 
|---|
| [222] | 2371 |  | 
|---|