Index: soft/giet_vm/xml/xml_parser.c
===================================================================
--- soft/giet_vm/xml/xml_parser.c	(revision 162)
+++ soft/giet_vm/xml/xml_parser.c	(revision 165)
@@ -52,8 +52,9 @@
 unsigned int		vobj_index     = 0;
 unsigned int		vobj_loc_index = 0;
-unsigned int		vobj_loc_vspace_index = 0;
+unsigned int		vobj_count     = 0;
+
+unsigned int		tty_index      = 1;
+unsigned int		fb_index       = 0;
             
-char one_elf_found = 0;//bool: wether a first vobj of type elf was found
-
 //////////////////////////////////////////////////
 unsigned int getIntValue( xmlTextReaderPtr reader, 
@@ -144,5 +145,5 @@
     unsigned int vobj_id;
     unsigned int vobj_min = vspace[vspace_id]->vobj_offset;
-    unsigned int vobj_max = vobj_min + vobj_loc_vspace_index;
+    unsigned int vobj_max = vobj_min + vobj_loc_index;
 
     for ( vobj_id = vobj_min ; vobj_id < vobj_max ; vobj_id++ )
@@ -199,4 +200,10 @@
 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);
+            exit(1);
+        }
         task[task_index]->clusterid = value;
     }  
@@ -215,4 +222,10 @@
 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);
+            exit(1);
+        }
         task[task_index]->proclocid = value;
     }  
@@ -233,5 +246,5 @@
 #if XML_PARSER_DEBUG
 printf("      stackname = %s\n", str);
-printf("      vsegid    = %d\n", index);
+printf("      stackid   = %d\n", index);
 #endif
             task[task_index]->vobjlocid = index;
@@ -239,6 +252,6 @@
         else              
         {
-            printf("[XML ERROR] illegal or missing <psegname> for vseg %d\n", 
-                     vseg_loc_index);
+            printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", 
+                    vspace_index, task_loc_index);
             exit(1);
         }
@@ -246,5 +259,5 @@
     else
     {
-        printf("[XML ERROR] illegal or missing <vsegname> for task (%d,%d)\n", 
+        printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", 
                 vspace_index, task_loc_index);
         exit(1);
@@ -267,24 +280,44 @@
     }
 
