Index: /soft/giet_vm/giet_boot/boot.c
===================================================================
--- /soft/giet_vm/giet_boot/boot.c	(revision 512)
+++ /soft/giet_vm/giet_boot/boot.c	(revision 513)
@@ -34,7 +34,6 @@
 //    - The structure of the various multi-threaded software applications:
 //      number of tasks, communication channels.
-//    - The mapping: grouping of virtual objects (vobj) in the virtual segments (vseg),
-//      placement of virtual segments (vseg) in the physical segments (pseg), placement 
-//      of software tasks on the processors, 
+//    - The mapping: placement of virtual segments (vseg) in the physical 
+//      segments (pseg), placement of software tasks on the processors, 
 //
 // 3) The GIET-VM uses the paged virtual memory to provides two services:
@@ -52,5 +51,5 @@
 //    Each page table (one page table per virtual space) is monolithic, and contains 
 //    one PT1 (8 Kbytes) and a variable number of PT2s (4 Kbytes each). For each vspace,
-//    the numberof PT2s is defined by the size of the PTAB vobj in the mapping.
+//    the number of PT2s is defined by the size of the PTAB vseg in the mapping.
 //    The PT1 is indexed by the ix1 field (11 bits) of the VPN. Each entry is 32 bits.
 //    A PT2 is indexed the ix2 field (9 bits) of the VPN. Each entry is a double word. 
@@ -334,7 +333,6 @@
 //   vseg can cover several contiguous big physical pages.
 //
-// 1) First step: it computes the vseg length, and register it in vseg->length field.
-//    It computes - for each vobj - the actual vbase address, taking into
-//    account the alignment constraints and register it in vobj->vbase field.
+// 1) First step: it computes various vseg attributes and checks 
+//    alignment constraints.
 //
 // 2) Second step: it allocates the required number of contiguous physical pages, 
@@ -345,5 +343,5 @@
 //    is reserved for the boot vsegs.
 //
-// 3) Third step (only for vseg that have the VOBJ_TYPE_PTAB): the M page tables
+// 3) Third step (only for vseg that have the VSEG_TYPE_PTAB): the M page tables
 //    associated to the M vspaces must be packed in the same vseg.
 //    We divide this vseg in M sub-segments, and compute the vbase and pbase
