Changeset 173


Ignore:
Timestamp:
Jul 18, 2012, 4:59:19 PM (12 years ago)
Author:
karaoui
Message:

Adding BLOB type for vobj.
Don't forget to set as BLOB type the mapping_info vobj in the xml.

Location:
soft/giet_vm
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/boot/reset.S

    r165 r173  
    178178boot_lf_string:         .asciiz "\n"
    179179
    180         .set    reorder
     180.set    reorder
    181181
    182182
  • soft/giet_vm/giet_config.h

    r170 r173  
    1212/* Debug parameters */
    1313
    14 #define BOOT_DEBUG_VIEW         0           /* display the mapping_info on system TTY */
    15 #define BOOT_DEBUG_PT           0           /* display the page tables after mapping */
    16 #define INIT_DEBUG_CTX          0           /* display the task contexts after mapping */
    17 #define GIET_DEBUG_SWITCH       0           /* Trace context switchs */
     14#define BOOT_DEBUG_VIEW         1           /* display the mapping_info on system TTY */
     15#define BOOT_DEBUG_PT           1           /* display the page tables after mapping */
     16#define INIT_DEBUG_CTX          1           /* display the task contexts after mapping */
     17#define GIET_DEBUG_SWITCH       1           /* Trace context switchs */
    1818
    1919
  • soft/giet_vm/map.xml

    r171 r173  
    8181                        ident     = "1" >
    8282                                        <vobj   name    = "seg_mapping"
    83                                                         type    = "ELF"
     83                                                        type    = "BLOB"
    8484                                                        length  = "0x00004000"
    8585                                                        binpath = "map.bin" />
  • soft/giet_vm/memo/Makefile

    r165 r173  
    1111        g++ -Wall -g  $(SRCS) $(INCLUDES) -o memo.x
    1212
     13debug: $(SRCS) $(HDRS)
     14        g++ -Wall -DMOVER_DEBUG -g  $(SRCS) $(INCLUDES) -o debug.x
     15
     16check:
     17        test/check.sh
     18
    1319clean:
    14         rm memo.x
     20        rm *.x
  • soft/giet_vm/memo/include/exception.h

    r163 r173  
    11/* -*- c++ -*-
    22 *
    3  * SOCLIB_LGPL_HEADER_BEGIN
    4  *
    5  * This file is part of SoCLib, GNU LGPLv2.1.
    6  *
    7  * SoCLib is free software; you can redistribute it and/or modify it
    8  * under the terms of the GNU Lesser General Public License as published
    9  * by the Free Software Foundation; version 2.1 of the License.
    10  *
    11  * SoCLib is distributed in the hope that it will be useful, but
    12  * WITHOUT ANY WARRANTY; without even the implied warranty of
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    14  * Lesser General Public License for more details.
    15  *
    16  * You should have received a copy of the GNU Lesser General Public
    17  * License along with SoCLib; if not, write to the Free Software
    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    19  * 02110-1301 USA
    20  *
    21  * SOCLIB_LGPL_HEADER_END
     3 * Copyright (c) UPMC, Lip6, Asim
     4 *      copy of the soclib exception file, original writer:
     5 *          Nicolas Pouillon <nipo@ssji.net>, 2007
     6 *      modified by:
     7 *         Mohamed Lamine Karaoui <Mohamed.Karaoui@lip6.fr>, 2012
    228 *
    23  * Copyright (c) UPMC, Lip6, Asim
    24  *         Nicolas Pouillon <nipo@ssji.net>, 2007
    25  *
    26  * Maintainers: nipo
    279 */
    2810
    29 #ifndef SOCLIB_EXCEPTION_H_
    30 #define SOCLIB_EXCEPTION_H_
     11#ifndef _EXCEPTION_H_
     12#define _EXCEPTION_H_
    3113
    3214#include <exception>
     
    3416#include <iostream>
    3517
    36 namespace soclib { namespace exception {
     18namespace exception {
    3719
    3820class Exception
     
    9678};
    9779
    98 }}
     80}
    9981
    10082#endif /* SOCLIB_EXCEPTION_H_ */
  • soft/giet_vm/memo/include/libelfpp/elfpp/elfpp_section.hh

    r163 r173  
    110110
    111111    /** @this sets pointer to section content buffer */
    112     inline void set_content(void* a);
     112    void set_content(void* a);
    113113    /** @this gets pointer to section content buffer */
    114114    inline uint8_t *get_content() const;
  • soft/giet_vm/memo/include/libelfpp/elfpp/elfpp_section.hxx

    r163 r173  
    2323
    2424#include <stdexcept>
     25
    2526
    2627namespace elfpp
     
    130131  }
    131132 
    132   void section::set_content(void* a)
    133   {
    134     content_ = (uint8_t*) a;
    135   }
    136 
    137133  uint8_t * section::get_content() const
    138134  {
  • soft/giet_vm/memo/include/memo.h

    r163 r173  
    7171    elfpp::object* m_generator;//TODO:delete
    7272
    73     void* load_bin(std::string name);
     73    size_t load_bin(std::string filename, void* buffer);   
     74    size_t bin_size(std::string filename);
     75
    7476    elfpp::section* get_sect_by_addr(elfpp::object *loader, unsigned int addr);
    7577    elfpp::section* get_sect_by_name(elfpp::object *loader, std::string name);
  • soft/giet_vm/memo/src/libelfpp/elfpp_section.cc

    r163 r173  
    2323#include <stdlib.h>
    2424#include <cstring>
     25#include <stdlib.h>
     26
    2527
    2628#include <dpp/foreach>
     
    8183
    8284    size_ = size;
     85  }
     86
     87  void section::set_content(void* a)
     88  {
     89    if(content_)
     90        free(content_);
     91    content_ = (uint8_t*) a;
    8392  }
    8493
  • soft/giet_vm/memo/src/memo.cpp

    r165 r173  
    5151    PSeg::setPageSize(pageSize);
    5252
    53     load_bin(m_path);
     53    /* loading map_info blob */
     54    m_data = std::malloc(bin_size(m_path));
     55    if ( !m_data )
     56        throw exception::RunTimeError("malloc failed... No memory space");
     57
     58    m_size = load_bin(m_path, m_data);
     59
     60    /* checking signature */
     61    mapping_header_t*   header = (mapping_header_t*)m_data;
     62    //assert((IN_MAPPING_SIGNATURE == header->signature) and "wrong signature");
     63    if((IN_MAPPING_SIGNATURE != header->signature))
     64    {
     65        std::cout  << "wrong signature " << std::hex <<header->signature << ", should be:"<< IN_MAPPING_SIGNATURE << std::endl;
     66        exit(1);
     67    }
     68   
     69   
    5470
    5571#ifdef MOVER_DEBUG
     
    107123}
    108124
    109 //TODO:delete
    110 elfpp::section* MeMo::get_sect_by_name(elfpp::object *loader, std::string name)
    111 {
    112 #ifdef MOVER_DEBUG
    113     std::cout << "get_sect_by_name " << name << std::endl;
    114 #endif
    115     FOREACH( sect, loader->get_section_table() )
    116     {
    117         assert(&*sect != NULL);
    118         elfpp::sh_flags_e eflags = sect->get_flags();
    119         if ( !(eflags & elfpp::SHF_ALLOC) )
    120             continue;
    121 
    122 #ifdef MOVER_DEBUG
    123         std::cout << "Trying " << sect->get_name() << std::endl;
    124 #endif
    125         if(!(sect->get_name()).compare(name))
    126         {
    127             return (&*sect);
    128         }
    129     }
    130     return NULL;
    131 }
    132125
    133126void MeMo::buildSoft(const std::string &filename)
    134127{
    135128    if(!m_ginit)
    136         throw soclib::exception::RunTimeError(std::string("Can't get generator! ") );
     129        throw exception::RunTimeError(std::string("Can't get generator! ") );
    137130
    138131    m_generator->write(filename);
     
    140133}
    141134
     135/* Load the content of filename in buffer, and send the size */
     136////////////////////////////////////////////////////////
     137size_t MeMo::load_bin(std::string filename, void* buffer)
     138{
     139
     140#ifdef MOVER_DEBUG
     141    std::cout  << "Trying to load the binary blob from file '" << filename << "'" << std::endl;
     142#endif
     143
     144    std::ifstream input(filename.c_str(), std::ios_base::binary|std::ios_base::in);
     145
     146    if ( ! input.good() )
     147        throw exception::RunTimeError(std::string("Can't open the file: ") + filename);
     148
     149    input.seekg( 0, std::ifstream::end );
     150    size_t size = input.tellg();
     151    input.seekg( 0, std::ifstream::beg );
     152
     153    if ( !buffer )
     154        throw exception::RunTimeError("Empty buffer!");
     155
     156    input.read( (char*)buffer, size );
     157
     158    input.close();
     159
     160    return size;
     161}
     162
     163
     164/* get the size of the content of the filename */
    142165//////////////////////////////////////////
    143 void* MeMo::load_bin(std::string filename)
    144 {
    145    
    146 #ifdef MOVER_DEBUG
    147     std::cout  << "Trying to load the binary blob from file '" << m_path << "'" << std::endl;
    148 #endif
    149 
    150     std::ifstream input(m_path.c_str(), std::ios_base::binary|std::ios_base::in);
     166size_t MeMo::bin_size(std::string filename)
     167{
     168
     169#ifdef MOVER_DEBUG
     170    std::cout  << "Trying to get the size of the binary blob '" << filename << "'" << std::endl;
     171#endif
     172
     173    std::ifstream input(filename.c_str(), std::ios_base::binary|std::ios_base::in);
    151174
    152175    if ( ! input.good() )
    153         throw soclib::exception::RunTimeError(std::string("Can't open the file: ") + m_path);
     176        throw exception::RunTimeError(std::string("Can't open the file: ") + filename);
    154177
    155178    input.seekg( 0, std::ifstream::end );
    156     m_size = input.tellg();
     179    size_t size = input.tellg();
    157180    input.seekg( 0, std::ifstream::beg );
    158181
    159     //m_data = new void*[m_size];
    160     m_data = std::malloc(m_size);
    161     if ( !m_data )
    162         throw soclib::exception::RunTimeError("malloc failed... No memory space");
    163 
    164     input.read( (char*)m_data, m_size );
    165    
    166     return m_data;
    167 }
     182    input.close();
     183
     184    return size;
     185}
     186
    168187
    169188/////////////
     
    171190{
    172191    //std::cout << "Deleted MeMo " << *this << std::endl;
    173     std::free(m_data);
     192    //std::free(m_data);//should be done by the elfpp driver since we passed the pointer
    174193    std::map<std::string, elfpp::object*>::iterator l;
    175194    for(l = m_loaders.begin(); l != m_loaders.end(); l++)
     
    322341
    323342//////////////////////////////////////////
    324 void MeMo::vseg_map( mapping_vseg_t* vseg) 
    325 {
    326     mapping_vobj_t*     vobj   = get_vobj_base( (mapping_header_t*) m_data ); 
     343void MeMo::vseg_map( mapping_vseg_t* vseg)
     344{
     345    mapping_vobj_t*     vobj   = get_vobj_base( (mapping_header_t*) m_data );
    327346    PSeg *ps = &(m_psegh.get(vseg->psegid));// get physical segment pointer(PSegHandler::get)
    328347    elfpp::section* sect = NULL;
     
    343362    mapping_vobj_t* cur_vobj;
    344363    size_t simple_size = 0; //for debug
    345    
     364
    346365#ifdef MOVER_DEBUG
    347366    std::cout << "--------------------vseg_map "<< vseg->name <<"---------------------" << std::endl;
    348367#endif
    349    
     368
    350369    for ( size_t vobj_id = vseg->vobj_offset ; vobj_id < (vseg->vobj_offset + vseg->vobjs) ; vobj_id++ )
    351370    {
     
    353372
    354373#ifdef MOVER_DEBUG
    355         std::cout << "current vobj("<< vobj_id <<"): " << cur_vobj->name << " (" <<cur_vobj->vaddr << ")"
     374        std::cout << std::hex << "current vobj("<< vobj_id <<"): " << cur_vobj->name << " (" <<cur_vobj->vaddr << ")"
    356375                        << " size: "<< cur_vobj->length << " type: " <<  cur_vobj->type << std::endl;
    357376#endif
    358 
    359         if(cur_vobj->type == VOBJ_TYPE_ELF)
    360         {
    361             if(!first)
    362                 throw soclib::exception::RunTimeError(std::string("elf vobj type, must be placed first in a vseg"));
     377        if(cur_vobj->type == VOBJ_TYPE_BLOB)
     378        {
     379            size_t blob_size;
     380            std::string filePath(m_pathHandler.getFullPath(std::string(cur_vobj->binpath)));
     381
     382#ifdef MOVER_DEBUG
     383            std::cout << std::hex << "Handling: " << filePath << " ..." << std::endl;
     384#endif
     385
     386            if(!filePath.compare(m_path))    //local blob: map_info
     387            {
     388#ifdef MOVER_DEBUG
     389                std::cout << "Found the vseg of the mapping info" << std::endl;
     390#endif
     391                blob_size = this->m_size;
     392                assert((blob_size >0) and "MAPPING INFO file is empty !?");
     393            }
     394            else
     395            {
     396#ifdef MOVER_DEBUG
     397                std::cout << "Found an BLOB vseg" << std::endl;
     398#endif
     399                blob_size = bin_size(filePath);
     400            }
     401
     402
     403            /**creating a new section */
     404            sect = new elfpp::section(*m_generator, elfpp::SHT_PROGBITS);
     405
     406            sect->set_name(std::string(cur_vobj->name));
     407            sect->set_flags(elfpp::SHF_ALLOC | elfpp::SHF_WRITE);
     408            sect->set_size(blob_size);//do the malloc for the get_content fonction
     409
     410            assert(sect->get_content());//check allocation
     411
     412            if(!filePath.compare(m_path))    //local blob: map_info
     413                //memcpy(sect->get_content(), m_data, sect->get_size());
     414                /* this way the modification of the elf size are propageted to the giet */
     415                sect->set_content(this->m_data);
     416            else
     417                load_bin(filePath, sect->get_content());
     418
     419
     420            if(blob_size > cur_vobj->length)
     421            {
     422                std::cout << std::hex << "!!! Warning, specified blob type vobj ("<<
     423                cur_vobj->name  <<") size is "<< cur_vobj->length << ", the actual size is "
     424                << blob_size  << " !!!" <<std::endl;
     425                assert(0 and "blob vobj length smaller than the actual content" );//???
     426            }
     427
     428            cur_vobj->length = blob_size;//set the true size of this BLOB vobj
     429
     430            vSO->m_file = filePath;
     431            vSO->m_loadable = true;
     432        }
     433        else if(cur_vobj->type == VOBJ_TYPE_ELF)
     434        {
     435            if(!first)
     436                throw exception::RunTimeError(std::string("elf vobj type, must be placed first in a vseg"));
    363437
    364438            size_t elf_size;
     
    366440#ifdef MOVER_DEBUG
    367441            std::cout << "Handling: " << filePath << " ..." << std::endl;
    368 #endif
    369             if(!filePath.compare(m_path))    //local blob: map_info
     442            std::cout << "Found an ELF vseg" << std::endl;
     443#endif
     444            if(m_loaders.count(filePath) == 0 )
     445                m_loaders[filePath] = new elfpp::object(filePath);
     446            elfpp::object* loader = m_loaders[filePath];//TODO:free!?
     447
     448            sect =  get_sect_by_addr(loader, cur_vaddr);
     449            assert(sect and "No section found");
     450
     451            sect->set_name(std::string(cur_vobj->name));
     452
     453
     454            elf_size = sect->get_size();
     455            assert((elf_size > 0) and "ELF section empty ?");
     456
     457            if(!m_ginit)
    370458            {
    371 #ifdef MOVER_DEBUG
    372                 std::cout << "Found the vseg of the mapping info" << std::endl;
    373 #endif
    374                 /**creating a new section */
    375                 sect = new elfpp::section(*m_generator, elfpp::SHT_PROGBITS);
    376 
    377                 sect->set_name(std::string(cur_vobj->name));
    378                 sect->set_flags(elfpp::SHF_ALLOC | elfpp::SHF_WRITE);
    379                 sect->set_size(this->m_size);
    380                 sect->set_content(this->m_data);               
    381 
    382                 elf_size = this->m_size;       
    383                 assert((elf_size >0) and "MAPPING INFO file is empty !?");
     459                /** Initailising the header of the generator from the first binary,
     460                ** we suppose that the header is the same for all the binarys **/
     461                m_generator->copy_info(*loader);
     462                m_ginit=true;
    384463            }
    385             else
    386             {
    387 #ifdef MOVER_DEBUG
    388                 std::cout << "Found an ELF vseg" << std::endl;
    389 #endif
    390                 if(m_loaders.count(filePath) == 0 )
    391                     m_loaders[filePath] = new elfpp::object(filePath);
    392                 elfpp::object* loader = m_loaders[filePath];//TODO:free!?
    393 
    394                 //TODO: delete
    395                 //sect =  get_sect_by_name(loader, std::string(cur_vobj->name));
    396                 //assert(( sect->get_vaddr() == cur_vaddr) and "Vaddr doesn't match!");
    397 
    398                 sect =  get_sect_by_addr(loader, cur_vaddr);
    399                 assert(sect and "No section found");
    400 
    401                 sect->set_name(std::string(cur_vobj->name));
    402 
    403 
    404                 elf_size = sect->get_size();
    405                 assert((elf_size >0) and "ELF section empty ?");
    406 
    407                 if(!m_ginit)
    408                 {
    409                     /** Initailising the header of the generator from the first binary,
    410                     * we suppose that the header is the same for all the binarys
    411                     * */
    412                     m_generator->copy_info(*loader);
    413                     m_ginit=true;
    414                 }
    415             }
    416464
    417465            if(elf_size > cur_vobj->length)
     466            {
    418467                std::cout << "Warning, specified elf type vobj ("<<
    419468                cur_vobj->name  <<") size is "<< cur_vobj->length << ", the actual size is "
    420469                << elf_size  << std::endl;
     470                //assert((elf_size < cur_vobj->length) and "elf vobj length smaller than the actual content" );//???
     471                assert((0) and "elf vobj length smaller than the actual content" );//???
     472            }
    421473
    422474            cur_vobj->length = elf_size;//set the true size of this ELF vobj
    423475
    424476            vSO->m_file = filePath;
    425             vSO->m_loadable = true;       
    426         }
    427         first = false;
     477            vSO->m_loadable = true;
     478        }
    428479
    429480        //aligning the vobj->paddr if necessary
     481        //
    430482        if(cur_vobj->align)
    431483        {
     
    437489        cur_paddr += cur_vobj->length;
    438490        simple_size += cur_vobj->length;
     491        first = false;
    439492    }
    440493
     
    449502        std::cout << "vseg base "<< std::hex << ps->nextLma()
    450503        <<(ps->nextLma()+simple_size)  <<" size " << std::dec << simple_size <<
    451         std::endl; 
     504        std::endl;
    452505
    453506        std::cout << "vseg aligned to: base: " << std::hex << ps->nextLma()
     
    456509    }
    457510#endif
    458      
    459     vSO->m_ident = vseg->ident;     
     511
     512    vSO->m_ident = vseg->ident;
    460513
    461514    //set the lma
     
    464517    else
    465518        ps->add( *vSO );
    466    
     519
    467520    if(!sect)
    468521        return;
     
    476529
    477530} // end vseg_map()
    478 
     531 
    479532
    480533///////////////////////////////
  • soft/giet_vm/memo/src/pseg.cpp

    r163 r173  
    208208                err << " Error" << error << " ,ovelapping Buffers:" << std::endl
    209209                    << *it << std::endl << m_vsegs[j] << std::endl;
    210                 throw soclib::exception::RunTimeError( err.str().c_str() );
     210                throw exception::RunTimeError( err.str().c_str() );
    211211            }
    212212
  • soft/giet_vm/xml/mapping_info.h

    r167 r173  
    5555#define OUT_MAPPING_SIGNATURE   0xBABEF00D
    5656
    57 enum 
     57enum
    5858{
    59     VOBJ_TYPE_ELF     = 0,     // loadable code object
    60     VOBJ_TYPE_PTAB    = 1,     // page table
    61     VOBJ_TYPE_PERI    = 2,     // hardware component
    62     VOBJ_TYPE_MWMR    = 3,     // MWMR channel
    63     VOBJ_TYPE_LOCK    = 4,     // Lock
    64     VOBJ_TYPE_BUFFER  = 5,     // Any "no intialiasation needed" objects (stacks...)
    65     VOBJ_TYPE_BARRIER = 6,     // Barrier
     59    VOBJ_TYPE_ELF     = 0,     // loadable code/data object of elf files
     60    VOBJ_TYPE_BLOB    = 1,     // loadable blob object
     61    VOBJ_TYPE_PTAB    = 2,     // page table
     62    VOBJ_TYPE_PERI    = 3,     // hardware component
     63    VOBJ_TYPE_MWMR    = 4,     // MWMR channel
     64    VOBJ_TYPE_LOCK    = 5,     // Lock
     65    VOBJ_TYPE_BUFFER  = 6,     // Any "no intialiasation needed" objects (stacks...)
     66    VOBJ_TYPE_BARRIER = 7,     // Barrier
    6667};
    6768
  • soft/giet_vm/xml/xml_driver.c

    r165 r173  
    2525    {
    2626        "ELF",
     27        "BLOB",
    2728        "PTAB",   //page table
    2829        "PERI",   //hardware component
  • soft/giet_vm/xml/xml_parser.c

    r167 r173  
    380380        }
    381381    }
     382    else if (ok && (strcmp(str, "BLOB")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BLOB;
    382383    else if (ok && (strcmp(str, "PTAB")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PTAB;
    383384    else if (ok && (strcmp(str, "PERI")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PERI;
Note: See TracChangeset for help on using the changeset viewer.