-    /////////// get ttylocid  attribute
-    value = getIntValue(reader,"ttylocid", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("      ttylocid = %x\n", value);
-#endif
-        if ( value >= vspace[vspace_index]->ttys )
-        {
-            printf("[XML ERROR] The ttylocid value is too large for task (%d,%d)\n", 
+    /////////// get use_tty  attribute (optionnal : 0 if missing)
+    value = getIntValue(reader,"usetty", &ok);
+    if ( ok )
+    {
+#if XML_PARSER_DEBUG
+printf("      usetty = %x\n", value);
+#endif
+        if ( (value != 0) && (tty_index >= header->ttys) )
+        {
+            printf("[XML ERROR] The tty index is too large for task (%d,%d)\n", 
                 vspace_index, task_loc_index);
             exit(1);
         }
-        task[task_index]->ttylocid = value;
+        task[task_index]->use_tty = value;
+        if (value != 0) tty_index++;
     }  
     else
     {
-        printf("[XML ERROR] illegal or missing <ttylocid> attribute for task (%d,%d)\n", 
+        task[task_index]->use_tty = 0;
+    }
+
+    /////////// get use_fb  attribute (optionnal : 0 if missing)
+    value = getIntValue(reader,"usefb", &ok);
+    if ( ok )
+    {
+#if XML_PARSER_DEBUG
+printf("      usefb = %x\n", value);
+#endif
+        if ( (value != 0) && (fb_index >= header->fbs) )
+        {
+            printf("[XML ERROR] The fb channel index is too large for task (%d,%d)\n", 
                 vspace_index, task_loc_index);
-        exit(1);
+            exit(1);
+        }
+        task[task_index]->use_fb = value;
+        if (value != 0) fb_index++;
+    }  
+    else
+    {
+        task[task_index]->use_fb = 0;
     }
 
@@ -293,4 +326,5 @@
 } // end taskNode()
 
+//////////////////////////////////////////
 void  vobjNode ( xmlTextReaderPtr reader )
 {
@@ -307,14 +341,6 @@
     }
 
-    if(one_elf_found != 0)
-    {
-        printf("[XML ERROR] a vobj of the type ELF must be defined alone in a vseg (%d,%d)\n", 
-                vspace_index, vobj_loc_vspace_index);
-        exit(1);
-
-    }
-
-#if XML_PARSER_DEBUG
-printf("    vobj %d\n", vobj_loc_index);
+#if XML_PARSER_DEBUG
+printf("      vobj %d\n", vobj_loc_index);
 #endif
 
@@ -326,5 +352,5 @@
     {
 #if XML_PARSER_DEBUG
-printf("      name = %s\n", str);
+printf("        name = %s\n", str);
 #endif
         strncpy( vobj[vobj_index]->name, str, 31);
@@ -337,41 +363,40 @@
     }
 
-
-    // get type attribute
+    //////// get type attribute
     str = getStringValue(reader, "type", &ok);
 #if XML_PARSER_DEBUG
-printf("      type = %s\n", str);
-#endif
-    if (ok && (strcmp(str, "ELF") == 0)){
-        vobj[vobj_index]->type = ELF;
-        one_elf_found = 1;
-        if(vobj_loc_index != 0) //check that this vobj is the first
-        {
-            printf("[XML ERROR] a vobj of the type ELF must be defined alone in a vobj (%d,%d)\n", 
-                    vspace_index, vobj_loc_vspace_index);
-            exit(1);
-
-        }
-    }
-    else if (ok && (strcmp(str, "PTAB") == 0)) vobj[vobj_index]->type = PTAB;
-    else if (ok && (strcmp(str, "PERI") == 0)) vobj[vobj_index]->type = PERI;
-    else if (ok && (strcmp(str, "MWMR") == 0)) vobj[vobj_index]->type = MWMR;
-    else if (ok && (strcmp(str, "LOCK") == 0)) vobj[vobj_index]->type = LOCK;
-    else if (ok && (strcmp(str, "BUFFER") == 0)) vobj[vobj_index]->type = BUFFER;
-    else if (ok && (strcmp(str, "BARRIER") == 0)) vobj[vobj_index]->type = BARRIER;
+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) 
+        {
+            printf("[XML ERROR] an ELF vobj must be alone in a vseg (%d,%d)\n", 
+                    vspace_index, vobj_loc_index);
+            exit(1);
+        }
+    }
+    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
     {
         printf("[XML ERROR] illegal or missing <type> attribute for vobj (%d,%d)\n", 
-                vspace_index, vobj_loc_vspace_index);
-        exit(1);
-    }
-
-
-    ////////// get length attribute (0 if missing)
+                vspace_index, vobj_loc_index);
+        exit(1);
+    }
+
+    ////////// get length attribute 
     value = getIntValue(reader,"length", &ok);
     if ( ok )
     {
 #if XML_PARSER_DEBUG
-printf("      length = %d\n", value);
+printf("        length = %d\n", value);
 #endif
         vobj[vobj_index]->length = value;
@@ -379,13 +404,15 @@
     else
     {
-        vobj[vobj_index]->length = 0;
-    }
-
-    ////////// get align attribute (0 if missing)
+        printf("[XML ERROR] illegal or missing <length> attribute for vobj (%d,%d)\n", 
+                vspace_index, vobj_loc_index);
+        exit(1);
+    }
+
+    ////////// get align attribute (optional : 0 if missing)
     value = getIntValue(reader,"align", &ok);
     if ( ok )
     {
 #if XML_PARSER_DEBUG
-printf("      align = %d\n", value);
+printf("        align = %d\n", value);
 #endif
         vobj[vobj_index]->align = value;
@@ -396,10 +423,10 @@
     }
 
