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