Index: soft/giet_vm/memo/src/pseg.cpp
===================================================================
--- soft/giet_vm/memo/src/pseg.cpp	(revision 227)
+++ soft/giet_vm/memo/src/pseg.cpp	(revision 238)
@@ -1,5 +1,5 @@
 /* -*- c++ -*-
  *
- * SOCLIB_LGPL_HEADER_BEGIN
+ * GIET_VM_LGPL_HEADER_BEGIN
  * 
  * This file is part of SoCLib, GNU LGPLv2.1.
@@ -19,5 +19,5 @@
  * 02110-1301 USA
  * 
- * SOCLIB_LGPL_HEADER_END
+ * GIET_VM_LGPL_HEADER_END
  *
  * Copyright (c) UPMC, Lip6, SoC
@@ -43,4 +43,5 @@
  */
 
+//////////////////////////////////////
 const std::string & VSeg::name() const
 {
@@ -48,4 +49,5 @@
 }
 
+//////////////////////////////////////
 const std::string & VSeg::file() const
 {
@@ -53,4 +55,5 @@
 }
 
+///////////////////////////
 uintptr_t VSeg::vma() const
 {
@@ -58,9 +61,11 @@
 }
 
-uintptr_t VSeg::lma() const
+/////////////////////////
+paddr_t VSeg::lma() const
 {
 	return m_lma;
 }
 
+///////////////////////////
 size_t VSeg::length() const
 {
@@ -68,4 +73,5 @@
 }
 
+/////////////////////////
 size_t VSeg::type() const
 {
@@ -73,4 +79,5 @@
 }
 
+/////////////////////////////////////////
 void VSeg::print( std::ostream &o ) const
 {
@@ -79,5 +86,5 @@
       << std::setw (8) << std::setfill('0') 
       << m_vma << ", to(paddr) 0x"
-      << std::setw (8) << std::setfill('0') 
+      << std::setw (16) << std::setfill('0') 
       << m_lma << ", size: 0x"
       << std::setw (8) << std::setfill('0') 
@@ -87,9 +94,10 @@
 }
 
+/////////////
 VSeg::~VSeg()
 {
-//    std::cout << "Deleted VSeg " << *this << std::endl;
-}
-
+}
+
+/////////////////////////////////////////
 VSeg & VSeg::operator=( const VSeg &ref )
 {
@@ -97,5 +105,4 @@
         return *this;
 
-    //std::cout << "Copying " << ref << " to " << *this << std::endl;
     m_name = ref.m_name,
     m_file = ref.m_file;
@@ -107,4 +114,5 @@
 }
 
+////////////
 VSeg::VSeg()
     : m_name("No Name"),
@@ -115,8 +123,13 @@
       m_ident(0)
 {
-    //std::cout << "New empty VSeg " << *this << std::endl;
-}
-
-VSeg::VSeg(std::string& binaryName, std::string& name, uintptr_t vma, size_t length, bool loadable, bool ident)
+}
+
+////////////////////////////////////
+VSeg::VSeg(std::string&  binaryName, 
+           std::string&  name, 
+           uintptr_t     vma, 
+           size_t        length, 
+           bool          loadable, 
+           bool          ident)
     : m_name(name),
       m_file(binaryName),
@@ -126,7 +139,7 @@
       m_ident(ident)
 {
-    //std::cout << "New VSeg " << *this << std::endl;
-}
-
+}
+
+/////////////////////////////
 VSeg::VSeg( const VSeg &ref )
     : m_name("To be copied"),
@@ -137,9 +150,6 @@
       m_ident(0)
 {
-    //std::cout << "New VSeg " << *this << " copied from " << ref << std::endl;
     (*this) = ref;
 }
-
-
 
 
@@ -147,19 +157,24 @@
  * PSeg
  */
-uintptr_t PSeg::lma() const
+
+/////////////////////////
+paddr_t PSeg::lma() const
 {
 	return m_lma;
 }
 
