Changeset 238 for soft/giet_vm/memo


Ignore:
Timestamp:
May 29, 2013, 1:24:09 AM (11 years ago)
Author:
alain
Message:

Major evolution to support physical addresses larger than 32 bits.
The map.xml format has been modified: the vsegs associated to schedulers
are now explicitely defined and mapped in the page tables.

Location:
soft/giet_vm/memo
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/memo/TODO

    r163 r238  
    11+ Support for debug info
    22+ Search the sections by name, the name should correspond to vobj->name and the adresse should correspond to vseg->addresse
     3+ Documentation
  • soft/giet_vm/memo/include/libelfpp/elfpp/elfpp_object.hh

    r163 r238  
    5959
    6060    /** Copy all header fields of obj and set the access_ variable*/
    61     void copy_info(object& obj);
     61    void copy_info(object& obj, size_t word_width = 0);
    6262
    6363    ~object();
  • soft/giet_vm/memo/include/memo.h

    r212 r238  
    11/* -*- c++ -*-
    22 *
    3  * SOCLIB_LGPL_HEADER_BEGIN
     3 * GIET_VM_LGPL_HEADER_BEGIN
    44 *
    5  * This file is part of SoCLib, GNU LGPLv2.1.
     5 * This file is part of GIET_VM, GNU LGPLv2.1.
    66 *
    7  * SoCLib is free software; you can redistribute it and/or modify it
     7 * GIET_VM is free software; you can redistribute it and/or modify it
    88 * under the terms of the GNU Lesser General Public License as published
    99 * by the Free Software Foundation; version 2.1 of the License.
    1010 *
    11  * SoCLib is distributed in the hope that it will be useful, but
     11 * GIET_VM is distributed in the hope that it will be useful, but
    1212 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1515 *
    1616 * You should have received a copy of the GNU Lesser General Public
    17  * License along with SoCLib; if not, write to the Free Software
     17 * License along with GIET_VM; if not, write to the Free Software
    1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    1919 * 02110-1301 USA
    2020 *
    21  * SOCLIB_LGPL_HEADER_END
     21 * GIET_VM_LGPL_HEADER_END
    2222 *
    2323 * Copyright (c) UPMC, Lip6, SoC
     
    2525 *
    2626 */
    27 #ifndef _MEMO_H_
    28 #define _MEMO_H_
     27
     28#ifndef GIET_VM_MEMO_H
     29#define GIET_VM_MEMO_H
    2930
    3031#include  <stdlib.h>
     
    5758class MeMo
    5859{
     60// TODO: make the name defined in the map_info relative to this wd.
    5961
    60     std::string m_path;         //map_info path name
    61     std::string m_wd;           //map_info path to directory TODO: make the name defined in the map_info relative to this wd.
    62     std::string m_simpleName;   //map_info filename TODO
    63     void* m_data;               //map_info structure
    64     uintptr_t m_addr;           //map_info address (virtual)
    65     size_t m_size;              //size of the structure
     62    std::string                                   m_path;       // map_info path name
     63    std::string                                   m_wd;         // map_info directory TODO
     64    std::string                                   m_simpleName; // map_info filename TODO
     65    void*                                         m_data;       // map_info structure
     66    uintptr_t                                     m_addr;       // map_info address (virtual)
     67    size_t                                        m_size;       // size of the structure
    6668    mutable std::map<std::string, elfpp::object*> m_loaders;
    67     PSegHandler m_psegh;
    68     PathHandler m_pathHandler;
    69    
    70     bool m_ginit;
    71     elfpp::object* m_generator;
     69    PSegHandler                                   m_psegh;
     70    PathHandler                                   m_pathHandler;
     71    bool                                          m_ginit;
     72    elfpp::object*                                m_generator;
    7273
    7374    size_t load_bin(std::string filename, void* buffer);   
     
    7879public:
    7980
    80     MeMo( const std::string &name, const size_t pageSize = 4096);
     81    MeMo( const std::string   &name,
     82          const size_t        pageSize = 4096);
     83
    8184    ~MeMo();
    8285
     
    9396    }
    9497
     98    // The following functions handle the map.bin structure
     99    // They must keep synchronised with functions defined in boot_init.c.
    95100
    96     //The following functions handle the map.bin structure
    97     //inspired from the boot_init.c of the GIET
    98101    mapping_cluster_t* get_cluster_base( mapping_header_t* header );
    99102    mapping_pseg_t* get_pseg_base( mapping_header_t* header );
     
    108111
    109112
    110 #endif /* _MEMO_H_ */
     113#endif /* GIET_VM_MEMO_H */
    111114
    112115// Local Variables:
  • soft/giet_vm/memo/include/pseg.h

    r210 r238  
    11/* -*- c++ -*-
    22 *
    3  * SOCLIB_LGPL_HEADER_BEGIN
     3 * GIET-VM_LGPL_HEADER_BEGIN
    44 *
    5  * This file is part of SoCLib, GNU LGPLv2.1.
     5 * This file is part of the GIET-VMS, GNU LGPLv2.1.
    66 *
    7  * SoCLib is free software; you can redistribute it and/or modify it
     7 * The GIET-VM is free software; you can redistribute it and/or modify it
    88 * under the terms of the GNU Lesser General Public License as published
    99 * by the Free Software Foundation; version 2.1 of the License.
    1010 *
    11  * SoCLib is distributed in the hope that it will be useful, but
     11 * THe GIET-VM is distributed in the hope that it will be useful, but
    1212 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1919 * 02110-1301 USA
    2020 *
    21  * SOCLIB_LGPL_HEADER_END
     21 * GIET-VM_LGPL_HEADER_END
    2222 *
    2323 * Copyright (c) UPMC, Lip6, SoC
     
    2525 *         
    2626 */
    27 #ifndef SOCLIB_PSEG_H_
    28 #define SOCLIB_PSEG_H_
     27#ifndef GIET_MEMO_PSEG_H
     28#define GIET_MEMO_PSEG_H
    2929
    3030#include <string>
     
    3939class MeMo;
    4040
     41//////////
    4142class VSeg
    4243{
     
    4546    friend class MeMo;
    4647
    47     std::string m_name;
    48     std::string m_file;
    49     uintptr_t m_vma;   //The address of the section to load in the binary file.
    50     uintptr_t m_lma;   //Physical address to which we load the seg (getted from the associated PSeg), setted by PSeg::add/addIdent.
    51     size_t m_length;
    52     size_t m_type;
    53     bool m_loadable;     // wether this is a loadable vseg ( code, data...)
     48    typedef unsigned long long paddr_t;
     49
     50    std::string m_name;     // vseg name
     51    std::string m_file;     // file name
     52    uintptr_t   m_vma;      // Virtual address of the section to load in the binary file.
     53    paddr_t     m_lma;      // Physical address 
     54    size_t      m_length;
     55    size_t      m_type;
     56    bool        m_loadable; // loadable vseg ( code, data...)
    5457
    5558public:
    56     bool m_ident;//Indicate if the idententy mapping is activited. used by PSegHandler::makeIdent()
     59
     60    bool        m_ident;    // identity mapping required if true
    5761
    5862    const std::string& name() const;
    5963    const std::string& file() const;
    6064    uintptr_t vma() const;
    61     uintptr_t lma() const;
     65    paddr_t lma() const;
    6266    size_t length() const;
    6367    size_t type() const;
     
    7579    VSeg();
    7680    VSeg( const VSeg &ref );
    77     VSeg(std::string& binaryName, std::string& name, uintptr_t vma, size_t length, bool loadable, bool ident);
     81    VSeg(std::string&   binaryName,
     82         std::string&   name,
     83         uintptr_t      vma,
     84         size_t         length,
     85         bool           loadable,
     86         bool           ident);
    7887
    7988    ~VSeg();
    8089};
    8190
    82 
     91//////////
    8392class PSeg
    8493{
    85     std::string m_name;
    86     uintptr_t m_lma;
    87     size_t m_length;
    88     size_t m_type;
     94    std::string   m_name;
     95    paddr_t      m_lma;
     96    paddr_t      m_length;
     97    size_t        m_type;
    8998
    90     uintptr_t m_pageLimit;  //The end (m_lma + m_length)  address of the segment pageSize aligned
    91     uintptr_t m_nextLma;    //next free base
     99    paddr_t       m_pageLimit;  // m_lma + m_length aligned on page size
     100    paddr_t       m_nextLma;    // next free base
    92101   
    93     void confNextLma();     //check that m_nextLma has a correct value: whithin the seg limits
     102    void confNextLma();         // check m_nextLma is whithin the seg limits
    94103
    95104public:
     105
    96106    std::vector<VSeg> m_vsegs;
    97     uintptr_t m_limit;// m_lma + m_length
    98107
     108    paddr_t     m_limit;        // m_lma + m_length
    99109
    100110    const std::string& name() const;
    101     uintptr_t lma() const;
    102     size_t length() const;
     111    paddr_t lma() const;
     112    paddr_t length() const;
    103113    size_t type() const;
    104     uintptr_t limit() const;
    105     uintptr_t nextLma() const;
     114    paddr_t limit() const;
     115    paddr_t nextLma() const;
    106116
    107117    void check() const;
    108118
    109119    void setName(std::string& name);
    110     void setLma( uintptr_t lma);
    111     void setLength(size_t length);
     120    void setLma( paddr_t lma);
     121    void setLength(paddr_t length);
    112122
    113     static size_t align( unsigned toAlign, unsigned alignPow2);
    114     static size_t pageAlign( size_t toAlign );
     123    static paddr_t align( paddr_t toAlign, unsigned alignPow2);
     124    static paddr_t pageAlign( paddr_t toAlign );
     125
    115126    static void setPageSize(size_t pg);
     127
    116128    static size_t& pageSize();
    117129
    118     void add( VSeg& vseg );//add a VSeg
     130    void add( VSeg& vseg );    //add a VSeg
    119131    void addIdent( VSeg& vseg );
    120132
    121     void setNextLma( uintptr_t nextLma);
    122     void incNextLma( size_t inc_next);
     133    void setNextLma( paddr_t nextLma);
     134    void incNextLma( size_t inc);
    123135
    124136    void print( std::ostream &o ) const;
     
    134146    PSeg( const PSeg &ref );
    135147    PSeg( const std::string &name);
    136     PSeg( const uintptr_t lma);
     148    PSeg( const paddr_t lma);
    137149    PSeg( const std::string &name,
    138                      uintptr_t lma,
    139              size_t length,
    140              size_t type);
     150          paddr_t lma,
     151          paddr_t length,
     152          size_t type);
    141153    ~PSeg();
    142154};
    143155
    144156
    145 #endif /* SOCLIB_PSEG_H_ */
     157#endif /* GIET_MEMO_PSEG_H */
  • soft/giet_vm/memo/src/libelfpp/elfpp_object.cc

    r163 r238  
    129129   
    130130
    131   void object::copy_info(object& obj)
    132   {
    133     this->word_width_  = obj.word_width_ ;
     131  void object::copy_info(object& obj, size_t word_width)
     132  {
     133
     134        if(word_width == 32)
     135                this->word_width_  = ELFCLASS32;
     136        else if(word_width == 64)
     137            this->word_width_  =  ELFCLASS64;
     138        else
     139            this->word_width_  = obj.word_width_ ;
     140
    134141    this->byteorder_  = obj.byteorder_ ;
    135142    this->machine_  = obj.machine_ ;
  • soft/giet_vm/memo/src/memo.cpp

    r215 r238  
    11/* -*- c++ -*-
    22 *
    3  * SOCLIB_LGPL_HEADER_BEGIN
     3 * GIET_VM_LGPL_HEADER_BEGIN
    44 *
    5  * This file is part of SoCLib, GNU LGPLv2.1.
     5 * This file is part of GIET_VM, GNU LGPLv2.1.
    66 *
    7  * SoCLib is free software; you can redistribute vSO and/or modify vSO
     7 * GIET_VM is free software; you can redistribute it and/or modify it
    88 * under the terms of the GNU Lesser General Public License as published
    99 * by the Free Software Foundation; version 2.1 of the License.
    1010 *
    11  * SoCLib is distributed in the hope that vSO will be useful, but
     11 * GIET_VM is distributed in the hope that it will be useful, but
    1212 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1515 *
    1616 * You should have received a copy of the GNU Lesser General Public
    17  * License along with SoCLib; if not, write to the Free Software
     17 * License along with GIET_VM; if not, write to the Free Software
    1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    1919 * 02110-1301 USA
    2020 *
    21  * SOCLIB_LGPL_HEADER_END
     21 * GIET_VM_LGPL_HEADER_END
    2222 *
    2323 * Copyright (c) UPMC, Lip6, SoC
     
    4141//#define MOVER_DEBUG
    4242
    43 MeMo::MeMo( const std::string &filename,
    44         const size_t pageSize)
    45         :m_path(filename),
    46         m_pathHandler(filename),
    47         m_ginit(false),
    48         m_generator(new elfpp::object())
    49 {
    50    
     43////////////////////////////////////////////
     44MeMo::MeMo( const std::string     &filename,
     45            const size_t          pageSize)
     46        : m_path(filename),
     47          m_pathHandler(filename),
     48          m_ginit(false),
     49          m_generator(new elfpp::object())
     50{
    5151    PSeg::setPageSize(pageSize);
    5252
    53     /* loading map_info blob */
     53    // loading map_info blob
    5454    m_data = std::malloc(bin_size(m_path));
    5555    if ( !m_data )
     
    5858    m_size = load_bin(m_path, m_data);
    5959
    60     /* checking signature */
     60    // checking signature
    6161    mapping_header_t*   header = (mapping_header_t*)m_data;
    62     //assert((IN_MAPPING_SIGNATURE == header->signature) and "wrong signature");
    6362    if((IN_MAPPING_SIGNATURE != header->signature))
    6463    {
    65         std::cout  << "wrong signature " << std::hex <<header->signature << ", should be:"<< IN_MAPPING_SIGNATURE << std::endl;
     64        std::cout  << "wrong signature "
     65                   << std::hex <<header->signature
     66                   << ", should be:"<< IN_MAPPING_SIGNATURE << std::endl;
    6667        exit(1);
    6768    }
    68    
    69    
    7069
    7170#ifdef MOVER_DEBUG
     
    9291}
    9392
     93/////////////////////////////////////////
    9494void MeMo::print( std::ostream &o ) const
    9595{
     
    102102}
    103103
     104////////////////////////////////
    104105void MeMo::print_mapping() const
    105106{
     
    107108}
    108109
     110////////////////////////////////////////////////////////////////////////////////
    109111elfpp::section* MeMo::get_sect_by_addr(elfpp::object *loader, unsigned int addr)
    110112{
     
    123125}
    124126
    125 
     127/////////////////////////////////////////////////
    126128void MeMo::buildSoft(const std::string &filename)
    127129{
     
    133135}
    134136
    135 /* Load the content of filename in buffer, and send the size */
    136 ////////////////////////////////////////////////////////
     137/////////////////////////////////////////////////////////
    137138size_t MeMo::load_bin(std::string filename, void* buffer)
    138139{
    139140
    140141#ifdef MOVER_DEBUG
    141     std::cout  << "Trying to load the binary blob from file '" << filename << "'" << std::endl;
     142    std::cout  << "Loading binary blob from file '" << filename << "'" << std::endl;
    142143#endif
    143144
     
    339340void MeMo::vseg_map( mapping_vseg_t* vseg)
    340341{
    341     mapping_vobj_t*     vobj   = get_vobj_base( (mapping_header_t*) m_data );
    342     PSeg *ps = &(m_psegh.get(vseg->psegid));// get physical segment pointer(PSegHandler::get)
    343     elfpp::section* sect = NULL;
    344     size_t cur_vaddr;
    345     size_t cur_paddr;
    346     bool first = true;
    347     bool aligned = false;
    348 
    349     VSeg   *vSO = new VSeg;
     342    mapping_vobj_t*  vobj   = get_vobj_base( (mapping_header_t*) m_data );
     343    PSeg             *ps = &(m_psegh.get(vseg->psegid));
     344    elfpp::section*  sect = NULL;
     345    size_t           cur_vaddr;
     346    paddr_t          cur_paddr;
     347    bool             first = true;
     348    bool             aligned = false;
     349    VSeg*            vSO = new VSeg;
     350    mapping_vobj_t*  cur_vobj;
    350351
    351352    vSO->m_name = std::string(vseg->name);
    352     vSO->m_vma = vseg->vbase;
    353     vSO->m_lma = ps->nextLma();
     353    vSO->m_vma  = vseg->vbase;
     354    vSO->m_lma  = ps->nextLma();
    354355
    355356    cur_vaddr = vseg->vbase;
    356357    cur_paddr = ps->nextLma();
    357358
    358     mapping_vobj_t* cur_vobj;
    359359    size_t simple_size = 0; //for debug
    360360
    361361#ifdef MOVER_DEBUG
    362     std::cout << "--------------------vseg_map "<< vseg->name <<"---------------------" << std::endl;
    363 #endif
    364 
    365     for ( size_t vobj_id = vseg->vobj_offset ; vobj_id < (vseg->vobj_offset + vseg->vobjs) ; vobj_id++ )
     362std::cout << "--------------- vseg_map "<< vseg->name <<" ------------------" << std::endl;
     363#endif
     364
     365    for ( size_t vobj_id = vseg->vobj_offset ;
     366          vobj_id < (vseg->vobj_offset + vseg->vobjs) ; vobj_id++ )
    366367    {
    367368        cur_vobj = &vobj[vobj_id];
    368369
    369370#ifdef MOVER_DEBUG
    370         std::cout << std::hex << "current vobj("<< vobj_id <<"): " << cur_vobj->name << " (" <<cur_vobj->vaddr << ")"
    371                         << " size: "<< cur_vobj->length << " type: " <<  cur_vobj->type << std::endl;
     371std::cout << std::hex << "current vobj("<< vobj_id <<"): " << cur_vobj->name
     372          << " (" <<cur_vobj->vaddr << ")"
     373          << " size: "<< cur_vobj->length
     374          << " type: " <<  cur_vobj->type << std::endl;
    372375#endif
    373376        if(cur_vobj->type == VOBJ_TYPE_BLOB)
     
    377380
    378381#ifdef MOVER_DEBUG
    379             std::cout << std::hex << "Handling: " << filePath << " ..." << std::endl;
    380 #endif
    381 
    382             if(!filePath.compare(m_path))    //local blob: map_info
     382std::cout << std::hex << "Handling: " << filePath << " ..." << std::endl;
     383#endif
     384
     385            if(!filePath.compare(m_path))    // local blob: map_info
    383386            {
    384387#ifdef MOVER_DEBUG
    385                 std::cout << "Found the vseg of the mapping info" << std::endl;
     388std::cout << "Found the vseg of the mapping info" << std::endl;
    386389#endif
    387390                blob_size = this->m_size;
     
    391394            {
    392395#ifdef MOVER_DEBUG
    393                 std::cout << "Found an BLOB vseg" << std::endl;
     396std::cout << "Found an BLOB vseg" << std::endl;
    394397#endif
    395398                blob_size = bin_size(filePath);
    396399            }
    397400
    398 
    399             /**creating a new section */
     401            // creating a new section
    400402            sect = new elfpp::section(*m_generator, elfpp::SHT_PROGBITS);
    401403
    402404            sect->set_name(std::string(cur_vobj->name));
    403405            sect->set_flags(elfpp::SHF_ALLOC | elfpp::SHF_WRITE);
    404             sect->set_size(blob_size);//do the malloc for the get_content fonction
     406            sect->set_size(blob_size);  //do the malloc for the get_content fonction
    405407
    406408            assert(sect->get_content());//check allocation
     
    459461                /** Initailising the header of the generator from the first binary,
    460462                ** we suppose that the header is the same for all the binarys **/
    461                 m_generator->copy_info(*loader);
     463                m_generator->copy_info(*loader, 64);
    462464                m_ginit=true;
    463465            }
     
    512514    vSO->m_ident = vseg->ident;
    513515
    514     //should we check that we have the same type for the pseg and vobj?
    515     if(ps->type() != PSEG_TYPE_PERI)//take into acount only vseg who are not of the peri type
    516     {
    517         //set the lma
    518         if ( vseg->ident != 0 )            // identity mapping required
    519             ps->addIdent( *vSO );
    520         else
    521             ps->add( *vSO );
    522     }
    523     if(!sect)
    524         return;
     516    //set the lma for vseg that are not peripherals
     517    if(ps->type() != PSEG_TYPE_PERI)
     518    {
     519        if ( vseg->ident != 0 )    ps->addIdent( *vSO );
     520        else                       ps->add( *vSO );
     521    }
     522
     523    // increment NextLma if required
     524    if(ps->type() == PSEG_TYPE_RAM)
     525    {
     526        ps->incNextLma( vSO->m_length );
     527    }
     528
     529    if(!sect) return;
    525530
    526531#ifdef MOVER_DEBUG
     
    550555#endif
    551556
    552 #ifdef DISTRIBUTED_SCHEDULERS
    553     char found;
    554 #endif
    555 
    556557    for ( size_t cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ )
    557558    {
    558 
    559 #ifdef DISTRIBUTED_SCHEDULERS
    560         found    = 0;
    561 #endif
    562 
    563559        for ( size_t pseg_id = cluster[cluster_id].pseg_offset ;
    564560              pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs ;
    565561              pseg_id++ )
    566562        {
    567             //build pseg
    568563            std::string name(pseg[pseg_id].name);
    569             PSeg *ps = new PSeg(name, pseg[pseg_id].base, pseg[pseg_id].length, pseg[pseg_id].type);
    570 
    571 #ifdef DISTRIBUTED_SCHEDULERS
    572             if ( (pseg[pseg_id].type == PSEG_TYPE_RAM) && (found == 0) )
    573             {
    574                 ps->incNextLma( (cluster[cluster_id].procs << 12) );
    575                 found  = 1;
    576             }
    577             if(!found){/* we could imagine a cluster without proc, let the giet choose*/ }
    578 #endif
     564            PSeg *ps = new PSeg( name,
     565                                 pseg[pseg_id].base,
     566                                 pseg[pseg_id].length,
     567                                 pseg[pseg_id].type );
    579568            m_psegh.m_pSegs.push_back(*ps);
    580 
    581569        }
    582570    }
  • soft/giet_vm/memo/src/pseg.cpp

    r227 r238  
    11/* -*- c++ -*-
    22 *
    3  * SOCLIB_LGPL_HEADER_BEGIN
     3 * GIET_VM_LGPL_HEADER_BEGIN
    44 *
    55 * This file is part of SoCLib, GNU LGPLv2.1.
     
    1919 * 02110-1301 USA
    2020 *
    21  * SOCLIB_LGPL_HEADER_END
     21 * GIET_VM_LGPL_HEADER_END
    2222 *
    2323 * Copyright (c) UPMC, Lip6, SoC
     
    4343 */
    4444
     45//////////////////////////////////////
    4546const std::string & VSeg::name() const
    4647{
     
    4849}
    4950
     51//////////////////////////////////////
    5052const std::string & VSeg::file() const
    5153{
     
    5355}
    5456
     57///////////////////////////
    5558uintptr_t VSeg::vma() const
    5659{
     
    5861}
    5962
    60 uintptr_t VSeg::lma() const
     63/////////////////////////
     64paddr_t VSeg::lma() const
    6165{
    6266        return m_lma;
    6367}
    6468
     69///////////////////////////
    6570size_t VSeg::length() const
    6671{
     
    6873}
    6974
     75/////////////////////////
    7076size_t VSeg::type() const
    7177{
     
    7379}
    7480
     81/////////////////////////////////////////
    7582void VSeg::print( std::ostream &o ) const
    7683{
     
    7986      << std::setw (8) << std::setfill('0')
    8087      << m_vma << ", to(paddr) 0x"
    81       << std::setw (8) << std::setfill('0')
     88      << std::setw (16) << std::setfill('0')
    8289      << m_lma << ", size: 0x"
    8390      << std::setw (8) << std::setfill('0')
     
    8794}
    8895
     96/////////////
    8997VSeg::~VSeg()
    9098{
    91 //    std::cout << "Deleted VSeg " << *this << std::endl;
    92 }
    93 
     99}
     100
     101/////////////////////////////////////////
    94102VSeg & VSeg::operator=( const VSeg &ref )
    95103{
     
    97105        return *this;
    98106
    99     //std::cout << "Copying " << ref << " to " << *this << std::endl;
    100107    m_name = ref.m_name,
    101108    m_file = ref.m_file;
     
    107114}
    108115
     116////////////
    109117VSeg::VSeg()
    110118    : m_name("No Name"),
     
    115123      m_ident(0)
    116124{
    117     //std::cout << "New empty VSeg " << *this << std::endl;
    118 }
    119 
    120 VSeg::VSeg(std::string& binaryName, std::string& name, uintptr_t vma, size_t length, bool loadable, bool ident)
     125}
     126
     127////////////////////////////////////
     128VSeg::VSeg(std::string&  binaryName,
     129           std::string&  name,
     130           uintptr_t     vma,
     131           size_t        length,
     132           bool          loadable,
     133           bool          ident)
    121134    : m_name(name),
    122135      m_file(binaryName),
     
    126139      m_ident(ident)
    127140{
    128     //std::cout << "New VSeg " << *this << std::endl;
    129 }
    130 
     141}
     142
     143/////////////////////////////
    131144VSeg::VSeg( const VSeg &ref )
    132145    : m_name("To be copied"),
     
    137150      m_ident(0)
    138151{
    139     //std::cout << "New VSeg " << *this << " copied from " << ref << std::endl;
    140152    (*this) = ref;
    141153}
    142 
    143 
    144154
    145155
     
    147157 * PSeg
    148158 */
    149 uintptr_t PSeg::lma() const
     159
     160/////////////////////////
     161paddr_t PSeg::lma() const
    150162{
    151163        return m_lma;
    152164}
    153165
    154 uintptr_t PSeg::limit() const
     166///////////////////////////
     167paddr_t PSeg::limit() const
    155168{
    156169        return m_limit;
    157170}
    158171
    159 size_t PSeg::length() const
     172/////////////////////////////
     173paddr_t PSeg::length() const
    160174{
    161175        return m_length;
    162176}
    163177
     178/////////////////////////
    164179size_t PSeg::type() const
    165180{
     
    167182}
    168183
    169 uintptr_t PSeg::nextLma() const
     184/////////////////////////////
     185paddr_t PSeg::nextLma() const
    170186{
    171187        return m_nextLma;
    172188}
    173189
     190//////////////////////////////////////
    174191const std::string & PSeg::name() const
    175192{
     
    177194}
    178195
     196//////////////////////// initialisation used[][] ??? (AG)
    179197void PSeg::check() const
    180198{
     
    184202
    185203    std::vector<VSeg>::const_iterator it;
    186     size_t size = m_vsegs.size();
    187     size_t used[size][2];//lma, lma+length
    188     size_t i,j,error=0;
     204    size_t    size = m_vsegs.size();
     205    paddr_t   used[size][2];          // lma, lma+length
     206    size_t    i,j,error=0;
    189207   
    190     for(it = m_vsegs.begin(), i= 0; it < m_vsegs.end(); it++, i++)
     208    for(it = m_vsegs.begin(), i= 0 ; it < m_vsegs.end() ; it++, i++)
    191209    {
    192         size_t it_limit = (*it).lma() + (*it).length();
     210        paddr_t it_limit = (*it).lma() + (*it).length();
    193211        for(j=0; j< i; j++)
    194212        {
    195            if(  (used[j][0] == (*it).lma() /*and (*it).length()?*/) ) //not the same lma ,
     213            if( used[j][0] == (*it).lma() ) //not the same lma ,
    196214            {
    197215                error = 1;
    198216                std::cout << "ok \n";
    199217            }
    200            if(  (used[j][1] == it_limit /*and (*it).legth()?*/))  // and not the same limit
     218            if( used[j][1] == it_limit )  // and not the same limit
    201219            {
    202220                error = 2;
    203221            }
    204            if(  ((used[j][0] < (*it).lma()) and ((*it).lma() < used[j][1] )) ) //lma  within the used slice
     222            if( (used[j][0] < (*it).lma()) and ((*it).lma() < used[j][1]) ) // lma  within
    205223            {
    206224                error = 3;
    207225            }
    208            if(  ((used[j][0] < it_limit) and (it_limit < used[j][1] )) )//limit not within the used slice
     226            if(  ((used[j][0] < it_limit) and (it_limit < used[j][1] )) ) // limit no within
    209227            {
    210228                error = 4;
     
    228246}
    229247
     248//////////////////////////////////////
    230249void PSeg::setName(std::string& name )
    231250{
     
    233252}
    234253
    235 size_t PSeg::align( unsigned toAlign, unsigned alignPow2)
    236 {
    237     return ((toAlign + (1 << alignPow2) - 1 ) >> alignPow2) << alignPow2;//page aligned
    238 }
    239 
    240 
    241 size_t PSeg::pageAlign( size_t toAlign )
     254/////////////////////////////////////////////////////////
     255paddr_t PSeg::align( paddr_t toAlign, unsigned alignPow2)
     256{
     257    return ((toAlign + (1 << alignPow2) - 1 ) >> alignPow2) << alignPow2;
     258}
     259
     260//////////////////////////////////////////
     261paddr_t PSeg::pageAlign( paddr_t toAlign )
    242262{
    243263    size_t pgs = pageSize();
    244264    size_t pageSizePow2 = __builtin_ctz(pgs);
    245265   
    246     return align(toAlign, pageSizePow2);//page aligned
    247 
    248 }
    249 
    250 void PSeg::setLma( uintptr_t lma )
     266    return align(toAlign, pageSizePow2);
     267}
     268
     269////////////////////////////////
     270void PSeg::setLma( paddr_t lma )
    251271{
    252272    m_lma = lma;
    253273   
    254     m_nextLma = pageAlign(lma);//page aligned
     274    m_nextLma = pageAlign(lma);
    255275
    256276    m_pageLimit = pageAlign(m_lma+m_length);
    257277
    258278    m_limit = (m_lma + m_length);
    259 
    260 }
    261 
    262 void PSeg::setLength( size_t length )
     279}
     280
     281/////////////////////////////////////
     282void PSeg::setLength( paddr_t length )
    263283{
    264284    m_length = length;
     
    267287
    268288    m_limit = (m_lma + m_length);
    269 
    270     //std::cout << std::hex << " length seted, m_limit: " << m_limit  << std::endl;
    271     //std::cout << *this <<std::endl;
    272 }
    273 
     289}
     290
     291////////////////////////////
    274292void PSeg::add( VSeg& vseg )
    275293{
    276294    vseg.m_lma = m_nextLma;
    277     incNextLma(vseg.length());//for the next vseg
     295//    incNextLma(vseg.length());   //for the next vseg
    278296    m_vsegs.push_back(vseg);
    279297}
    280298
     299/////////////////////////////////
    281300void PSeg::addIdent( VSeg& vseg )
    282301{
    283302    vseg.m_lma = vseg.m_vma;
    284     //incNextLma(vseg.length());//to keep track of space used
    285303    m_vsegs.push_back(vseg);
    286304}
    287305
    288 void PSeg::setNextLma( uintptr_t nextLma)
     306/////////////////////////////////////////
     307void PSeg::setNextLma( paddr_t nextLma)
    289308{
    290309    m_nextLma = nextLma;
    291 
    292310    confNextLma();
    293311}
    294312
    295 void PSeg::incNextLma( size_t inc_next)
    296 {
    297 
    298     m_nextLma += inc_next;
    299 
     313//////////////////////////////////
     314void PSeg::incNextLma( size_t inc)
     315{
     316    m_nextLma += inc;
    300317    confNextLma();
    301318}
    302319
     320////////////////////////
    303321void PSeg::confNextLma()
    304322{
     
    322340}
    323341
     342/////////////////////////////////
    324343void PSeg::setPageSize(size_t pg)
    325344{
     
    332351}
    333352
     353////////////////////////
    334354size_t& PSeg::pageSize()
    335355{
     
    338358}
    339359
     360/////////////////////////////////////////
    340361PSeg & PSeg::operator=( const PSeg &ref )
    341362{
    342363    if ( &ref == this )
    343364        return *this;
    344 
    345     //std::cout << "Copying " << ref << " to " << *this << std::endl;
    346365
    347366    m_name = ref.m_name;
     
    357376}
    358377
     378//////////////////////////////////////////
    359379void PSeg::print( std::ostream &o ) const
    360380{
     
    374394}
    375395
     396////////////////////////////////////
    376397PSeg::PSeg( const std::string &name,
    377                 uintptr_t lma,
    378                 size_t length,
    379                 size_t type)
     398            paddr_t          lma,
     399            paddr_t          length,
     400            size_t            type)
    380401{
    381402    m_name = name;
     
    384405
    385406    setLma(lma);
    386     //std::cout <<"New PSeg :"<< *this ;         
    387 }
    388 
     407}
     408
     409////////////////////////////////////
    389410PSeg::PSeg( const std::string &name):
    390411      m_lma(0),
     
    396417}
    397418
    398 PSeg::PSeg( uintptr_t lma):
     419////////////////////////
     420PSeg::PSeg( paddr_t lma):
    399421      m_name("No name"),
    400422      m_lma(0),
     
    406428}
    407429
    408 
     430////////////
    409431PSeg::PSeg()
    410432    :
     
    415437      m_limit(0)
    416438{
    417     //std::cout << "New empty PSeg " << *this << std::endl;
    418 }
    419 
     439}
     440
     441/////////////////////////////
    420442PSeg::PSeg( const PSeg &ref )
    421443    : m_name("To be copied"),
     
    425447      m_limit(0)
    426448{
    427     //std::cout << "New PSeg " << *this << " copied from " << ref << std::endl;
    428449    (*this) = ref;
    429450}
     
    431452PSeg::~PSeg()
    432453{
    433 //    std::cout << "Deleted PSeg " << *this << std::endl;
    434454}
    435455
  • soft/giet_vm/memo/src/pseg_handler.cpp

    r163 r238  
    11/* -*- c++ -*-
    22 *
    3  * SOCLIB_LGPL_HEADER_BEGIN
     3 * GIET_VM_LGPL_HEADER_BEGIN
    44 *
    5  * This file is part of SoCLib, GNU LGPLv2.1.
     5 * This file is part of GIET_VM, GNU LGPLv2.1.
    66 *
    7  * SoCLib is free software; you can redistribute it and/or modify it
     7 * GIET_VM is free software; you can redistribute it and/or modify it
    88 * under the terms of the GNU Lesser General Public License as published
    99 * by the Free Software Foundation; version 2.1 of the License.
    1010 *
    11  * SoCLib is distributed in the hope that it will be useful, but
     11 * GIET_VM is distributed in the hope that it will be useful, but
    1212 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1515 *
    1616 * You should have received a copy of the GNU Lesser General Public
    17  * License along with SoCLib; if not, write to the Free Software
     17 * License along with GIET_VM; if not, write to the Free Software
    1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    1919 * 02110-1301 USA
    2020 *
    21  * SOCLIB_LGPL_HEADER_END
     21 * GIET_VM_LGPL_HEADER_END
    2222 *
    2323 * Copyright (c) UPMC, Lip6, SoC
     
    3737#include "exception.h"
    3838
    39 
    40 
    4139/*
    4240 * PSegHandler
    4341 */
    4442
     43/////////////////////////////////////
    4544PSeg& PSegHandler::get( size_t pos  )
    4645{
     
    5554}
    5655
     56//////////////////////////////////////////////////////////////
    5757const PSeg& PSegHandler::getByAddr(uintptr_t segAddress) const
    5858{
     
    6060    for(it = m_pSegs.begin(); it < m_pSegs.end(); it++)
    6161    {
    62         uintptr_t lma = (*it).lma();
     62        paddr_t lma = (*it).lma();
    6363        if( lma == segAddress )
    6464            return *it;
     
    7171}
    7272
     73///////////////////////////////
    7374void PSegHandler::check() const
    7475{
Note: See TracChangeset for help on using the changeset viewer.