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