-uintptr_t PSeg::limit() const
+///////////////////////////
+paddr_t PSeg::limit() const
 {
 	return m_limit;
 }
 
-size_t PSeg::length() const
+/////////////////////////////
+paddr_t PSeg::length() const
 {
 	return m_length;
 }
 
+/////////////////////////
 size_t PSeg::type() const
 {
@@ -167,9 +182,11 @@
 }
 
-uintptr_t PSeg::nextLma() const
+/////////////////////////////
+paddr_t PSeg::nextLma() const
 {
 	return m_nextLma;
 }
 
+//////////////////////////////////////
 const std::string & PSeg::name() const
 {
@@ -177,4 +194,5 @@
 }
 
+//////////////////////// initialisation used[][] ??? (AG)
 void PSeg::check() const
 {
@@ -184,27 +202,27 @@
 
     std::vector<VSeg>::const_iterator it;
-    size_t size = m_vsegs.size();
-    size_t used[size][2];//lma, lma+length
-    size_t i,j,error=0;
+    size_t    size = m_vsegs.size();
+    paddr_t   used[size][2];          // lma, lma+length
+    size_t    i,j,error=0;
     
-    for(it = m_vsegs.begin(), i= 0; it < m_vsegs.end(); it++, i++)
+    for(it = m_vsegs.begin(), i= 0 ; it < m_vsegs.end() ; it++, i++)
     {
-        size_t it_limit = (*it).lma() + (*it).length();
+        paddr_t it_limit = (*it).lma() + (*it).length();
         for(j=0; j< i; j++)
         {
-           if(  (used[j][0] == (*it).lma() /*and (*it).length()?*/) ) //not the same lma ,
+            if( used[j][0] == (*it).lma() ) //not the same lma ,
             {
                 error = 1;
                 std::cout << "ok \n";
             }
-           if(  (used[j][1] == it_limit /*and (*it).legth()?*/))  // and not the same limit
+            if( used[j][1] == it_limit )  // and not the same limit
             {
                 error = 2;
             }
-           if(  ((used[j][0] < (*it).lma()) and ((*it).lma() < used[j][1] )) ) //lma  within the used slice
+            if( (used[j][0] < (*it).lma()) and ((*it).lma() < used[j][1]) ) // lma  within
             {
                 error = 3;
             }
-           if(  ((used[j][0] < it_limit) and (it_limit < used[j][1] )) )//limit not within the used slice
+            if(  ((used[j][0] < it_limit) and (it_limit < used[j][1] )) ) // limit no within
             {
                 error = 4;
@@ -228,4 +246,5 @@
 }
 
+//////////////////////////////////////
 void PSeg::setName(std::string& name )
 {
@@ -233,32 +252,33 @@
 }
 
-size_t PSeg::align( unsigned toAlign, unsigned alignPow2)
-{
-    return ((toAlign + (1 << alignPow2) - 1 ) >> alignPow2) << alignPow2;//page aligned 
-}
-
-
-size_t PSeg::pageAlign( size_t toAlign )
+/////////////////////////////////////////////////////////
+paddr_t PSeg::align( paddr_t toAlign, unsigned alignPow2)
+{
+    return ((toAlign + (1 << alignPow2) - 1 ) >> alignPow2) << alignPow2; 
+}
+
+//////////////////////////////////////////
+paddr_t PSeg::pageAlign( paddr_t toAlign )
 {
     size_t pgs = pageSize();
     size_t pageSizePow2 = __builtin_ctz(pgs);
     
-    return align(toAlign, pageSizePow2);//page aligned 
-
-}
-
-void PSeg::setLma( uintptr_t lma )
+    return align(toAlign, pageSizePow2); 
+}
+
+////////////////////////////////
+void PSeg::setLma( paddr_t lma )
 {
     m_lma = lma;
     
-    m_nextLma = pageAlign(lma);//page aligned 
+    m_nextLma = pageAlign(lma);
 
     m_pageLimit = pageAlign(m_lma+m_length); 
 
     m_limit = (m_lma + m_length);
-
-}
-
-void PSeg::setLength( size_t length )
+}
+
+/////////////////////////////////////
+void PSeg::setLength( paddr_t length )
 {
     m_length = length;
@@ -267,38 +287,36 @@
 
     m_limit = (m_lma + m_length);
-
-    //std::cout << std::hex << " length seted, m_limit: " << m_limit  << std::endl;
-    //std::cout << *this <<std::endl;
-}
-
+}
+
+////////////////////////////
 void PSeg::add( VSeg& vseg )
 {
     vseg.m_lma = m_nextLma;
-    incNextLma(vseg.length());//for the next vseg
+//    incNextLma(vseg.length());   //for the next vseg
     m_vsegs.push_back(vseg); 
 }
 
