Changeset 238 for soft/giet_vm/xml
- Timestamp:
- May 29, 2013, 1:24:09 AM (11 years ago)
- Location:
- soft/giet_vm/xml
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/xml/mapping_info.h
r232 r238 50 50 #define OUT_MAPPING_SIGNATURE 0xBABEF00D 51 51 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 { 52 typedef unsigned long long paddr_t; 53 54 enum vobjType 55 { 56 VOBJ_TYPE_ELF = 0, // loadable code/data object of elf files 57 VOBJ_TYPE_BLOB = 1, // loadable blob object 58 VOBJ_TYPE_PTAB = 2, // page table 59 VOBJ_TYPE_PERI = 3, // hardware component 60 VOBJ_TYPE_MWMR = 4, // MWMR channel 61 VOBJ_TYPE_LOCK = 5, // Lock 62 VOBJ_TYPE_BUFFER = 6, // Any "no initialization" objects (stacks...) 63 VOBJ_TYPE_BARRIER = 7, // Barrier 64 VOBJ_TYPE_CONST = 8, // Constant 65 VOBJ_TYPE_MEMSPACE = 9, // Memspace (descriptor must be initialised) 66 VOBJ_TYPE_SCHED = 10, // Array of schedulers (one per cluster) 67 }; 68 69 70 enum psegType 71 { 67 72 PSEG_TYPE_RAM = 0, 68 73 PSEG_TYPE_ROM = 1, … … 71 76 72 77 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 { 78 enum periphType 79 { 80 PERIPH_TYPE_ICU = 0, 81 PERIPH_TYPE_TIM = 1, 82 PERIPH_TYPE_DMA = 2, 83 PERIPH_TYPE_CMA = 3, 84 PERIPH_TYPE_IOC = 4, 85 PERIPH_TYPE_TTY = 5, 86 PERIPH_TYPE_FBF = 6, 87 PERIPH_TYPE_NIC = 7, 88 PERIPH_TYPE_IOB = 8, 89 PERIPH_TYPE_GCD = 9, 90 PERIPH_TYPE_MAX_VALUE = 10, 91 }; 92 93 94 enum mwmrPortDirection 95 { 87 96 PORT_TO_COPROC = 0, // status register 88 97 PORT_FROM_COPROC = 1, // config register … … 92 101 /////////////////////////////// 93 102 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 103 typedef struct mapping_header_s 104 { 105 unsigned int signature; // must contain MAPPING_SIGNATURE 106 unsigned int clusters; // number of clusters 107 unsigned int cluster_x; // number of cluster in a row 108 unsigned int cluster_y; // number of cluster in a column 109 unsigned int globals; // number of vsegs mapped in all vspaces 110 unsigned int vspaces; // number of virtual spaces 111 112 unsigned int tty_cluster; // index of cluster containing TTY controler 113 unsigned int tty_cluster_bis; // index of cluster containing second TTY controler 114 unsigned int ioc_cluster; // index of cluster containing IOC controler 115 unsigned int ioc_cluster_bis; // index of cluster containing second IOC controler 116 unsigned int nic_cluster; // index of cluster containing NIC controler 117 unsigned int nic_cluster_bis; // index of cluster containing second NIC controler 118 unsigned int fbf_cluster; // index of cluster containing FBF controler 119 unsigned int fbf_cluster_bis; // index of cluster containing second FBF controler 120 unsigned int cma_cluster; // index of cluster containing CMA controler 121 unsigned int cma_cluster_bis; // index of cluster containing second CMA controler 122 unsigned int iob_cluster; // index of cluster containing IOB controler 123 unsigned int iob_cluster_bis; // index of cluster containing second IOB controler 124 125 unsigned int psegs; // total number of physical segments (for all clusters) 126 unsigned int vsegs; // total number of virtual segments (for all vspaces) 127 unsigned int vobjs; // total number of virtual objects (for all vspaces) 128 unsigned int tasks; // total number of tasks (for all vspaces) 129 unsigned int procs; // total number of procs (for all clusters) 130 unsigned int irqs; // total number of irqs (for all processors) 131 unsigned int coprocs; // total number of coprocs (for all clusters) 132 unsigned int cp_ports; // total number of cp_ports (for all coprocs) 133 unsigned int periphs; // total number of peripherals (for all clusters) 134 135 char name[32]; // mapping name 118 136 } mapping_header_t; 119 137 120 138 121 139 //////////////////////////////// 122 typedef struct mapping_cluster_s { 140 typedef struct mapping_cluster_s 141 { 123 142 unsigned int psegs; // number of psegs in cluster 124 143 unsigned int pseg_offset; // index of first pseg in pseg set … … 136 155 137 156 ///////////////////////////// 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) 157 typedef struct mapping_pseg_s 158 { 159 char name[32]; // pseg name (unique in a cluster) 160 paddr_t base; // base address in physical space 161 paddr_t length; // size (bytes) 142 162 unsigned int type; // RAM / ROM / PERI 143 163 unsigned int cluster; // index of cluster containing pseg 144 unsigned intnext_base; // first free page base address164 paddr_t next_base; // first free page base address 145 165 } mapping_pseg_t; 146 166 147 167 148 168 /////////////////////////////// 149 typedef struct mapping_vspace_s { 150 char name[32]; // virtual space name 169 typedef struct mapping_vspace_s 170 { 171 char name[32]; // virtual space name 151 172 unsigned int start_offset; // offset of the vobj containing the start vector 152 173 unsigned int vsegs; // number of vsegs in vspace … … 160 181 161 182 ///////////////////////////// 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) 183 typedef struct mapping_vseg_s 184 { 185 char name[32]; // vseg name (unique in vspace) 186 unsigned int vbase; // base address in virtual space 187 paddr_t pbase; // base address in physical space 166 188 unsigned int length; // size (bytes) 167 189 unsigned int psegid; // physical segment global index … … 169 191 unsigned int ident; // identity mapping if non zero 170 192 unsigned int vobjs; // number of vobjs in vseg 171 unsigned int vobj_offset; // index of first vobj sin vseg193 unsigned int vobj_offset; // index of first vobj in vseg 172 194 } mapping_vseg_t; 173 195 174 196 175 197 ///////////////////////////// 176 typedef struct mapping_task_s { 177 char name[32]; // task name (unique in vspace) 198 typedef struct mapping_task_s 199 { 200 char name[32]; // task name (unique in vspace) 178 201 unsigned int clusterid; // physical cluster index 179 202 unsigned int proclocid; // processor local index (inside cluster) … … 181 204 unsigned int heap_vobjid; // heap vobj index in vspace 182 205 unsigned int startid; // index in start_vector 183 unsigned int use_tty; // TTY terminal required (global)206 unsigned int use_tty; // TTY channel required (global) 184 207 unsigned int use_nic; // NIC channel required (global) 185 unsigned int use_timer; // user timer required (local) 186 unsigned int use_fbdma; // DMA channel to frame buffer required (local) 208 unsigned int use_cma; // CMA channel required (global) 209 unsigned int use_ioc; // IOC channel required (global) 210 unsigned int use_tim; // user timer required (local) 211 unsigned int use_dma; // DMA channel required (local) 187 212 } mapping_task_t; 188 213 189 214 190 215 ///////////////////////////// 191 typedef struct mapping_vobj_s { 192 char name[32]; // vobj name (unique in a vspace) 193 char binpath[64]; // path for the binary code ("*.elf") 216 typedef struct mapping_vobj_s 217 { 218 char name[32]; // vobj name (unique in a vspace) 219 char binpath[64]; // path for the binary code ("*.elf") 194 220 unsigned int type; // type of vobj 195 221 unsigned int length; // size (bytes) 196 222 unsigned int align; // required alignement (logarithm of 2) 197 223 unsigned int vaddr; // virtual base addresse of the vobj 198 unsigned intpaddr; // physical base addresse of the vobj224 paddr_t paddr; // physical base addresse of the vobj 199 225 unsigned int init; // init value (used by barrier or mwmr channel) 200 226 } mapping_vobj_t; … … 202 228 203 229 ///////////////////////////// 204 typedef struct mapping_proc_s { 230 typedef struct mapping_proc_s 231 { 205 232 unsigned int irqs; // number of IRQs allocated to processor 206 233 unsigned int irq_offset; // index of first IRQ allocated to processor … … 209 236 210 237 ///////////////////////////// 211 typedef struct mapping_irq_s { 238 typedef struct mapping_irq_s 239 { 212 240 unsigned int type; // 0 => HW_IRQ / 1 => SW_IRQ 213 241 unsigned int icuid; // IRQ Index for the ICU component 214 unsigned int isr; // I nterrupt Service Routine Index215 unsigned int channel; // Channel Index (for multi-c annels peripherals)242 unsigned int isr; // ISR Index (defined in irq_handler.h) 243 unsigned int channel; // Channel Index (for multi-channels peripherals) 216 244 } mapping_irq_t; 217 245 218 246 219 247 /////////////////////////////// 220 typedef struct mapping_coproc_s { 221 char name[32]; // coprocessor name 248 typedef struct mapping_coproc_s 249 { 250 char name[32]; // coprocessor name 222 251 unsigned int psegid; // global pseg index 223 252 unsigned int ports; // number of MWMR ports used by coprocessor … … 227 256 228 257 //////////////////////////////// 229 typedef struct mapping_cp_port_s { 258 typedef struct mapping_cp_port_s 259 { 230 260 unsigned int direction; // TO_COPROC == 0 / FROM_COPROC == 1 231 261 unsigned int vspaceid; // index of the vspace containing the MWMR channel 232 unsigned int mwmr_vobjid; 262 unsigned int mwmr_vobjid; // local index of the vobj containing the MWMR channel 233 263 } mapping_cp_port_t; 234 264 235 265 236 266 /////////////////////////////// 237 typedef struct mapping_periph_s { 267 typedef struct mapping_periph_s 268 { 238 269 unsigned int type; // IOC / TTY / TIM / DMA / FBF / NIC / IOB 239 270 unsigned int psegid; // pseg index in cluster -
soft/giet_vm/xml/xml_driver.c
r232 r238 31 31 "CONST", // Constant 32 32 "MEMSPACE", // Memspace 33 "SCHED", // Scheduler 33 34 }; 34 35 … … 238 239 fprintf(fpout, " <pseg name = \"%s\" ", pseg[pseg_id].name); 239 240 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);241 fprintf(fpout, " base = \"0x%llx\" ", pseg[pseg_id].base); 242 fprintf(fpout, " length = \"0x%llx\" />\n", pseg[pseg_id].length); 242 243 } 243 244 … … 366 367 fprintf(fpout, "usetty = \"%d\" ", task[task_id].use_tty); 367 368 fprintf(fpout, "usenic = \"%d\" ", task[task_id].use_nic); 368 fprintf(fpout, "usetimer = \"%d\" ", task[task_id].use_timer); 369 fprintf(fpout, "usefbma = \"%d\" />\n", task[task_id].use_fbdma); 369 fprintf(fpout, "usedma = \"%d\" ", task[task_id].use_dma); 370 fprintf(fpout, "usecma = \"%d\" ", task[task_id].use_cma); 371 fprintf(fpout, "usetim = \"%d\" ", task[task_id].use_tim); 372 fprintf(fpout, "useioc = \"%d\" />\n", task[task_id].use_ioc); 370 373 } 371 374 fprintf(fpout, " </vspace>\n\n"); -
soft/giet_vm/xml/xml_parser.c
r232 r238 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 … … 95 95 96 96 97 ///////////////////////// 98 // fo und peripheral99 ///////////////////////// 97 ////////////////////////////// 98 // for replicated peripheral 99 ////////////////////////////// 100 100 char found_timer = 0; 101 101 char found_icu = 0; 102 char found_xicu = 0;103 102 char found_dma = 0; 104 103 105 104 106 ////////////////////////////////// 107 //needed to generate map_config.ld 108 ////////////////////////////////// 109 unsigned int cluster_y = 0; 110 unsigned int cluster_x = 0; 111 unsigned int nb_proc_max = 0; // max number of processors per cluste 112 113 unsigned int nb_tasks_max = 0; // max number of tasks (for all vspaces) 114 unsigned int nb_timer_channel_max = 0; // max number of user timer 115 unsigned int nb_dma_channel_max = 0; 116 unsigned int nb_tty_channel = 0; 117 unsigned int nb_ioc_channel = 0; 118 unsigned int nb_nic_channel = 0; 119 unsigned int io_mmu_active = 0; 120 unsigned int use_xicu = 0xFFFFFFFF; 121 122 123 ////////////////////////////////// 124 //needed to generate giet_vseg.ld 125 ////////////////////////////////// 126 127 //kernel and boot code 128 unsigned int kernel_code_base = 0x80000000; /* kernel code */ 129 unsigned int kernel_data_base = 0x80010000; /* system cacheable data */ 130 unsigned int kernel_uncdata_base = 0x80080000; /* system uncacheable data */ 131 unsigned int kernel_init_base = 0x80090000; /* system init entry */ 132 133 unsigned int boot_code_base = 0xBFC00000; /* boot code */ 134 unsigned int boot_stack_base = 0xBFC08000; /* boot temporary stack */ 135 unsigned int boot_mapping_base = 0xBFC0C000; /* mapping_info blob */ 136 137 //periphs 138 unsigned int tim_base_offset = 0xFFFFFFFF; 139 unsigned int tty_base_offset = 0xFFFFFFFF; 140 unsigned int dma_base_offset = 0xFFFFFFFF; 141 unsigned int ioc_base_offset = 0xFFFFFFFF; 142 unsigned int nic_base_offset = 0xFFFFFFFF; 143 unsigned int fbf_base_offset = 0xFFFFFFFF; 144 unsigned int icu_base_offset = 0xFFFFFFFF; 145 unsigned int gcd_base_offset = 0xFFFFFFFF; 146 unsigned int iob_base_offset = 0xFFFFFFFF; 147 105 //////////////////////////////////////////////////////////////////// 106 // These variables are used to generate the hard_config.h file 107 //////////////////////////////////////////////////////////////////// 108 109 unsigned int cluster_y = 0; // number of clusters in a column 110 unsigned int cluster_x = 0; // number of clusters in a row 111 unsigned int nb_proc_max = 0; // max number of processors per cluster 112 unsigned int nb_tasks_max = 0; // max number of tasks (for all vspaces) 113 114 unsigned int tim_channels = 0; // max number of user timers per cluster 115 unsigned int dma_channels = 0; // max number of DMA channels per cluster 116 117 unsigned int tty_channels = 0; // total number of terminals in first TTY 118 unsigned int ioc_channels = 0; // total number of channels in first IOC 119 unsigned int nic_channels = 0; // total number of channels in first NIC 120 unsigned int cma_channels = 0; // total number of channels in first CMA 121 122 unsigned int io_mmu_active = 0; // using IOB component 123 unsigned int use_xicu = 0; // using XICU (not ICU) 124 125 126 //////////////////////////////////////////////////////////////// 127 // These variables are used to generate the giet_vseg.ld file 128 //////////////////////////////////////////////////////////////// 129 130 unsigned int periph_vbase_array[PERIPH_TYPE_MAX_VALUE] 131 = { [0 ... (PERIPH_TYPE_MAX_VALUE - 1)] = 0xFFFFFFFF }; 148 132 149 133 ////////////////////////////////////////////////////////////////////// … … 153 137 // once all the vspace have been parsed. 154 138 ///////////////////////////////////////////////////////////////////// 155 typedef struct vobj_ref_s { 139 typedef struct vobj_ref_s 140 { 156 141 char vspace_name[32]; 157 142 char vobj_name[32]; … … 162 147 163 148 ////////////////////////////////////////////////// 164 unsigned int getIntValue(xmlTextReaderPtr reader, const char * attributeName, unsigned int * ok) { 149 unsigned int getIntValue( xmlTextReaderPtr reader, 150 const char * attributeName, 151 unsigned int * ok) 152 { 165 153 unsigned int value = 0; 166 154 unsigned int i; 167 155 char c; 168 156 169 char * string = (char *) xmlTextReaderGetAttribute(reader, (const xmlChar *) attributeName); 170 171 if (string == NULL) { 157 char * string = (char *) xmlTextReaderGetAttribute(reader, 158 (const xmlChar *) attributeName); 159 160 if (string == NULL) 161 { 172 162 // missing argument 173 163 *ok = 0; 174 164 return 0; 175 165 } 176 else { 177 if ((string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X'))) { 166 else 167 { 168 if ((string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X'))) 169 { 178 170 // Hexa 179 for (i = 2 ; (string[i] != 0) && (i < 10) ; i++) { 171 for (i = 2 ; (string[i] != 0) && (i < 10) ; i++) 172 { 180 173 c = string[i]; 181 174 if ((c >= '0') && (c <= '9')) { value = (value << 4) + string[i] - 48; } 182 175 else if ((c >= 'a') && (c <= 'f')) { value = (value << 4) + string[i] - 87; } 183 176 else if ((c >= 'A') && (c <= 'F')) { value = (value << 4) + string[i] - 55; } 184 else { 177 else 178 { 185 179 *ok = 0; 186 180 return 0; … … 188 182 } 189 183 } 190 else { 184 else 185 { 191 186 // Decimal 192 for (i = 0; (string[i] != 0) && (i < 9); i++) { 187 for (i = 0; (string[i] != 0) && (i < 9); i++) 188 { 193 189 c = string[i]; 194 190 if ((c >= '0') && (c <= '9')) value = (value * 10) + string[i] - 48; 195 else { 191 else 192 { 196 193 *ok = 0; 197 194 return 0; … … 204 201 } // end getIntValue() 205 202 206 207 /////////////////////////////////////////////// 208 char * getStringValue(xmlTextReaderPtr reader, const char * attributeName, unsigned int * ok) { 209 char * string = (char *) xmlTextReaderGetAttribute(reader, (const xmlChar *) attributeName); 210 211 212 if (string == NULL) { 203 //////////////////////////////////////////////// 204 paddr_t getPaddrValue( xmlTextReaderPtr reader, 205 const char * attributeName, 206 unsigned int * ok) 207 { 208 paddr_t value = 0; 209 unsigned int i; 210 char c; 211 212 char * string = (char *) xmlTextReaderGetAttribute(reader, 213 (const xmlChar *) attributeName); 214 215 if (string == NULL) 216 { 217 // missing argument 218 *ok = 0; 219 return 0; 220 } 221 else 222 { 223 if ((string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X'))) 224 { 225 // Hexa 226 for (i = 2 ; (string[i] != 0) && (i < 18) ; i++) 227 { 228 c = string[i]; 229 if ((c >= '0') && (c <= '9')) { value = (value << 4) + string[i] - 48; } 230 else if ((c >= 'a') && (c <= 'f')) { value = (value << 4) + string[i] - 87; } 231 else if ((c >= 'A') && (c <= 'F')) { value = (value << 4) + string[i] - 55; } 232 else 233 { 234 *ok = 0; 235 return 0; 236 } 237 } 238 } 239 else 240 { 241 // Decimal not supported for paddr_t 242 *ok = 0; 243 return 0; 244 } 245 *ok = 1; 246 return value; 247 } 248 } // end getPaddrValue() 249 250 //////////////////////////////////////////////// 251 char * getStringValue( xmlTextReaderPtr reader, 252 const char * attributeName, 253 unsigned int * ok ) 254 { 255 char * string = (char *) xmlTextReaderGetAttribute(reader, 256 (const xmlChar *) attributeName); 257 258 259 if (string == NULL) 260 { 213 261 // missing argument 214 262 *ok = 0; 215 263 return NULL; 216 264 } 217 else { 265 else 266 { 218 267 //we read only string smaller than 32 byte 219 if (strlen(string) > 32) { 268 if (strlen(string) > 32) 269 { 220 270 printf("[XML ERROR] all strings must be less than 32 bytes\n"); 221 271 exit(1); … … 227 277 } // end getStringValue() 228 278 229 230 /////////////////////////////////////// 231 int getPsegId(unsigned int cluster_id, char * pseg_name) { 279 /////////////////////////////////////////////////////// 280 void set_periph_vbase_array( unsigned int vseg_index ) 281 { 282 unsigned int vbase = vseg[vseg_index]->vbase; // peripheral vbase address 283 unsigned int psegid = vseg[vseg_index]->psegid; // pseg global index 284 unsigned int type; // peripheral type 285 unsigned int periph_id; 286 287 for ( periph_id = 0 ; periph_id < header->periphs ; periph_id++) 288 { 289 if( periph[periph_id]->psegid == psegid ) 290 { 291 type = periph[periph_id]->type; 292 if ( periph_vbase_array[type] == 0xFFFFFFFF ) 293 periph_vbase_array[type] = vbase; 294 } 295 } 296 } // end set_periph_vbase_array() 297 298 //////////////////////////////////////////////////////// 299 int getPsegId(unsigned int cluster_id, char * pseg_name) 300 { 232 301 unsigned int pseg_id; 233 302 unsigned int pseg_min = cluster[cluster_id]->pseg_offset; 234 303 unsigned int pseg_max = pseg_min + cluster[cluster_id]->psegs; 235 304 236 for (pseg_id = pseg_min; pseg_id < pseg_max; pseg_id++) { 237 if (strcmp(pseg[pseg_id]->name, pseg_name) == 0) { 305 for (pseg_id = pseg_min; pseg_id < pseg_max; pseg_id++) 306 { 307 if (strcmp(pseg[pseg_id]->name, pseg_name) == 0) 308 { 238 309 return pseg_id; 239 310 } … … 242 313 } 243 314 244 245 //////////////////////////////////////////// 246 int getVspaceId(char * vspace_name){315 /////////////////////////////////// 316 int getVspaceId(char * vspace_name) 317 { 247 318 unsigned int vspace_id; 248 319 249 for (vspace_id = 0; vspace_id < vspace_index; vspace_id++) { 250 if (!strcmp(vspace[vspace_id]->name, vspace_name)) { 320 for (vspace_id = 0; vspace_id < vspace_index; vspace_id++) 321 { 322 if (strcmp(vspace[vspace_id]->name, vspace_name) == 0) 323 { 251 324 return vspace_id; 252 325 } … … 255 328 } 256 329 257 258 //////////////////////////////////////////// 259 int getVobjLocId(unsigned int vspace_id, char * vobj_name, unsigned int vspace_max){330 /////////////////////////////////////////////////////////////////////////////////// 331 int getVobjLocId(unsigned int vspace_id, char * vobj_name, unsigned int vspace_max) 332 { 260 333 unsigned int vobj_id; 261 334 unsigned int vobj_min = vspace[vspace_id]->vobj_offset; … … 272 345 273 346 ///////////////////////////////////////// 274 void taskNode(xmlTextReaderPtr reader) { 347 void taskNode(xmlTextReaderPtr reader) 348 { 275 349 unsigned int ok; 276 350 unsigned int value; 277 351 char * str; 278 352 279 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { 280 return; 281 } 282 283 if (task_index >= MAX_TASKS) { 353 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } 354 355 if (task_index >= MAX_TASKS) 356 { 284 357 printf("[XML ERROR] The number of tasks is larger than %d\n", MAX_TASKS); 285 358 } 286 359 287 360 #if XML_PARSER_DEBUG 288 361 printf(" task %d\n", task_loc_index); 289 362 #endif 290 363 … … 293 366 ////////// get name attribute 294 367 str = getStringValue(reader, "name", &ok); 295 if (ok) { 296 #if XML_PARSER_DEBUG 297 printf(" name = %s\n", str); 368 if (ok) 369 { 370 #if XML_PARSER_DEBUG 371 printf(" name = %s\n", str); 298 372 #endif 299 373 strncpy( task[task_index]->name, str, 31 ); 300 374 } 301 else { 375 else 376 { 302 377 printf("[XML ERROR] illegal or missing <name> attribute for task (%d,%d)\n", 303 378 vspace_index, task_loc_index); … … 307 382 ///////// get clusterid attribute 308 383 value = getIntValue(reader, "clusterid", &ok); 309 if (ok) { 310 #if XML_PARSER_DEBUG 311 printf(" clusterid = %x\n", value); 312 #endif 313 if (value >= header->clusters) { 384 if (ok) 385 { 386 #if XML_PARSER_DEBUG 387 printf(" clusterid = %x\n", value); 388 #endif 389 if (value >= header->clusters) 390 { 314 391 printf("[XML ERROR] <clusterid> too large for task (%d,%d)\n", 315 392 vspace_index, task_loc_index); … … 318 395 task[task_index]->clusterid = value; 319 396 } 320 else { 397 else 398 { 321 399 printf("[XML ERROR] illegal or missing <clusterid> attribute for task (%d,%d)\n", 322 400 vspace_index, task_loc_index); … … 326 404 ////////// get proclocid attribute 327 405 value = getIntValue(reader, "proclocid", &ok); 328 if (ok) { 329 #if XML_PARSER_DEBUG 330 printf(" proclocid = %x\n", value); 331 #endif 332 if (value >= cluster[task[task_index]->clusterid]->procs) { 406 if (ok) 407 { 408 #if XML_PARSER_DEBUG 409 printf(" proclocid = %x\n", value); 410 #endif 411 if (value >= cluster[task[task_index]->clusterid]->procs) 412 { 333 413 printf("[XML ERROR] <proclocid> too large for task (%d,%d)\n", 334 414 vspace_index, task_loc_index); … … 337 417 task[task_index]->proclocid = value; 338 418 } 339 else { 419 else 420 { 340 421 printf("[XML ERROR] illegal or missing <locprocid> attribute for task (%d,%d)\n", 341 422 vspace_index, task_loc_index); … … 345 426 ////////// get stackname attribute 346 427 str = getStringValue(reader, "stackname" , &ok); 347 if (ok) { 428 if (ok) 429 { 348 430 int index = getVobjLocId(vspace_index, str , vobj_loc_index); 349 if (index >= 0) { 350 #if XML_PARSER_DEBUG 351 printf(" stackname = %s\n", str); 352 printf(" stackid = %d\n", index); 431 if (index >= 0) 432 { 433 #if XML_PARSER_DEBUG 434 printf(" stackname = %s\n", str); 435 printf(" stackid = %d\n", index); 353 436 #endif 354 437 task[task_index]->stack_vobjid = index; 355 438 } 356 else { 439 else 440 { 357 441 printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", 358 442 vspace_index, task_loc_index); … … 360 444 } 361 445 } 362 else { 446 else 447 { 363 448 printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", 364 449 vspace_index, task_loc_index); … … 368 453 ////////// get heap attribute 369 454 str = getStringValue(reader, "heapname", &ok); 370 if (ok) { 455 if (ok) 456 { 371 457 int index = getVobjLocId(vspace_index, str, vobj_loc_index); 372 if (index >= 0) { 373 #if XML_PARSER_DEBUG 374 printf(" heapname = %s\n", str); 375 printf(" heapid = %d\n", index); 458 if (index >= 0) 459 { 460 #if XML_PARSER_DEBUG 461 printf(" heapname = %s\n", str); 462 printf(" heapid = %d\n", index); 376 463 #endif 377 464 task[task_index]->heap_vobjid = index; 378 465 } 379 else { 380 printf("[XML ERROR] illegal or missing <heapname> for task (%d,%d)\n", vspace_index, task_loc_index); 466 else 467 { 468 printf("[XML ERROR] illegal or missing <heapname> for task (%d,%d)\n", 469 vspace_index, task_loc_index); 381 470 exit(1); 382 471 } 383 472 } 384 else { 473 else 474 { 385 475 task[task_index]->heap_vobjid = -1; 386 476 } … … 389 479 ////////// get startid attribute 390 480 value = getIntValue(reader, "startid", &ok); 391 if (ok) { 392 #if XML_PARSER_DEBUG 393 printf(" startid = %x\n", value); 481 if (ok) 482 { 483 #if XML_PARSER_DEBUG 484 printf(" startid = %x\n", value); 394 485 #endif 395 486 task[task_index]->startid = value; 396 487 } 397 else { 488 else 489 { 398 490 printf("[XML ERROR] illegal or missing <startid> attribute for task (%d,%d)\n", 399 491 vspace_index, task_loc_index); … … 403 495 /////////// get usetty attribute (optionnal : 0 if missing) 404 496 value = getIntValue(reader, "usetty", &ok); 405 if (ok) { 406 #if XML_PARSER_DEBUG 407 printf(" usetty = %x\n", value); 408 #endif 409 task[task_index]->use_tty = value; 410 } 411 else { 412 task[task_index]->use_tty = 0; 413 } 497 #if XML_PARSER_DEBUG 498 printf(" usetty = %x\n", value); 499 #endif 500 task[task_index]->use_tty = (ok)? value : 0; 414 501 415 502 /////////// get usenic attribute (optionnal : 0 if missing) 416 503 value = getIntValue(reader, "usenic", &ok); 417 if (ok) { 418 #if XML_PARSER_DEBUG 419 printf(" usenic = %x\n", value); 420 #endif 421 task[task_index]->use_nic = value; 422 } 423 else { 424 task[task_index]->use_nic = 0; 425 } 426 427 /////////// get usetimer attribute (optionnal : 0 if missing) 428 value = getIntValue(reader, "usetimer", &ok); 429 if (ok) { 430 #if XML_PARSER_DEBUG 431 printf(" usetimer = %x\n", value); 432 #endif 433 task[task_index]->use_timer = value; 434 } 435 else { 436 task[task_index]->use_timer = 0; 437 } 438 439 /////////// get usefbdma attribute (optionnal : 0 if missing) 440 value = getIntValue(reader, "usefbdma", &ok); 441 if (ok) { 442 #if XML_PARSER_DEBUG 443 printf(" usefbdma = %x\n", value); 444 #endif 445 task[task_index]->use_fbdma = value; 446 } 447 else { 448 task[task_index]->use_fbdma = 0; 449 } 504 #if XML_PARSER_DEBUG 505 printf(" usenic = %x\n", value); 506 #endif 507 task[task_index]->use_nic = (ok)? value : 0; 508 509 /////////// get usetim attribute (optionnal : 0 if missing) 510 value = getIntValue(reader, "usetim", &ok); 511 #if XML_PARSER_DEBUG 512 printf(" usetim = %x\n", value); 513 #endif 514 task[task_index]->use_tim = (ok)? value : 0; 515 516 /////////// get usedma attribute (optionnal : 0 if missing) 517 value = getIntValue(reader, "usedma", &ok); 518 #if XML_PARSER_DEBUG 519 printf(" usedma = %x\n", value); 520 #endif 521 task[task_index]->use_dma = (ok)? value : 0; 522 523 /////////// get useioc attribute (optionnal : 0 if missing) 524 value = getIntValue(reader, "useioc", &ok); 525 #if XML_PARSER_DEBUG 526 printf(" useioc = %x\n", value); 527 #endif 528 task[task_index]->use_ioc = (ok)? value : 0; 529 530 /////////// get usecma attribute (optionnal : 0 if missing) 531 value = getIntValue(reader, "usecma", &ok); 532 #if XML_PARSER_DEBUG 533 printf(" usecma = %x\n", value); 534 #endif 535 task[task_index]->use_cma = (ok)? value : 0; 450 536 451 537 task_index++; … … 454 540 455 541 456 ////////////////////////////////////////// 457 void vobjNode(xmlTextReaderPtr reader) { 542 ////////////////////////////////////// 543 void vobjNode(xmlTextReaderPtr reader) 544 { 458 545 unsigned int ok; 459 546 unsigned int value; 460 547 char * str; 461 548 462 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { 463 return; 464 } 465 466 if (vobj_index >= MAX_VOBJS) { 467 printf("[XML ERROR] The number of vobjs is larger than %d\n", MAX_VSEGS); 468 exit(1); 469 } 470 471 #if XML_PARSER_DEBUG 472 printf(" vobj %d\n", vobj_loc_index); 549 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } 550 551 if (vobj_index >= MAX_VOBJS) 552 { 553 printf("[XML ERROR] The number of vobjs is larger than %d\n", MAX_VOBJS); 554 exit(1); 555 } 556 557 #if XML_PARSER_DEBUG 558 printf(" vobj %d\n", vobj_loc_index); 473 559 #endif 474 560 … … 477 563 ///////// get name attribute 478 564 str = getStringValue(reader, "name", &ok); 479 if (ok) { 480 #if XML_PARSER_DEBUG 481 printf(" name = %s\n", str); 565 if (ok) 566 { 567 #if XML_PARSER_DEBUG 568 printf(" name = %s\n", str); 482 569 #endif 483 570 strncpy(vobj[vobj_index]->name, str, 31); 484 571 } 485 else { 572 else 573 { 486 574 printf("[XML ERROR] illegal or missing <name> attribute for vobj (%d,%d)\n", 487 575 vseg_index, vobj_loc_index); … … 492 580 str = getStringValue(reader, "type", &ok); 493 581 #if XML_PARSER_DEBUG 494 printf(" type = %s\n", str); 495 #endif 496 if (ok && (strcmp(str, "ELF") == 0)) { 582 printf(" type = %s\n", str); 583 #endif 584 if (ok && (strcmp(str, "ELF") == 0)) 585 { 497 586 vobj[vobj_index]->type = VOBJ_TYPE_ELF; 498 587 499 //check that this vobj is the first in vseg 500 if (vobj_count != 0) { 501 printf("[XML ERROR] an ELF vobj must be alone in a vseg (%d,%d)\n", 502 vspace_index, vobj_loc_index); 503 exit(1); 504 } 505 } 506 else if (ok && (strcmp(str, "BLOB") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BLOB; } 507 else if (ok && (strcmp(str, "PTAB") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_PTAB; } 508 else if (ok && (strcmp(str, "PERI") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_PERI; } 509 else if (ok && (strcmp(str, "MWMR") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MWMR; } 510 else if (ok && (strcmp(str, "LOCK") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_LOCK; } 511 else if (ok && (strcmp(str, "BUFFER") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BUFFER; } 512 else if (ok && (strcmp(str, "BARRIER") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BARRIER; } 513 else if (ok && (strcmp(str, "CONST") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_CONST; } 588 assert( (vobj_count == 0) && "[XML ERROR] an ELF vobj must be alone in a vseg"); 589 } 590 else if (ok && (strcmp(str, "PERI") == 0)) 591 { 592 vobj[vobj_index]->type = VOBJ_TYPE_PERI; 593 594 assert( (vobj_count == 0) && "[XML ERROR] a PERI vobj must be alone in a vseg"); 595 596 // fill the peripheral base address array 597 set_periph_vbase_array( vseg_index ); 598 } 599 else if (ok && (strcmp(str, "BLOB") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BLOB; } 600 else if (ok && (strcmp(str, "PTAB") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_PTAB; } 601 else if (ok && (strcmp(str, "MWMR") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MWMR; } 602 else if (ok && (strcmp(str, "LOCK") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_LOCK; } 603 else if (ok && (strcmp(str, "BUFFER") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BUFFER; } 604 else if (ok && (strcmp(str, "BARRIER") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BARRIER; } 605 else if (ok && (strcmp(str, "CONST") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_CONST; } 514 606 else if (ok && (strcmp(str, "MEMSPACE") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MEMSPACE; } 515 else { 607 else if (ok && (strcmp(str, "SCHED") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_SCHED; } 608 else 609 { 516 610 printf("[XML ERROR] illegal or missing <type> attribute for vobj (%d,%d)\n", 517 611 vspace_index, vobj_loc_index); … … 523 617 if (ok) { 524 618 #if XML_PARSER_DEBUG 525 619 printf(" length = %d\n", value); 526 620 #endif 527 621 vobj[vobj_index]->length = value; … … 537 631 if (ok) { 538 632 #if XML_PARSER_DEBUG 539 633 printf(" align = %d\n", value); 540 634 #endif 541 635 vobj[vobj_index]->align = value; … … 549 643 if (ok) { 550 644 #if XML_PARSER_DEBUG 551 645 printf(" binpath = %s\n", str); 552 646 #endif 553 647 strncpy(vobj[vobj_index]->binpath, str, 63); … … 559 653 ////////// get init attribute (mandatory for mwmr and barrier) 560 654 value = getIntValue(reader, "init", &ok); 561 if (ok) { 562 #if XML_PARSER_DEBUG 563 printf(" init = %d\n", value); 655 if (ok) 656 { 657 #if XML_PARSER_DEBUG 658 printf(" init = %d\n", value); 564 659 #endif 565 660 vobj[vobj_index]->init = value; 566 661 } 567 else { 662 else 663 { 568 664 if ((vobj[vobj_index]->type == VOBJ_TYPE_MWMR) || 569 (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) || 570 (vobj[vobj_index]->type == VOBJ_TYPE_CONST)) { 665 (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) || 666 (vobj[vobj_index]->type == VOBJ_TYPE_CONST)) 667 { 571 668 printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d). \ 572 All MWMR or BARRIER vobj must have a init value \n",669 All MWMR or BARRIER or CONST vobj must have a init value \n", 573 670 vspace_index, vobj_loc_index); 574 671 exit(1); … … 583 680 584 681 585 ////////////////////////////////////////// 586 void vsegNode(xmlTextReaderPtr reader) { 682 ////////////////////////////////////// 683 void vsegNode(xmlTextReaderPtr reader) 684 { 587 685 unsigned int ok; 588 686 unsigned int value; … … 591 689 vobj_count = 0; 592 690 593 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { 594 return; 595 } 596 597 if (vseg_index >= MAX_VSEGS) { 691 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } 692 693 if (vseg_index >= MAX_VSEGS) 694 { 598 695 printf("[XML ERROR] The number of vsegs is larger than %d\n", MAX_VSEGS); 599 696 exit(1); … … 601 698 602 699 #if XML_PARSER_DEBUG 603 700 printf(" vseg %d\n", vseg_loc_index); 604 701 #endif 605 702 … … 608 705 ////////// set vobj_offset attributes 609 706 vseg[vseg_index]->vobj_offset = vobj_index; 610 #if XML_PARSER_DEBUG 611 printf(" vobj_offset = %d\n", vobj_index); 707 708 #if XML_PARSER_DEBUG 709 printf(" vobj_offset = %d\n", vobj_index); 612 710 #endif 613 711 614 712 ///////// get name attribute 615 713 str = getStringValue(reader, "name", &ok); 616 if (ok) { 617 #if XML_PARSER_DEBUG 618 printf(" name = %s\n", str); 714 if (ok) 715 { 716 #if XML_PARSER_DEBUG 717 printf(" name = %s\n", str); 619 718 #endif 620 719 strncpy( vseg[vseg_index]->name, str, 31); 621 720 } 622 else { 721 else 722 { 623 723 printf("[XML ERROR] illegal or missing <name> attribute for vseg (%d,%d)\n", 624 724 vspace_index, vseg_loc_index); … … 628 728 ////////// get ident attribute (optional : 0 if missing) 629 729 value = getIntValue(reader, "ident", &ok); 630 if (ok) { 631 #if XML_PARSER_DEBUG 632 printf(" ident = %d\n", value); 730 if (ok) 731 { 732 #if XML_PARSER_DEBUG 733 printf(" ident = %d\n", value); 633 734 #endif 634 735 vseg[vseg_index]->ident = value; 635 736 } 636 else { 737 else 738 { 637 739 vseg[vseg_index]->ident = 0; 638 740 } … … 640 742 /////////// get vbase attribute 641 743 value = getIntValue(reader, "vbase", &ok); 642 if (ok) { 643 #if XML_PARSER_DEBUG 644 printf(" vbase = 0x%x\n", value); 744 if (ok) 745 { 746 #if XML_PARSER_DEBUG 747 printf(" vbase = 0x%x\n", value); 645 748 #endif 646 749 vseg[vseg_index]->vbase = value; 647 750 } 648 else { 751 else 752 { 649 753 printf("[XML ERROR] illegal or missing <vbase> attribute for vseg (%d,%d)\n", 650 754 vspace_index, vseg_loc_index); … … 654 758 ////////// get clusterid and psegname attributes 655 759 value = getIntValue(reader, "clusterid", &ok); 656 if (ok == 0) { 760 if (ok == 0) 761 { 657 762 printf("[XML ERROR] illegal or missing <clusterid> for vseg %d\n", 658 763 vseg_loc_index); … … 660 765 } 661 766 str = getStringValue(reader, "psegname", &ok); 662 if (ok == 0) { 767 if (ok == 0) 768 { 663 769 printf("[XML ERROR] illegal or missing <psegname> for vseg %d\n", 664 770 vseg_loc_index); … … 668 774 /////////// set psegid field 669 775 int index = getPsegId(value, str); 670 if (index >= 0) { 671 #if XML_PARSER_DEBUG 672 printf(" clusterid = %d\n", value); 673 printf(" psegname = %s\n", str); 674 printf(" psegid = %d\n", index); 776 if (index >= 0) 777 { 778 #if XML_PARSER_DEBUG 779 printf(" clusterid = %d\n", value); 780 printf(" psegname = %s\n", str); 781 printf(" psegid = %d\n", index); 675 782 #endif 676 783 vseg[vseg_index]->psegid = index; 677 784 } 678 else { 785 else 786 { 679 787 printf("[XML ERROR] pseg not found for vseg %d / clusterid = %d / psegname = %s\n", 680 788 vseg_loc_index, value, str ); … … 685 793 str = getStringValue(reader, "mode", &ok); 686 794 #if XML_PARSER_DEBUG 687 795 printf(" mode = %s\n", str); 688 796 #endif 689 797 if (ok && (strcmp(str, "CXWU") == 0)) { vseg[vseg_index]->mode = 0xF; } … … 714 822 const char * tag = (const char *) xmlTextReaderConstName(reader); 715 823 716 if (strcmp(tag, "vobj") == 0 ) { 717 vobjNode(reader); 718 } 824 if (strcmp(tag, "vobj") == 0 ) { vobjNode(reader); } 719 825 else if (strcmp(tag, "#text" ) == 0 ) { } 720 826 else if (strcmp(tag, "#comment") == 0 ) { } 721 else if (strcmp(tag, "vseg") == 0 ) { 827 else if (strcmp(tag, "vseg") == 0 ) 828 { 722 829 vseg[vseg_index]->vobjs = vobj_count; 723 830 vseg_index++; … … 756 863 757 864 #if XML_PARSER_DEBUG 758 865 printf("\n vspace %d\n", vspace_index); 759 866 #endif 760 867 … … 765 872 if (ok) { 766 873 #if XML_PARSER_DEBUG 767 874 printf(" name = %s\n", str); 768 875 #endif 769 876 strncpy(vspace[vspace_index]->name, str, 31); … … 936 1043 937 1044 938 /////////////////////////////////////////// 939 void periphNode(xmlTextReaderPtr reader) { 1045 //////////////////////////////////////// 1046 void periphNode(xmlTextReaderPtr reader) 1047 { 940 1048 char * str; 941 1049 unsigned int value; 942 1050 unsigned int ok; 943 1051 944 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { 945 return; 946 } 947 948 if (periph_index >= MAX_PERIPHS) { 1052 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } 1053 1054 if (periph_index >= MAX_PERIPHS) 1055 { 949 1056 printf("[XML ERROR] The number of periphs is larger than %d\n", MAX_PERIPHS); 950 1057 } … … 955 1062 956 1063 periph[periph_index] = (mapping_periph_t *) malloc(sizeof(mapping_periph_t)); 957 958 1064 959 1065 ///////// get channels attribute (optionnal : 1 if missing) 960 1066 value = getIntValue(reader, "channels", &ok); 961 if (ok) { 1067 if (ok) 1068 { 962 1069 #if XML_PARSER_DEBUG 963 1070 printf(" channels = %d\n", value); … … 965 1072 periph[periph_index]->channels = value; 966 1073 } 967 else { 1074 else 1075 { 968 1076 periph[periph_index]->channels = 1; 969 1077 } … … 971 1079 /////////// get psegname attribute 972 1080 str = getStringValue(reader, "psegname", &ok); 973 if (ok == 0) { 1081 if (ok == 0) 1082 { 974 1083 printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", 975 1084 coproc_index, cluster_index); … … 979 1088 /////////// set psegid attribute 980 1089 int index = getPsegId(cluster_index, str); 981 if (index >= 0) { 1090 if (index >= 0) 1091 { 982 1092 #if XML_PARSER_DEBUG 983 1093 printf(" clusterid = %d\n", cluster_index); … … 989 1099 "peripheral psegname attribute must refer to a pseg of type PERI" ); 990 1100 } 991 else { 1101 else 1102 { 992 1103 printf("[XML ERROR] pseg not found for periph %d / clusterid = %d / psegname = %s\n", 993 1104 periph_loc_index, cluster_index, str ); … … 995 1106 } 996 1107 997 998 1108 /////////// get type attribute 999 1109 str = getStringValue(reader, "type", &ok); 1000 if (ok) { 1110 if (ok) 1111 { 1001 1112 #if XML_PARSER_DEBUG 1002 1113 printf(" type = %s\n", str); … … 1004 1115 unsigned int error = 0; 1005 1116 1006 // The TTY, IOC, NIC, FBF and IOB peripherals cannot be replicated 1007 // one per architecture 1008 if (strcmp(str, "IOC") == 0) { 1117 // The TTY, IOC, NIC, FBF, CMA and IOB peripherals are not replicated in all clusters 1118 // but can be replicated in two different clusters for fault tolerance 1119 // In case of replication, the number of channels must be the same 1120 if (strcmp(str, "IOC") == 0) 1121 { 1009 1122 periph[periph_index]->type = PERIPH_TYPE_IOC; 1010 if (header->ioc_clusterid == 0xFFFFFFFF) { 1011 header->ioc_clusterid = cluster_index; 1012 } 1013 else { 1123 if (header->ioc_cluster == 0xFFFFFFFF) 1124 { 1125 header->ioc_cluster = cluster_index; 1126 ioc_channels = periph[periph_index]->channels; 1127 } 1128 else if (header->ioc_cluster_bis == 0xFFFFFFFF) 1129 { 1130 header->ioc_cluster_bis = cluster_index; 1131 } 1132 else 1133 { 1014 1134 error = 1; 1015 1135 } 1016 1017 ioc_base_offset = pseg[periph[periph_index]->psegid]->base;1018 nb_ioc_channel = periph[periph_index]->channels;1019 1136 } 1020 else if (strcmp(str, "TTY") == 0) { 1137 else if (strcmp(str, "TTY") == 0) 1138 { 1021 1139 periph[periph_index]->type = PERIPH_TYPE_TTY; 1022 if (header->tty_clusterid == 0xFFFFFFFF) { 1023 header->tty_clusterid = cluster_index; 1024 } 1025 else { 1140 if (header->tty_cluster == 0xFFFFFFFF) 1141 { 1142 header->tty_cluster = cluster_index; 1143 tty_channels = periph[periph_index]->channels; 1144 } 1145 else if (header->tty_cluster_bis == 0xFFFFFFFF) 1146 { 1147 header->tty_cluster_bis = cluster_index; 1148 } 1149 else 1150 { 1026 1151 error = 1; 1027 1152 } 1028 1029 tty_base_offset = pseg[periph[periph_index]->psegid]->base; 1030 nb_tty_channel = periph[periph_index]->channels; 1031 } 1032 else if (strcmp(str, "FBF") == 0) { 1153 } 1154 else if (strcmp(str, "FBF") == 0) 1155 { 1033 1156 periph[periph_index]->type = PERIPH_TYPE_FBF; 1034 if (header->fbf_clusterid == 0xFFFFFFFF) { 1035 header->fbf_clusterid = cluster_index; 1036 } 1037 else { 1157 if (header->fbf_cluster == 0xFFFFFFFF) 1158 { 1159 header->fbf_cluster = cluster_index; 1160 } 1161 else if (header->fbf_cluster_bis == 0xFFFFFFFF) 1162 { 1163 header->fbf_cluster_bis = cluster_index; 1164 } 1165 else 1166 { 1038 1167 error = 1; 1039 1168 } 1040 fbf_base_offset = pseg[periph[periph_index]->psegid]->base;1041 }1042 else if (strcmp(str, "NIC") == 0){1169 } 1170 else if (strcmp(str, "NIC") == 0) 1171 { 1043 1172 periph[periph_index]->type = PERIPH_TYPE_NIC; 1044 if (header->nic_clusterid == 0xFFFFFFFF) { 1045 header->nic_clusterid = cluster_index; 1046 } 1047 else { 1173 if (header->nic_cluster == 0xFFFFFFFF) 1174 { 1175 header->nic_cluster = cluster_index; 1176 nic_channels = periph[periph_index]->channels; 1177 } 1178 else if (header->nic_cluster_bis == 0xFFFFFFFF) 1179 { 1180 header->nic_cluster_bis = cluster_index; 1181 } 1182 else 1183 { 1048 1184 error = 1; 1049 1185 } 1050 nic_base_offset = pseg[periph[periph_index]->psegid]->base; 1051 nb_nic_channel = periph[periph_index]->channels; 1052 } 1053 else if (strcmp(str, "IOB") == 0) { 1186 } 1187 else if (strcmp(str, "CMA") == 0) 1188 { 1189 periph[periph_index]->type = PERIPH_TYPE_CMA; 1190 if (header->cma_cluster == 0xFFFFFFFF) 1191 { 1192 header->cma_cluster = cluster_index; 1193 cma_channels = periph[periph_index]->channels; 1194 } 1195 else if (header->nic_cluster_bis == 0xFFFFFFFF) 1196 { 1197 header->cma_cluster_bis = cluster_index; 1198 } 1199 else 1200 { 1201 error = 1; 1202 } 1203 } 1204 else if (strcmp(str, "IOB") == 0) 1205 { 1054 1206 periph[periph_index]->type = PERIPH_TYPE_IOB; 1055 iob_base_offset = pseg[periph[periph_index]->psegid]->base; 1056 1057 if (io_mmu_active) { 1207 io_mmu_active = 1; 1208 if (header->iob_cluster == 0xFFFFFFFF) 1209 { 1210 header->iob_cluster = cluster_index; 1211 } 1212 else if (header->iob_cluster_bis == 0xFFFFFFFF) 1213 { 1214 header->iob_cluster_bis = cluster_index; 1215 } 1216 else 1217 { 1058 1218 error = 1; 1059 1219 } 1060 io_mmu_active = 1;1061 }1062 // The TIM, ICU, XICU, DMA and IOB peripherals can be replicated in several clusters1063 // one per cluster1064 else if (strcmp(str, "TIM") == 0 ){1220 } 1221 // The TIM, ICU, XICU, DMA peripherals are replicated in all clusters 1222 // but only one component per cluster 1223 else if (strcmp(str, "TIM") == 0 ) 1224 { 1065 1225 periph[periph_index]->type = PERIPH_TYPE_TIM; 1066 if (found_timer) { 1067 error = 1; 1068 } 1226 if (found_timer || use_xicu) error = 1; 1069 1227 found_timer = 1; 1070 1071 if (tim_base_offset == 0xFFFFFFFF) { 1072 tim_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1073 } 1074 1075 if (nb_timer_channel_max < periph[periph_index]->channels) { 1076 nb_timer_channel_max = periph[periph_index]->channels; 1077 } 1078 } 1079 else if (strcmp(str, "ICU") == 0) { 1228 if (tim_channels < periph[periph_index]->channels) 1229 { 1230 tim_channels = periph[periph_index]->channels; 1231 } 1232 } 1233 else if (strcmp(str, "ICU") == 0) 1234 { 1080 1235 periph[periph_index]->type = PERIPH_TYPE_ICU; 1081 if (found_icu) { 1082 error = 1; 1083 } 1236 if (found_icu) error = 1; 1084 1237 found_icu = 1; 1085 1086 if (icu_base_offset == 0xFFFFFFFF) { 1087 icu_base_offset = pseg[periph[periph_index]->psegid]->base; 1088 } 1089 } 1090 else if (strcmp(str, "XICU") == 0) { 1091 periph[periph_index]->type = PERIPH_TYPE_XICU; 1092 if (found_xicu) { 1093 error = 1; 1094 } 1095 found_xicu = 1; 1096 1097 //'icu' since we can't have both xicu and icu in an arch 1098 if (icu_base_offset == 0xFFFFFFFF) { 1099 icu_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1100 } 1101 1102 if (nb_timer_channel_max == 0) { 1103 nb_timer_channel_max = 32; 1104 } 1105 } 1106 else if (strcmp(str, "DMA") == 0) { 1238 } 1239 else if (strcmp(str, "XICU") == 0) 1240 { 1241 periph[periph_index]->type = PERIPH_TYPE_ICU; 1242 if (found_icu || found_timer) error = 1; 1243 found_icu = 1; 1244 if (tim_channels == 0) 1245 { 1246 tim_channels = 32; 1247 } 1248 use_xicu = 1; 1249 } 1250 else if (strcmp(str, "DMA") == 0) 1251 { 1107 1252 periph[periph_index]->type = PERIPH_TYPE_DMA; 1108 if (found_dma) { 1109 error = 1; 1110 } 1253 if (found_dma) error = 1; 1111 1254 found_dma = 1; 1112 1113 if (dma_base_offset == 0xFFFFFFFF) { 1114 dma_base_offset = pseg[periph[periph_index]->psegid]->base; 1115 } 1116 if (nb_dma_channel_max < periph[periph_index]->channels) { 1117 nb_dma_channel_max = periph[periph_index]->channels; 1118 } 1119 } 1120 else { 1255 if (dma_channels < periph[periph_index]->channels) 1256 dma_channels = periph[periph_index]->channels; 1257 } 1258 else 1259 { 1121 1260 printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n", 1122 1261 periph_loc_index, cluster_index); … … 1124 1263 } 1125 1264 1126 if (error) { 1265 if (error) 1266 { 1127 1267 printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n", 1128 1268 periph_loc_index, cluster_index); … … 1130 1270 } 1131 1271 } 1132 else { 1272 else 1273 { 1133 1274 printf("[XML ERROR] missing <type> for peripheral %d in cluster %d\n", 1134 1275 periph_loc_index, cluster_index); 1135 1276 exit(1); 1136 1277 } 1137 1138 1278 1139 1279 periph_index++; … … 1403 1543 void psegNode(xmlTextReaderPtr reader) { 1404 1544 unsigned int ok; 1405 unsigned intvalue;1545 paddr_t ll_value; 1406 1546 char * str; 1407 1547 … … 1450 1590 1451 1591 //////// get base attribute 1452 value = getIntValue(reader, "base", &ok);1453 #if XML_PARSER_DEBUG 1454 printf(" base = 0x% x\n",value);1592 ll_value = getPaddrValue(reader, "base", &ok); 1593 #if XML_PARSER_DEBUG 1594 printf(" base = 0x%llx\n", ll_value); 1455 1595 #endif 1456 1596 if (ok) { 1457 pseg[pseg_index]->base = value;1597 pseg[pseg_index]->base = ll_value; 1458 1598 } 1459 1599 else { … … 1464 1604 1465 1605 //////// get length attribute 1466 value = getIntValue(reader, "length", &ok);1467 #if XML_PARSER_DEBUG 1468 printf(" length = 0x% x\n",value);1606 ll_value = getPaddrValue(reader, "length", &ok); 1607 #if XML_PARSER_DEBUG 1608 printf(" length = 0x%llx\n", ll_value); 1469 1609 #endif 1470 1610 if (ok) { 1471 pseg[pseg_index]->length = value;1611 pseg[pseg_index]->length = ll_value; 1472 1612 } 1473 1613 else { … … 1485 1625 1486 1626 1487 ///////////////////////////////////////////// 1488 void clusterNode(xmlTextReaderPtr reader) { 1627 ///////////////////////////////////////// 1628 void clusterNode(xmlTextReaderPtr reader) 1629 { 1489 1630 unsigned int ok; 1490 1631 unsigned int value; … … 1510 1651 found_timer = 0; 1511 1652 found_icu = 0; 1512 found_xicu = 0;1513 1653 found_dma = 0; 1514 1654 … … 1552 1692 int status = xmlTextReaderRead(reader); 1553 1693 1554 while (status == 1) { 1694 while (status == 1) 1695 { 1555 1696 const char * tag = (const char *) xmlTextReaderConstName(reader); 1556 1697 … … 1561 1702 else if (strcmp(tag, "#text") == 0) { } 1562 1703 else if (strcmp(tag, "#comment") == 0) { } 1563 else if (strcmp(tag, "cluster") == 0) { 1564 1565 if (use_xicu == 0xFFFFFFFF) { 1566 use_xicu = found_xicu; 1567 } 1568 1569 ////////////////// peripherals checks //////////////////// 1570 if ((found_timer && use_xicu) || (!found_timer && !use_xicu)) { 1704 else if (strcmp(tag, "cluster") == 0) 1705 { 1706 1707 ////////////////// peripherals checks ///////////////////////// 1708 if ((found_timer && use_xicu) || (!found_timer && !use_xicu)) 1709 { 1571 1710 printf("[XML ERROR] illegal or missing timer peripheral in cluster %d\n", cluster_index); 1572 1711 exit(1); 1573 1712 } 1574 1713 1575 if ((found_icu && use_xicu) || (!found_icu && !use_xicu)) { 1714 if (!found_icu) 1715 { 1576 1716 printf("[XML ERROR] illegal or missing icu peripheral in cluster %d\n", cluster_index); 1577 1717 exit(1); 1578 1718 } 1579 1719 1580 if (!found_xicu && use_xicu) { 1720 if (!found_dma) 1721 { 1581 1722 printf("[XML ERROR] illegal or missing dma peripheral in cluster %d\n", cluster_index); 1582 1723 exit(1); 1583 1724 } 1584 1725 1585 if (!found_dma) { 1586 printf("[XML ERROR] illegal or missing dma peripheral in cluster %d\n", cluster_index); 1587 exit(1); 1588 } 1589 1590 1591 if (nb_proc_max < cluster[cluster_index]->procs) { 1726 1727 if (nb_proc_max < cluster[cluster_index]->procs) 1728 { 1592 1729 nb_proc_max = cluster[cluster_index]->procs; 1593 1730 } … … 1609 1746 1610 1747 ////////////////////////////////////////////// 1611 void clusterSetNode(xmlTextReaderPtr reader) { 1612 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { 1613 return; 1614 } 1748 void clusterSetNode(xmlTextReaderPtr reader) 1749 { 1750 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } 1615 1751 1616 1752 #if XML_PARSER_DEBUG … … 1619 1755 1620 1756 int status = xmlTextReaderRead(reader); 1621 while (status == 1) { 1757 while (status == 1) 1758 { 1622 1759 const char * tag = (const char *) xmlTextReaderConstName(reader); 1623 1760 1624 if (strcmp(tag, "cluster") == 0) { 1625 clusterNode(reader); 1626 } 1761 if (strcmp(tag, "cluster") == 0) { clusterNode(reader); } 1627 1762 else if (strcmp(tag, "#text") == 0) { } 1628 1763 else if (strcmp(tag, "#comment") == 0) { } 1629 else if (strcmp(tag, "clusterset") == 0) { 1764 else if (strcmp(tag, "clusterset") == 0) 1765 { 1630 1766 // checking source file consistency 1631 if (cluster_index != header->clusters) { 1767 if (cluster_index != header->clusters) 1768 { 1632 1769 printf("[XML ERROR] Wrong number of clusters\n"); 1633 1770 exit(1); 1634 1771 } 1635 1772 1636 if (header->tty_clusterid == 0xFFFFFFFF) { 1773 // At least one TTY terminal for system boot 1774 if (header->tty_cluster == 0xFFFFFFFF) 1775 { 1637 1776 printf("[XML ERROR] illegal or missing tty peripheral"); 1638 1777 exit(1); … … 1647 1786 header->coprocs = coproc_index; 1648 1787 header->cp_ports = cp_port_index; 1788 header->periphs = periph_index; 1649 1789 return; 1650 1790 } … … 1669 1809 1670 1810 int status = xmlTextReaderRead(reader); 1671 while (status == 1) { 1811 while (status == 1) 1812 { 1672 1813 const char * tag = (const char *) xmlTextReaderConstName(reader); 1673 1814 1674 if (strcmp(tag, "vseg") == 0) { 1675 vsegNode(reader); 1676 } 1815 if (strcmp(tag, "vseg") == 0) { vsegNode(reader); } 1677 1816 else if (strcmp(tag, "#text") == 0) { } 1678 1817 else if (strcmp(tag, "#comment") == 0) { } … … 1736 1875 1737 1876 ////////////////////////////////////////// 1738 void headerNode(xmlTextReaderPtr reader) { 1877 void headerNode(xmlTextReaderPtr reader) 1878 { 1739 1879 char * name; 1740 1880 unsigned int value; 1741 1881 unsigned int ok; 1742 1882 1743 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { 1744 return; 1745 } 1883 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) { return; } 1746 1884 1747 1885 #if XML_PARSER_DEBUG … … 1820 1958 } 1821 1959 1822 //////// initialise non replicated peripherals cluster_id 1823 header->tty_clusterid = 0xFFFFFFFF; 1824 header->nic_clusterid = 0xFFFFFFFF; 1825 header->ioc_clusterid = 0xFFFFFFFF; 1826 header->fbf_clusterid = 0xFFFFFFFF; 1960 //////// initialise non replicated peripherals cluster index 1961 header->tty_cluster = 0xFFFFFFFF; 1962 header->nic_cluster = 0xFFFFFFFF; 1963 header->ioc_cluster = 0xFFFFFFFF; 1964 header->fbf_cluster = 0xFFFFFFFF; 1965 header->cma_cluster = 0xFFFFFFFF; 1966 header->iob_cluster = 0xFFFFFFFF; 1967 header->tty_cluster_bis = 0xFFFFFFFF; 1968 header->nic_cluster_bis = 0xFFFFFFFF; 1969 header->ioc_cluster_bis = 0xFFFFFFFF; 1970 header->fbf_cluster_bis = 0xFFFFFFFF; 1971 header->cma_cluster_bis = 0xFFFFFFFF; 1972 header->iob_cluster_bis = 0xFFFFFFFF; 1827 1973 1828 1974 ///////// set signature … … 1940 2086 // this function set the value the vobj_id fiels of all cp_ports 1941 2087 /////////////////////////////////////////////////////////////////////// 1942 void prepareBuild() { 2088 void prepareBuild() 2089 { 1943 2090 unsigned int i; 1944 2091 //asign for all cp_ports the correct vspaceid and vobjid … … 1972 2119 } 1973 2120 1974 1975 2121 ////////////////////////////////////////// 1976 void file_write(int fdout, char * towrite) { 2122 void file_write(int fdout, char * towrite) 2123 { 1977 2124 unsigned int size = strlen(towrite); 1978 if (size != write(fdout, towrite, size)) { 2125 if (size != write(fdout, towrite, size)) 2126 { 1979 2127 printf("file_write error"); 1980 2128 exit(1); … … 1982 2130 } 1983 2131 1984 1985 2132 ////////////////////////////////////////////////// 1986 void def_int_write(int fdout, char * def, int num) { 2133 void def_int_write(int fdout, char * def, int num) 2134 { 1987 2135 char buf[64]; 1988 2136 sprintf(buf, "#define\t %s %d\n", def, num); … … 1990 2138 } 1991 2139 1992 1993 ///////////////////////////////////////////////// 1994 void def_hex_write(int fdout, char * def, int num){2140 ////////////////////////////////////////////////// 2141 void def_hex_write(int fdout, char * def, int num) 2142 { 1995 2143 char buf[64]; 1996 2144 sprintf(buf, "#define\t %s 0x%x\n", def, num); … … 1998 2146 } 1999 2147 2000 2001 /////////////////////////////////////// 2002 void genHd(const char * file_path){2148 /////////////////////////////////// 2149 void genHd(const char * file_path) 2150 { 2003 2151 int fdout = open_file(file_path); 2004 2152 2005 char * prol = " /* Generated from the mapping_info file */\n\n#ifndef _HD_CONFIG_H\n#define _HD_CONFIG_H\n\n"; 2153 char * prol = "/* Generated from the mapping_info file */\n\n"; 2154 char * ifdef = "#ifndef _HD_CONFIG_H\n#define _HD_CONFIG_H\n\n"; 2155 char * epil = "\n#endif //_HD_CONFIG_H"; 2156 2006 2157 file_write(fdout, prol); 2007 2008 def_int_write(fdout, "CLUSTER_X" , cluster_x); 2009 def_int_write(fdout, "CLUSTER_Y" , cluster_y); 2010 def_int_write(fdout, "NB_CLUSTERS" , cluster_index); 2011 def_hex_write(fdout, "CLUSTER_SIZE" , (((unsigned long long) 1) << 32) / cluster_index); 2012 def_int_write(fdout, "NB_PROCS_MAX" , nb_proc_max); 2013 def_int_write(fdout, "NB_TIMERS_MAX", nb_timer_channel_max); 2014 def_int_write(fdout, "NB_DMAS_MAX" , nb_dma_channel_max); 2015 def_int_write(fdout, "NB_TTYS" , nb_tty_channel); 2016 def_int_write(fdout, "NB_IOCS" , nb_ioc_channel); 2017 def_int_write(fdout, "NB_NICS" , nb_nic_channel); 2018 def_int_write(fdout, "NB_TASKS" , nb_tasks_max); 2158 file_write(fdout, ifdef); 2159 2160 def_int_write(fdout, "CLUSTER_X ", cluster_x); 2161 def_int_write(fdout, "CLUSTER_Y ", cluster_y); 2162 def_int_write(fdout, "NB_CLUSTERS ", cluster_index); 2163 def_int_write(fdout, "NB_PROCS_MAX ", nb_proc_max); 2164 def_int_write(fdout, "NB_TASKS_MAX ", nb_tasks_max); 2019 2165 2020 2166 file_write(fdout, "\n"); 2021 def_int_write(fdout, "USE_XICU" , use_xicu); 2022 def_int_write(fdout, "IOMMU_ACTIVE ", io_mmu_active); 2023 2024 char * epil = "\n#endif //_HD_CONFIG_H"; 2167 2168 def_int_write(fdout, "NB_TIM_CHANNELS ", tim_channels); 2169 def_int_write(fdout, "NB_DMA_CHANNELS ", dma_channels); 2170 2171 file_write(fdout, "\n"); 2172 2173 def_int_write(fdout, "NB_TTY_CHANNELS ", tty_channels); 2174 def_int_write(fdout, "NB_IOC_CHANNELS ", ioc_channels); 2175 def_int_write(fdout, "NB_NIC_CHANNELS ", nic_channels); 2176 def_int_write(fdout, "NB_CMA_CHANNELS ", cma_channels); 2177 2178 file_write(fdout, "\n"); 2179 2180 def_int_write(fdout, "USE_XICU ", use_xicu); 2181 def_int_write(fdout, "IOMMU_ACTIVE ", io_mmu_active); 2182 2025 2183 file_write(fdout, epil); 2026 2184 … … 2028 2186 } 2029 2187 2030 2031 2188 //////////////////////////////////////////////////////// 2032 void ld_write(int fdout, char * seg, unsigned int addr) { 2189 void ld_write(int fdout, char * seg, unsigned int addr) 2190 { 2033 2191 char buf[64]; 2034 2192 sprintf(buf, "%s = 0x%x;\n", seg, addr); 2035 2193 file_write(fdout, buf); 2036 2037 2194 } 2038 2195 2039 2040 /////////////////////////////////////// 2041 void genLd(const char * file_path) { 2042 int fdout = open_file(file_path); 2196 ////////////////////////////////// 2197 void genLd(const char * file_path) 2198 { 2199 int fdout = open_file(file_path); 2200 unsigned int count = 0; 2201 unsigned int vseg_id; 2043 2202 2044 2203 char * prol = "/* Generated from the mapping_info file */\n\n"; 2045 2204 file_write(fdout, prol); 2046 2205 2047 //boot 2048 ld_write(fdout, "seg_boot_code_base", boot_code_base); 2049 ld_write(fdout, "seg_boot_stack_base", boot_stack_base); 2050 ld_write(fdout, "seg_mapping_base", boot_mapping_base); 2051 2052 //kernel 2053 ld_write(fdout, "\nseg_kernel_code_base", kernel_code_base); 2054 ld_write(fdout, "seg_kernel_data_base", kernel_data_base); 2055 ld_write(fdout, "seg_kernel_uncdata_base", kernel_uncdata_base); 2056 ld_write(fdout, "seg_kernel_init_base", kernel_init_base); 2057 2058 //peripherals 2059 ld_write(fdout, "\nseg_fbf_base", fbf_base_offset); 2060 ld_write(fdout, "seg_icu_base", icu_base_offset); 2061 ld_write(fdout, "seg_ioc_base", ioc_base_offset); 2062 ld_write(fdout, "seg_nic_base", nic_base_offset); 2063 ld_write(fdout, "seg_tty_base", tty_base_offset); 2064 ld_write(fdout, "seg_dma_base", dma_base_offset); 2065 ld_write(fdout, "seg_tim_base", tim_base_offset); 2066 ld_write(fdout, "seg_gcd_base", gcd_base_offset); 2067 ld_write(fdout, "seg_iob_base", iob_base_offset); 2206 // boot and kernel segments 2207 for (vseg_id = 0 ; vseg_id < header->vsegs ; vseg_id++) 2208 { 2209 if ( strcmp(vseg[vseg_id]->name, "seg_boot_code") == 0 ) 2210 { 2211 ld_write(fdout, "seg_boot_code_base ", vseg[vseg_id]->vbase); 2212 count++; 2213 } 2214 else if ( strcmp(vseg[vseg_id]->name, "seg_boot_stack") == 0 ) 2215 { 2216 ld_write(fdout, "seg_boot_stack_base ", vseg[vseg_id]->vbase); 2217 count++; 2218 } 2219 else if ( strcmp(vseg[vseg_id]->name, "seg_boot_mapping") == 0 ) 2220 { 2221 ld_write(fdout, "seg_mapping_base ", vseg[vseg_id]->vbase); 2222 count++; 2223 } 2224 else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_code") == 0 ) 2225 { 2226 ld_write(fdout, "seg_kernel_code_base ", vseg[vseg_id]->vbase); 2227 count++; 2228 } 2229 else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_data") == 0 ) 2230 { 2231 ld_write(fdout, "seg_kernel_data_base ", vseg[vseg_id]->vbase); 2232 count++; 2233 } 2234 else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_uncdata") == 0 ) 2235 { 2236 ld_write(fdout, "seg_kernel_uncdata_base ", vseg[vseg_id]->vbase); 2237 count++; 2238 } 2239 else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_init") == 0 ) 2240 { 2241 ld_write(fdout, "seg_kernel_init_base ", vseg[vseg_id]->vbase); 2242 count++; 2243 } 2244 } 2245 if ( count != 7 ) 2246 { 2247 printf ("[XML ERROR] Missing Boot or Kernel vseg : only %d\n", count); 2248 printf ("Mandatory segments are :\n"); 2249 printf (" - seg_boot_code\n"); 2250 printf (" - seg_boot_stack\n"); 2251 printf (" - seg_boot_mapping\n"); 2252 printf (" - seg_kernel_code\n"); 2253 printf (" - seg_kernel_data\n"); 2254 printf (" - seg_kernel_uncdata\n"); 2255 printf (" - seg_kernel_init\n"); 2256 } 2257 2258 file_write(fdout, "\n"); 2259 2260 // non replicated peripherals 2261 ld_write(fdout, "\nseg_fbf_base ", periph_vbase_array[PERIPH_TYPE_FBF]); 2262 ld_write(fdout, "seg_ioc_base ", periph_vbase_array[PERIPH_TYPE_IOC]); 2263 ld_write(fdout, "seg_nic_base ", periph_vbase_array[PERIPH_TYPE_NIC]); 2264 ld_write(fdout, "seg_tty_base ", periph_vbase_array[PERIPH_TYPE_TTY]); 2265 ld_write(fdout, "seg_gcd_base ", periph_vbase_array[PERIPH_TYPE_GCD]); 2266 ld_write(fdout, "seg_iob_base ", periph_vbase_array[PERIPH_TYPE_IOB]); 2267 2268 file_write(fdout, "\n"); 2269 2270 // replicated peripherals 2271 ld_write(fdout, "seg_icu_base ", periph_vbase_array[PERIPH_TYPE_ICU]); 2272 ld_write(fdout, "seg_dma_base ", periph_vbase_array[PERIPH_TYPE_DMA]); 2273 ld_write(fdout, "seg_tim_base ", periph_vbase_array[PERIPH_TYPE_TIM]); 2068 2274 2069 2275 close(fdout); 2070 2276 } 2071 2277 2072 2073 char * buildPath(const char * path, const char * name) { 2278 ////////////////////////////////////////////////////// 2279 char * buildPath(const char * path, const char * name) 2280 { 2074 2281 char * res = calloc(strlen(path) + strlen(name) + 1, 1); 2075 2282 strcat(res, path); … … 2080 2287 2081 2288 2082 ///////////////////////////////////// 2083 int main(int argc, char * argv[]) { 2289 ////////////////////////////////// 2290 int main(int argc, char * argv[]) 2291 { 2084 2292 if (argc < 3) { 2085 2293 printf("Usage: xml2bin <input_file_path> <output_path>\n");
Note: See TracChangeset
for help on using the changeset viewer.