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