+/////////////////////////////////
 void PSeg::addIdent( VSeg& vseg )
 {
     vseg.m_lma = vseg.m_vma;
-    //incNextLma(vseg.length());//to keep track of space used
     m_vsegs.push_back(vseg); 
 }
 
-void PSeg::setNextLma( uintptr_t nextLma)
+/////////////////////////////////////////
+void PSeg::setNextLma( paddr_t nextLma)
 {
     m_nextLma = nextLma;
-
     confNextLma();
 }
 
-void PSeg::incNextLma( size_t inc_next)
-{
-
-    m_nextLma += inc_next;
-
+//////////////////////////////////
+void PSeg::incNextLma( size_t inc)
+{
+    m_nextLma += inc;
     confNextLma();
 }
 
+////////////////////////
 void PSeg::confNextLma()
 {
@@ -322,4 +340,5 @@
 }
 
+/////////////////////////////////
 void PSeg::setPageSize(size_t pg)
 {
@@ -332,4 +351,5 @@
 }
 
+////////////////////////
 size_t& PSeg::pageSize()
 {
@@ -338,10 +358,9 @@
 }
 
+/////////////////////////////////////////
 PSeg & PSeg::operator=( const PSeg &ref )
 {
     if ( &ref == this )
         return *this;
-
-    //std::cout << "Copying " << ref << " to " << *this << std::endl;
 
     m_name = ref.m_name;
@@ -357,4 +376,5 @@
 }
 
+//////////////////////////////////////////
 void PSeg::print( std::ostream &o ) const
 {
@@ -374,8 +394,9 @@
 }
 
+////////////////////////////////////
 PSeg::PSeg( const std::string &name,
-                uintptr_t lma,
-                size_t length,
-                size_t type)
+            paddr_t           lma,
+            paddr_t           length,
+            size_t            type)
 {
     m_name = name;
@@ -384,7 +405,7 @@
 
     setLma(lma);
-    //std::cout <<"New PSeg :"<< *this ;          
-}
-
+}
+
+////////////////////////////////////
 PSeg::PSeg( const std::string &name):
       m_lma(0),
@@ -396,5 +417,6 @@
 }
 
-PSeg::PSeg( uintptr_t lma):
+////////////////////////
+PSeg::PSeg( paddr_t lma):
       m_name("No name"),
       m_lma(0),
@@ -406,5 +428,5 @@
 }
 
-
+////////////
 PSeg::PSeg()
     :
@@ -415,7 +437,7 @@
       m_limit(0)
 {
-    //std::cout << "New empty PSeg " << *this << std::endl;
-}
-
+}
+
+/////////////////////////////
 PSeg::PSeg( const PSeg &ref )
     : m_name("To be copied"),
@@ -425,5 +447,4 @@
       m_limit(0)
 {
-    //std::cout << "New PSeg " << *this << " copied from " << ref << std::endl;
     (*this) = ref;
 }
@@ -431,5 +452,4 @@
 PSeg::~PSeg()
 {
-//    std::cout << "Deleted PSeg " << *this << std::endl;
 }
 