@@ -356,7 +354,8 @@
 {
     mapping_header_t*   header  = (mapping_header_t *)SEG_BOOT_MAPPING_BASE;
-    mapping_vobj_t*     vobj    = _get_vobj_base(header);
     mapping_cluster_t*  cluster = _get_cluster_base(header);
     mapping_pseg_t*     pseg    = _get_pseg_base(header);
+
+    //////////// First step : compute vseg attributes 
 
     // compute destination cluster pointer & coordinates
@@ -366,9 +365,14 @@
     unsigned int        y_dest     = cluster->y;
 
-    // compute the first vobj global index
-    unsigned int        vobj_id = vseg->vobj_offset;
-    
     // compute the "big" vseg attribute
     unsigned int        big = vseg->big;
+
+    // all vsegs must be aligned on 4Kbytes
+    if ( vseg->vbase & 0x00000FFF ) 
+    {
+        _printf("\n[BOOT ERROR] vseg %s not aligned : vbase = %x\n", 
+                vseg->name, vseg->vbase );
+        _exit();
+    }
 
     // compute the "is_ram" vseg attribute
@@ -379,6 +383,6 @@
     // compute the "is_ptab" attribute
     unsigned int        is_ptab;
-    if ( vobj[vobj_id].type == VOBJ_TYPE_PTAB ) is_ptab = 1;
-    else                                        is_ptab = 0;
+    if ( vseg->type == VSEG_TYPE_PTAB ) is_ptab = 1;
+    else                                is_ptab = 0;
 
     // compute actual vspace index
@@ -387,22 +391,4 @@
     else                           vsid = vspace_id;
 
-    //////////// First step : compute vseg length and vobj(s) vbase
-
-    unsigned int vobj_vbase = vseg->vbase;   // min vbase for first vobj
-
-    for ( vobj_id = vseg->vobj_offset ;
-          vobj_id < (vseg->vobj_offset + vseg->vobjs) ; 
-          vobj_id++ ) 
-    {
-        // compute and register vobj vbase
-        vobj[vobj_id].vbase = vaddr_align_to( vobj_vbase, vobj[vobj_id].align );
-   
-        // compute min vbase for next vobj
-        vobj_vbase = vobj[vobj_id].vbase + vobj[vobj_id].length;
-    }
-
-    // compute and register vseg length (multiple of 4 Kbytes)
-    vseg->length = vaddr_align_to( vobj_vbase - vseg->vbase, 12 );
-    
     //////////// Second step : compute ppn and npages  
     //////////// - if identity mapping :  ppn <= vpn 
@@ -490,6 +476,4 @@
     vseg->pbase     = ((paddr_t)ppn) << 12;
     vseg->mapped    = 1;
-    vseg->next_vseg = pseg->next_vseg;
-    pseg->next_vseg = (unsigned int)vseg;
 
 
@@ -782,5 +766,4 @@
     mapping_vspace_t*   vspace = _get_vspace_base(header);
     mapping_vseg_t*     vseg   = _get_vseg_base(header);
-    mapping_vobj_t*     vobj   = _get_vobj_base(header);
     mapping_cluster_t*  cluster ;
     mapping_pseg_t*     pseg    ;
@@ -808,12 +791,11 @@
     ///////// Phase 1 : global vseg containing the PTAB (two barriers required)
 
-    // get local PTAB vseg
+    // get PTAB global vseg in cluster(cx,cy)
     unsigned int found = 0;
     for (vseg_id = 0; vseg_id < header->globals; vseg_id++) 
     {
-        unsigned int vobj_id = vseg[vseg_id].vobj_offset;
         pseg    = _get_pseg_base(header) + vseg[vseg_id].psegid;
         cluster = _get_cluster_base(header) + pseg->clusterid;
-        if ( (vobj[vobj_id].type == VOBJ_TYPE_PTAB) && 
+        if ( (vseg[vseg_id].type == VSEG_TYPE_PTAB) && 
              (cluster->x == cx) && (cluster->y == cy) )
         {
@@ -845,8 +827,7 @@
     for (vseg_id = 0; vseg_id < header->globals; vseg_id++) 
     {
-        unsigned int vobj_id = vseg[vseg_id].vobj_offset;
         pseg    = _get_pseg_base(header) + vseg[vseg_id].psegid;
         cluster = _get_cluster_base(header) + pseg->clusterid;
-        if ( (vobj[vobj_id].length > 0x200000) &&
+        if ( (vseg[vseg_id].length > 0x200000) &&
              (vseg[vseg_id].mapped == 0) &&
              (cluster->x == cx) && (cluster->y == cy) )
@@ -930,5 +911,4 @@
 {
     mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE;
-    mapping_vobj_t*   vobj   = _get_vobj_base(header);
     mapping_vseg_t*   vseg   = _get_vseg_base(header);
     mapping_pseg_t*   pseg   = _get_pseg_base(header);
@@ -939,9 +919,9 @@
     for ( vseg_id = 0 ; (vseg_id < header->vsegs) && (found == 0) ; vseg_id++ )
     {
-        if ( (vobj[vseg[vseg_id].vobj_offset].type == VOBJ_TYPE_SCHED) && 
+        if ( (vseg[vseg_id].type == VSEG_TYPE_SCHED) && 
              (pseg[vseg[vseg_id].psegid].clusterid == cluster_id ) )
         {
             *vbase  = vseg[vseg_id].vbase;
-            *length = vobj[vseg[vseg_id].vobj_offset].length;
+            *length = vseg[vseg_id].length;
             found = 1;
         }
@@ -950,5 +930,5 @@
     {
         mapping_cluster_t* cluster = _get_cluster_base(header);
-        _printf("\n[BOOT ERROR] No vobj of type SCHED in cluster [%d,%d]\n",
+        _printf("\n[BOOT ERROR] No vseg of type SCHED in cluster [%d,%d]\n",
                 cluster[cluster_id].x, cluster[cluster_id].y );
         _exit();
@@ -972,6 +952,6 @@
     mapping_cluster_t*   cluster = _get_cluster_base(header);
     mapping_vspace_t*    vspace  = _get_vspace_base(header);
+    mapping_vseg_t*      vseg    = _get_vseg_base(header);
     mapping_task_t*      task    = _get_task_base(header);
-    mapping_vobj_t*      vobj    = _get_vobj_base(header);
     mapping_periph_t*    periph  = _get_periph_base(header);
     mapping_irq_t*       irq     = _get_irq_base(header);
@@ -980,6 +960,6 @@
     unsigned int         irq_id;
     unsigned int         vspace_id;
+    unsigned int         vseg_id;
     unsigned int         task_id; 
-    unsigned int         vobj_id; 
 
     unsigned int         sched_vbase;          // schedulers array vbase address 
@@ -1133,10 +1113,10 @@
             // the task entry point : the start_vector is stored by GCC in the seg_data 
             // segment and we must wait the .elf loading to get the entry point value...
-            vobj_id = vspace[vspace_id].start_vobj_id;     
-            unsigned int ctx_epc = vobj[vobj_id].vbase + (task[task_id].startid)*4;
-
-            // ctx_sp :  Get the vobj containing the stack 
-            vobj_id = task[task_id].stack_vobj_id;
-            unsigned int ctx_sp = vobj[vobj_id].vbase + vobj[vobj_id].length;
+            vseg_id = vspace[vspace_id].start_vseg_id;     
+            unsigned int ctx_epc = vseg[vseg_id].vbase + (task[task_id].startid)*4;
+
+            // ctx_sp :  Get the vseg containing the stack 
+            vseg_id = task[task_id].stack_vseg_id;
+            unsigned int ctx_sp = vseg[vseg_id].vbase + vseg[vseg_id].length;
 
             // get vspace thread index
@@ -1332,5 +1312,5 @@
 
         while ( (lpid >= cluster[cluster_id].procs) ||
-                (_wti_channel_alloc[cx][cy] >= 16) )
+                (_wti_channel_alloc[cx][cy] >= 32) )
         {
             cluster_id = (cluster_id + 1) % (X_SIZE*Y_SIZE);
@@ -1501,5 +1481,4 @@
     mapping_vspace_t  * vspace  = _get_vspace_base(header);
     mapping_vseg_t    * vseg    = _get_vseg_base(header);
-    mapping_vobj_t    * vobj    = _get_vobj_base(header);
 
     unsigned int seg_id;
@@ -1629,6 +1608,5 @@
                     // get destination buffer physical address and size
                     paddr_t      seg_paddr  = vseg[vseg_id].pbase;
-                    unsigned int vobj_id    = vseg[vseg_id].vobj_offset;
-                    unsigned int seg_size   = vobj[vobj_id].length;
+                    unsigned int seg_size   = vseg[vseg_id].length;
                     
 #if BOOT_DEBUG_ELF
@@ -1690,5 +1668,5 @@
 // - The "preloader.elf" file is not loaded, because it has been burned in the ROM.
 // - The "boot.elf" file is not loaded, because it has been loaded by the preloader.
-// This function scans all vobjs defined in the map.bin data structure to collect
+// This function scans all vsegs defined in the map.bin data structure to collect
 // all .elf files pathnames, and calls the load_one_elf_file() for each .elf file.
 // As the code can be replicated in several vsegs, the same code can be copied 
@@ -1699,15 +1677,15 @@
     mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE;
     mapping_vspace_t* vspace = _get_vspace_base( header );
-    mapping_vobj_t*   vobj   = _get_vobj_base( header );
+    mapping_vseg_t*   vseg   = _get_vseg_base( header );
+
     unsigned int      vspace_id;
-    unsigned int      vobj_id;
+    unsigned int      vseg_id;
     unsigned int      found;
 
-    // Scan all vobjs corresponding to global vsegs,
-    // to find the pathname to the kernel.elf file
+    // Scan all global vsegs to find the pathname to the kernel.elf file
     found = 0;
-    for( vobj_id = 0 ; vobj_id < header->globals ; vobj_id++ )
-    {
-        if(vobj[vobj_id].type == VOBJ_TYPE_ELF) 
+    for( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ )
+    {
+        if(vseg[vseg_id].type == VSEG_TYPE_ELF) 
         {   
             found = 1;
@@ -1725,18 +1703,18 @@
     // Load the kernel 
     load_one_elf_file( 1,                           // kernel file
-                       vobj[vobj_id].binpath,       // file pathname
+                       vseg[vseg_id].binpath,       // file pathname
                        0 );                         // vspace 0
 
-    // loop on the vspaces, scanning all vobjs in the vspace,
+    // loop on the vspaces, scanning all vsegs in the vspace,
     // to find the pathname of the .elf file associated to the vspace.
     for( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ )
     {
-        // loop on the vobjs in vspace (vobj_id is the global index)
+        // loop on the private vsegs
         unsigned int found = 0;
-        for (vobj_id = vspace[vspace_id].vobj_offset;
-             vobj_id < (vspace[vspace_id].vobj_offset + vspace[vspace_id].vobjs);
-             vobj_id++) 
-        {
-            if(vobj[vobj_id].type == VOBJ_TYPE_ELF) 
+        for (vseg_id = vspace[vspace_id].vseg_offset;
+             vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs);
+             vseg_id++) 
+        {
+            if(vseg[vseg_id].type == VSEG_TYPE_ELF) 
             {   
                 found = 1;
@@ -1754,5 +1732,5 @@
 
         load_one_elf_file( 0,                          // not a kernel file
-                           vobj[vobj_id].binpath,      // file pathname
+                           vseg[vseg_id].binpath,      // file pathname
                            vspace_id );                // vspace index
 
@@ -1770,5 +1748,5 @@
     mapping_cluster_t * cluster = _get_cluster_base(header);
     mapping_periph_t * periph   = _get_periph_base(header);
-    mapping_vobj_t * vobj       = _get_vobj_base(header);
+    mapping_vseg_t * vseg       = _get_vseg_base(header);
     mapping_coproc_t * coproc   = _get_coproc_base(header);
     mapping_cp_port_t * cp_port = _get_cp_port_base(header);
@@ -1890,10 +1868,10 @@
                   cp_port_id++ ) 
             {
-                // get global index of associted vobj
-                unsigned int vobj_id   = cp_port[cp_port_id].mwmr_vobj_id; 
+                // get global index of associted vseg
+                unsigned int vseg_id   = cp_port[cp_port_id].mwmr_vseg_id; 
 
                 // get MWMR channel base address 
                 page_table_t* ptab  = (page_table_t*)_ptabs_vaddr[0][x][y];
-                unsigned int  vbase = vobj[vobj_id].vbase;
+                unsigned int  vbase = vseg[vseg_id].vbase;
                 unsigned int  ppn;
                 unsigned int  flags;
