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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.