-    ////////// get binpath attribute ('\0' if missing)
+    ////////// get binpath attribute (optional : '\0' if missing)
     str = getStringValue(reader, "binpath", &ok);
     if ( ok )
     {
 #if XML_PARSER_DEBUG
-printf("      binpath = %s\n", str);
+printf("        binpath = %s\n", str);
 #endif
         strncpy(vobj[vobj_index]->binpath, str, 63);
@@ -410,11 +437,24 @@
     }
     
+    ////////// get init attribute (optional : 0 if missing)
+    value = getIntValue(reader,"init", &ok);
+    if ( ok )
+    {
+#if XML_PARSER_DEBUG
+printf("        init  = %d\n", value);
+#endif
+        vobj[vobj_index]->init = value;
+    }  
+    else
+    {
+        vobj[vobj_index]->init = 0;
+    }
+
     vobj_index++;
+    vobj_count++;
     vobj_loc_index++;
-    vobj_loc_vspace_index++;
-}
-
-
-///////////////////////////////////////////////////////////////
+} // end vobjNode()
+
+//////////////////////////////////////////
 void  vsegNode ( xmlTextReaderPtr reader )
 {
@@ -422,6 +462,6 @@
     unsigned int 	value;
     char*    		str;
-	vobj_loc_index = 0;
-	one_elf_found = 0;
+
+	vobj_count = 0;
 
     if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
@@ -442,5 +482,5 @@
     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
 
@@ -477,6 +517,5 @@
     }
 
-
-    ////////// get ident attribute (0 if missing)
+    ////////// get ident attribute (optional : 0 if missing)
     value = getIntValue(reader,"ident", &ok);
     if ( ok )
@@ -492,5 +531,4 @@
     }
 
-
     ////////// get psegname attribute
     str = getStringValue(reader,"psegname", &ok);
@@ -520,5 +558,5 @@
     }
 
-    // get mode attribute
+    //////// get mode attribute
     str = getStringValue(reader,"mode", &ok);
 #if XML_PARSER_DEBUG
@@ -548,7 +586,5 @@
     }
     
-    
     ////////// set the length attribute to 0
-    //the final value will be set by the VLoader
     vseg[vseg_index]->length = value;
 
@@ -564,5 +600,5 @@
         {
             //  checking source file consistency?
-            vseg[vseg_index]->vobjs = vobj_loc_index;
+            vseg[vseg_index]->vobjs = vobj_count;
             vseg_index++;
             vseg_loc_index++;
@@ -576,6 +612,4 @@
         status = xmlTextReaderRead ( reader );
     }
-    
-
 } // end vsegNode()
 
@@ -585,6 +619,6 @@
     char*    		str;
     unsigned int 	ok;
-    unsigned int 	value;
-    vobj_loc_vspace_index = 0;
+
+    vobj_loc_index = 0;
 	vseg_loc_index = 0;
 	task_loc_index = 0;
@@ -601,10 +635,26 @@
 
 #if XML_PARSER_DEBUG
-printf("  vspace %d\n", vspace_index);
+printf("\n  vspace %d\n", vspace_index);
 #endif
 
     vspace[vspace_index] = (mapping_vspace_t*)malloc(sizeof(mapping_vspace_t));
 
-    ////////// set vseg_offsetand task_offset attributes
+    ////////// get name attribute
+    str = getStringValue(reader, "name", &ok);
+    if ( ok )
+    {
+#if XML_PARSER_DEBUG
+printf("  name = %s\n", str);
+#endif
+        strncpy(vspace[vspace_index]->name, str, 31);
+    }
+    else
+    {
+        printf("[XML ERROR] illegal or missing <name> attribute for vspace %d\n", 
+                 vspace_index);
+        exit(1);
+    }
+
+    ////////// set vseg_offset and task_offset attributes
     vspace[vspace_index]->vseg_offset = vseg_index;
     vspace[vspace_index]->vobj_offset = vobj_index;
@@ -612,54 +662,19 @@
     
 #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 name attribute
