Index: soft/giet_vm/xml/xml_parser.c
===================================================================
--- soft/giet_vm/xml/xml_parser.c	(revision 226)
+++ soft/giet_vm/xml/xml_parser.c	(revision 228)
@@ -30,67 +30,67 @@
 #include  <irq_handler.h>
 
-#define MAX_CLUSTERS	1024
-#define MAX_PSEGS		4096
-#define MAX_VSPACES		1024
-#define MAX_TASKS		4096
-#define MAX_MWMRS		4096
-#define MAX_VSEGS		4096
-#define MAX_VOBJS		8192
-#define MAX_PROCS		1024
-#define MAX_IRQS		8192
-#define MAX_COPROCS		4096
-#define MAX_CP_PORTS	8192
-#define MAX_PERIPHS		8192
-
-#define XML_PARSER_DEBUG   0
+#define MAX_CLUSTERS   1024
+#define MAX_PSEGS      4096
+#define MAX_VSPACES    1024
+#define MAX_TASKS      4096
+#define MAX_MWMRS      4096
+#define MAX_VSEGS      4096
+#define MAX_VOBJS      8192
+#define MAX_PROCS      1024
+#define MAX_IRQS       8192
+#define MAX_COPROCS    4096
+#define MAX_CP_PORTS   8192
+#define MAX_PERIPHS    8192
+
+#define XML_PARSER_DEBUG  0
 
 ///////////////////////////////////////////////////////////////////////////////////
-// 	global variables used to store and index the data structures
+//     global variables used to store and index the data structures
 ///////////////////////////////////////////////////////////////////////////////////
 
-mapping_header_t*       header;
-mapping_cluster_t*      cluster[MAX_CLUSTERS];	// cluster array
-mapping_pseg_t*	        pseg[MAX_PSEGS];		// pseg array
-mapping_vspace_t*       vspace[MAX_VSPACES];	// vspace array
-mapping_vseg_t*	        vseg[MAX_VSEGS];		// vseg array
-mapping_vobj_t*	        vobj[MAX_VOBJS];		// vobj array
-mapping_task_t*	        task[MAX_TASKS];		// task array
-mapping_proc_t*	        proc[MAX_PROCS];		// proc array
-mapping_irq_t*	        irq[MAX_IRQS];			// irq array
-mapping_coproc_t*       coproc[MAX_COPROCS];	// coproc array
-mapping_cp_port_t*	    cp_port[MAX_CP_PORTS];	// coproc port array
-mapping_periph_t*       periph[MAX_PERIPHS];    // peripheral array
+mapping_header_t * header;
+mapping_cluster_t * cluster[MAX_CLUSTERS];  // cluster array
+mapping_pseg_t * pseg[MAX_PSEGS];           // pseg array
+mapping_vspace_t * vspace[MAX_VSPACES];     // vspace array
+mapping_vseg_t * vseg[MAX_VSEGS];           // vseg array
+mapping_vobj_t * vobj[MAX_VOBJS];           // vobj array
+mapping_task_t * task[MAX_TASKS];           // task array
+mapping_proc_t * proc[MAX_PROCS];           // proc array
+mapping_irq_t * irq[MAX_IRQS];              // irq array
+mapping_coproc_t * coproc[MAX_COPROCS];     // coproc array
+mapping_cp_port_t * cp_port[MAX_CP_PORTS];  // coproc port array
+mapping_periph_t * periph[MAX_PERIPHS];     // peripheral array
 
 // Index for the various arrays
 
-unsigned int		cluster_index  = 0;
-unsigned int		vspace_index   = 0;
-unsigned int		global_index   = 0;
-unsigned int		pseg_index     = 0;		
-
-unsigned int		proc_index     = 0;
-unsigned int		proc_loc_index = 0;
-
-unsigned int		irq_index      = 0;
-unsigned int		irq_loc_index  = 0;
-
-unsigned int		coproc_index     = 0;
-unsigned int		coproc_loc_index = 0;
-
-unsigned int		cp_port_index     = 0;
-unsigned int		cp_port_loc_index = 0;
-
-unsigned int		periph_index     = 0;
-unsigned int		periph_loc_index = 0;
-
-unsigned int		vseg_index     = 0;
-unsigned int		vseg_loc_index = 0;
-
-unsigned int		task_index     = 0;
-unsigned int		task_loc_index = 0;
-
-unsigned int		vobj_index     = 0;
-unsigned int		vobj_loc_index = 0;
-unsigned int		vobj_count     = 0;
+unsigned int cluster_index  = 0;
+unsigned int vspace_index = 0;
+unsigned int global_index = 0;
+unsigned int pseg_index = 0;        
+
+unsigned int proc_index = 0;
+unsigned int proc_loc_index = 0;
+
+unsigned int irq_index = 0;
+unsigned int irq_loc_index  = 0;
+
+unsigned int coproc_index = 0;
+unsigned int coproc_loc_index = 0;
+
+unsigned int cp_port_index = 0;
+unsigned int cp_port_loc_index = 0;
+
+unsigned int periph_index = 0;
+unsigned int periph_loc_index = 0;
+
+unsigned int vseg_index = 0;
+unsigned int vseg_loc_index = 0;
+
+unsigned int task_index = 0;
+unsigned int task_loc_index = 0;
+
+unsigned int vobj_index = 0;
+unsigned int vobj_loc_index = 0;
+unsigned int vobj_count = 0;
 
 
@@ -107,14 +107,14 @@
 //needed to generate map_config.ld
 //////////////////////////////////
-unsigned int cluster_y              = 0;
-unsigned int cluster_x              = 0; 
-unsigned int nb_proc_max            = 0; // max number of processors per cluster 
-unsigned int nb_timer_channel_max   = 0; // max number of user timer
-unsigned int nb_dma_channel_max     = 0;
-unsigned int nb_tty_channel         = 0;
-unsigned int nb_ioc_channel         = 0;
-unsigned int nb_nic_channel         = 0;
-unsigned int io_mmu_active          = 0;
-unsigned int use_xicu               = 0xFFFFFFFF;
+unsigned int cluster_y            = 0;
+unsigned int cluster_x            = 0; 
+unsigned int nb_proc_max          = 0; // max number of processors per cluster 
+unsigned int nb_timer_channel_max = 0; // max number of user timer
+unsigned int nb_dma_channel_max   = 0;
+unsigned int nb_tty_channel       = 0;
+unsigned int nb_ioc_channel       = 0;
+unsigned int nb_nic_channel       = 0;
+unsigned int io_mmu_active        = 0;
+unsigned int use_xicu             = 0xFFFFFFFF;
 
 
@@ -124,12 +124,12 @@
 
 //kernel and boot code
-unsigned int kernel_code_base    = 0x80000000;	/* kernel code */
-unsigned int kernel_data_base    = 0x80010000;	/* system cacheable data */
-unsigned int kernel_uncdata_base = 0x80080000;	/* system uncacheable data */
-unsigned int kernel_init_base    = 0x80090000;	/* system init entry */ 
-
-unsigned int boot_code_base      = 0xBFC00000;  /* boot code */
-unsigned int boot_stack_base     = 0xBFC08000;	/* boot temporary stack */ 
-unsigned int boot_mapping_base   = 0xBFC0C000;	/* mapping_info blob */
+unsigned int kernel_code_base    = 0x80000000; /* kernel code */
+unsigned int kernel_data_base    = 0x80010000; /* system cacheable data */
+unsigned int kernel_uncdata_base = 0x80080000; /* system uncacheable data */
+unsigned int kernel_init_base    = 0x80090000; /* system init entry */ 
+
+unsigned int boot_code_base      = 0xBFC00000; /* boot code */
+unsigned int boot_stack_base     = 0xBFC08000; /* boot temporary stack */ 
+unsigned int boot_mapping_base   = 0xBFC0C000; /* mapping_info blob */
 
 //periphs
@@ -151,41 +151,34 @@
 // once all the vspace have been parsed.
 /////////////////////////////////////////////////////////////////////
-typedef struct vobj_ref_s
-{
+typedef struct vobj_ref_s {
     char vspace_name[32];
     char vobj_name[32];
-}vobj_ref_t;
-
-vobj_ref_t*	        cp_port_vobj_ref[MAX_CP_PORTS];	
+} vobj_ref_t;
+
+vobj_ref_t * cp_port_vobj_ref[MAX_CP_PORTS];    
 
 
 //////////////////////////////////////////////////
