Changeset 189 for soft/giet_vm/xml
- Timestamp:
- Aug 7, 2012, 6:37:49 PM (12 years ago)
- Location:
- soft/giet_vm/xml
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/xml/Makefile
r181 r189 3 3 4 4 bin2xml: xml_driver.c mapping_info.h 5 gcc -Wall -g -I. xml_driver.c -o bin2xml5 gcc -Wall -g -I. -I../sys xml_driver.c -o bin2xml 6 6 7 7 xml2bin: xml_parser.c mapping_info.h 8 gcc -Wall -g -I. -I /usr/include/libxml2 xml_parser.c -o xml2bin -lxml28 gcc -Wall -g -I. -I../sys -I/usr/include/libxml2 xml_parser.c -o xml2bin -lxml2 9 9 10 10 test: -
soft/giet_vm/xml/mapping_info.h
r181 r189 13 13 // a fixed size header, and 6 variable size arrays: 14 14 // 15 // - mapping_header_t header (MAPPING_HEADER_SIZE) 16 // - mapping_cluster_t cluster[clusters] (MAPPING_CLUSTER_SIZE * clusters) 17 // - mapping_pseg_t pseg[psegs] (MAPPING_PSEG_SIZE * psegs) 18 // - mapping_vspace_t vspace[vspaces] (MAPPING_VSPACE_SIZE * vspaces) 19 // - mapping_vseg_t vseg[vsegs] (MAPPING_VSEG_SIZE * vsegs) 20 // - mapping_vseg_t vobj[vsegs] (MAPPING_VOBJ_SIZE * vsegs) 21 // - mapping_task_t task[tasks] (MAPPING_TASK_SIZE * tasks) 22 // 23 // The number of clusters and the number of vspaces are defined in the header. 24 // The number of psegs are defined in each cluster. 25 // The number of vsegs, tasks ans mwmrs are defined in each vspace. 15 // - mapping_cluster_t cluster[] 16 // - mapping_pseg_t pseg[] 17 // - mapping_vspace_t vspace[] 18 // - mapping_vseg_t vseg[] 19 // - mapping_vseg_t vobj[] 20 // - mapping_task_t task[] 21 // - mapping_irq_t irq[irqs] 22 // - mapping_coproc_t coproc[] 23 // - mapping_cp_port_t cp_port[] 24 // - mapping_periph_t periph[] 26 25 // 27 26 // It is intended to be stored in the boot ROM at address MAPPING_BOOT_BASE. 28 // For each cluster, the base address of the first pseg descriptor29 // is defined by a pseg_offset relative to MAPPING_BOOT_BASE.30 // For each vspace, the base address of the first vseg descriptor31 // is defined by a vseg_offset relative to MAPPING_BOOT_BASE.32 // For each vspace, the base address of the first task desciptor33 // is defined by a task_offset relative to MAPPING_BOOT_BASE.34 // For each vspace, the base address of the first mwmr desciptor35 // is defined by a mwmr_offset relative to MAPPING_BOOT_BASE.36 27 //////////////////////////////////////////////////////////////////////////// 37 28 … … 49 40 #define MAPPING_IRQ_SIZE sizeof(mapping_irq_t) 50 41 #define MAPPING_COPROC_SIZE sizeof(mapping_coproc_t) 51 #define MAPPING_CP_PORT_SIZE sizeof(mapping_coproc_port_t) 52 #define MAPPING_CP_REG_SIZE sizeof(mapping_coproc_reg_t) 42 #define MAPPING_CP_PORT_SIZE sizeof(mapping_cp_port_t) 53 43 54 44 #define C_MODE_MASK 0b1000 // cacheable … … 81 71 enum 82 72 { 83 IRQ_TYPE_HARD = 0, // hardware interrupt (peripheral) 84 IRQ_TYPE_SOFT = 1, // software interrupt (IPI) 85 }; 86 87 enum 88 { 89 ISR_SWITCH = 0, 90 ISR_IOC = 1, 91 ISR_FBDMA = 2, 92 ISR_TTY = 3, 93 }; 94 95 enum 96 { 97 REG_TYPE_STATUS = 0, // status register 98 REG_TYPE_CONFIG = 1, // config register 73 PERIPH_TYPE_IOC = 0, 74 PERIPH_TYPE_TTY = 1, 75 PERIPH_TYPE_TIM = 2, 76 PERIPH_TYPE_DMA = 3, 77 PERIPH_TYPE_FBF = 4, 78 PERIPH_TYPE_NIC = 5, 79 PERIPH_TYPE_IOB = 6, 99 80 }; 100 81 … … 106 87 107 88 /////////////////////////////// 89 108 90 typedef struct mapping_header_s 109 91 { 110 92 unsigned int signature; // must contain MAPPING_SIGNATURE 111 93 unsigned int clusters; // number of clusters 112 unsigned int ttys; // number of TTY terminals113 unsigned int fbs; // number of FBDMA channels114 94 unsigned int globals; // number of vsegs mapped in all vspaces 115 95 unsigned int vspaces; // number of virtual spaces 96 97 unsigned int tty_clusterid; // index of cluster containing TTY controler 98 unsigned int ioc_clusterid; // index of cluster containing IOC controler 99 unsigned int nic_clusterid; // index of cluster containing NIC controler 100 unsigned int fbf_clusterid; // index of cluster containing FBF controler 101 116 102 unsigned int psegs; // total number of physical segments (for all clusters) 117 103 unsigned int vsegs; // total number of virtual segments (for all vspaces) 118 104 unsigned int vobjs; // total number of virtual objects (for all vspaces) 119 105 unsigned int tasks; // total number of tasks (for all vspaces) 120 unsigned int procs; // total number of procs 121 unsigned int irqs; // total number of irqs 122 unsigned int coprocs; // total number of coprocs 123 unsigned int cp_ports; // total number of cp_ports 124 unsigned int cp_regs; // total number of cp_regss 106 unsigned int procs; // total number of procs (for all clusters) 107 unsigned int irqs; // total number of irqs (for all processors) 108 unsigned int coprocs; // total number of coprocs (for all clusters) 109 unsigned int cp_ports; // total number of cp_ports (for all coprocs) 110 unsigned int periphs; // total number of peripherals (for all clusters) 111 125 112 char name[32]; // mapping name 126 113 } mapping_header_t; … … 129 116 typedef struct mapping_cluster_s 130 117 { 118 unsigned int psegs; // number of psegs in cluster 119 unsigned int pseg_offset; // index of first pseg in pseg set 120 131 121 unsigned int procs; // number of processors in cluster 132 122 unsigned int proc_offset; // index of first proc in proc set 123 133 124 unsigned int coprocs; // number of coprocessors in cluster 134 125 unsigned int coproc_offset; // index of first coproc in coproc set 135 unsigned int psegs; // number of psegs in cluster 136 unsigned int pseg_offset; // index of first pseg in pseg set 126 127 unsigned int periphs; // number of peripherals in cluster 128 unsigned int periph_offset; // index of first coproc in coproc set 137 129 } mapping_cluster_t; 138 130 … … 183 175 unsigned int vobjlocid; // stack vobj index in vspace 184 176 unsigned int startid; // index in start_vector 185 unsigned int use_tty; // TTY terminal required 186 unsigned int use_fb; // DMA channel to frame buffer required 177 unsigned int use_tty; // TTY terminal required (global) 178 unsigned int use_nic; // NIC channel required (global) 179 unsigned int use_timer; // user timer required (local) 180 unsigned int use_fbdma; // DMA channel to frame buffer required (local) 187 181 } mapping_task_t; 188 182 … … 210 204 typedef struct mapping_irq_s 211 205 { 212 unsigned int type; // HW_IRQ /SW_IRQ206 unsigned int type; // 0 => HW_IRQ / 1 => SW_IRQ 213 207 unsigned int icuid; // IRQ Index for the ICU component 214 208 unsigned int isr; // Interrupt Service Routine Index 215 209 unsigned int channel; // Channel Index (for multi-cannels peripherals) 216 217 unsigned int cluster_id; // physical cluster index218 unsigned int proclocid; // processor local index (inside cluster)219 210 } mapping_irq_t; 220 211 … … 226 217 unsigned int ports; // number of MWMR ports used by coprocessor 227 218 unsigned int port_offset; // index of first MWMR port used by coprocessor 228 unsigned int regs; // number of config/status registers229 unsigned int reg_offset; // index of first register230 219 } mapping_coproc_t; 231 220 232 //////////////////////////////// ///////233 typedef struct mapping_c oproc_port_s221 //////////////////////////////// 222 typedef struct mapping_cp_port_s 234 223 { 235 224 unsigned int direction; // TO_COPROC == 0 / FROM_COPROC == 1 236 unsigned int vspaceid; // global index of the vspace containing the MWMR channel 237 unsigned int vobjlocid; // local(to vspace) index of the vobj containing the MWMR channel 238 } mapping_coproc_port_t; 239 240 /////////////////////////////////// 241 typedef struct mapping_coproc_reg_s 242 { 243 char name[32]; // register name 244 unsigned int type; // STATUS = 0 / CONFIG == 1 245 unsigned int loc_id; // register index in coprocessor (word offset) 246 unsigned int channel_id; // channel index in coprocessor (page offset) 247 unsigned int value; // initialisation value 248 } mapping_coproc_reg_t; 225 unsigned int vspaceid; // index of the vspace containing the MWMR channel 226 unsigned int vobjlocid; // local index of the vobj containing the MWMR channel 227 } mapping_cp_port_t; 228 229 /////////////////////////////// 230 typedef struct mapping_periph_s 231 { 232 unsigned int type; // IOC / TTY / TIM / DMA / FBF / NIC / IOB 233 unsigned int psegid; // pseg index in cluster 234 unsigned int channels; // number of channels 235 } mapping_periph_t; 236 249 237 250 238 #endif -
soft/giet_vm/xml/xml_driver.c
r181 r189 17 17 #include <mapping_info.h> 18 18 19 ///////////////////////////////////////////////////// 20 void buildXml( mapping_header_t* header, FILE* fpout )19 ////////////////////////////////////////////////////// 20 void buildXml( mapping_header_t* header, FILE* fpout ) 21 21 { 22 23 22 const char* vobj_type[] = 24 23 { … … 30 29 "LOCK", // Spin-Lock 31 30 "BUFFER", // Any "no intialiasation needed" objects (stacks...) 32 "BARRIER" // Barrier31 "BARRIER", // Barrier 33 32 }; 34 33 … … 37 36 "RAM", 38 37 "ROM", 39 "PERI" 38 "PERI", 40 39 }; 41 40 … … 43 42 { 44 43 "HARD", 45 "SOFT" 44 "SOFT", 46 45 }; 47 46 48 47 const char* isr_type[] = 49 48 { 49 "ISR_DEFAULT", 50 "ISR_SWITCH", 51 "ISR_TTY", 52 "ISR_DMA", 50 53 "ISR_IOC", 51 "ISR_FBDMA", 52 "ISR_TTY" 53 }; 54 55 const char* reg_type[] = 56 { 57 "STATUS", 58 "CONFIG" 54 "ISR_TIMER", 55 }; 56 57 const char* periph_type[] = 58 { 59 "IOC", 60 "TTY", 61 "TIM", 62 "DMA", 63 "FBF", 64 "NIC", 65 "IOB", 59 66 }; 60 67 … … 62 69 { 63 70 "TO_COPROC", 64 "FROM_COPROC" 71 "FROM_COPROC", 65 72 }; 66 73 … … 81 88 "CX_U", 82 89 "CXW_", 83 "CXWU" 90 "CXWU", 84 91 }; 85 92 … … 94 101 unsigned int coproc_id; 95 102 unsigned int port_id; 96 unsigned int reg_id;97 98 mapping_cluster_t* 99 mapping_pseg_t* 100 mapping_vspace_t* 101 mapping_vseg_t* 102 mapping_vobj_t* 103 mapping_task_t* 104 mapping_proc_t* 105 mapping_irq_t* 106 mapping_coproc_t* 107 mapping_c oproc_port_t* cp_port;108 mapping_ coproc_reg_t* cp_reg;103 unsigned int periph_id; 104 105 mapping_cluster_t* cluster; 106 mapping_pseg_t* pseg; 107 mapping_vspace_t* vspace; 108 mapping_vseg_t* vseg; 109 mapping_vobj_t* vobj; 110 mapping_task_t* task; 111 mapping_proc_t* proc; 112 mapping_irq_t* irq; 113 mapping_coproc_t* coproc; 114 mapping_cp_port_t* cp_port; 115 mapping_periph_t* periph; 109 116 110 117 // computes the base adresss for clusters array, … … 147 154 MAPPING_VSEG_SIZE*header->vsegs ); 148 155 149 // computes the base address thearray156 // computes the base address for procs array 150 157 proc = (mapping_proc_t*) ((char*)header + 151 158 MAPPING_HEADER_SIZE + … … 157 164 MAPPING_TASK_SIZE*header->tasks); 158 165 159 // computes the base address the array 160 irq = (mapping_irq_t*) ((char*)header + 161 MAPPING_HEADER_SIZE + 162 MAPPING_CLUSTER_SIZE*header->clusters + 163 MAPPING_PSEG_SIZE*header->psegs + 164 MAPPING_VSPACE_SIZE*header->vspaces + 165 MAPPING_VOBJ_SIZE*header->vobjs + 166 MAPPING_VSEG_SIZE*header->vsegs+ 167 MAPPING_TASK_SIZE*header->tasks+ 168 MAPPING_PROC_SIZE*header->procs 169 ); 170 171 // computes the base address the array 172 coproc = (mapping_coproc_t*) ((char*)header + 173 MAPPING_HEADER_SIZE + 174 MAPPING_CLUSTER_SIZE*header->clusters + 175 MAPPING_PSEG_SIZE*header->psegs + 176 MAPPING_VSPACE_SIZE*header->vspaces + 177 MAPPING_VOBJ_SIZE*header->vobjs + 178 MAPPING_VSEG_SIZE*header->vsegs+ 179 MAPPING_TASK_SIZE*header->tasks+ 180 MAPPING_PROC_SIZE*header->procs+ 181 MAPPING_IRQ_SIZE*header->irqs 182 ); 183 184 // computes the base address the array 185 cp_port = (mapping_coproc_port_t*) ((char*)header + 186 MAPPING_HEADER_SIZE + 187 MAPPING_CLUSTER_SIZE*header->clusters + 188 MAPPING_PSEG_SIZE*header->psegs + 189 MAPPING_VSPACE_SIZE*header->vspaces + 190 MAPPING_VOBJ_SIZE*header->vobjs + 191 MAPPING_VSEG_SIZE*header->vsegs+ 192 MAPPING_TASK_SIZE*header->tasks+ 193 MAPPING_PROC_SIZE*header->procs+ 194 MAPPING_IRQ_SIZE*header->irqs+ 195 MAPPING_COPROC_SIZE*header->coprocs 196 ); 197 198 // computes the base address the array 199 cp_reg = (mapping_coproc_reg_t*) ((char*)header + 200 MAPPING_HEADER_SIZE + 201 MAPPING_CLUSTER_SIZE*header->clusters + 202 MAPPING_PSEG_SIZE*header->psegs + 203 MAPPING_VSPACE_SIZE*header->vspaces + 204 MAPPING_VOBJ_SIZE*header->vobjs + 205 MAPPING_VSEG_SIZE*header->vsegs+ 206 MAPPING_TASK_SIZE*header->tasks+ 207 MAPPING_PROC_SIZE*header->procs+ 208 MAPPING_IRQ_SIZE*header->irqs+ 209 MAPPING_COPROC_SIZE*header->coprocs+ 210 MAPPING_CP_PORT_SIZE*header->cp_ports 211 ); 166 // computes the base address for irqs array 167 irq = (mapping_irq_t*) ((char*)header + 168 MAPPING_HEADER_SIZE + 169 MAPPING_CLUSTER_SIZE*header->clusters + 170 MAPPING_PSEG_SIZE*header->psegs + 171 MAPPING_VSPACE_SIZE*header->vspaces + 172 MAPPING_VOBJ_SIZE*header->vobjs + 173 MAPPING_VSEG_SIZE*header->vsegs + 174 MAPPING_TASK_SIZE*header->tasks + 175 MAPPING_PROC_SIZE*header->procs); 176 177 // computes the base address for coprocs array 178 coproc = (mapping_coproc_t*) ((char*)header + 179 MAPPING_HEADER_SIZE + 180 MAPPING_CLUSTER_SIZE*header->clusters + 181 MAPPING_PSEG_SIZE*header->psegs + 182 MAPPING_VSPACE_SIZE*header->vspaces + 183 MAPPING_VOBJ_SIZE*header->vobjs + 184 MAPPING_VSEG_SIZE*header->vsegs + 185 MAPPING_TASK_SIZE*header->tasks + 186 MAPPING_PROC_SIZE*header->procs + 187 MAPPING_IRQ_SIZE*header->irqs); 188 189 // computes the base address for cp_ports array 190 cp_port = (mapping_cp_port_t*)((char*)header + 191 MAPPING_HEADER_SIZE + 192 MAPPING_CLUSTER_SIZE*header->clusters + 193 MAPPING_PSEG_SIZE*header->psegs + 194 MAPPING_VSPACE_SIZE*header->vspaces + 195 MAPPING_VOBJ_SIZE*header->vobjs + 196 MAPPING_VSEG_SIZE*header->vsegs + 197 MAPPING_TASK_SIZE*header->tasks + 198 MAPPING_PROC_SIZE*header->procs + 199 MAPPING_IRQ_SIZE*header->irqs + 200 MAPPING_COPROC_SIZE*header->coprocs); 201 202 // computes the base address for periphs array 203 periph = (mapping_periph_t*) ((char*)header + 204 MAPPING_HEADER_SIZE + 205 MAPPING_CLUSTER_SIZE*header->clusters + 206 MAPPING_PSEG_SIZE*header->psegs + 207 MAPPING_VSPACE_SIZE*header->vspaces + 208 MAPPING_VOBJ_SIZE*header->vobjs + 209 MAPPING_VSEG_SIZE*header->vsegs + 210 MAPPING_TASK_SIZE*header->tasks + 211 MAPPING_PROC_SIZE*header->procs + 212 MAPPING_IRQ_SIZE*header->irqs + 213 MAPPING_COPROC_SIZE*header->coprocs + 214 MAPPING_CP_PORT_SIZE*header->cp_ports); 215 216 ///////////////////////// header ///////////////////////////////////////////// 212 217 213 218 fprintf( fpout, "<?xml version = \"1.0\"?>\n\n"); 214 215 ///////////////////////// header /////////////////////////////////////////////216 219 217 220 fprintf( fpout, "<mapping_info signature = \"0x%x\"\n", header->signature); 218 221 fprintf( fpout, " name = \"%s\"\n", header->name); 219 222 fprintf( fpout, " clusters = \"%d\"\n", header->clusters); 220 fprintf( fpout, " ttys = \"%d\"\n", header->ttys);221 fprintf( fpout, " fbs = \"%d\"\n", header->fbs);222 223 fprintf( fpout, " vspaces = \"%d\"\n", header->vspaces); 223 224 fprintf( fpout, " globals = \"%d\" >\n\n", header->globals); … … 238 239 fprintf( fpout, " length = \"0x%x\" />\n", pseg[pseg_id].length); 239 240 } 241 242 ///////////////////// processors ///////////////////////////////////////////// 243 240 244 for ( proc_id = cluster[cluster_id].proc_offset ; 241 245 proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs ; … … 253 257 } 254 258 259 260 ///////////////////// coprocessors /////////////////////////////////////////// 261 255 262 for ( coproc_id = cluster[cluster_id].coproc_offset ; 256 263 coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs ; … … 266 273 fprintf( fpout, " vobjname = \"%s\" />\n", vobj[vobj_id].name); 267 274 } 268 for ( reg_id = coproc[coproc_id].reg_offset ;269 reg_id < coproc[coproc_id].reg_offset+coproc[coproc_id].regs ;270 reg_id++ )271 {272 fprintf( fpout, " <reg name = \"%s\"\n", cp_reg[reg_id].name);273 fprintf( fpout, " type = \"%s\"\n", reg_type[cp_reg[reg_id].type]);274 fprintf( fpout, " value = \"0x%x\"\n", cp_reg[reg_id].value);275 fprintf( fpout, " channel = \"0x%x\"\n", cp_reg[reg_id].channel_id);276 fprintf( fpout, " index = \"0x%x\" />\n", cp_reg[reg_id].loc_id);277 }278 275 fprintf( fpout, " </coproc>\n" ); 276 } 277 278 ///////////////////// periphs /////////////////////////////////////////////// 279 280 for ( periph_id = cluster[cluster_id].periph_offset ; 281 periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs ; 282 periph_id++ ) 283 { 284 fprintf( fpout, " <periph type = \"%s\"\n", periph_type[periph[periph_id].type]); 285 fprintf( fpout, " psegname = \"%s\"\n", pseg[periph[periph_id].psegid].name); 286 fprintf( fpout, " channels = \"%d\" />\n", periph[periph_id].channels); 279 287 } 280 288 fprintf( fpout, " </cluster>\n" ); … … 356 364 fprintf( fpout, " startid = \"%d\"\n", task[task_id].startid); 357 365 fprintf( fpout, " usetty = \"%d\"\n", task[task_id].use_tty); 358 fprintf( fpout, " usefb = \"%d\" />\n\n", task[task_id].use_fb); 366 fprintf( fpout, " usenic = \"%d\"\n", task[task_id].use_nic); 367 fprintf( fpout, " usetimer = \"%d\"\n", task[task_id].use_timer); 368 fprintf( fpout, " usefbma = \"%d\" />\n\n", task[task_id].use_fbdma); 359 369 } 360 370 fprintf( fpout, " </vspace>\n\n"); -
soft/giet_vm/xml/xml_parser.c
r188 r189 20 20 #include <libxml/xmlreader.h> 21 21 #include <mapping_info.h> 22 #include <irq_handler.h> 22 23 23 24 #define MAX_CLUSTERS 1024 … … 32 33 #define MAX_COPROCS 4096 33 34 #define MAX_CP_PORTS 8192 34 #define MAX_ CP_REGS 819235 #define MAX_PERIPHS 8192 35 36 36 37 #define XML_PARSER_DEBUG 0 … … 49 50 mapping_proc_t* proc[MAX_PROCS]; // proc array 50 51 mapping_irq_t* irq[MAX_IRQS]; // irq array 51 mapping_coproc_t* coproc[MAX_COPROCS]; // coproc array 52 mapping_coproc_port_t* cp_port[MAX_CP_PORTS]; // coproc port array 53 mapping_coproc_reg_t* cp_reg[MAX_CP_REGS]; // coproc reg array 54 55 typedef struct vobj_ref_s 56 { 57 char vspace_name[32]; 58 char vobj_name[32]; 59 }vobj_ref_t; 60 61 // This arrray is useful to temporary save the a vobj referece 62 // formed by a vspace_name and a vobj_name (struct vobj_ref_s). 63 // This arry will be used to set the attribute vobj_id of coproc_port 64 // once all the vspace have been parsed. 65 vobj_ref_t* cp_port_vobj_ref[MAX_CP_PORTS]; 52 mapping_coproc_t* coproc[MAX_COPROCS]; // coproc array 53 mapping_cp_port_t* cp_port[MAX_CP_PORTS]; // coproc port array 54 mapping_periph_t* periph[MAX_PERIPHS]; // peripheral array 55 56 // Index for the various arrays 66 57 67 58 unsigned int cluster_index = 0; … … 82 73 unsigned int cp_port_loc_index = 0; 83 74 84 unsigned int cp_reg_index = 0;85 unsigned int cp_reg_loc_index = 0;75 unsigned int periph_index = 0; 76 unsigned int periph_loc_index = 0; 86 77 87 78 unsigned int vseg_index = 0; 88 79 unsigned int vseg_loc_index = 0; 80 89 81 unsigned int task_index = 0; 90 82 unsigned int task_loc_index = 0; 83 91 84 unsigned int vobj_index = 0; 92 85 unsigned int vobj_loc_index = 0; 93 86 unsigned int vobj_count = 0; 94 87 95 unsigned int tty_index = 1; 96 unsigned int fb_index = 0; 97 88 /////////////////////////////////////////////////////////////////////// 89 // This arrray is useful to build a temporary list of vobj references. 90 // The struct vobj_ref_s is formed by a vspace_name and a vobj_name. 91 // This array is used to set the attribute vobj_id of a cp_port 92 // once all the vspace have been parsed. 93 94 typedef struct vobj_ref_s 95 { 96 char vspace_name[32]; 97 char vobj_name[32]; 98 }vobj_ref_t; 99 100 vobj_ref_t* cp_port_vobj_ref[MAX_CP_PORTS]; 101 102 98 103 ////////////////////////////////////////////////// 99 104 unsigned int getIntValue( xmlTextReaderPtr reader, … … 183 188 //////////////////////////////////////////// 184 189 int getVspaceId( char* vspace_name) 185 ////////////////////////////////////////////186 190 { 187 191 unsigned int vspace_id; … … 201 205 char* vobj_name, 202 206 unsigned int vspace_max) 203 ////////////////////////////////////////////204 207 { 205 208 unsigned int vobj_id; … … 235 238 #endif 236 239 237 cp_port[cp_port_index] = (mapping_c oproc_port_t*)malloc(sizeof(mapping_coproc_port_t));240 cp_port[cp_port_index] = (mapping_cp_port_t*)malloc(sizeof(mapping_cp_port_t)); 238 241 cp_port_vobj_ref[cp_port_index] = (vobj_ref_t*)malloc(sizeof(vobj_ref_t)); 239 242 … … 251 254 else 252 255 { 253 printf("[XML ERROR] illegal <direction> for c oproc_port %d in cluster %d\n",256 printf("[XML ERROR] illegal <direction> for cp_port %d in cluster %d\n", 254 257 cp_port_index, cluster_index); 255 258 exit(1); … … 258 261 else 259 262 { 260 printf("[XML ERROR] missing <direction> for c oproc_port %d in cluster %d\n",263 printf("[XML ERROR] missing <direction> for cp_port %d in cluster %d\n", 261 264 cp_port_index, cluster_index); 262 265 exit(1); … … 274 277 else 275 278 { 276 printf("[XML ERROR] missing <vspacename> for c oproc_port %d in cluster %d\n",279 printf("[XML ERROR] missing <vspacename> for cp_port %d in cluster %d\n", 277 280 cp_port_index, cluster_index); 278 281 exit(1); … … 290 293 else 291 294 { 292 printf("[XML ERROR] missing <vobjname> for c oproc_port %d in cluster %d\n",295 printf("[XML ERROR] missing <vobjname> for cp_port %d in cluster %d\n", 293 296 cp_port_index, cluster_index); 294 297 exit(1); … … 300 303 } // end cpPortNode() 301 304 302 ///////////////////////////////////////// 303 void cpRegNode ( xmlTextReaderPtr reader )304 ///////////////////////////////////////// 305 /////////////////////////////////////////// 306 void periphNode ( xmlTextReaderPtr reader ) 307 /////////////////////////////////////////// 305 308 { 306 309 char* str; 307 310 unsigned int value; 308 unsigned int 311 unsigned int ok; 309 312 310 313 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 311 314 312 /* TWO: check source file consistency if possible */ 313 if ( cp_reg_index >= MAX_CP_REGS ) 314 { 315 printf("[XML ERROR] The number of regs (for coprocs) is larger than %d\n", MAX_CP_REGS); 316 } 317 318 #if XML_PARSER_DEBUG 319 printf("\n reg %d\n", cp_reg_index); 320 #endif 321 322 /* THIRD*/ 323 cp_reg[cp_reg_index] = (mapping_coproc_reg_t*)malloc(sizeof(mapping_coproc_reg_t)); 324 325 /* FOURTH: read all attribute*/ 326 327 /////////// get name attribute 328 str = getStringValue( reader, "name", &ok ); 329 #if XML_PARSER_DEBUG 330 printf(" name = %s\n", str); 331 #endif 315 if ( periph_index >= MAX_PERIPHS ) 316 { 317 printf("[XML ERROR] The number of periphs is larger than %d\n", MAX_PERIPHS); 318 } 319 320 #if XML_PARSER_DEBUG 321 printf("\n periph %d\n", periph_index); 322 #endif 323 324 periph[periph_index] = (mapping_periph_t*)malloc(sizeof(mapping_periph_t)); 325 326 /////////// get type attribute 327 str = getStringValue( reader, "type", &ok ); 332 328 if ( ok ) 333 329 { 334 strncpy(cp_reg[cp_reg_index]->name, str, 31); 335 } 336 else 337 { 338 printf("[XML ERROR] illegal or missing <name> for coproc_reg %d in cluster %d\n", 339 cp_reg_index, cluster_index); 340 exit(1); 341 } 330 #if XML_PARSER_DEBUG 331 printf(" type = %s\n", str); 332 #endif 333 unsigned int error = 0; 334 335 // The TTY, IOC, NIC, FBF and IOB peripherals cannot be replicated 336 if ( strcmp( str, "IOC" ) == 0 ) 337 { 338 periph[periph_index]->type = PERIPH_TYPE_IOC; 339 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index; 340 else error = 1; 341 } 342 else if ( strcmp( str, "TTY" ) == 0 ) 343 { 344 periph[periph_index]->type = PERIPH_TYPE_TTY; 345 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index; 346 else error = 1; 347 } 348 else if ( strcmp( str, "FBF" ) == 0 ) 349 { 350 periph[periph_index]->type = PERIPH_TYPE_FBF; 351 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index; 352 else error = 1; 353 } 354 else if ( strcmp( str, "NIC" ) == 0 ) 355 { 356 periph[periph_index]->type = PERIPH_TYPE_NIC; 357 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index; 358 else error = 1; 359 } 360 // The TIM, DMA and IOB peripherals can be replicated in several clusters 361 else if ( strcmp( str, "TIM" ) == 0 ) 362 { 363 periph[periph_index]->type = PERIPH_TYPE_TIM; 364 } 365 else if ( strcmp( str, "DMA" ) == 0 ) 366 { 367 periph[periph_index]->type = PERIPH_TYPE_DMA; 368 } 369 else if ( strcmp( str, "IOB" ) == 0 ) 370 { 371 periph[periph_index]->type = PERIPH_TYPE_IOB; 372 } 373 else 374 { 375 printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n", 376 periph_loc_index, cluster_index); 377 exit(1); 378 } 379 } 380 else 381 { 382 printf("[XML ERROR] missing <type> for peripheral %d in cluster %d\n", 383 periph_loc_index, cluster_index); 384 exit(1); 385 } 386 387 ///////// get channels attribute (optionnal : 1 if missing) 388 value = getIntValue( reader, "channels", &ok ); 389 if ( ok ) 390 { 391 #if XML_PARSER_DEBUG 392 printf(" channels = %d\n", value); 393 #endif 394 periph[periph_index]->channels = value; 395 } 396 else 397 { 398 periph[periph_index]->channels = 1; 399 } 400 401 /////////// get psegname attribute 402 str = getStringValue(reader,"psegname", &ok); 403 if ( ok == 0 ) 404 { 405 printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", 406 coproc_index, cluster_index); 407 exit(1); 408 } 409 410 /////////// set psegid attribute 411 int index = getPsegId( cluster_index, str ); 412 if ( index >= 0 ) 413 { 414 #if XML_PARSER_DEBUG 415 printf(" clusterid = %d\n", cluster_index); 416 printf(" psegname = %s\n", str); 417 printf(" psegid = %d\n", index); 418 #endif 419 periph[periph_index]->psegid = index; 420 assert(pseg[index]->type == PSEG_TYPE_PERI && 421 "peripheral psegname attribute must refer to a pseg of type PERI" ); 422 } 423 else 424 { 425 printf("[XML ERROR] pseg not found for periph %d / clusterid = %d / psegname = %s\n", 426 periph_loc_index, cluster_index, str ); 427 exit(1); 428 } 342 429 343 ///////// get type attribute 344 str = getStringValue( reader, "type", &ok ); 345 if ( ok ) 346 { 347 #if XML_PARSER_DEBUG 348 printf(" type = %s\n", str); 349 #endif 350 if ( strcmp(str, "STATUS") ) cp_reg[cp_reg_index]->type = REG_TYPE_STATUS; 351 else if ( strcmp(str, "CONFIG") ) cp_reg[cp_reg_index]->type = REG_TYPE_CONFIG; 352 else 353 { 354 printf("[XML ERROR] illegal <type> for coproc_reg %d in cluster %d\n", 355 cp_reg_index, cluster_index); 356 exit(1); 357 } 358 } 359 else 360 { 361 printf("[XML ERROR] missing <type> for coproc_reg %d in cluster %d\n", 362 cp_reg_index, cluster_index); 363 exit(1); 364 } 365 366 ///////// get value attribute 367 value = getIntValue(reader, "value", &ok); 368 if ( ok ) 369 { 370 #if XML_PARSER_DEBUG 371 printf(" value = %d\n", value); 372 #endif 373 cp_reg[cp_reg_index]->value = value; 374 } 375 else 376 { 377 printf("[XML ERROR] illegal or missing <value> for coproc_reg %d in cluster %d\n", 378 cp_reg_index, cluster_index); 379 exit(1); 380 } 381 382 ///////// get channel attribute 383 value = getIntValue(reader, "channel", &ok); 384 if ( ok ) 385 { 386 #if XML_PARSER_DEBUG 387 printf(" channel = %d\n", value); 388 #endif 389 cp_reg[cp_reg_index]->channel_id = value; 390 } 391 else 392 { 393 printf("[XML ERROR] illegal or missing <channel> for coproc_reg %d in cluster %d\n", 394 cp_reg_index, cluster_index); 395 exit(1); 396 } 397 398 ///////// get index attribute 399 value = getIntValue(reader, "index", &ok); 400 if ( ok ) 401 { 402 #if XML_PARSER_DEBUG 403 printf(" index = %d\n", value); 404 #endif 405 cp_reg[cp_reg_index]->loc_id = value; 406 } 407 else 408 { 409 printf("[XML ERROR] illegal or missing <index> for coproc_reg %d in cluster %d\n", 410 cp_reg_index, cluster_index); 411 exit(1); 412 } 413 414 cp_reg_index++; 415 cp_reg_loc_index++; 416 417 } // end cpRegNode() 430 periph_index++; 431 periph_loc_index++; 432 433 } // end periphNode 418 434 419 435 ///////////////////////////////////////// … … 425 441 426 442 cp_port_loc_index = 0; 427 cp_reg_loc_index = 0;428 443 429 444 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 439 454 440 455 coproc[coproc_index] = (mapping_coproc_t*)malloc(sizeof(mapping_coproc_t)); 441 442 456 443 457 /////////// get name attribute … … 485 499 } 486 500 487 ////////// set port_offset and reg_offset attribute501 ////////// set port_offset 488 502 coproc[coproc_index]->port_offset = cp_port_index; 489 coproc[coproc_index]->reg_offset = cp_reg_index; 490 491 #if XML_PARSER_DEBUG 492 printf(" port_offset = %d\n", cp_port_index); 493 printf(" reg_offset = %d\n", cp_reg_index); 503 504 #if XML_PARSER_DEBUG 505 printf(" port_offset = %d\n", cp_port_index); 494 506 #endif 495 507 … … 499 511 const char* tag = (const char*)xmlTextReaderConstName(reader); 500 512 501 if ( strcmp(tag,"port") == 0 ) cpPortNode(reader); 502 else if ( strcmp(tag,"reg") == 0 ) cpRegNode(reader); 503 else if ( strcmp(tag,"#text" ) == 0 ) { } 504 else if ( strcmp(tag,"#comment") == 0 ); 505 else if ( strcmp(tag,"coproc") == 0 ) 513 if ( strcmp(tag, "port") == 0 ) cpPortNode(reader); 514 else if ( strcmp(tag, "#text") == 0 ) { } 515 else if ( strcmp(tag, "#comment") == 0 ) { } 516 else if ( strcmp(tag, "coproc") == 0 ) 506 517 { 507 518 coproc[coproc_index]->ports = cp_port_loc_index; 508 coproc[coproc_index]->regs = cp_reg_loc_index;509 519 coproc_loc_index++; 510 520 coproc_index++; … … 548 558 printf(" type = %s\n", str); 549 559 #endif 550 if ( strcmp(str, "HARD") ) irq[irq_index]->type = IRQ_TYPE_HARD;551 else if ( strcmp(str, "SOFT") ) irq[irq_index]->type = IRQ_TYPE_SOFT;560 if ( strcmp(str, "HARD") == 0 ) irq[irq_index]->type = 0; 561 else if ( strcmp(str, "SOFT") == 0 ) irq[irq_index]->type = 1; 552 562 else 553 563 { … … 564 574 } 565 575 566 ///////// get i rqid attribute576 ///////// get icuid attribute 567 577 value = getIntValue(reader, "icuid", &ok); 568 578 if ( ok ) … … 593 603 printf(" isr = %s\n", str); 594 604 #endif 595 if ( strcmp(str, "ISR_SWITCH") ) irq[irq_index]->isr = ISR_SWITCH; 596 else if ( strcmp(str, "ISR_IOC") ) irq[irq_index]->isr = ISR_IOC; 597 else if ( strcmp(str, "ISR_FBDMA") ) irq[irq_index]->isr = ISR_FBDMA; 598 else if ( strcmp(str, "ISR_TTY") ) irq[irq_index]->isr = ISR_TTY; 605 if ( strcmp(str, "ISR_SWITCH" ) == 0 ) irq[irq_index]->isr = ISR_SWITCH; 606 else if ( strcmp(str, "ISR_IOC" ) == 0 ) irq[irq_index]->isr = ISR_IOC; 607 else if ( strcmp(str, "ISR_DMA" ) == 0 ) irq[irq_index]->isr = ISR_DMA; 608 else if ( strcmp(str, "ISR_TTY" ) == 0 ) irq[irq_index]->isr = ISR_TTY; 609 else if ( strcmp(str, "ISR_TIMER" ) == 0 ) irq[irq_index]->isr = ISR_TIMER; 599 610 else 600 611 { … … 603 614 exit(1); 604 615 } 616 #if XML_PARSER_DEBUG 617 printf(" isrnum = %d\n", irq[irq_index]->isr); 618 #endif 605 619 } 606 620 else … … 664 678 ////////// set irq_offset attribute 665 679 proc[proc_index]->irq_offset = irq_index; 680 666 681 #if XML_PARSER_DEBUG 667 682 printf(" irq_offset = %d\n", irq_index); … … 673 688 const char* tag = (const char*)xmlTextReaderConstName(reader); 674 689 675 if ( strcmp(tag, "irq")== 0 ) irqNode(reader);676 else if ( strcmp(tag, "#text")== 0 ) { }677 else if ( strcmp(tag, "#comment") == 0 );678 else if ( strcmp(tag, "proc")== 0 )690 if ( strcmp(tag, "irq") == 0 ) irqNode(reader); 691 else if ( strcmp(tag, "#text") == 0 ) { } 692 else if ( strcmp(tag, "#comment") == 0 ) { } 693 else if ( strcmp(tag, "proc") == 0 ) 679 694 { 680 695 proc[proc_index]->irqs = irq_loc_index; … … 817 832 } 818 833 819 /////////// get use _tty attribute (optionnal : 0 if missing)834 /////////// get usetty attribute (optionnal : 0 if missing) 820 835 value = getIntValue(reader,"usetty", &ok); 821 836 if ( ok ) … … 824 839 printf(" usetty = %x\n", value); 825 840 #endif 826 if ( (value != 0) && (tty_index >= header->ttys) )827 {828 printf("[XML ERROR] The tty index is too large for task (%d,%d)\n",829 vspace_index, task_loc_index);830 exit(1);831 }832 841 task[task_index]->use_tty = value; 833 if (value != 0) tty_index++;834 842 } 835 843 else … … 838 846 } 839 847 840 /////////// get use_fb attribute (optionnal : 0 if missing) 841 value = getIntValue(reader,"usefb", &ok); 842 if ( ok ) 843 { 844 #if XML_PARSER_DEBUG 845 printf(" usefb = %x\n", value); 846 #endif 847 if ( (value != 0) && (fb_index >= header->fbs) ) 848 { 849 printf("[XML ERROR] The fb channel index is too large for task (%d,%d)\n", 850 vspace_index, task_loc_index); 851 exit(1); 852 } 853 task[task_index]->use_fb = value; 854 if (value != 0) fb_index++; 848 /////////// get usenic attribute (optionnal : 0 if missing) 849 value = getIntValue(reader,"usenic", &ok); 850 if ( ok ) 851 { 852 #if XML_PARSER_DEBUG 853 printf(" usenic = %x\n", value); 854 #endif 855 task[task_index]->use_nic = value; 855 856 } 856 857 else 857 858 { 858 task[task_index]->use_fb = 0; 859 task[task_index]->use_nic = 0; 860 } 861 862 /////////// get usetimer attribute (optionnal : 0 if missing) 863 value = getIntValue(reader,"usetimer", &ok); 864 if ( ok ) 865 { 866 #if XML_PARSER_DEBUG 867 printf(" usetimer = %x\n", value); 868 #endif 869 task[task_index]->use_timer = value; 870 } 871 else 872 { 873 task[task_index]->use_timer = 0; 874 } 875 876 /////////// get usefbdma attribute (optionnal : 0 if missing) 877 value = getIntValue(reader,"usefbdma", &ok); 878 if ( ok ) 879 { 880 #if XML_PARSER_DEBUG 881 printf(" usefbdma = %x\n", value); 882 #endif 883 task[task_index]->use_fbdma = value; 884 } 885 else 886 { 887 task[task_index]->use_fbdma = 0; 859 888 } 860 889 … … 865 894 ////////////////////////////////////////// 866 895 void vobjNode ( xmlTextReaderPtr reader ) 896 ////////////////////////////////////////// 867 897 { 868 898 unsigned int ok; … … 986 1016 else 987 1017 { 988 if((vobj[vobj_index]->type == VOBJ_TYPE_MWMR || vobj[vobj_index]->type == VOBJ_TYPE_BARRIER )) 1018 if( (vobj[vobj_index]->type == VOBJ_TYPE_MWMR) || 1019 (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) ) 989 1020 { 990 1021 printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d). \ … … 1003 1034 ////////////////////////////////////////// 1004 1035 void vsegNode ( xmlTextReaderPtr reader ) 1036 ////////////////////////////////////////// 1005 1037 { 1006 1038 unsigned int ok; … … 1144 1176 const char* tag = (const char*)xmlTextReaderConstName(reader); 1145 1177 1146 if ( strcmp(tag,"vobj") == 0 ) vobjNode(reader); 1147 else if ( strcmp(tag,"#text" ) == 0 ) { } 1148 else if ( strcmp(tag,"vseg") == 0 ) 1178 if ( strcmp(tag, "vobj") == 0 ) vobjNode(reader); 1179 else if ( strcmp(tag, "#text" ) == 0 ) { } 1180 else if ( strcmp(tag, "#comment") == 0 ) { } 1181 else if ( strcmp(tag, "vseg") == 0 ) 1149 1182 { 1150 1183 vseg[vseg_index]->vobjs = vobj_count; … … 1164 1197 ////////////////////////////////////////// 1165 1198 void vspaceNode( xmlTextReaderPtr reader ) 1199 ////////////////////////////////////////// 1166 1200 { 1167 1201 char* str; … … 1233 1267 const char* tag = (const char*)xmlTextReaderConstName(reader); 1234 1268 1235 if ( strcmp(tag, "vseg")== 0 ) vsegNode(reader);1236 else if ( strcmp(tag, "task")== 0 ) taskNode(reader);1237 else if ( strcmp(tag, "#text")== 0 ) { }1238 else if ( strcmp(tag, "#comment") == 0 );1239 else if ( strcmp(tag, "vspace")== 0 )1269 if ( strcmp(tag, "vseg") == 0 ) vsegNode(reader); 1270 else if ( strcmp(tag, "task") == 0 ) taskNode(reader); 1271 else if ( strcmp(tag, "#text") == 0 ) { } 1272 else if ( strcmp(tag, "#comment") == 0 ) { } 1273 else if ( strcmp(tag, "vspace") == 0 ) 1240 1274 { 1241 1275 vspace[vspace_index]->vobjs = vobj_loc_index; … … 1288 1322 ////////////////////////////////////////// 1289 1323 void psegNode ( xmlTextReaderPtr reader ) 1324 ////////////////////////////////////////// 1290 1325 { 1291 1326 unsigned int ok; … … 1379 1414 ///////////////////////////////////////////// 1380 1415 void clusterNode ( xmlTextReaderPtr reader ) 1416 ///////////////////////////////////////////// 1381 1417 { 1382 1418 unsigned int ok; … … 1385 1421 proc_loc_index = 0; 1386 1422 coproc_loc_index = 0; 1387 cluster[cluster_index]= 0;1423 periph_loc_index = 0; 1388 1424 1389 1425 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 1402 1438 cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t)); 1403 1439 1404 /////////// getindex attribute (optional)1440 /////////// check cluster index attribute (optional) 1405 1441 value = getIntValue(reader,"index",&ok); 1406 1442 if ( ok && (value != cluster_index) ) … … 1411 1447 } 1412 1448 1413 1414 ////////// set pseg_offset attribute 1415 cluster[cluster_index]->pseg_offset = pseg_index; 1416 cluster[cluster_index]->proc_offset = proc_index; 1449 ////////// set offsets 1450 cluster[cluster_index]->pseg_offset = pseg_index; 1451 cluster[cluster_index]->proc_offset = proc_index; 1417 1452 cluster[cluster_index]->coproc_offset = coproc_index; 1418 #if XML_PARSER_DEBUG 1419 printf(" pseg_offset = %d\n", pseg_index); 1420 printf(" proc_offset = %d\n", proc_index); 1453 cluster[cluster_index]->periph_offset = periph_index; 1454 1455 #if XML_PARSER_DEBUG 1456 printf(" pseg_offset = %d\n", pseg_index); 1457 printf(" proc_offset = %d\n", proc_index); 1421 1458 printf(" coproc_offset = %d\n", coproc_index); 1422 #endif 1423 1424 ////////// get psegs, coproc and/or procs 1459 printf(" periph_offset = %d\n", coproc_index); 1460 #endif 1461 1462 ////////// get psegs, procs, coprocs and periphs 1425 1463 int status = xmlTextReaderRead(reader); 1426 1464 … … 1429 1467 const char* tag = (const char*)xmlTextReaderConstName(reader); 1430 1468 1431 if ( strcmp(tag, "pseg") == 0 ) psegNode(reader); 1432 else if ( strcmp(tag, "proc") == 0 ) procNode(reader); 1433 else if ( strcmp(tag, "coproc") == 0 ) coprocNode(reader); 1434 else if ( strcmp(tag, "#text") == 0 ) { } 1435 else if ( strcmp(tag,"#comment") == 0 ); 1436 else if ( strcmp(tag, "cluster") == 0 ) 1437 { 1438 #if XML_PARSER_DEBUG 1469 if ( strcmp(tag, "pseg") == 0 ) psegNode(reader); 1470 else if ( strcmp(tag, "proc") == 0 ) procNode(reader); 1471 else if ( strcmp(tag, "coproc") == 0 ) coprocNode(reader); 1472 else if ( strcmp(tag, "periph") == 0 ) periphNode(reader); 1473 else if ( strcmp(tag, "#text") == 0 ) { } 1474 else if ( strcmp(tag, "#comment") == 0 ) { } 1475 else if ( strcmp(tag, "cluster") == 0 ) 1476 { 1477 cluster[cluster_index]->procs = proc_loc_index; 1478 cluster[cluster_index]->coprocs = coproc_loc_index; 1479 cluster[cluster_index]->periphs = periph_loc_index; 1480 1481 // cluster[cluster_index]psegs update is done in psegNode(), 1482 // because the coprocNode() call to getPsegId() need it 1483 1484 #if XML_PARSER_DEBUG 1485 printf(" psegs = %d\n", cluster[cluster_index]->psegs); 1486 printf(" procs = %d\n", cluster[cluster_index]->procs); 1487 printf(" coprocs = %d\n", cluster[cluster_index]->coprocs); 1488 printf(" periphs = %d\n", cluster[cluster_index]->periphs); 1439 1489 printf(" end cluster %d\n", cluster_index); 1440 1490 #endif 1441 cluster[cluster_index]->procs = proc_loc_index;1442 cluster[cluster_index]->coprocs = coproc_loc_index;1443 //psegs = pseg_loc_index is done in psegNode(), so coprocNode() call to getPsegId() success1444 1491 cluster_index++; 1445 1492 return; … … 1451 1498 ////////////////////////////////////////////// 1452 1499 void clusterSetNode( xmlTextReaderPtr reader ) 1500 ////////////////////////////////////////////// 1453 1501 { 1454 1502 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 1463 1511 const char* tag = (const char*)xmlTextReaderConstName(reader); 1464 1512 1465 if ( strcmp(tag, "cluster")== 0 ) clusterNode(reader);1466 else if ( strcmp(tag, "#text")== 0 ) { }1467 else if ( strcmp(tag, "#comment") == 0 );1468 else if ( strcmp(tag, "clusterset") == 0 )1513 if ( strcmp(tag, "cluster") == 0 ) clusterNode(reader); 1514 else if ( strcmp(tag, "#text") == 0 ) { } 1515 else if ( strcmp(tag, "#comment") == 0 ) { } 1516 else if ( strcmp(tag, "clusterset") == 0 ) 1469 1517 { 1470 1518 // checking source file consistency … … 1479 1527 printf(" end cluster set\n\n"); 1480 1528 #endif 1481 header->psegs = pseg_index;1482 header->procs = proc_index;1483 header->irqs = irq_index;1484 header->coprocs = coproc_index;1529 header->psegs = pseg_index; 1530 header->procs = proc_index; 1531 header->irqs = irq_index; 1532 header->coprocs = coproc_index; 1485 1533 header->cp_ports = cp_port_index; 1486 header->cp_regs = cp_reg_index;1487 1534 return; 1488 1535 } … … 1499 1546 ///////////////////////////////////////////// 1500 1547 void globalSetNode( xmlTextReaderPtr reader ) 1548 ///////////////////////////////////////////// 1501 1549 { 1502 1550 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 1511 1559 const char* tag = (const char*)xmlTextReaderConstName(reader); 1512 1560 1513 if ( strcmp(tag, "vseg") == 0) vsegNode(reader);1514 else if ( strcmp(tag, "#text" )== 0 ) { }1515 else if ( strcmp(tag, "#comment") == 0 );1516 else if ( strcmp(tag, "globalset") == 0)1561 if ( strcmp(tag, "vseg") == 0 ) vsegNode(reader); 1562 else if ( strcmp(tag, "#text" ) == 0 ) { } 1563 else if ( strcmp(tag, "#comment") == 0 ) { } 1564 else if ( strcmp(tag, "globalset") == 0 ) 1517 1565 { 1518 1566 // checking source file consistency … … 1542 1590 ///////////////////////////////////////////// 1543 1591 void vspaceSetNode( xmlTextReaderPtr reader ) 1592 ///////////////////////////////////////////// 1544 1593 { 1545 1594 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 1554 1603 const char* tag = (const char*)xmlTextReaderConstName(reader); 1555 1604 1556 if ( strcmp(tag, "vspace") == 0) vspaceNode(reader);1557 else if ( strcmp(tag, "#text") == 0 ) { }1558 else if ( strcmp(tag, "#comment") == 0 );1559 else if ( strcmp(tag, "vspaceset") == 0)1605 if ( strcmp(tag, "vspace" ) == 0 ) vspaceNode(reader); 1606 else if ( strcmp(tag, "#text" ) == 0 ) { } 1607 else if ( strcmp(tag, "#comment" ) == 0 ) { } 1608 else if ( strcmp(tag, "vspaceset") == 0 ) 1560 1609 { 1561 1610 // checking source file consistency … … 1584 1633 ////////////////////////////////////////// 1585 1634 void headerNode(xmlTextReaderPtr reader ) 1635 ////////////////////////////////////////// 1586 1636 { 1587 1637 char* name; … … 1632 1682 } 1633 1683 1634 ///////// get ttys attribute1635 value = getIntValue(reader, "ttys", &ok);1636 if ( ok )1637 {1638 #if XML_PARSER_DEBUG1639 printf(" ttys = %d\n", value);1640 #endif1641 header->ttys = value;1642 }1643 else1644 {1645 printf("[XML ERROR] illegal or missing <ttys> attribute in header\n");1646 exit(1);1647 }1648 1649 ///////// get fbs attribute1650 value = getIntValue(reader, "fbs", &ok);1651 if ( ok )1652 {1653 #if XML_PARSER_DEBUG1654 printf(" fbs = %d\n", value);1655 #endif1656 header->fbs = value;1657 }1658 else1659 {1660 printf("[XML ERROR] illegal or missing <fbs> attribute in header\n");1661 exit(1);1662 }1663 1664 1684 ///////// get vspaces attribute 1665 1685 value = getIntValue(reader, "vspaces", &ok); … … 1702 1722 } 1703 1723 1724 //////// initialise non replicated peripherals cluster_id 1725 header->tty_clusterid = 0xFFFFFFFF; 1726 header->nic_clusterid = 0xFFFFFFFF; 1727 header->ioc_clusterid = 0xFFFFFFFF; 1728 header->fbf_clusterid = 0xFFFFFFFF; 1729 1730 ///////// set signature 1704 1731 header->signature = IN_MAPPING_SIGNATURE; 1705 1732 … … 1709 1736 const char* tag = (const char*)xmlTextReaderConstName(reader); 1710 1737 1711 if ( strcmp(tag, "clusterset") == 0 ) clusterSetNode(reader);1712 else if ( strcmp(tag, "globalset") == 0 ) globalSetNode(reader);1713 else if ( strcmp(tag, "vspaceset") == 0 ) vspaceSetNode(reader);1714 else if ( strcmp(tag, "#text") == 0 ) ;1715 else if ( strcmp(tag, "#comment") == 0 ) ;1716 else if ( strcmp(tag, "mapping_info") == 0 )1738 if ( strcmp(tag, "clusterset") == 0 ) clusterSetNode(reader); 1739 else if ( strcmp(tag, "globalset") == 0 ) globalSetNode(reader); 1740 else if ( strcmp(tag, "vspaceset") == 0 ) vspaceSetNode(reader); 1741 else if ( strcmp(tag, "#text") == 0 ) { } 1742 else if ( strcmp(tag, "#comment") == 0 ) { } 1743 else if ( strcmp(tag, "mapping_info") == 0 ) 1717 1744 { 1718 1745 #if XML_PARSER_DEBUG … … 1730 1757 } // end headerNode() 1731 1758 1759 /////////////////////////////////////// 1732 1760 void BuildTable( int fdout, 1733 1761 const char* type, … … 1735 1763 unsigned int elem_size, 1736 1764 char** table) 1765 //////////////////////////////////////// 1737 1766 { 1738 1767 unsigned int i; … … 1758 1787 /////////////////////////// 1759 1788 void buildBin( int fdout ) 1789 /////////////////////////// 1760 1790 { 1761 1791 unsigned int vspace_id; … … 1823 1853 } 1824 1854 1825 // write tasks 1855 // write tasks array 1826 1856 BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char**) task); 1827 //building proc 1857 //building procs array 1828 1858 BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char**) proc); 1829 //building irq 1859 //building irqs array 1830 1860 BuildTable(fdout, "irq", irq_index, sizeof(mapping_irq_t), (char**)irq); 1831 //building coproc 1861 //building coprocs array 1832 1862 BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char**)coproc); 1833 //building cp_port 1834 BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_c oproc_port_t),(char**) cp_port);1835 //building cp_reg1836 BuildTable(fdout, " cp_reg", cp_reg_index, sizeof(mapping_coproc_reg_t), (char**)cp_reg);1863 //building cp_ports array 1864 BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_cp_port_t),(char**) cp_port); 1865 //building periphs array 1866 BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char**)periph); 1837 1867 1838 1868 } // end buildBin() 1839 1869 1840 ///////////////////////////////////////// 1841 // this function set the value of vobj_id 1842 // of the coproc_ports. 1843 /////////////////// 1870 /////////////////////////////////////////////////////////////////////// 1871 // this function set the value the vobj_id fiels of all cp_ports 1872 /////////////////////////////////////////////////////////////////////// 1844 1873 void prepareBuild() 1845 1874 { … … 1850 1879 if ( vspace_id < 0 ) 1851 1880 { 1852 printf("[XML ERROR] illegal <vspacename> for c oproc_port %d,\n",1881 printf("[XML ERROR] illegal <vspacename> for cp_port %d,\n", 1853 1882 i); 1854 1883 exit(1); … … 1856 1885 cp_port[i]->vspaceid = vspace_id; 1857 1886 1858 int vobj_id = getVobjLocId( vspace_id, cp_port_vobj_ref[i]->vobj_name, vspace[vspace_id]->vobjs ); 1887 int vobj_id = getVobjLocId( vspace_id, 1888 cp_port_vobj_ref[i]->vobj_name, 1889 vspace[vspace_id]->vobjs ); 1859 1890 if ( vobj_id >= 0 ) 1860 1891 { 1861 #if XML_PARSER_DEBUG 1862 printf("coproc_port = %d\n", i); 1892 1893 #if XML_PARSER_DEBUG 1894 printf("\ncp_port = %d\n", i); 1863 1895 printf(" vspace_name = %s\n", cp_port_vobj_ref[i]->vspace_name); 1864 1896 printf(" vobj_name = %s\n", cp_port_vobj_ref[i]->vobj_name); … … 1866 1898 #endif 1867 1899 cp_port[i]->vobjlocid = vobj_id; 1868 assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR) && "coproc ports has to refere to a vobj of type MWMR"); 1900 1901 assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR) 1902 && "coproc ports has to refere to a vobj of type MWMR"); 1869 1903 } 1870 1904 else 1871 1905 { 1872 printf("[XML ERROR] illegal <vobjname> for c oproc_port %d,\n",1906 printf("[XML ERROR] illegal <vobjname> for cp_port %d,\n", 1873 1907 i); 1874 1908 exit(1); 1875 1909 } 1876 1877 1910 } 1878 1911 } … … 1880 1913 ///////////////////////////////////// 1881 1914 int main ( int argc, char* argv[] ) 1915 ///////////////////////////////////// 1882 1916 { 1883 1917 if ( argc < 3 ) … … 1913 1947 } 1914 1948 else 1915 if ( strcmp(tag,"#comment") == 0 );// a way to skips comment1916 else1917 1949 { 1918 1950 printf("[XML ERROR] Wrong file type: \"%s\"\n", argv[1]);
Note: See TracChangeset
for help on using the changeset viewer.