-    str = getStringValue(reader, "name", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("    name = %s\n", str);
-#endif
-        strncpy(vspace[vspace_index]->name, str, 31);
-    }
-    else
-    {
-        printf("[XML ERROR] illegal or missing <name> attribute for vspace %d", 
+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 )
+    {
+        //used after parsing the vobjs
+    }
+    else
+    {
+        printf("[XML ERROR] illegal or missing <startname> attribute for vspace %d\n", 
                  vspace_index);
-        exit(1);
-    }
-
-    ////////// get funcs_entry attribute
-    str = getStringValue(reader, "funcs", &ok);
-    if ( ok )
-    {
-#if XML_PARSER_DEBUG
-printf("    name = %s\n", str);
-#endif
-        //used after parsing all the vobjs
-    }
-    else
-    {
-        printf("[XML ERROR] illegal or missing <name> attribute for vspace %d", 
-                 vspace_index);
-        exit(1);
-    }
-
-    // get ttys attribute
-    value = getIntValue(reader,"ttys", &ok);
-#if XML_PARSER_DEBUG
-printf("    ttys = %d\n", value);
-#endif
-    if ( ok )
-    {
-        vspace[vspace_index]->ttys = value;
-    }
-    else
-    {
-        printf("[XML ERROR] illegal or missing <ttys> attribute for vspace %d", 
-                  vspace_index);
         exit(1);
     }
@@ -675,14 +690,37 @@
         else if ( strcmp(tag,"vspace") == 0  ) 
         {
-            vspace[vspace_index]->vobjs = vobj_loc_vspace_index;
+            vspace[vspace_index]->vobjs = vobj_loc_index;
             vspace[vspace_index]->tasks = task_loc_index ;
             vspace[vspace_index]->vsegs = vseg_loc_index ;
+
+            // get index of the vobj containing the start vector
             int index =  getVobjLocId( vspace_index, str );
             if(index == -1)
             {
-                printf("Error funcs entry vobj not found %s\n",str);
+                printf("[XML ERROR] vobj containing the start vector not found %s\n",str);
                 exit(-1);
             }
-            vspace[vspace_index]->funcs_offset = index;
+            else
+            {
+                vspace[vspace_index]->start_offset = index;
+#if XML_PARSER_DEBUG
+printf("  startname = %s\n", str);
+printf("  startid   = %d\n", index);
+#endif
+            }
+
+            // checking startid values for all tasks in vspace
+            int task_id;
+            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 )
+                {
+                    printf("[XML ERROR] <startid> too large for task (%d,%d)\n", 
+                           vspace_index, task_id );
+                    exit(1);
+                }
+            }
 
             vspace_index++;
@@ -722,5 +760,5 @@
     str = getStringValue( reader, "name", &ok );
 #if XML_PARSER_DEBUG
-printf("  - name = %s\n", str);
+printf("    name = %s\n", str);
 #endif
     if ( ok ) 
@@ -737,5 +775,5 @@
     value = getIntValue( reader, "base", &ok );
 #if XML_PARSER_DEBUG
-printf("  - base = %x\n", value);
+printf("    base = %x\n", value);
 #endif
     if ( ok ) 
@@ -752,5 +790,5 @@
     value = getIntValue( reader, "length", &ok );
 #if XML_PARSER_DEBUG
-printf("  - length = %x\n\n", value);
+printf("    length = %x\n\n", value);
 #endif
     if ( ok )
@@ -789,8 +827,20 @@
     cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t));
 
+    // get index attribute (optional)
+    value = getIntValue(reader,"index",&ok);
+#if XML_PARSER_DEBUG
+printf("    index = %d\n", value);
+#endif
+    if ( ok && (value != cluster_index) )
+    {
+            printf("[XML ERROR] wrong cluster index / expected value is %d", 
+                cluster_index);
+            exit(1);
+    }
+
     // get procs attribute
     value = getIntValue(reader,"procs",&ok);
 #if XML_PARSER_DEBUG
-printf("  - procs = %d\n", value);
+printf("    procs = %d\n", value);
 #endif
     if ( ok )
@@ -805,36 +855,4 @@
     }
 