-unsigned int getIntValue( xmlTextReaderPtr reader, 
-                          const char*      attributeName, 
-                          unsigned int*    ok )
-{
-    unsigned int 	value = 0;
-    unsigned int 	i;
-    char	c;
-
-    char* string = (char*)xmlTextReaderGetAttribute(reader, (const xmlChar*)attributeName);
-
-    if ( string == NULL )  // missing argument
-    {
+unsigned int getIntValue(xmlTextReaderPtr reader, const char * attributeName, unsigned int * ok) {
+    unsigned int value = 0;
+    unsigned int i;
+    char c;
+
+    char * string = (char *) xmlTextReaderGetAttribute(reader, (const xmlChar *) attributeName);
+
+    if (string == NULL) {
+        // missing argument
         *ok = 0;
         return 0;
     }
-    else
-    {
-        if ( (string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X')) )  // Hexa
-        {
-            for ( i = 2 ; (string[i] != 0) && (i < 10) ; i++ )
-            {
+    else {
+        if ((string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X'))) {
+            // Hexa
+            for (i = 2 ; (string[i] != 0) && (i < 10) ; i++) {
                 c = string[i];
-                if      ((c >= '0') && (c <= '9')) value = (value<<4) + string[i] - 48;
-                else if ((c >= 'a') && (c <= 'f')) value = (value<<4) + string[i] - 87;
-                else if ((c >= 'A') && (c <= 'F')) value = (value<<4) + string[i] - 55;
-                else    
-                {
+                if      ((c >= '0') && (c <= '9')) { value = (value << 4) + string[i] - 48; }
+                else if ((c >= 'a') && (c <= 'f')) { value = (value << 4) + string[i] - 87; }
+                else if ((c >= 'A') && (c <= 'F')) { value = (value << 4) + string[i] - 55; }
+                else {
                     *ok = 0;
                     return 0;
@@ -193,12 +186,10 @@
             }
         }
-        else 								// Decimal
-        {
-            for ( i = 0 ; (string[i] != 0) && (i < 9) ; i++ )
-            {
+        else {
+            // Decimal
+            for (i = 0; (string[i] != 0) && (i < 9); i++) {
                 c = string[i];
-                if ((c >= '0') && (c <= '9')) value = (value*10) + string[i] - 48;
-                else 
-                {
+                if ((c >= '0') && (c <= '9')) value = (value * 10) + string[i] - 48;
+                else {
                     *ok = 0;
                     return 0;
@@ -211,22 +202,18 @@
 } // end getIntValue()
 
+
 ///////////////////////////////////////////////
-char* getStringValue ( xmlTextReaderPtr reader, 
-                       const char* 	attributeName, 
-                       unsigned int* 	ok )
-{
-    char* string = (char*)xmlTextReaderGetAttribute(reader, (const xmlChar*)attributeName);
-
-    
-    if ( string == NULL )  // missing argument
-    {
+char * getStringValue(xmlTextReaderPtr reader, const char * attributeName, unsigned int * ok) {
+    char * string = (char *) xmlTextReaderGetAttribute(reader, (const xmlChar *) attributeName);
+
+
+    if (string == NULL) {
+        // missing argument
         *ok = 0;
         return NULL;
     }
-    else
-    {
+    else {
         //we read only string smaller than 32 byte
-        if(strlen(string) > 32)
-        {
+        if (strlen(string) > 32) {
             printf("[XML ERROR] all strings must be less than 32 bytes\n");
             exit(1);
@@ -238,16 +225,13 @@
 } // end getStringValue()
 
+
 ///////////////////////////////////////
-int getPsegId( unsigned int	cluster_id,
-               char*        pseg_name )
-{
+int getPsegId(unsigned int cluster_id, char * pseg_name) {
     unsigned int pseg_id;
     unsigned int pseg_min = cluster[cluster_id]->pseg_offset;
     unsigned int pseg_max = pseg_min + cluster[cluster_id]->psegs;
 
-    for ( pseg_id = pseg_min ; pseg_id < pseg_max ; pseg_id++ )
-    {
-        if ( strcmp(pseg[pseg_id]->name, pseg_name) == 0 ) 
-        {
+    for (pseg_id = pseg_min; pseg_id < pseg_max; pseg_id++) {
+        if (strcmp(pseg[pseg_id]->name, pseg_name) == 0) {
             return pseg_id;
         }
@@ -256,13 +240,11 @@
 }
 
+
 ////////////////////////////////////////////
-int getVspaceId( char*         vspace_name)
-{
+int getVspaceId(char * vspace_name) {
     unsigned int vspace_id;
 
-    for( vspace_id = 0; vspace_id < vspace_index ; vspace_id++)
-    {
-        if( !strcmp(vspace[vspace_id]->name, vspace_name))
-        {
+    for (vspace_id = 0; vspace_id < vspace_index; vspace_id++) {
+        if (!strcmp(vspace[vspace_id]->name, vspace_name)) {
             return vspace_id;
         }
@@ -271,18 +253,14 @@
 }
 
+
 ////////////////////////////////////////////
-int getVobjLocId( unsigned int	vspace_id,
-                  char*		    vobj_name,
-                  unsigned int  vspace_max)
-{
+int getVobjLocId(unsigned int vspace_id, char * vobj_name, unsigned int vspace_max) {
     unsigned int vobj_id;
     unsigned int vobj_min = vspace[vspace_id]->vobj_offset;
     unsigned int vobj_max = vobj_min + vspace_max;
 
-    for ( vobj_id = vobj_min ; vobj_id < vobj_max ; vobj_id++ )
-    {
-        if ( strcmp(vobj[vobj_id]->name, vobj_name) == 0 )
-        {
-             return (vobj_id - vobj_min);
+    for (vobj_id = vobj_min; vobj_id < vobj_max; vobj_id++) {
+        if (strcmp(vobj[vobj_id]->name, vobj_name) == 0) {
+            return (vobj_id - vobj_min);
         }
     }
@@ -290,80 +268,72 @@
 }
 
+
 /////////////////////////////////////////
-void taskNode ( xmlTextReaderPtr reader )
-/////////////////////////////////////////
-{
-    unsigned int 	ok;
-    unsigned int 	value;
-    char*    		str;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( task_index >= MAX_TASKS )
-    {
+void taskNode(xmlTextReaderPtr reader) {
+    unsigned int ok;
+    unsigned int value;
+    char * str;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (task_index >= MAX_TASKS) {
         printf("[XML ERROR] The number of tasks is larger than %d\n", MAX_TASKS);
     }
 
 #if XML_PARSER_DEBUG
-printf("   task %d\n", task_loc_index);
-#endif
-
-    task[task_index] = (mapping_task_t*)malloc(sizeof(mapping_task_t));
+    printf("   task %d\n", task_loc_index);
+#endif
+
+    task[task_index] = (mapping_task_t *) malloc(sizeof(mapping_task_t));
 
     ////////// get name attribute
     str = getStringValue(reader, "name", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      name = %s\n", str);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      name = %s\n", str);
 #endif
         strncpy( task[task_index]->name, str, 31 );
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <name> attribute for task (%d,%d)\n", 
-               vspace_index, task_loc_index);
+                vspace_index, task_loc_index);
         exit(1);
     }
 
     ///////// get clusterid attribute
-    value = getIntValue(reader,"clusterid", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      clusterid = %x\n", value);
-#endif
-        if ( value >= header->clusters )
-        {
+    value = getIntValue(reader, "clusterid", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      clusterid = %x\n", value);
+#endif
+        if (value >= header->clusters) {
             printf("[XML ERROR] <clusterid> too large for task (%d,%d)\n",
-                   vspace_index, task_loc_index);
+                    vspace_index, task_loc_index);
             exit(1);
         }
         task[task_index]->clusterid = value;
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <clusterid> attribute for task (%d,%d)\n",
-               vspace_index, task_loc_index);
+                vspace_index, task_loc_index);
         exit(1);
     }
 
     ////////// get proclocid attribute
-    value = getIntValue(reader,"proclocid", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      proclocid = %x\n", value);
-#endif
-        if ( value >= cluster[task[task_index]->clusterid]->procs )
-        {
+    value = getIntValue(reader, "proclocid", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      proclocid = %x\n", value);
+#endif
+        if (value >= cluster[task[task_index]->clusterid]->procs) {
             printf("[XML ERROR] <proclocid> too large for task (%d,%d)\n",
-                   vspace_index, task_loc_index);
+                    vspace_index, task_loc_index);
             exit(1);
         }
         task[task_index]->proclocid = value;
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <locprocid> attribute for task (%d,%d)\n", 
                 vspace_index, task_loc_index);
@@ -373,17 +343,14 @@
     ////////// get stackname attribute
     str = getStringValue(reader, "stackname" , &ok);
-    if ( ok )
-    {
-        int index = getVobjLocId( vspace_index, str , vobj_loc_index);
-        if ( index >= 0 ) 
-        {
-#if XML_PARSER_DEBUG
-printf("      stackname = %s\n", str);
-printf("      stackid   = %d\n", index);
+    if (ok) {
+        int index = getVobjLocId(vspace_index, str , vobj_loc_index);
+        if (index >= 0) {
+#if XML_PARSER_DEBUG
+            printf("      stackname = %s\n", str);
+            printf("      stackid   = %d\n", index);
 #endif
             task[task_index]->vobjlocid = index;
         }
-        else              
-        {
+        else {
             printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", 
                     vspace_index, task_loc_index);
@@ -391,6 +358,5 @@
         }
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", 
                 vspace_index, task_loc_index);
@@ -399,14 +365,12 @@
 
     ////////// get startid  attribute
-    value = getIntValue(reader,"startid", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      startid = %x\n", value);
+    value = getIntValue(reader, "startid", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      startid = %x\n", value);
 #endif
         task[task_index]->startid = value;
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <startid> attribute for task (%d,%d)\n", 
                 vspace_index, task_loc_index);
@@ -415,56 +379,48 @@
 
     /////////// get usetty  attribute (optionnal : 0 if missing)
-    value = getIntValue(reader,"usetty", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      usetty = %x\n", value);
+    value = getIntValue(reader, "usetty", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      usetty = %x\n", value);
 #endif
         task[task_index]->use_tty = value;
     }  
-    else
-    {
+    else {
         task[task_index]->use_tty = 0;
     }
 
     /////////// get usenic  attribute (optionnal : 0 if missing)
-    value = getIntValue(reader,"usenic", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      usenic = %x\n", value);
+    value = getIntValue(reader, "usenic", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      usenic = %x\n", value);
 #endif
         task[task_index]->use_nic = value;
     }  
-    else
-    {
+    else {
         task[task_index]->use_nic = 0;
     }
 
     /////////// get usetimer attribute (optionnal : 0 if missing)
-    value = getIntValue(reader,"usetimer", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      usetimer = %x\n", value);
+    value = getIntValue(reader, "usetimer", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      usetimer = %x\n", value);
 #endif
         task[task_index]->use_timer = value;
     }  
-    else
-    {
+    else {
         task[task_index]->use_timer = 0;
     }
 
     /////////// get usefbdma  attribute (optionnal : 0 if missing)
-    value = getIntValue(reader,"usefbdma", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      usefbdma = %x\n", value);
+    value = getIntValue(reader, "usefbdma", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      usefbdma = %x\n", value);
 #endif
         task[task_index]->use_fbdma = value;
-    }  
-    else
-    {
+    }
+    else {
         task[task_index]->use_fbdma = 0;
     }
@@ -474,16 +430,16 @@
 } // end taskNode()
 
+
 //////////////////////////////////////////
-void  vobjNode ( xmlTextReaderPtr reader )
-//////////////////////////////////////////
-{
-    unsigned int 	ok;
-    unsigned int 	value;
-    char*    		str;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( vobj_index >= MAX_VOBJS )
-    {
+void vobjNode(xmlTextReaderPtr reader) {
+    unsigned int ok;
+    unsigned int value;
+    char * str;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (vobj_index >= MAX_VOBJS) {
         printf("[XML ERROR] The number of vobjs is larger than %d\n", MAX_VSEGS);
         exit(1);
@@ -491,20 +447,18 @@
 
 #if XML_PARSER_DEBUG
-printf("      vobj %d\n", vobj_loc_index);
-#endif
-
-    vobj[vobj_index] = (mapping_vobj_t*)malloc(sizeof(mapping_vobj_t));
+    printf("      vobj %d\n", vobj_loc_index);
+#endif
+
+    vobj[vobj_index] = (mapping_vobj_t *) malloc(sizeof(mapping_vobj_t));
 
     ///////// get name attribute
     str = getStringValue(reader, "name", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        name = %s\n", str);
-#endif
-        strncpy( vobj[vobj_index]->name, str, 31);
-    }
-    else
-    {
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        name = %s\n", str);
+#endif
+        strncpy(vobj[vobj_index]->name, str, 31);
+    }
+    else {
         printf("[XML ERROR] illegal or missing <name> attribute for vobj (%d,%d)\n", 
                 vseg_index, vobj_loc_index);
@@ -515,13 +469,11 @@
     str = getStringValue(reader, "type", &ok);
 #if XML_PARSER_DEBUG
-printf("        type = %s\n", str);
-#endif
-    if (ok && (strcmp(str, "ELF") == 0))
-    {
+    printf("        type = %s\n", str);
+#endif
+    if (ok && (strcmp(str, "ELF") == 0)) {
         vobj[vobj_index]->type = VOBJ_TYPE_ELF;
 
         //check that this vobj is the first in vseg
-        if(vobj_count != 0) 
-        {
+        if (vobj_count != 0) {
             printf("[XML ERROR] an ELF vobj must be alone in a vseg (%d,%d)\n", 
                     vspace_index, vobj_loc_index);
@@ -529,13 +481,14 @@
         }
     }
-    else if (ok && (strcmp(str, "BLOB")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BLOB;
-    else if (ok && (strcmp(str, "PTAB")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PTAB;
-    else if (ok && (strcmp(str, "PERI")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PERI;
-    else if (ok && (strcmp(str, "MWMR")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_MWMR;
-    else if (ok && (strcmp(str, "LOCK")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_LOCK;
-    else if (ok && (strcmp(str, "BUFFER")  == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BUFFER;
-    else if (ok && (strcmp(str, "BARRIER") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BARRIER;
-    else
-    {
+    else if (ok && (strcmp(str, "BLOB")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BLOB; }
+    else if (ok && (strcmp(str, "PTAB")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_PTAB; }
+    else if (ok && (strcmp(str, "PERI")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_PERI; }
+    else if (ok && (strcmp(str, "MWMR")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MWMR; }
+    else if (ok && (strcmp(str, "LOCK")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_LOCK; }
+    else if (ok && (strcmp(str, "BUFFER")   == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BUFFER; }
+    else if (ok && (strcmp(str, "BARRIER")  == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BARRIER; }
+    else if (ok && (strcmp(str, "CONST")    == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_CONST; }
+    else if (ok && (strcmp(str, "MEMSPACE") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MEMSPACE; }
+    else {
         printf("[XML ERROR] illegal or missing <type> attribute for vobj (%d,%d)\n", 
                 vspace_index, vobj_loc_index);
@@ -544,14 +497,12 @@
 
     ////////// get length attribute 
-    value = getIntValue(reader,"length", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        length = %d\n", value);
+    value = getIntValue(reader, "length", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        length = %d\n", value);
 #endif
         vobj[vobj_index]->length = value;
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <length> attribute for vobj (%d,%d)\n", 
                 vspace_index, vobj_loc_index);
@@ -560,14 +511,12 @@
 
     ////////// get align attribute (optional : 0 if missing)
-    value = getIntValue(reader,"align", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        align = %d\n", value);
+    value = getIntValue(reader, "align", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        align = %d\n", value);
 #endif
         vobj[vobj_index]->align = value;
     }  
-    else
-    {
+    else {
         vobj[vobj_index]->align = 0;
     }
@@ -575,32 +524,28 @@
     ////////// get binpath attribute (optional : '\0' if missing)
     str = getStringValue(reader, "binpath", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        binpath = %s\n", str);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        binpath = %s\n", str);
 #endif
         strncpy(vobj[vobj_index]->binpath, str, 63);
     }  
-    else
-    {
+    else {
         vobj[vobj_index]->binpath[0] = '\0';
     }
-    
+
     ////////// get init attribute (mandatory for mwmr and barrier)
-    value = getIntValue(reader,"init", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        init  = %d\n", value);
+    value = getIntValue(reader, "init", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        init  = %d\n", value);
 #endif
         vobj[vobj_index]->init = value;
     }  
-    else
-    {
-        if( (vobj[vobj_index]->type == VOBJ_TYPE_MWMR) || 
-            (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) )
-        {
+    else {
+        if ((vobj[vobj_index]->type == VOBJ_TYPE_MWMR) || 
+                (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) ||
+                (vobj[vobj_index]->type == VOBJ_TYPE_CONST)) {
             printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d). \
-                                        All MWMR or BARRIER vobj must have a init value \n", 
+                    All MWMR or BARRIER vobj must have a init value \n", 
                     vspace_index, vobj_loc_index);
             exit(1);
@@ -614,18 +559,18 @@
 } // end vobjNode()
 
+
 //////////////////////////////////////////
-void  vsegNode ( xmlTextReaderPtr reader )
-//////////////////////////////////////////
-{
-    unsigned int 	ok;
-    unsigned int 	value;
-    char*    		str;
-
-	vobj_count = 0;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( vseg_index >= MAX_VSEGS )
-    {
+void vsegNode(xmlTextReaderPtr reader) {
+    unsigned int ok;
+    unsigned int value;
+    char * str;
+
+    vobj_count = 0;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (vseg_index >= MAX_VSEGS) {
         printf("[XML ERROR] The number of vsegs is larger than %d\n", MAX_VSEGS);
         exit(1);
@@ -633,26 +578,24 @@
 
 #if XML_PARSER_DEBUG
-printf("    vseg %d\n", vseg_loc_index);
-#endif
-
-    vseg[vseg_index] = (mapping_vseg_t*)malloc(sizeof(mapping_vseg_t));
-    
+    printf("    vseg %d\n", vseg_loc_index);
+#endif
+
+    vseg[vseg_index] = (mapping_vseg_t *) malloc(sizeof(mapping_vseg_t));
+
     ////////// set vobj_offset attributes
     vseg[vseg_index]->vobj_offset = vobj_index;
 #if XML_PARSER_DEBUG
-printf("      vobj_offset = %d\n", vobj_index);
+    printf("      vobj_offset = %d\n", vobj_index);
 #endif
 
     ///////// get name attribute
     str = getStringValue(reader, "name", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      name = %s\n", str);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      name = %s\n", str);
 #endif
         strncpy( vseg[vseg_index]->name, str, 31);
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <name> attribute for vseg (%d,%d)\n", 
                 vspace_index, vseg_loc_index);
@@ -661,28 +604,24 @@
 
     ////////// get ident attribute (optional : 0 if missing)
-    value = getIntValue(reader,"ident", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      ident = %d\n", value);
+    value = getIntValue(reader, "ident", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      ident = %d\n", value);
 #endif
         vseg[vseg_index]->ident = value;
     }  
-    else
-    {
+    else {
         vseg[vseg_index]->ident = 0;
     }
 
     /////////// get vbase attribute
-    value = getIntValue(reader,"vbase", &ok);
-    if ( ok ) 
-    {
-#if XML_PARSER_DEBUG
-printf("      vbase = 0x%x\n", value);
+    value = getIntValue(reader, "vbase", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      vbase = 0x%x\n", value);
 #endif
         vseg[vseg_index]->vbase = value;
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <vbase> attribute for vseg (%d,%d)\n", 
                 vspace_index, vseg_loc_index);
@@ -691,76 +630,71 @@
 
     ////////// get clusterid and psegname attributes
-    value = getIntValue(reader,"clusterid", &ok);
-    if ( ok == 0 )
-    {
+    value = getIntValue(reader, "clusterid", &ok);
+    if (ok == 0) {
         printf("[XML ERROR] illegal or missing <clusterid> for vseg %d\n", 
-                 vseg_loc_index);
-        exit(1);
-    }
-    str = getStringValue(reader,"psegname", &ok);
-    if ( ok == 0 )
-    {
+                vseg_loc_index);
+        exit(1);
+    }
+    str = getStringValue(reader, "psegname", &ok);
+    if (ok == 0) {
         printf("[XML ERROR] illegal or missing <psegname> for vseg %d\n", 
-                 vseg_loc_index);
+                vseg_loc_index);
         exit(1);
     }
 
     /////////// set psegid field
-    int index = getPsegId( value, str );
-    if ( index >= 0 ) 
-    {
-#if XML_PARSER_DEBUG
-printf("      clusterid = %d\n", value);
-printf("      psegname  = %s\n", str);
-printf("      psegid    = %d\n", index);
+    int index = getPsegId(value, str);
+    if (index >= 0) {
+#if XML_PARSER_DEBUG
+        printf("      clusterid = %d\n", value);
+        printf("      psegname  = %s\n", str);
+        printf("      psegid    = %d\n", index);
 #endif
         vseg[vseg_index]->psegid = index;
     }
-    else              
-    {
+    else {
         printf("[XML ERROR] pseg not found for vseg %d / clusterid = %d / psegname = %s\n", 
-                   vseg_loc_index, value, str );
+                vseg_loc_index, value, str );
         exit(1);
     }  
 
     //////// get mode attribute
-    str = getStringValue(reader,"mode", &ok);
-#if XML_PARSER_DEBUG
-printf("      mode = %s\n", str);
-#endif
-    if      (ok && (strcmp(str, "CXWU") == 0)) vseg[vseg_index]->mode = 0xF;
-    else if (ok && (strcmp(str, "CXW_") == 0)) vseg[vseg_index]->mode = 0xE;
-    else if (ok && (strcmp(str, "CX_U") == 0)) vseg[vseg_index]->mode = 0xD;
-    else if (ok && (strcmp(str, "CX__") == 0)) vseg[vseg_index]->mode = 0xC;
-    else if (ok && (strcmp(str, "C_WU") == 0)) vseg[vseg_index]->mode = 0xB;
-    else if (ok && (strcmp(str, "C_W_") == 0)) vseg[vseg_index]->mode = 0xA;
-    else if (ok && (strcmp(str, "C__U") == 0)) vseg[vseg_index]->mode = 0x9;
-    else if (ok && (strcmp(str, "C___") == 0)) vseg[vseg_index]->mode = 0x8;
-    else if (ok && (strcmp(str, "_XWU") == 0)) vseg[vseg_index]->mode = 0x7;
-    else if (ok && (strcmp(str, "_XW_") == 0)) vseg[vseg_index]->mode = 0x6;
-    else if (ok && (strcmp(str, "_X_U") == 0)) vseg[vseg_index]->mode = 0x5;
-    else if (ok && (strcmp(str, "_X__") == 0)) vseg[vseg_index]->mode = 0x4;
-    else if (ok && (strcmp(str, "__WU") == 0)) vseg[vseg_index]->mode = 0x3;
-    else if (ok && (strcmp(str, "__W_") == 0)) vseg[vseg_index]->mode = 0x2;
-    else if (ok && (strcmp(str, "___U") == 0)) vseg[vseg_index]->mode = 0x1;
-    else if (ok && (strcmp(str, "____") == 0)) vseg[vseg_index]->mode = 0x0;
-    else
-    {
+    str = getStringValue(reader, "mode", &ok);
+#if XML_PARSER_DEBUG
+    printf("      mode = %s\n", str);
+#endif
+    if      (ok && (strcmp(str, "CXWU") == 0)) { vseg[vseg_index]->mode = 0xF; }
+    else if (ok && (strcmp(str, "CXW_") == 0)) { vseg[vseg_index]->mode = 0xE; }
+    else if (ok && (strcmp(str, "CX_U") == 0)) { vseg[vseg_index]->mode = 0xD; }
+    else if (ok && (strcmp(str, "CX__") == 0)) { vseg[vseg_index]->mode = 0xC; }
+    else if (ok && (strcmp(str, "C_WU") == 0)) { vseg[vseg_index]->mode = 0xB; }
+    else if (ok && (strcmp(str, "C_W_") == 0)) { vseg[vseg_index]->mode = 0xA; }
+    else if (ok && (strcmp(str, "C__U") == 0)) { vseg[vseg_index]->mode = 0x9; }
+    else if (ok && (strcmp(str, "C___") == 0)) { vseg[vseg_index]->mode = 0x8; }
+    else if (ok && (strcmp(str, "_XWU") == 0)) { vseg[vseg_index]->mode = 0x7; }
+    else if (ok && (strcmp(str, "_XW_") == 0)) { vseg[vseg_index]->mode = 0x6; }
+    else if (ok && (strcmp(str, "_X_U") == 0)) { vseg[vseg_index]->mode = 0x5; }
+    else if (ok && (strcmp(str, "_X__") == 0)) { vseg[vseg_index]->mode = 0x4; }
+    else if (ok && (strcmp(str, "__WU") == 0)) { vseg[vseg_index]->mode = 0x3; }
+    else if (ok && (strcmp(str, "__W_") == 0)) { vseg[vseg_index]->mode = 0x2; }
+    else if (ok && (strcmp(str, "___U") == 0)) { vseg[vseg_index]->mode = 0x1; }
+    else if (ok && (strcmp(str, "____") == 0)) { vseg[vseg_index]->mode = 0x0; }
+    else {
         printf("[XML ERROR] illegal or missing <mode> attribute for vseg (%d,%d)\n", 
                 vspace_index, vseg_loc_index);
         exit(1);
     }
-    
+
     ////////// get vobjs in vseg
     int status = xmlTextReaderRead(reader);
-    while ( status == 1 ) 
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "vobj")     == 0 ) vobjNode(reader);
-        else if ( strcmp(tag, "#text"  )  == 0 ) { }
-        else if ( strcmp(tag, "#comment") == 0 ) { }
-        else if ( strcmp(tag, "vseg")     == 0 ) 
-        {
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if (strcmp(tag, "vobj")     == 0 ) {
+            vobjNode(reader);
+        }
+        else if (strcmp(tag, "#text"  )  == 0 ) { }
+        else if (strcmp(tag, "#comment") == 0 ) { }
+        else if (strcmp(tag, "vseg")     == 0 ) {
             vseg[vseg_index]->vobjs = vobj_count;
             vseg_index++;
@@ -768,53 +702,50 @@
             return;
         }
-        else 
-        {
-            printf("[XML ERROR] Unknown tag %s",tag);
-            exit(1);
-        }
-        status = xmlTextReaderRead ( reader );
+        else {
+            printf("[XML ERROR] Unknown tag %s", tag);
+            exit(1);
+        }
+        status = xmlTextReaderRead (reader);
     }
 } // end vsegNode()
 
+
 //////////////////////////////////////////
-void vspaceNode( xmlTextReaderPtr reader )
-//////////////////////////////////////////
-{
-    char*    		str;
-    unsigned int 	ok;
+void vspaceNode(xmlTextReaderPtr reader) {
+    char * str;
+    unsigned int ok;
 
     vobj_loc_index = 0;
-	vseg_loc_index = 0;
-	task_loc_index = 0;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
+    vseg_loc_index = 0;
+    task_loc_index = 0;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
 
     // checking source file consistency
-    if ( vspace_index >= header->vspaces )
-    {
+    if (vspace_index >= header->vspaces) {
         printf("[XML ERROR] The vspace index is too large : %d\n", 
-                 vspace_index);
-        exit(1);
-    }
-
-#if XML_PARSER_DEBUG
-printf("\n  vspace %d\n", vspace_index);
-#endif
-
-    vspace[vspace_index] = (mapping_vspace_t*)malloc(sizeof(mapping_vspace_t));
+                vspace_index);
+        exit(1);
+    }
+
+#if XML_PARSER_DEBUG
+    printf("\n  vspace %d\n", vspace_index);
+#endif
+
+    vspace[vspace_index] = (mapping_vspace_t *) malloc(sizeof(mapping_vspace_t));
 
     ////////// get name attribute
     str = getStringValue(reader, "name", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("  name = %s\n", str);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("  name = %s\n", str);
 #endif
         strncpy(vspace[vspace_index]->name, str, 31);
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <name> attribute for vspace %d\n", 
-                 vspace_index);
+                vspace_index);
         exit(1);
     }
@@ -824,35 +755,35 @@
     vspace[vspace_index]->vobj_offset = vobj_index;
     vspace[vspace_index]->task_offset = task_index;
-    
-#if XML_PARSER_DEBUG
-printf("  vseg_offset = %d\n", vseg_index);
-printf("  vobj_offset = %d\n", vobj_index);
-printf("  task_offset = %d\n", task_index);
+
+#if XML_PARSER_DEBUG
+    printf("  vseg_offset = %d\n", vseg_index);
+    printf("  vobj_offset = %d\n", vobj_index);
+    printf("  task_offset = %d\n", task_index);
 #endif
 
     ////////// get startname attribute
     str = getStringValue(reader, "startname", &ok);
-    if ( ok )
-    {
+    if (ok) {
         //used after parsing the vobjs
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <startname> attribute for vspace %s\n", 
-                 vspace[vspace_index]->name);
+                vspace[vspace_index]->name);
         exit(1);
     }
 
     int status = xmlTextReaderRead(reader);
-    while ( status == 1 ) 
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "vseg")     == 0 ) vsegNode(reader);
-        else if ( strcmp(tag, "task")     == 0 ) taskNode(reader);
-        else if ( strcmp(tag, "#text")    == 0 ) { }
-        else if ( strcmp(tag, "#comment") == 0 ) { }
-        else if ( strcmp(tag, "vspace")   == 0 ) 
-        {
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if (strcmp(tag, "vseg")     == 0 ) {
+            vsegNode(reader);
+        }
+        else if (strcmp(tag, "task")     == 0 ) {
+            taskNode(reader);
+        }
+        else if (strcmp(tag, "#text")    == 0 ) { }
+        else if (strcmp(tag, "#comment") == 0 ) { }
+        else if (strcmp(tag, "vspace")   == 0 ) {
             vspace[vspace_index]->vobjs = vobj_loc_index; 
             vspace[vspace_index]->tasks = task_loc_index ;
@@ -860,18 +791,16 @@
 
             // get index of the vobj containing the start vector
-            int index =  getVobjLocId( vspace_index, str , vobj_loc_index );
-            if(index == -1)
-            {
+            int index = getVobjLocId(vspace_index, str , vobj_loc_index);
+            if (index == -1) {
                 printf("[XML ERROR] vobj containing start vector not found in vspace %s\n",
                         vspace[vspace_index]->name);
                 exit(-1);
             }
-            else
-            {
+            else {
                 vspace[vspace_index]->start_offset = index;
 #if XML_PARSER_DEBUG
-printf("      startname = %s\n", str);
-printf("      startid   = %d\n", index);
-printf("  end vspace %d\n\n", vspace_index);
+                printf("      startname = %s\n", str);
+                printf("      startid   = %d\n", index);
+                printf("  end vspace %d\n\n", vspace_index);
 #endif
             }
@@ -881,10 +810,8 @@
             int task_min = vspace[vspace_index]->task_offset;
             int task_max = task_min + vspace[vspace_index]->tasks; 
-            for ( task_id = task_min ; task_id < task_max ; task_id++ )
-            {
-                if ( task[task_id]->startid >= vspace[vspace_index]->tasks )
-                {
+            for (task_id = task_min; task_id < task_max; task_id++) {
+                if (task[task_id]->startid >= vspace[vspace_index]->tasks) {
                     printf("[XML ERROR] <startid> too large for task (%d,%d)\n", 
-                           vspace_index, task_id );
+                            vspace_index, task_id );
                     exit(1);
                 }
@@ -894,91 +821,87 @@
             return;
         }
-        else 
-        {
-            printf("[XML ERROR] Unknown tag %s",tag);
-            exit(1);
-        }
-        status = xmlTextReaderRead ( reader );
+        else {
+            printf("[XML ERROR] Unknown tag %s", tag);
+            exit(1);
+        }
+        status = xmlTextReaderRead(reader);
     }
 } // end vspaceNode()
 
+
 ///////////////////////////////////////////
-void cpPortNode ( xmlTextReaderPtr reader )
-///////////////////////////////////////////
-{
-    char*           str;
-    unsigned int    ok;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( cp_port_index >= MAX_CP_PORTS )
-    {
+void cpPortNode(xmlTextReaderPtr reader) {
+    char * str;
+    unsigned int ok;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (cp_port_index >= MAX_CP_PORTS) {
         printf("[XML ERROR] The number of ports (for coprocs) is larger than %d\n", MAX_CP_PORTS);
     }
 
 #if XML_PARSER_DEBUG
-printf("\n  port %d\n", cp_port_index);
-#endif
-
-    cp_port[cp_port_index] = (mapping_cp_port_t*)malloc(sizeof(mapping_cp_port_t));
-    cp_port_vobj_ref[cp_port_index] = (vobj_ref_t*)malloc(sizeof(vobj_ref_t));
-
-
-    
+    printf("\n  port %d\n", cp_port_index);
+#endif
+
+    cp_port[cp_port_index] = (mapping_cp_port_t *) malloc(sizeof(mapping_cp_port_t));
+    cp_port_vobj_ref[cp_port_index] = (vobj_ref_t *) malloc(sizeof(vobj_ref_t));
+
+
+
     ///////// get direction attribute
-    str = getStringValue( reader, "direction", &ok );
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      direction = %s\n", str);
-#endif
-        if      ( strcmp(str, "TO_COPROC")   ==  0 ) cp_port[cp_port_index]->direction = PORT_TO_COPROC;
-        else if ( strcmp(str, "FROM_COPROC") ==  0 ) cp_port[cp_port_index]->direction = PORT_FROM_COPROC;
-        else
-        {
+    str = getStringValue(reader, "direction", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      direction = %s\n", str);
+#endif
+        if (strcmp(str, "TO_COPROC")   ==  0) {
+            cp_port[cp_port_index]->direction = PORT_TO_COPROC;
+        }
+        else if (strcmp(str, "FROM_COPROC") ==  0) {
+            cp_port[cp_port_index]->direction = PORT_FROM_COPROC;
+        }
+        else {
             printf("[XML ERROR] illegal <direction> for cp_port %d in cluster %d\n",
-                   cp_port_index, cluster_index);
+                    cp_port_index, cluster_index);
             exit(1);
         }
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] missing <direction> for cp_port %d in cluster %d\n",
-               cp_port_index, cluster_index);
-        exit(1);
-    }
-    
+                cp_port_index, cluster_index);
+        exit(1);
+    }
+
     /////////// get vspacename attribute 
-    str = getStringValue( reader, "vspacename", &ok );
-#if XML_PARSER_DEBUG
-printf("      vspacename = %s\n", str);
-#endif
-    if ( ok ) 
-    {
+    str = getStringValue(reader, "vspacename", &ok);
+#if XML_PARSER_DEBUG
+    printf("      vspacename = %s\n", str);
+#endif
+    if (ok) {
         strncpy(cp_port_vobj_ref[cp_port_index]->vspace_name, str, 31);
     }
-    else
-    {
+    else {
         printf("[XML ERROR] missing <vspacename> for cp_port %d in cluster %d\n",
-               cp_port_index, cluster_index);
+                cp_port_index, cluster_index);
         exit(1);
     }
 
     /////////// get vobjname attribute 
-    str = getStringValue( reader, "vobjname", &ok );
-#if XML_PARSER_DEBUG
-printf("      vobjname = %s\n", str);
-#endif
-    if ( ok ) 
-    {
+    str = getStringValue(reader, "vobjname", &ok);
+#if XML_PARSER_DEBUG
+    printf("      vobjname = %s\n", str);
+#endif
+    if (ok) {
         strncpy(cp_port_vobj_ref[cp_port_index]->vobj_name, str, 31);
     }
-    else
-    {
+    else {
         printf("[XML ERROR] missing <vobjname> for cp_port %d in cluster %d\n",
-               cp_port_index, cluster_index);
-        exit(1);
-    }
-    
+                cp_port_index, cluster_index);
+        exit(1);
+    }
+
     cp_port_index++;
     cp_port_loc_index++;
@@ -986,66 +909,61 @@
 } // end cpPortNode()
 
+
 ///////////////////////////////////////////
-void periphNode ( xmlTextReaderPtr reader )
-///////////////////////////////////////////
-{
-    char*           str;
-    unsigned int    value;
-    unsigned int 	ok;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( periph_index >= MAX_PERIPHS )
-    {
+void periphNode(xmlTextReaderPtr reader) {
+    char * str;
+    unsigned int value;
+    unsigned int ok;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (periph_index >= MAX_PERIPHS) {
         printf("[XML ERROR] The number of periphs is larger than %d\n", MAX_PERIPHS);
     }
 
 #if XML_PARSER_DEBUG
-printf("\n  periph %d\n", periph_index);
-#endif
-
-    periph[periph_index] = (mapping_periph_t*)malloc(sizeof(mapping_periph_t));
+    printf("\n  periph %d\n", periph_index);
+#endif
+
+    periph[periph_index] = (mapping_periph_t *) malloc(sizeof(mapping_periph_t));
 
 
     ///////// get channels attribute (optionnal : 1 if missing)
-    value = getIntValue( reader, "channels", &ok );
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      channels = %d\n", value);
+    value = getIntValue(reader, "channels", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      channels = %d\n", value);
 #endif
         periph[periph_index]->channels = value;
     }
-    else
-    {
+    else {
         periph[periph_index]->channels = 1;
     }
 
     /////////// get psegname attribute 
-    str = getStringValue(reader,"psegname", &ok);
-    if ( ok == 0 )
-    {
+    str = getStringValue(reader, "psegname", &ok);
+    if (ok == 0) {
         printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", 
-                 coproc_index, cluster_index);
+                coproc_index, cluster_index);
         exit(1);
     }
 
     /////////// set psegid attribute
-    int index = getPsegId( cluster_index, str );
-    if ( index >= 0 ) 
-    {
-#if XML_PARSER_DEBUG
-printf("      clusterid = %d\n", cluster_index);
-printf("      psegname  = %s\n", str);
-printf("      psegid    = %d\n", index);
+    int index = getPsegId(cluster_index, str);
+    if (index >= 0) {
+#if XML_PARSER_DEBUG
+        printf("      clusterid = %d\n", cluster_index);
+        printf("      psegname  = %s\n", str);
+        printf("      psegid    = %d\n", index);
 #endif
         periph[periph_index]->psegid = index;
         assert(pseg[index]->type == PSEG_TYPE_PERI && 
-        "peripheral psegname attribute must refer to a pseg of type PERI" );
-    }
-    else              
-    {
+                "peripheral psegname attribute must refer to a pseg of type PERI" );
+    }
+    else {
         printf("[XML ERROR] pseg not found for periph %d / clusterid = %d / psegname = %s\n", 
-                   periph_loc_index, cluster_index, str );
+                periph_loc_index, cluster_index, str );
         exit(1);
     }  
@@ -1053,126 +971,144 @@
 
     /////////// get type attribute 
-    str = getStringValue( reader, "type", &ok );
-    if ( ok ) 
-    {
-#if XML_PARSER_DEBUG
-printf("      type     = %s\n", str);
+    str = getStringValue(reader, "type", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      type     = %s\n", str);
 #endif
         unsigned int error = 0;
-  
+
         // The TTY, IOC, NIC, FBF and IOB peripherals cannot be replicated
         // one per architecture
-        if      ( strcmp( str, "IOC" ) == 0 ) 
-        {
+        if (strcmp(str, "IOC") == 0) {
             periph[periph_index]->type = PERIPH_TYPE_IOC;
-            if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;
-            else  error = 1;
-
-            ioc_base_offset = pseg[ periph[periph_index]->psegid ]->base;
+            if (header->ioc_clusterid == 0xFFFFFFFF) {
+                header->ioc_clusterid = cluster_index;
+            }
+            else {
+                error = 1;
+            }
+
+            ioc_base_offset = pseg[periph[periph_index]->psegid]->base;
             nb_ioc_channel = periph[periph_index]->channels;
         } 
-        else if ( strcmp( str, "TTY" ) == 0 )
-        {
+        else if (strcmp(str, "TTY") == 0) {
             periph[periph_index]->type = PERIPH_TYPE_TTY;
-            if ( header->tty_clusterid == 0xFFFFFFFF) header->tty_clusterid = cluster_index;
-            else  error = 1;
-
-            tty_base_offset = pseg[ periph[periph_index]->psegid ]->base;
+            if (header->tty_clusterid == 0xFFFFFFFF) {
+                header->tty_clusterid = cluster_index;
+            }
+            else  {
+                error = 1;
+            }
+
+            tty_base_offset = pseg[periph[periph_index]->psegid]->base;
             nb_tty_channel = periph[periph_index]->channels;
         }
-        else if ( strcmp( str, "FBF" ) == 0 ) 
-        {
+        else if (strcmp(str, "FBF") == 0) {
             periph[periph_index]->type = PERIPH_TYPE_FBF;
-            if ( header->fbf_clusterid == 0xFFFFFFFF) header->fbf_clusterid = cluster_index;
-            else  error = 1;
-
-            fbf_base_offset = pseg[ periph[periph_index]->psegid ]->base;
-        }
-        else if ( strcmp( str, "NIC" ) == 0 ) 
-        {
+            if (header->fbf_clusterid == 0xFFFFFFFF) {
+                header->fbf_clusterid = cluster_index;
+            }
+            else {
+                error = 1;
+            }
+            fbf_base_offset = pseg[periph[periph_index]->psegid]->base;
+        }
+        else if (strcmp(str, "NIC") == 0) {
             periph[periph_index]->type = PERIPH_TYPE_NIC;
-            if ( header->nic_clusterid == 0xFFFFFFFF) header->nic_clusterid = cluster_index;
-            else  error = 1;
-
-            nic_base_offset = pseg[ periph[periph_index]->psegid ]->base;
+            if (header->nic_clusterid == 0xFFFFFFFF) {
+                header->nic_clusterid = cluster_index;
+            }
+            else {
+                error = 1;
+            }
+            nic_base_offset = pseg[periph[periph_index]->psegid]->base;
             nb_nic_channel = periph[periph_index]->channels;
         }
-        else if ( strcmp( str, "IOB" ) == 0 ) 
-        {
+        else if (strcmp(str, "IOB") == 0) {
             periph[periph_index]->type = PERIPH_TYPE_IOB;
-            iob_base_offset = pseg[ periph[periph_index]->psegid ]->base;
-
-            if(io_mmu_active) error = 1;
+            iob_base_offset = pseg[periph[periph_index]->psegid]->base;
+
+            if (io_mmu_active) {
+                error = 1;
+            }
             io_mmu_active = 1;
         }
         // The TIM, ICU, XICU, DMA and IOB peripherals can be replicated in several clusters
         // one per cluster
-        else if ( strcmp( str, "TIM" ) == 0 ) 
-        {
+        else if (strcmp(str, "TIM") == 0 ) {
             periph[periph_index]->type = PERIPH_TYPE_TIM;
-            if(found_timer) error = 1;
+            if (found_timer) {
+                error = 1;
+            }
             found_timer = 1;
 
-            if(tim_base_offset == 0xFFFFFFFF)
+            if (tim_base_offset == 0xFFFFFFFF) {
                 tim_base_offset = pseg[ periph[periph_index]->psegid ]->base;
-
-            if(nb_timer_channel_max < periph[periph_index]->channels)
+            }
+
+            if (nb_timer_channel_max < periph[periph_index]->channels) {
                 nb_timer_channel_max = periph[periph_index]->channels;
-        }
-        else if ( strcmp( str, "ICU" ) == 0 ) 
-        {
+            }
+        }
+        else if (strcmp(str, "ICU") == 0) {
             periph[periph_index]->type = PERIPH_TYPE_ICU;
-            if(found_icu) error = 1;
+            if (found_icu) {
+                error = 1;
+            }
             found_icu = 1;
 
-            if(icu_base_offset == 0xFFFFFFFF)
+            if (icu_base_offset == 0xFFFFFFFF) {
+                icu_base_offset = pseg[periph[periph_index]->psegid]->base;
+            }
+        }
+        else if (strcmp(str, "XICU") == 0) {
+            periph[periph_index]->type = PERIPH_TYPE_XICU;
+            if (found_xicu) {
+                error = 1;
+            }
+            found_xicu = 1;
+
+            //'icu' since we can't have both xicu and icu in an arch
+            if (icu_base_offset == 0xFFFFFFFF) {
                 icu_base_offset = pseg[ periph[periph_index]->psegid ]->base;
-        }
-        else if ( strcmp( str, "XICU" ) == 0 ) 
-        {
-            periph[periph_index]->type = PERIPH_TYPE_XICU;
-            if(found_xicu) error = 1;
-            found_xicu = 1;
-
-            //'icu' since we can't have both xicu and icu in an arch
-            if(icu_base_offset == 0xFFFFFFFF)
-                icu_base_offset = pseg[ periph[periph_index]->psegid ]->base;
-
-            if(nb_timer_channel_max == 0)
+            }
+
+            if (nb_timer_channel_max == 0) {
                 nb_timer_channel_max = 32;
-        }
-        else if ( strcmp( str, "DMA" ) == 0 ) 
-        {
+            }
+        }
+        else if (strcmp(str, "DMA") == 0) {
             periph[periph_index]->type = PERIPH_TYPE_DMA;
-            if(found_dma) error = 1;
+            if (found_dma) {
+                error = 1;
+            }
             found_dma = 1;
 
-            if(dma_base_offset == 0xFFFFFFFF)
-                dma_base_offset = pseg[ periph[periph_index]->psegid ]->base;
-            if(nb_dma_channel_max < periph[periph_index]->channels)
+            if (dma_base_offset == 0xFFFFFFFF) {
+                dma_base_offset = pseg[periph[periph_index]->psegid]->base;
+            }
+            if (nb_dma_channel_max < periph[periph_index]->channels) {
                 nb_dma_channel_max = periph[periph_index]->channels;
-        }
-        else
-        {
+            }
+        }
+        else {
             printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n",
-                   periph_loc_index, cluster_index);
-            exit(1);
-        }
-
-        if(error)
-        {
+                    periph_loc_index, cluster_index);
+            exit(1);
+        }
+
+        if (error) {
             printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n",
-                   periph_loc_index, cluster_index);
-            exit(1);
-        }
-    }
-    else
-    {
+                    periph_loc_index, cluster_index);
+            exit(1);
+        }
+    }
+    else {
         printf("[XML ERROR] missing <type> for peripheral  %d in cluster %d\n",
-               periph_loc_index, cluster_index);
-        exit(1);
-    }
-
-    
+                periph_loc_index, cluster_index);
+        exit(1);
+    }
+
+
     periph_index++;
     periph_loc_index++;
@@ -1181,67 +1117,62 @@
 } // end periphNode
 
+
 /////////////////////////////////////////
-void coprocNode ( xmlTextReaderPtr reader )
-/////////////////////////////////////////
-{
-    char*           str;
-    unsigned int 	ok;
+void coprocNode(xmlTextReaderPtr reader) {
+    char * str;
+    unsigned int ok;
 
     cp_port_loc_index = 0;
 
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( coproc_index >= MAX_COPROCS )
-    {
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (coproc_index >= MAX_COPROCS) {
         printf("[XML ERROR] The number of coprocs is larger than %d\n", MAX_COPROCS);
     }
 
 #if XML_PARSER_DEBUG
-printf("\n  coproc %d\n", coproc_index);
-#endif
-
-    coproc[coproc_index] = (mapping_coproc_t*)malloc(sizeof(mapping_coproc_t));
+    printf("\n  coproc %d\n", coproc_index);
+#endif
+
+    coproc[coproc_index] = (mapping_coproc_t *) malloc(sizeof(mapping_coproc_t));
 
     /////////// get name attribute 
-    str = getStringValue( reader, "name", &ok );
-    if ( ok ) 
-    {
-#if XML_PARSER_DEBUG
-       printf("      name = %s\n", str);
+    str = getStringValue(reader, "name", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("      name = %s\n", str);
 #endif
         strncpy(coproc[coproc_index]->name, str, 31);
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <name> for coproc %d in cluster %d\n",
-               coproc_index, cluster_index);
+                coproc_index, cluster_index);
         exit(1);
     }
 
     /////////// get psegname attribute 
-    str = getStringValue(reader,"psegname", &ok);
-    if ( ok == 0 )
-    {
+    str = getStringValue(reader, "psegname", &ok);
+    if (ok == 0) {
         printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", 
-                 coproc_index, cluster_index);
+                coproc_index, cluster_index);
         exit(1);
     }
 
     /////////// set psegid attribute
-    int index = getPsegId( cluster_index, str );
-    if ( index >= 0 ) 
-    {
-#if XML_PARSER_DEBUG
-printf("      clusterid = %d\n", cluster_index);
-printf("      psegname  = %s\n", str);
-printf("      psegid    = %d\n", index);
+    int index = getPsegId(cluster_index, str);
+    if (index >= 0) {
+#if XML_PARSER_DEBUG
+        printf("      clusterid = %d\n", cluster_index);
+        printf("      psegname  = %s\n", str);
+        printf("      psegid    = %d\n", index);
 #endif
         coproc[coproc_index]->psegid = index;
         assert(pseg[index]->type == PSEG_TYPE_PERI && "coproc psegname attribute must refer to a pseg of type PERI" );
     }
-    else              
-    {
+    else {
         printf("[XML ERROR] pseg not found for coproc %d / clusterid = %d / psegname = %s\n", 
-                   coproc_index, cluster_index, str );
+                coproc_index, cluster_index, str );
         exit(1);
     }  
@@ -1251,17 +1182,17 @@
 
 #if XML_PARSER_DEBUG
-printf("      port_offset = %d\n", cp_port_index);
+    printf("      port_offset = %d\n", cp_port_index);
 #endif
 
     int status = xmlTextReaderRead(reader);
-    while ( status == 1 ) 
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "port")     == 0 ) cpPortNode(reader);
-        else if ( strcmp(tag, "#text")    == 0 ) { }
-        else if ( strcmp(tag, "#comment") == 0 ) { }
-        else if ( strcmp(tag, "coproc")   == 0 ) 
-        {
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if (strcmp(tag, "port") == 0 ) {
+            cpPortNode(reader);
+        }
+        else if (strcmp(tag, "#text")    == 0 ) { }
+        else if (strcmp(tag, "#comment") == 0 ) { }
+        else if (strcmp(tag, "coproc") == 0 ) {
             coproc[coproc_index]->ports = cp_port_loc_index;
             cluster[cluster_index]->coprocs++;
@@ -1270,54 +1201,54 @@
             return;
         }
-        else 
-        {
-            printf("[XML ERROR] Unknown tag %s",tag);
-            exit(1);
-        }
-        status = xmlTextReaderRead ( reader );
+        else {
+            printf("[XML ERROR] Unknown tag %s", tag);
+            exit(1);
+        }
+        status = xmlTextReaderRead(reader);
     }
 } // end coprocNode()
 
+
 ///////////////////////////////////////
-void irqNode( xmlTextReaderPtr reader )
-///////////////////////////////////////
-{
-    unsigned int 	ok;
-    unsigned int 	value;
-    char*    		str;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( irq_index >= MAX_IRQS )
-    {
+void irqNode(xmlTextReaderPtr reader) {
+    unsigned int ok;
+    unsigned int value;
+    char * str;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (irq_index >= MAX_IRQS) {
         printf("[XML ERROR] The number of irqs is larger than %d\n", MAX_IRQS);
     }
 
 #if XML_PARSER_DEBUG
-printf("     irq %d\n", irq_loc_index);
-#endif
-
-    irq[irq_index] = (mapping_irq_t*)malloc(sizeof(mapping_irq_t));
+    printf("     irq %d\n", irq_loc_index);
+#endif
+
+    irq[irq_index] = (mapping_irq_t *) malloc(sizeof(mapping_irq_t));
 
     ///////// get type attribute
-    str = getStringValue(reader,"type", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        type    = %s\n", str);
-#endif
-        if      ( strcmp(str, "HARD") == 0 ) irq[irq_index]->type = 0;
-        else if ( strcmp(str, "SOFT") == 0 ) irq[irq_index]->type = 1;
-        else
-        {
+    str = getStringValue(reader, "type", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        type    = %s\n", str);
+#endif
+        if (strcmp(str, "HARD") == 0 ) {
+            irq[irq_index]->type = 0;
+        }
+        else if (strcmp(str, "SOFT") == 0 ) {
+            irq[irq_index]->type = 1;
+        }
+        else {
             printf("[XML ERROR] undefined IRQ  <type> for processor %d in cluster %d\n",
-                   cluster_index, proc_loc_index );
+                    cluster_index, proc_loc_index);
             exit(1);
         }
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] missing IRQ <type> for processor %d in cluster %d\n",
-               cluster_index, proc_loc_index );
+                cluster_index, proc_loc_index);
         exit(1);
     }
@@ -1325,50 +1256,44 @@
     ///////// get icuid attribute
     value = getIntValue(reader, "icuid", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        icuid   = %d\n", value);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        icuid   = %d\n", value);
 #endif
         irq[irq_index]->icuid = value;
-        if ( value >= 32 )
-        {
+        if (value >= 32) {
             printf("[XML ERROR] IRQ <icuid> too large for processor %d in cluster %d\n",
-                   cluster_index, proc_loc_index );
-            exit(1);
-        }
-    }
-    else
-    {
+                    cluster_index, proc_loc_index);
+            exit(1);
+        }
+    }
+    else {
         printf("[XML ERROR] missing IRQ <icuid> for processor %d in cluster %d\n",
-               cluster_index, proc_loc_index );
+                cluster_index, proc_loc_index);
         exit(1);
     }
 
     ///////// get isr attribute
-    str = getStringValue(reader,"isr", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        isr     = %s\n", str);
-#endif
-        if      ( strcmp(str, "ISR_SWITCH" ) == 0 ) irq[irq_index]->isr = ISR_SWITCH;
-        else if ( strcmp(str, "ISR_IOC"    ) == 0 ) irq[irq_index]->isr = ISR_IOC;
-        else if ( strcmp(str, "ISR_DMA"    ) == 0 ) irq[irq_index]->isr = ISR_DMA;
-        else if ( strcmp(str, "ISR_TTY"    ) == 0 ) irq[irq_index]->isr = ISR_TTY;
-        else if ( strcmp(str, "ISR_TIMER"  ) == 0 ) irq[irq_index]->isr = ISR_TIMER;
-        else
-        {
+    str = getStringValue(reader, "isr", &ok);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        isr     = %s\n", str);
+#endif
+        if      (strcmp(str, "ISR_SWITCH" ) == 0) { irq[irq_index]->isr = ISR_SWITCH; }
+        else if (strcmp(str, "ISR_IOC"    ) == 0) { irq[irq_index]->isr = ISR_IOC; }
+        else if (strcmp(str, "ISR_DMA"    ) == 0) { irq[irq_index]->isr = ISR_DMA; }
+        else if (strcmp(str, "ISR_TTY"    ) == 0) { irq[irq_index]->isr = ISR_TTY; }
+        else if (strcmp(str, "ISR_TIMER"  ) == 0) { irq[irq_index]->isr = ISR_TIMER; }
+        else {
             printf("[XML ERROR] illegal IRQ <isr> for processor %d in cluster %d\n",
-                   cluster_index, proc_loc_index );
-            exit(1);
-        }
-#if XML_PARSER_DEBUG
-printf("        isrnum  = %d\n", irq[irq_index]->isr);
+                    cluster_index, proc_loc_index);
+            exit(1);
+        }
+#if XML_PARSER_DEBUG
+        printf("        isrnum  = %d\n", irq[irq_index]->isr);
 #endif
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] missing IRQ <isr> for processor %d in cluster %d\n",
-               cluster_index, proc_loc_index );
+                cluster_index, proc_loc_index);
         exit(1);
     }
@@ -1376,13 +1301,11 @@
     ///////// get channel attribute (optionnal : 0 if missing)
     value = getIntValue(reader, "channel", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("        channel = %d\n", value);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("        channel = %d\n", value);
 #endif
         irq[irq_index]->channel = value;
     }
-    else
-    {
+    else {
         irq[irq_index]->channel = 0;
     }
@@ -1393,34 +1316,33 @@
 } // end irqNode
 
+
 /////////////////////////////////////////
-void procNode ( xmlTextReaderPtr reader )
-/////////////////////////////////////////
-{
-    unsigned int 	ok;
-    unsigned int    value;
+void procNode(xmlTextReaderPtr reader) {
+    unsigned int ok;
+    unsigned int value;
 
     irq_loc_index = 0;
 
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( proc_index >= MAX_PROCS )
-    {
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (proc_index >= MAX_PROCS) {
         printf("[XML ERROR] The number of procs is larger than %d\n", MAX_PROCS);
     }
 
 #if XML_PARSER_DEBUG
-printf("\n  proc %d\n", proc_index);
-#endif
-
-    proc[proc_index] = (mapping_proc_t*)malloc(sizeof(mapping_proc_t));
+    printf("\n  proc %d\n", proc_index);
+#endif
+
+    proc[proc_index] = (mapping_proc_t *) malloc(sizeof(mapping_proc_t));
 
 
     /////////// get index attribute (optional)
-    value = getIntValue(reader,"index",&ok);
-    if ( ok && (value != proc_loc_index) )
-    {
-            printf("[XML ERROR] wrong proc index / expected value is %d", 
+    value = getIntValue(reader, "index", &ok);
+    if (ok && (value != proc_loc_index)) {
+        printf("[XML ERROR] wrong proc index / expected value is %d", 
                 proc_loc_index);
-            exit(1);
+        exit(1);
     }
 
@@ -1429,17 +1351,17 @@
 
 #if XML_PARSER_DEBUG
-printf("    irq_offset = %d\n", irq_index);
+    printf("    irq_offset = %d\n", irq_index);
 #endif
 
     int status = xmlTextReaderRead(reader);
-    while ( status == 1 ) 
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "irq")      == 0 ) irqNode(reader);
-        else if ( strcmp(tag, "#text")    == 0 ) { }
-        else if ( strcmp(tag, "#comment") == 0 ) { }
-        else if ( strcmp(tag, "proc")     == 0 ) 
-        {
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if (strcmp(tag, "irq") == 0) {
+            irqNode(reader);
+        }
+        else if (strcmp(tag, "#text")    == 0) { }
+        else if (strcmp(tag, "#comment") == 0) { }
+        else if (strcmp(tag, "proc")     == 0) {
             proc[proc_index]->irqs = irq_loc_index;
             cluster[cluster_index]->procs++;
@@ -1448,10 +1370,9 @@
             return;
         }
-        else 
-        {
-            printf("[XML ERROR] Unknown tag %s",tag);
-            exit(1);
-        }
-        status = xmlTextReaderRead ( reader );
+        else {
+            printf("[XML ERROR] Unknown tag %s", tag);
+            exit(1);
+        }
+        status = xmlTextReaderRead(reader);
     }
 } // end procNode()
@@ -1459,15 +1380,14 @@
 
 //////////////////////////////////////////
-void  psegNode ( xmlTextReaderPtr reader )
-//////////////////////////////////////////
-{
-    unsigned int 	ok;
-    unsigned int 	value;
-    char*    		str;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-    if ( pseg_index >= MAX_PSEGS )
-    {
+void psegNode(xmlTextReaderPtr reader) {
+    unsigned int ok;
+    unsigned int value;
+    char * str;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+    if (pseg_index >= MAX_PSEGS) {
         printf("[XML ERROR] The number of psegs is larger than %d\n", MAX_PSEGS);
         exit(1);
@@ -1475,22 +1395,20 @@
 
 #if XML_PARSER_DEBUG
-printf("    pseg %d\n", pseg_index);
-#endif
-
-    pseg[pseg_index] = (mapping_pseg_t*)malloc(sizeof(mapping_pseg_t));
+    printf("    pseg %d\n", pseg_index);
+#endif
+
+    pseg[pseg_index] = (mapping_pseg_t *) malloc(sizeof(mapping_pseg_t));
 
     /////// get name attribute
-    str = getStringValue( reader, "name", &ok );
-#if XML_PARSER_DEBUG
-printf("      name = %s\n", str);
-#endif
-    if ( ok ) 
-    {
+    str = getStringValue(reader, "name", &ok);
+#if XML_PARSER_DEBUG
+    printf("      name = %s\n", str);
+#endif
+    if (ok) {
         strncpy(pseg[pseg_index]->name, str, 31);
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <name> for pseg %d in cluster %d\n",
-               pseg_index, cluster_index);
+                pseg_index, cluster_index);
         exit(1);
     }
@@ -1499,45 +1417,40 @@
     str = getStringValue(reader, "type", &ok);
 #if XML_PARSER_DEBUG
-printf("      type = %s\n", str);
-#endif
-    if      (ok && (strcmp(str, "RAM" ) == 0)) pseg[pseg_index]->type = PSEG_TYPE_RAM;
-    else if (ok && (strcmp(str, "ROM" ) == 0)) pseg[pseg_index]->type = PSEG_TYPE_ROM;
-    else if (ok && (strcmp(str, "PERI") == 0)) pseg[pseg_index]->type = PSEG_TYPE_PERI;
-    else
-    {
+    printf("      type = %s\n", str);
+#endif
+    if      (ok && (strcmp(str, "RAM" ) == 0)) { pseg[pseg_index]->type = PSEG_TYPE_RAM; }
+    else if (ok && (strcmp(str, "ROM" ) == 0)) { pseg[pseg_index]->type = PSEG_TYPE_ROM; }
+    else if (ok && (strcmp(str, "PERI") == 0)) { pseg[pseg_index]->type = PSEG_TYPE_PERI; }
+    else {
         printf("[XML ERROR] illegal or missing <type> for pseg %s in cluster %d\n",
-        pseg[pseg_index]->name, cluster_index);
+                pseg[pseg_index]->name, cluster_index);
         exit(1);
     }
 
     //////// get base attribute
-    value = getIntValue( reader, "base", &ok );
-#if XML_PARSER_DEBUG
-printf("      base = 0x%x\n", value);
-#endif
-    if ( ok ) 
-    {
+    value = getIntValue(reader, "base", &ok);
+#if XML_PARSER_DEBUG
+    printf("      base = 0x%x\n", value);
+#endif
+    if (ok) {
         pseg[pseg_index]->base = value;
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <base> for pseg %s in cluster %d\n",
-        pseg[pseg_index]->name, cluster_index);
+                pseg[pseg_index]->name, cluster_index);
         exit(1);
     }
 
     //////// get length attribute
-    value = getIntValue( reader, "length", &ok );
-#if XML_PARSER_DEBUG
-printf("      length = 0x%x\n", value);
-#endif
-    if ( ok )
-    {
+    value = getIntValue(reader, "length", &ok);
+#if XML_PARSER_DEBUG
+    printf("      length = 0x%x\n", value);
+#endif
+    if (ok) {
         pseg[pseg_index]->length = value;
     }  
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <length> for pseg %s in cluster %d\n",
-        pseg[pseg_index]->name, cluster_index);
+                pseg[pseg_index]->name, cluster_index);
         exit(1);
     }
@@ -1550,13 +1463,12 @@
 } // end psegNode()
 
+
 /////////////////////////////////////////////
-void  clusterNode ( xmlTextReaderPtr reader )
-/////////////////////////////////////////////
-{
+void clusterNode(xmlTextReaderPtr reader) {
     unsigned int ok;
     unsigned int value;
 
-    cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t));
-    
+    cluster[cluster_index] = (mapping_cluster_t *) malloc(sizeof(mapping_cluster_t));
+
     //initialise all variables
     //they will be incremented by *Node() functions
@@ -1580,9 +1492,10 @@
     found_dma = 0;
 
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
 
     // checking source file consistency
-    if ( cluster_index >= header->clusters )
-    {
+    if (cluster_index >= header->clusters) {
         printf("[XML ERROR] The cluster index is too large : %d\n", cluster_index);
         exit(1);
@@ -1590,28 +1503,27 @@
 
 #if XML_PARSER_DEBUG
-printf("  cluster %d\n", cluster_index);
+    printf("  cluster %d\n", cluster_index);
 #endif
 
 
     /////////// check cluster index attribute (optional)
-    value = getIntValue(reader,"index",&ok);
-    if ( ok && (value != cluster_index) )
-    {
-            printf("[XML ERROR] wrong cluster index / expected value is %d", 
+    value = getIntValue(reader, "index", &ok);
+    if (ok && (value != cluster_index)) {
+        printf("[XML ERROR] wrong cluster index / expected value is %d", 
                 cluster_index);
-            exit(1);
+        exit(1);
     }
 
     ////////// set offsets
-    cluster[cluster_index]->pseg_offset   = pseg_index;
-    cluster[cluster_index]->proc_offset   = proc_index;
+    cluster[cluster_index]->pseg_offset = pseg_index;
+    cluster[cluster_index]->proc_offset = proc_index;
     cluster[cluster_index]->coproc_offset = coproc_index;
     cluster[cluster_index]->periph_offset = periph_index;
 
 #if XML_PARSER_DEBUG
-printf("    pseg_offset   = %d\n", pseg_index);
-printf("    proc_offset   = %d\n", proc_index);
-printf("    coproc_offset = %d\n", coproc_index);
-printf("    periph_offset = %d\n", coproc_index);
+    printf("    pseg_offset   = %d\n", pseg_index);
+    printf("    proc_offset   = %d\n", proc_index);
+    printf("    coproc_offset = %d\n", coproc_index);
+    printf("    periph_offset = %d\n", coproc_index);
 #endif
 
@@ -1619,55 +1531,51 @@
     int status = xmlTextReaderRead(reader);
 
-    while ( status == 1 )
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "pseg")     == 0 ) psegNode(reader);
-        else if ( strcmp(tag, "proc")     == 0 ) procNode(reader);
-        else if ( strcmp(tag, "coproc")   == 0 ) coprocNode(reader);
-        else if ( strcmp(tag, "periph")   == 0 ) periphNode(reader);
-        else if ( strcmp(tag, "#text")    == 0 ) { }
-        else if ( strcmp(tag, "#comment") == 0 ) { }
-        else if ( strcmp(tag, "cluster")  == 0 ) 
-        {
-
-            if(use_xicu == 0xFFFFFFFF)
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if      (strcmp(tag, "pseg")     == 0) psegNode(reader);
+        else if (strcmp(tag, "proc")     == 0) procNode(reader);
+        else if (strcmp(tag, "coproc")   == 0) coprocNode(reader);
+        else if (strcmp(tag, "periph")   == 0) periphNode(reader);
+        else if (strcmp(tag, "#text")    == 0) { }
+        else if (strcmp(tag, "#comment") == 0) { }
+        else if (strcmp(tag, "cluster")  == 0) {
+
+            if (use_xicu == 0xFFFFFFFF) {
                 use_xicu = found_xicu;
+            }
 
             ////////////////// peripherals checks ////////////////////
-            if( (found_timer  && use_xicu) || (!found_timer  && !use_xicu) )
-            {
+            if ((found_timer  && use_xicu) || (!found_timer  && !use_xicu)) {
                 printf("[XML ERROR] illegal or missing timer peripheral in cluster %d\n", cluster_index);
                 exit(1);
             }
 
-            if( (found_icu  && use_xicu) || (!found_icu  && !use_xicu) )
-            {
+            if ((found_icu && use_xicu) || (!found_icu && !use_xicu)) {
                 printf("[XML ERROR] illegal or missing icu peripheral in cluster %d\n", cluster_index);
                 exit(1);
             }
 
-            if( !found_xicu && use_xicu)
-            {
+            if (!found_xicu && use_xicu) {
                 printf("[XML ERROR] illegal or missing dma peripheral in cluster %d\n", cluster_index);
                 exit(1);
             }
 
-            if(!found_dma)
-            {
+            if (!found_dma) {
                 printf("[XML ERROR] illegal or missing dma peripheral in cluster %d\n", cluster_index);
                 exit(1);
             }
 
-               
-            if(nb_proc_max < cluster[cluster_index]->procs)
+
+            if (nb_proc_max < cluster[cluster_index]->procs) {
                 nb_proc_max = cluster[cluster_index]->procs;
-
-#if XML_PARSER_DEBUG
-printf("    psegs   = %d\n", cluster[cluster_index]->psegs);
-printf("    procs   = %d\n", cluster[cluster_index]->procs);
-printf("    coprocs = %d\n", cluster[cluster_index]->coprocs);
-printf("    periphs = %d\n", cluster[cluster_index]->periphs);
-printf("    end cluster %d\n", cluster_index);
+            }
+
+#if XML_PARSER_DEBUG
+            printf("    psegs   = %d\n", cluster[cluster_index]->psegs);
+            printf("    procs   = %d\n", cluster[cluster_index]->procs);
+            printf("    coprocs = %d\n", cluster[cluster_index]->coprocs);
+            printf("    periphs = %d\n", cluster[cluster_index]->periphs);
+            printf("    end cluster %d\n", cluster_index);
 #endif
             cluster_index++;
@@ -1678,33 +1586,32 @@
 } // end clusterNode()
 
+
 //////////////////////////////////////////////
-void clusterSetNode( xmlTextReaderPtr reader )
-//////////////////////////////////////////////
-{
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-#if XML_PARSER_DEBUG
-printf("\n  clusters set\n");
+void clusterSetNode(xmlTextReaderPtr reader) {
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+#if XML_PARSER_DEBUG
+    printf("\n  clusters set\n");
 #endif
 
     int status = xmlTextReaderRead(reader);
-    while ( status == 1 ) 
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "cluster")    == 0 ) clusterNode(reader);
-        else if ( strcmp(tag, "#text")      == 0 ) { }
-        else if ( strcmp(tag, "#comment")   == 0 ) { }
-        else if ( strcmp(tag, "clusterset") == 0 ) 
-        {
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if (strcmp(tag, "cluster")    == 0) {
+            clusterNode(reader);
+        }
+        else if (strcmp(tag, "#text")      == 0) { }
+        else if (strcmp(tag, "#comment")   == 0) { }
+        else if (strcmp(tag, "clusterset") == 0) {
             // checking source file consistency
-            if ( cluster_index != header->clusters )
-            {
+            if (cluster_index != header->clusters) {
                 printf("[XML ERROR] Wrong number of clusters\n");
                 exit(1);
             }
 
-            if(header->tty_clusterid == 0xFFFFFFFF)
-            {
+            if (header->tty_clusterid == 0xFFFFFFFF) {
                 printf("[XML ERROR] illegal or missing tty peripheral");
                 exit(1);
@@ -1712,15 +1619,14 @@
 
 #if XML_PARSER_DEBUG
-printf("  end cluster set\n\n");
-#endif
-            header->psegs    = pseg_index;
-            header->procs    = proc_index;
-            header->irqs     = irq_index;
-            header->coprocs  = coproc_index;
+            printf("  end cluster set\n\n");
+#endif
+            header->psegs = pseg_index;
+            header->procs = proc_index;
+            header->irqs = irq_index;
+            header->coprocs = coproc_index;
             header->cp_ports = cp_port_index;
             return;
         }
-        else 
-        {
+        else {
             printf("[XML ERROR] Unknown tag in clusterset node : %s",tag);
             exit(1);
@@ -1730,26 +1636,27 @@
 } // end clusterSetNode()
 
+
 /////////////////////////////////////////////
-void globalSetNode( xmlTextReaderPtr reader )
-/////////////////////////////////////////////
-{
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-#if XML_PARSER_DEBUG
-printf("  globals set\n");
+void globalSetNode(xmlTextReaderPtr reader) {
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+#if XML_PARSER_DEBUG
+    printf("  globals set\n");
 #endif
 
     int status = xmlTextReaderRead(reader);
-    while ( status == 1 ) 
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "vseg")      == 0 ) vsegNode(reader);
-        else if ( strcmp(tag, "#text"  )   == 0 ) { }
-        else if ( strcmp(tag, "#comment")  == 0 ) { }
-        else if ( strcmp(tag, "globalset") == 0 ) 
-        {
-#if XML_PARSER_DEBUG
-printf("  end global set\n\n");
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if (strcmp(tag, "vseg") == 0) {
+            vsegNode(reader);
+        }
+        else if (strcmp(tag, "#text")     == 0) { }
+        else if (strcmp(tag, "#comment")  == 0) { }
+        else if (strcmp(tag, "globalset") == 0) {
+#if XML_PARSER_DEBUG
+            printf("  end global set\n\n");
 #endif
             header->globals = vseg_index;
@@ -1757,41 +1664,39 @@
             return;
         }
-        else 
-        {
+        else {
             printf("[XML ERROR] Unknown tag in globalset node : %s",tag);
             exit(1);
         }
-        status = xmlTextReaderRead ( reader );
+        status = xmlTextReaderRead(reader);
     }
 } // end globalSetNode()
 
+
 /////////////////////////////////////////////
-void vspaceSetNode( xmlTextReaderPtr reader )
-/////////////////////////////////////////////
-{
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-#if XML_PARSER_DEBUG
-printf("\n  vspaces set\n");
+void vspaceSetNode(xmlTextReaderPtr reader) {
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+#if XML_PARSER_DEBUG
+    printf("\n  vspaces set\n");
 #endif
 
     int status = xmlTextReaderRead ( reader );
-    while ( status == 1 ) 
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "vspace"   ) == 0 ) vspaceNode(reader);
-        else if ( strcmp(tag, "#text"    ) == 0 ) { }
-        else if ( strcmp(tag, "#comment" ) == 0 ) { }
-        else if ( strcmp(tag, "vspaceset") == 0 ) 
-        {
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if (strcmp(tag, "vspace") == 0) {
+            vspaceNode(reader);
+        }
+        else if (strcmp(tag, "#text"    ) == 0 ) { }
+        else if (strcmp(tag, "#comment" ) == 0 ) { }
+        else if (strcmp(tag, "vspaceset") == 0 ) {
             // checking source file consistency
-            if ( vspace_index != header->vspaces )
-            {
+            if (vspace_index != header->vspaces) {
                 printf("[XML ERROR] Wrong number of vspaces\n");
                 exit(1);
             }
-            else
-            {
+            else {
                 header->vsegs = vseg_index;
                 header->vobjs = vobj_index;
@@ -1800,40 +1705,38 @@
             }
         }
-        else 
-        {
+        else {
             printf("[XML ERROR] Unknown tag in vspaceset node : %s",tag);
             exit(1);
         }
-        status = xmlTextReaderRead ( reader );
+        status = xmlTextReaderRead(reader);
     }
 } // end globalSetNode()
 
+
 //////////////////////////////////////////
-void headerNode(xmlTextReaderPtr reader )
-//////////////////////////////////////////
-{
-    char*       	name;
-    unsigned int 	value;
-    unsigned int 	ok;
-
-    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
-
-#if XML_PARSER_DEBUG
-printf("mapping_info\n");
-#endif
-
-    header = (mapping_header_t*)malloc(sizeof(mapping_header_t));
+void headerNode(xmlTextReaderPtr reader) {
+    char * name;
+    unsigned int value;
+    unsigned int ok;
+
+    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
+        return;
+    }
+
+#if XML_PARSER_DEBUG
+    printf("mapping_info\n");
+#endif
+
+    header = (mapping_header_t *) malloc(sizeof(mapping_header_t));
 
     ////////// get name attribute
     name = getStringValue(reader, "name", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("  name = %s\n", name);
-#endif
-	strncpy( header->name, name, 31);
-    }      
-    else
-    {
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("  name = %s\n", name);
+#endif
+        strncpy( header->name, name, 31);
+    }
+    else {
         printf("[XML ERROR] illegal or missing <name> attribute in header\n");
         exit(1);
@@ -1842,13 +1745,11 @@
     /////////// get cluster_x attribute
     cluster_x = getIntValue(reader, "cluster_x", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("  cluster_x = %d\n", cluster_x);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("  cluster_x = %d\n", cluster_x);
 #endif
         header->cluster_x = cluster_x;
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <cluster_x> attribute in header\n");
         exit(1);
@@ -1857,13 +1758,11 @@
     /////////// get cluster_y attribute
     cluster_y = getIntValue(reader, "cluster_y", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("  cluster_y = %d\n", cluster_y);
+    if (ok) {
+#if XML_PARSER_DEBUG
+        printf("  cluster_y = %d\n", cluster_y);
 #endif
         header->cluster_y = cluster_y;
     }
-    else
-    {
+    else {
         printf("[XML ERROR] illegal or missing <cluster_y> attribute in header\n");
         exit(1);
@@ -1871,33 +1770,29 @@
 
     //check the number of cluster
-    value = cluster_x*cluster_y;
-    if ( value >= MAX_CLUSTERS )
-    {
+    value = cluster_x * cluster_y;
+    if (value >= MAX_CLUSTERS) {
         printf("[XML ERROR] The number of clusters is larger than %d\n", MAX_CLUSTERS);
         exit(1);
     }
-	
+
     header->clusters  = value;
 
 #if XML_PARSER_DEBUG
-printf("  clusters = %d\n", value);
+    printf("  clusters = %d\n", value);
 #endif
 
     ///////// get vspaces attribute
     value = getIntValue(reader, "vspaces", &ok);
-    if ( ok )
-    {
-        if ( value >= MAX_VSPACES )
-        {
+    if (ok) {
+        if (value >= MAX_VSPACES) {
             printf("[XML ERROR] The number of vspaces is larger than %d\n", MAX_VSPACES);
             exit(1);
         }
 #if XML_PARSER_DEBUG
-printf("  vspaces = %d\n", value);
-#endif
-	header->vspaces  = value;
-    }
-    else
-    {
+        printf("  vspaces = %d\n", value);
+#endif
+        header->vspaces  = value;
+    }
+    else {
         printf("[XML ERROR] illegal or missing <vspaces> attribute in mapping\n");
         exit(1);
@@ -1914,22 +1809,21 @@
 
     int status = xmlTextReaderRead(reader);
-    while ( status == 1 ) 
-    {
-        const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-        if      ( strcmp(tag, "clusterset")   == 0 ) clusterSetNode(reader);
-        else if ( strcmp(tag, "globalset")    == 0 ) globalSetNode(reader);
-        else if ( strcmp(tag, "vspaceset")    == 0 ) vspaceSetNode(reader);
-        else if ( strcmp(tag, "#text")        == 0 ) { }
-        else if ( strcmp(tag, "#comment")     == 0 ) { }
-        else if ( strcmp(tag, "mapping_info") == 0 ) 
-        {
-#if XML_PARSER_DEBUG
-printf("end mapping_info\n");
+    while (status == 1) {
+        const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+        if (strcmp(tag, "clusterset") == 0) {
+            clusterSetNode(reader);
+        }
+        else if (strcmp(tag, "globalset")    == 0) { globalSetNode(reader); }
+        else if (strcmp(tag, "vspaceset")    == 0) { vspaceSetNode(reader); }
+        else if (strcmp(tag, "#text")        == 0) { }
+        else if (strcmp(tag, "#comment")     == 0) { }
+        else if (strcmp(tag, "mapping_info") == 0) {
+#if XML_PARSER_DEBUG
+            printf("end mapping_info\n");
 #endif
             return;
         }
-        else 
-        {
+        else {
             printf("[XML ERROR] Unknown tag in header node : %s\n",tag);
             exit(1);
@@ -1938,19 +1832,13 @@
     }
 } // end headerNode()
-    
+
+
 ///////////////////////////////////////
-void BuildTable( int fdout,
-               const char* type,
-               unsigned int nb_elem,
-               unsigned int elem_size,
-               char** table)        
-////////////////////////////////////////
-{
+void BuildTable(int fdout, const char * type, unsigned int nb_elem,
+                unsigned int elem_size, char ** table) {
     unsigned int i;
     // write element
-    for ( i = 0 ; i < nb_elem ; i++ )
-    {
-        if(elem_size != write(fdout, table[i], elem_size))
-        {
+    for (i = 0; i < nb_elem; i++) {
+        if (elem_size != write(fdout, table[i], elem_size)) {
             printf("function %s: %s(%d) write  error \n", __FUNCTION__, type, i);
             exit(1);
@@ -1958,23 +1846,28 @@
 
 #if XML_PARSER_DEBUG
-printf("Building binary: writing %s %d\n", type, i);
+        printf("Building binary: writing %s %d\n", type, i);
 #endif
     }
 }
 
-int open_file(const char* file_path)
-{
+
+int open_file(const char * file_path) {
 
     //open file
-    int fdout = open( file_path, (O_CREAT | O_RDWR | O_TRUNC), (S_IWUSR | S_IRUSR) );
-    if ( fdout < 0)
-    {
+    int fdout = open( file_path, (O_CREAT | O_RDWR), (S_IWUSR | S_IRUSR) );
+    if (fdout < 0) {
         perror("open");
         exit(1);
     }
 
-//#if XML_PARSER_DEBUG
-    printf("%s\n",file_path);
-//#endif
+    //reinitialise the file
+    if (ftruncate(fdout, 0)) {
+        perror("truncate");
+        exit(1);
+    }
+
+    //#if XML_PARSER_DEBUG
+    printf("%s\n", file_path);
+    //#endif
 
     return fdout;
@@ -1983,15 +1876,12 @@
 
 ///////////////////////////
-void  buildBin( const char* file_path )
-///////////////////////////
-{
-    unsigned int    length;
+void buildBin(const char * file_path) {
+    unsigned int length;
 
     int fdout = open_file(file_path);
 
     // write header to binary file
-    length = write(fdout, (char*)header, sizeof(mapping_header_t));
-    if ( length != sizeof(mapping_header_t) )
-    {
+    length = write(fdout, (char *) header, sizeof(mapping_header_t));
+    if (length != sizeof(mapping_header_t)) {
         printf("write header error : length = %d \n", length);
         exit(1);
@@ -1999,69 +1889,61 @@
 
     // write clusters
-    BuildTable(fdout, "cluster", cluster_index, sizeof(mapping_cluster_t), (char**) cluster);
+    BuildTable(fdout, "cluster", cluster_index, sizeof(mapping_cluster_t), (char **) cluster);
     // write psegs
-    BuildTable(fdout, "pseg", pseg_index, sizeof(mapping_pseg_t), (char**) pseg);
+    BuildTable(fdout, "pseg", pseg_index, sizeof(mapping_pseg_t), (char **) pseg);
     // write vspaces
-    BuildTable(fdout, "vspace", vspace_index, sizeof(mapping_vspace_t), (char**) vspace);
+    BuildTable(fdout, "vspace", vspace_index, sizeof(mapping_vspace_t), (char **) vspace);
     // write vsegs
-    BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char**) vseg);
+    BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char **) vseg);
     // write vobjs
-    BuildTable(fdout, "vobj", vobj_index, sizeof(mapping_vobj_t), (char**) vobj);
+    BuildTable(fdout, "vobj", vobj_index, sizeof(mapping_vobj_t), (char **) vobj);
     // write tasks array
-    BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char**) task);
+    BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char **) task);
     //building procs array
-    BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char**) proc);
+    BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char **) proc);
     //building irqs array
-    BuildTable(fdout, "irq", irq_index, sizeof(mapping_irq_t), (char**)irq);
+    BuildTable(fdout, "irq", irq_index, sizeof(mapping_irq_t), (char **) irq);
     //building coprocs array
-    BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char**)coproc);
+    BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char **) coproc);
     //building cp_ports array
-    BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_cp_port_t),(char**) cp_port);
+    BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_cp_port_t),(char **) cp_port);
     //building periphs array
-    BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char**)periph);
-    
+    BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char **) periph);
+
     close(fdout);
 
 } // end buildBin()
+
 
 ///////////////////////////////////////////////////////////////////////
 // this function set the value the vobj_id fiels of all cp_ports
 ///////////////////////////////////////////////////////////////////////
-void prepareBuild()
-{
+void prepareBuild() {
     unsigned int i;
     //asign for all cp_ports the correct vspaceid and vobjid
-    for(i=0; i< cp_port_index; i++)
-    {
-        int vspace_id = getVspaceId( cp_port_vobj_ref[i]->vspace_name );
-        if ( vspace_id < 0 ) 
-        {
-            printf("[XML ERROR] illegal  <vspacename> for cp_port %d,\n", 
-                    i);
+    for (i = 0; i < cp_port_index; i++) {
+        int vspace_id = getVspaceId(cp_port_vobj_ref[i]->vspace_name);
+        if (vspace_id < 0) {
+            printf("[XML ERROR] illegal  <vspacename> for cp_port %d,\n", i);
             exit(1);
         }
         cp_port[i]->vspaceid = vspace_id;
-        
-        int vobj_id = getVobjLocId( vspace_id, 
-                                    cp_port_vobj_ref[i]->vobj_name, 
-                                    vspace[vspace_id]->vobjs );
-        if ( vobj_id >= 0 ) 
-        {
-
-#if XML_PARSER_DEBUG
-printf("\ncp_port = %d\n", i);
-printf("      vspace_name  = %s\n", cp_port_vobj_ref[i]->vspace_name);
-printf("      vobj_name    = %s\n", cp_port_vobj_ref[i]->vobj_name);
-printf("      vobj_index   = %d\n", vobj_id);
+
+        int vobj_id = getVobjLocId(vspace_id, cp_port_vobj_ref[i]->vobj_name, vspace[vspace_id]->vobjs);
+        if (vobj_id >= 0) {
+
+#if XML_PARSER_DEBUG
+            printf("\ncp_port = %d\n", i);
+            printf("      vspace_name  = %s\n", cp_port_vobj_ref[i]->vspace_name);
+            printf("      vobj_name    = %s\n", cp_port_vobj_ref[i]->vobj_name);
+            printf("      vobj_index   = %d\n", vobj_id);
 #endif
             cp_port[i]->vobjlocid = vobj_id;
 
             assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR)
-            && "coproc ports has to refere to a vobj of type MWMR");
-        }
-        else              
-        {
-            printf("[XML ERROR] illegal  <vobjname> for cp_port %d,\n", 
-                    i);
+                    && "coproc ports have to refer to a vobj of type MWMR");
+        }
+        else {
+            printf("[XML ERROR] illegal  <vobjname> for cp_port %d,\n", i);
             exit(1);
         }
@@ -2069,10 +1951,9 @@
 }
 
+
 //////////////////////////////////////////
-void file_write(int fdout, char* towrite)
-{
+void file_write(int fdout, char * towrite) {
     unsigned int size = strlen(towrite);
-    if(size != write(fdout, towrite, size))
-    {
+    if (size != write(fdout, towrite, size)) {
         printf("file_write error");
         exit(1);
@@ -2080,45 +1961,44 @@
 }
 
+
 //////////////////////////////////////////////////
-void def_int_write(int fdout, char* def, int num)
-{
-    char buf[64];
+void def_int_write(int fdout, char * def, int num) {
+    char  buf[64];
     sprintf(buf, "#define\t %s  %d\n", def, num);
     file_write(fdout, buf);
 }
 
+
 /////////////////////////////////////////////////
-void def_hex_write(int fdout, char* def, int num)
-{
-    char buf[64];
+void def_hex_write(int fdout, char * def, int num) {
+    char  buf[64];
     sprintf(buf, "#define\t %s  0x%x\n", def, num);
     file_write(fdout, buf);
 }
 
+
 ///////////////////////////////////////
-void  genHd( const char* file_path )
-///////////////////////////////////////
-{
+void  genHd(const char * file_path) {
     int fdout = open_file(file_path);
 
-    char* prol = " /* Generated from the mapping_info file */\n\n#ifndef _HD_CONFIG_H\n#define _HD_CONFIG_H\n\n";
+    char * prol = " /* Generated from the mapping_info file */\n\n#ifndef _HD_CONFIG_H\n#define _HD_CONFIG_H\n\n";
     file_write(fdout, prol);
 
-    def_int_write(fdout, "CLUSTER_X"       , cluster_x);
-    def_int_write(fdout, "CLUSTER_Y"       , cluster_y);
-    def_int_write(fdout, "NB_CLUSTERS"     , cluster_index);
-    def_hex_write(fdout, "CLUSTER_SIZE"    , (((unsigned long long) 1) << 32) / cluster_index);
-    def_int_write(fdout, "NB_PROCS_MAX"    , nb_proc_max);
-    def_int_write(fdout, "NB_TIMERS_MAX"   , nb_timer_channel_max);
-    def_int_write(fdout, "NB_DMAS_MAX"     , nb_dma_channel_max);
-    def_int_write(fdout, "NB_TTYS"         , nb_tty_channel);
-    def_int_write(fdout, "NB_IOCS"         , nb_ioc_channel);
-    def_int_write(fdout, "NB_NICS"         , nb_nic_channel);
-    
+    def_int_write(fdout, "CLUSTER_X"    , cluster_x);
+    def_int_write(fdout, "CLUSTER_Y"    , cluster_y);
+    def_int_write(fdout, "NB_CLUSTERS"  , cluster_index);
+    def_hex_write(fdout, "CLUSTER_SIZE" , (((unsigned long long) 1) << 32) / cluster_index);
+    def_int_write(fdout, "NB_PROCS_MAX" , nb_proc_max);
+    def_int_write(fdout, "NB_TIMERS_MAX", nb_timer_channel_max);
+    def_int_write(fdout, "NB_DMAS_MAX"  , nb_dma_channel_max);
+    def_int_write(fdout, "NB_TTYS"      , nb_tty_channel);
+    def_int_write(fdout, "NB_IOCS"      , nb_ioc_channel);
+    def_int_write(fdout, "NB_NICS"      , nb_nic_channel);
+
     file_write(fdout, "\n");
-    def_int_write(fdout, "USE_XICU"         , use_xicu);
-    def_int_write(fdout, "IOMMU_ACTIVE "    , io_mmu_active);
-
-    char* epil = "\n#endif //_HD_CONFIG_H";
+    def_int_write(fdout, "USE_XICU"     , use_xicu);
+    def_int_write(fdout, "IOMMU_ACTIVE ", io_mmu_active);
+
+    char * epil = "\n#endif //_HD_CONFIG_H";
     file_write(fdout, epil);
 
@@ -2126,8 +2006,8 @@
 }
 
+
 ////////////////////////////////////////////////////////
-void ld_write(int fdout, char* seg, unsigned int addr)
-{
-    char  buf[64];
+void ld_write(int fdout, char * seg, unsigned int addr) {
+    char buf[64];
     sprintf(buf, "%s = 0x%x;\n", seg, addr);
     file_write(fdout, buf);
@@ -2135,40 +2015,39 @@
 }
 
+
 ///////////////////////////////////////
-void  genLd (const char * file_path)
-///////////////////////////////////////
-{
+void genLd(const char * file_path) {
     int fdout = open_file(file_path);
 
-    char* prol = "/* Generated from the mapping_info file */\n\n";
+    char * prol = "/* Generated from the mapping_info file */\n\n";
     file_write(fdout, prol);
 
     //boot
-    ld_write(fdout, "seg_boot_code_base"           , boot_code_base);
-    ld_write(fdout, "seg_boot_stack_base"          , boot_stack_base);
-    ld_write(fdout, "seg_mapping_base"             , boot_mapping_base);
+    ld_write(fdout, "seg_boot_code_base", boot_code_base);
+    ld_write(fdout, "seg_boot_stack_base", boot_stack_base);
+    ld_write(fdout, "seg_mapping_base", boot_mapping_base);
 
     //kernel
-    ld_write(fdout, "\nseg_kernel_code_base"       , kernel_code_base);
-    ld_write(fdout, "seg_kernel_data_base"         , kernel_data_base);
-    ld_write(fdout, "seg_kernel_uncdata_base"      , kernel_uncdata_base);
-    ld_write(fdout, "seg_kernel_init_base"         , kernel_init_base);
+    ld_write(fdout, "\nseg_kernel_code_base",  kernel_code_base);
+    ld_write(fdout, "seg_kernel_data_base",    kernel_data_base);
+    ld_write(fdout, "seg_kernel_uncdata_base", kernel_uncdata_base);
+    ld_write(fdout, "seg_kernel_init_base",    kernel_init_base);
 
     //peripherals
-    ld_write(fdout, "\nseg_fbf_base",  fbf_base_offset);
-    ld_write(fdout, "seg_icu_base"  ,  icu_base_offset);
-    ld_write(fdout, "seg_ioc_base"  ,  ioc_base_offset);
-    ld_write(fdout, "seg_nic_base"  ,  nic_base_offset);
-    ld_write(fdout, "seg_tty_base"  ,  tty_base_offset);
-    ld_write(fdout, "seg_dma_base"  ,  dma_base_offset);
-    ld_write(fdout, "seg_tim_base"  ,  tim_base_offset);
-    ld_write(fdout, "seg_gcd_base"  ,  gcd_base_offset);
-    ld_write(fdout, "seg_iob_base"  ,  iob_base_offset);
+    ld_write(fdout, "\nseg_fbf_base", fbf_base_offset);
+    ld_write(fdout, "seg_icu_base",   icu_base_offset);
+    ld_write(fdout, "seg_ioc_base",   ioc_base_offset);
+    ld_write(fdout, "seg_nic_base",   nic_base_offset);
+    ld_write(fdout, "seg_tty_base",   tty_base_offset);
+    ld_write(fdout, "seg_dma_base",   dma_base_offset);
+    ld_write(fdout, "seg_tim_base",   tim_base_offset);
+    ld_write(fdout, "seg_gcd_base",   gcd_base_offset);
+    ld_write(fdout, "seg_iob_base",   iob_base_offset);
 
     close(fdout);
 }
 
-char * buildPath(const char * path, const char * name)
-{
+
+char * buildPath(const char * path, const char * name) {
     char * res = calloc(strlen(path) + strlen(name) + 1, 1);
     strcat(res, path);
@@ -2178,10 +2057,8 @@
 }
 
+
 /////////////////////////////////////
-int  main(int argc, char * argv[])
-/////////////////////////////////////
-{
-    if ( argc < 3 ) 
-    {
+int main(int argc, char * argv[]) {
+    if (argc < 3) {
         printf("Usage: xml2bin <input_file_path> <output_path>\n");
         return 1;
@@ -2189,52 +2066,45 @@
 
     struct stat dir_st;
-    if(stat( argv[2], &dir_st ))
-    {
+    if (stat( argv[2], &dir_st)) {
         perror("bad path");
         exit(1);
     }
 
-    if((dir_st.st_mode & S_IFDIR) == 0)
-    {
+    if ((dir_st.st_mode & S_IFDIR) == 0) {
         printf("path is not a dir: %s", argv[2] );
         exit(1);
     }
 
-    
-    char *map_path = buildPath(argv[2], "map.bin"); 
-    char *ld_path = buildPath(argv[2],  "giet_vsegs.ld"); 
-    char *hd_path = buildPath(argv[2],  "hard_config.h"); 
+
+    char * map_path = buildPath(argv[2], "map.bin"); 
+    char * ld_path = buildPath(argv[2], "giet_vsegs.ld"); 
+    char * hd_path = buildPath(argv[2], "hard_config.h"); 
 
     LIBXML_TEST_VERSION;
 
     int status;
-    xmlTextReaderPtr reader = xmlReaderForFile ( argv[1], NULL, 0 );
-
-    if ( reader != NULL ) 
-    {
-        status = xmlTextReaderRead ( reader );
-        while ( status == 1 ) 
-        {
-            const char* tag = (const char*)xmlTextReaderConstName(reader);
-
-            if ( strcmp(tag,"mapping_info") == 0 )
-            { 
-                headerNode( reader );
+    xmlTextReaderPtr reader = xmlReaderForFile(argv[1], NULL, 0);
+
+    if (reader != NULL) {
+        status = xmlTextReaderRead (reader);
+        while (status == 1) {
+            const char * tag = (const char *) xmlTextReaderConstName(reader);
+
+            if (strcmp(tag, "mapping_info") == 0) { 
+                headerNode(reader);
                 prepareBuild();
-                buildBin( map_path );
+                buildBin(map_path);
                 genHd(hd_path);
                 genLd(ld_path);
             }
-            else
-            {
+            else {
                 printf("[XML ERROR] Wrong file type: \"%s\"\n", argv[1]);
                 return 1;
             }
-            status = xmlTextReaderRead ( reader );
-        }
-        xmlFreeTextReader ( reader );
-
-        if ( status != 0 ) 
-        {
+            status = xmlTextReaderRead(reader);
+        }
+        xmlFreeTextReader(reader);
+
+        if (status != 0) {
             printf("[XML ERROR] Wrong Syntax in \"%s\" file\n", argv[1]);
             return 1;
@@ -2245,4 +2115,10 @@
 
 
-
-
+// Local Variables:
+// tab-width: 4
+// c-basic-offset: 4
+// c-file-offsets:((innamespace . 0)(inline-open . 0))
+// indent-tabs-mode: nil
+// End:
+// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
+