-    // get timers attribute
-    value = getIntValue(reader,"timers",&ok);
-#if XML_PARSER_DEBUG
-printf("  - timers = %d\n", value);
-#endif
-    if ( ok )
-    {
-        cluster[cluster_index]->timers = value;
-    }
-    else
-    {
-        printf("[XML ERROR] illegal or missing <timers> attribute for cluster %d", 
-                cluster_index);
-        exit(1);
-    }
-
-    // get dmas attribute
-    value = getIntValue(reader,"dmas",&ok);
-#if XML_PARSER_DEBUG
-printf("  - dmas = %d\n\n", value);
-#endif
-    if ( ok )
-    {
-        cluster[cluster_index]->dmas = value;
-    }
-    else
-    {
-        printf("[XML ERROR] illegal or missing <dmas> attribute for cluster %d", 
-                cluster_index);
-        exit(1);
-    }
-
     cluster_index++;
 } // end clusterNode()
@@ -846,5 +864,5 @@
 
 #if XML_PARSER_DEBUG
-printf("  clusters set\n");
+printf("\n  clusters set\n");
 #endif
 
@@ -922,5 +940,5 @@
 
 #if XML_PARSER_DEBUG
-printf("  global vsegs set\n");
+printf("  globals set\n");
 #endif
 
@@ -961,5 +979,5 @@
 
 #if XML_PARSER_DEBUG
-printf("  vspaces set\n");
+printf("\n  vspaces set\n");
 #endif
 
@@ -1011,10 +1029,10 @@
     header = (mapping_header_t*)malloc(sizeof(mapping_header_t));
 
-    // get name attribute
+    ////////// get name attribute
     name = getStringValue(reader, "name", &ok);
     if ( ok )
     {
 #if XML_PARSER_DEBUG
-printf("- name = %s\n", name);
+printf("  name = %s\n", name);
 #endif
 	strncpy( header->name, name, 31);
@@ -1026,5 +1044,5 @@
     }
 
-    // get clusters attribute
+    /////////// get clusters attribute
     value = getIntValue(reader, "clusters", &ok);
     if ( ok )
@@ -1036,5 +1054,5 @@
         }
 #if XML_PARSER_DEBUG
-printf("- clusters = %d\n", value);
+printf("  clusters = %d\n", value);
 #endif
 	header->clusters  = value;
@@ -1046,5 +1064,5 @@
     }
 
-    // get psegs attribute
+    ////////// get psegs attribute
     value = getIntValue(reader, "psegs", &ok);
     if ( ok )
@@ -1056,5 +1074,5 @@
         }
 #if XML_PARSER_DEBUG
-printf("- psegs = %d\n", value);
+printf("  psegs = %d\n", value);
 #endif
 	header->psegs = value;
@@ -1066,10 +1084,10 @@
     }
 
-    // get ttys attribute
+    ///////// get ttys attribute
     value = getIntValue(reader, "ttys", &ok);
     if ( ok )
     {
 #if XML_PARSER_DEBUG
-printf("- ttys = %d\n", value);
+printf("  ttys = %d\n", value);
 #endif
 	header->ttys  = value;
@@ -1081,5 +1099,20 @@
     }
 
-    // get vspaces attribute
+    ///////// get fbs attribute
+    value = getIntValue(reader, "fbs", &ok);
+    if ( ok )
+    {
+#if XML_PARSER_DEBUG
+printf("  fbs = %d\n", value);
+#endif
+	header->fbs  = value;
+    }
+    else
+    {
+        printf("[XML ERROR] illegal or missing <fbs> attribute in header\n");
+        exit(1);
+    }
+
+    ///////// get vspaces attribute
     value = getIntValue(reader, "vspaces", &ok);
     if ( ok )
@@ -1091,5 +1124,5 @@
         }
 #if XML_PARSER_DEBUG
-printf("- vspaces = %d\n", value);
+printf("  vspaces = %d\n", value);
 #endif
 	header->vspaces  = value;
@@ -1101,5 +1134,5 @@
     }
 
-    // get globals attribute
+    ////////// get globals attribute
     value = getIntValue(reader, "globals", &ok);
     if ( ok )
@@ -1111,5 +1144,5 @@
         }
 #if XML_PARSER_DEBUG
-printf("- globals = %d\n", value);
+printf("  globals = %d\n", value);
 #endif
 	header->globals  = value;
