Changeset 238 for soft/giet_vm/memo
- Timestamp:
- May 29, 2013, 1:24:09 AM (11 years ago)
- Location:
- soft/giet_vm/memo
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/memo/TODO
r163 r238 1 1 + Support for debug info 2 2 + 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 59 59 60 60 /** 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); 62 62 63 63 ~object(); -
soft/giet_vm/memo/include/memo.h
r212 r238 1 1 /* -*- c++ -*- 2 2 * 3 * SOCLIB_LGPL_HEADER_BEGIN3 * GIET_VM_LGPL_HEADER_BEGIN 4 4 * 5 * This file is part of SoCLib, GNU LGPLv2.1.5 * This file is part of GIET_VM, GNU LGPLv2.1. 6 6 * 7 * SoCLibis free software; you can redistribute it and/or modify it7 * GIET_VM is free software; you can redistribute it and/or modify it 8 8 * under the terms of the GNU Lesser General Public License as published 9 9 * by the Free Software Foundation; version 2.1 of the License. 10 10 * 11 * SoCLibis distributed in the hope that it will be useful, but11 * GIET_VM is distributed in the hope that it will be useful, but 12 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with SoCLib; if not, write to the Free Software17 * License along with GIET_VM; if not, write to the Free Software 18 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 19 * 02110-1301 USA 20 20 * 21 * SOCLIB_LGPL_HEADER_END21 * GIET_VM_LGPL_HEADER_END 22 22 * 23 23 * Copyright (c) UPMC, Lip6, SoC … … 25 25 * 26 26 */ 27 #ifndef _MEMO_H_ 28 #define _MEMO_H_ 27 28 #ifndef GIET_VM_MEMO_H 29 #define GIET_VM_MEMO_H 29 30 30 31 #include <stdlib.h> … … 57 58 class MeMo 58 59 { 60 // TODO: make the name defined in the map_info relative to this wd. 59 61 60 std::string m_path; //map_info path name61 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 TODO63 void* m_data; //map_info structure64 uintptr_t m_addr; //map_info address (virtual)65 size_t m_size; //size of the structure62 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 66 68 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; 72 73 73 74 size_t load_bin(std::string filename, void* buffer); … … 78 79 public: 79 80 80 MeMo( const std::string &name, const size_t pageSize = 4096); 81 MeMo( const std::string &name, 82 const size_t pageSize = 4096); 83 81 84 ~MeMo(); 82 85 … … 93 96 } 94 97 98 // The following functions handle the map.bin structure 99 // They must keep synchronised with functions defined in boot_init.c. 95 100 96 //The following functions handle the map.bin structure97 //inspired from the boot_init.c of the GIET98 101 mapping_cluster_t* get_cluster_base( mapping_header_t* header ); 99 102 mapping_pseg_t* get_pseg_base( mapping_header_t* header ); … … 108 111 109 112 110 #endif /* _MEMO_H_*/113 #endif /* GIET_VM_MEMO_H */ 111 114 112 115 // Local Variables: -
soft/giet_vm/memo/include/pseg.h
r210 r238 1 1 /* -*- c++ -*- 2 2 * 3 * SOCLIB_LGPL_HEADER_BEGIN3 * GIET-VM_LGPL_HEADER_BEGIN 4 4 * 5 * This file is part of SoCLib, GNU LGPLv2.1.5 * This file is part of the GIET-VMS, GNU LGPLv2.1. 6 6 * 7 * SoCLibis free software; you can redistribute it and/or modify it7 * The GIET-VM is free software; you can redistribute it and/or modify it 8 8 * under the terms of the GNU Lesser General Public License as published 9 9 * by the Free Software Foundation; version 2.1 of the License. 10 10 * 11 * SoCLibis distributed in the hope that it will be useful, but11 * THe GIET-VM is distributed in the hope that it will be useful, but 12 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 19 19 * 02110-1301 USA 20 20 * 21 * SOCLIB_LGPL_HEADER_END21 * GIET-VM_LGPL_HEADER_END 22 22 * 23 23 * Copyright (c) UPMC, Lip6, SoC … … 25 25 * 26 26 */ 27 #ifndef SOCLIB_PSEG_H_28 #define SOCLIB_PSEG_H_27 #ifndef GIET_MEMO_PSEG_H 28 #define GIET_MEMO_PSEG_H 29 29 30 30 #include <string> … … 39 39 class MeMo; 40 40 41 ////////// 41 42 class VSeg 42 43 { … … 45 46 friend class MeMo; 46 47 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...) 54 57 55 58 public: 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 57 61 58 62 const std::string& name() const; 59 63 const std::string& file() const; 60 64 uintptr_t vma() const; 61 uintptr_t lma() const;65 paddr_t lma() const; 62 66 size_t length() const; 63 67 size_t type() const; … … 75 79 VSeg(); 76 80 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); 78 87 79 88 ~VSeg(); 80 89 }; 81 90 82 91 ////////// 83 92 class PSeg 84 93 { 85 std::string m_name;86 uintptr_tm_lma;87 size_tm_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; 89 98 90 uintptr_t m_pageLimit; //The end (m_lma + m_length) address of the segment pageSize aligned91 uintptr_t m_nextLma; //next free base99 paddr_t m_pageLimit; // m_lma + m_length aligned on page size 100 paddr_t m_nextLma; // next free base 92 101 93 void confNextLma(); //check that m_nextLma has a correct value:whithin the seg limits102 void confNextLma(); // check m_nextLma is whithin the seg limits 94 103 95 104 public: 105 96 106 std::vector<VSeg> m_vsegs; 97 uintptr_t m_limit;// m_lma + m_length98 107 108 paddr_t m_limit; // m_lma + m_length 99 109 100 110 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; 103 113 size_t type() const; 104 uintptr_t limit() const;105 uintptr_t nextLma() const;114 paddr_t limit() const; 115 paddr_t nextLma() const; 106 116 107 117 void check() const; 108 118 109 119 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); 112 122 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 115 126 static void setPageSize(size_t pg); 127 116 128 static size_t& pageSize(); 117 129 118 void add( VSeg& vseg ); //add a VSeg130 void add( VSeg& vseg ); //add a VSeg 119 131 void addIdent( VSeg& vseg ); 120 132 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); 123 135 124 136 void print( std::ostream &o ) const; … … 134 146 PSeg( const PSeg &ref ); 135 147 PSeg( const std::string &name); 136 PSeg( const uintptr_t lma);148 PSeg( const paddr_t lma); 137 149 PSeg( const std::string &name, 138 uintptr_t lma,139 size_t length,140 150 paddr_t lma, 151 paddr_t length, 152 size_t type); 141 153 ~PSeg(); 142 154 }; 143 155 144 156 145 #endif /* SOCLIB_PSEG_H_*/157 #endif /* GIET_MEMO_PSEG_H */ -
soft/giet_vm/memo/src/libelfpp/elfpp_object.cc
r163 r238 129 129 130 130 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 134 141 this->byteorder_ = obj.byteorder_ ; 135 142 this->machine_ = obj.machine_ ; -
soft/giet_vm/memo/src/memo.cpp
r215 r238 1 1 /* -*- c++ -*- 2 2 * 3 * SOCLIB_LGPL_HEADER_BEGIN3 * GIET_VM_LGPL_HEADER_BEGIN 4 4 * 5 * This file is part of SoCLib, GNU LGPLv2.1.5 * This file is part of GIET_VM, GNU LGPLv2.1. 6 6 * 7 * SoCLib is free software; you can redistribute vSO and/or modify vSO7 * GIET_VM is free software; you can redistribute it and/or modify it 8 8 * under the terms of the GNU Lesser General Public License as published 9 9 * by the Free Software Foundation; version 2.1 of the License. 10 10 * 11 * SoCLib is distributed in the hope that vSOwill be useful, but11 * GIET_VM is distributed in the hope that it will be useful, but 12 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with SoCLib; if not, write to the Free Software17 * License along with GIET_VM; if not, write to the Free Software 18 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 19 * 02110-1301 USA 20 20 * 21 * SOCLIB_LGPL_HEADER_END21 * GIET_VM_LGPL_HEADER_END 22 22 * 23 23 * Copyright (c) UPMC, Lip6, SoC … … 41 41 //#define MOVER_DEBUG 42 42 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 //////////////////////////////////////////// 44 MeMo::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 { 51 51 PSeg::setPageSize(pageSize); 52 52 53 / * loading map_info blob */53 // loading map_info blob 54 54 m_data = std::malloc(bin_size(m_path)); 55 55 if ( !m_data ) … … 58 58 m_size = load_bin(m_path, m_data); 59 59 60 / * checking signature */60 // checking signature 61 61 mapping_header_t* header = (mapping_header_t*)m_data; 62 //assert((IN_MAPPING_SIGNATURE == header->signature) and "wrong signature");63 62 if((IN_MAPPING_SIGNATURE != header->signature)) 64 63 { 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; 66 67 exit(1); 67 68 } 68 69 70 69 71 70 #ifdef MOVER_DEBUG … … 92 91 } 93 92 93 ///////////////////////////////////////// 94 94 void MeMo::print( std::ostream &o ) const 95 95 { … … 102 102 } 103 103 104 //////////////////////////////// 104 105 void MeMo::print_mapping() const 105 106 { … … 107 108 } 108 109 110 //////////////////////////////////////////////////////////////////////////////// 109 111 elfpp::section* MeMo::get_sect_by_addr(elfpp::object *loader, unsigned int addr) 110 112 { … … 123 125 } 124 126 125 127 ///////////////////////////////////////////////// 126 128 void MeMo::buildSoft(const std::string &filename) 127 129 { … … 133 135 } 134 136 135 /* Load the content of filename in buffer, and send the size */ 136 //////////////////////////////////////////////////////// 137 ///////////////////////////////////////////////////////// 137 138 size_t MeMo::load_bin(std::string filename, void* buffer) 138 139 { 139 140 140 141 #ifdef MOVER_DEBUG 141 std::cout << " Trying to load thebinary blob from file '" << filename << "'" << std::endl;142 std::cout << "Loading binary blob from file '" << filename << "'" << std::endl; 142 143 #endif 143 144 … … 339 340 void MeMo::vseg_map( mapping_vseg_t* vseg) 340 341 { 341 mapping_vobj_t* 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_tcur_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; 350 351 351 352 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(); 354 355 355 356 cur_vaddr = vseg->vbase; 356 357 cur_paddr = ps->nextLma(); 357 358 358 mapping_vobj_t* cur_vobj;359 359 size_t simple_size = 0; //for debug 360 360 361 361 #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++ ) 362 std::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++ ) 366 367 { 367 368 cur_vobj = &vobj[vobj_id]; 368 369 369 370 #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; 371 std::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; 372 375 #endif 373 376 if(cur_vobj->type == VOBJ_TYPE_BLOB) … … 377 380 378 381 #ifdef MOVER_DEBUG 379 380 #endif 381 382 if(!filePath.compare(m_path)) // local blob: map_info382 std::cout << std::hex << "Handling: " << filePath << " ..." << std::endl; 383 #endif 384 385 if(!filePath.compare(m_path)) // local blob: map_info 383 386 { 384 387 #ifdef MOVER_DEBUG 385 388 std::cout << "Found the vseg of the mapping info" << std::endl; 386 389 #endif 387 390 blob_size = this->m_size; … … 391 394 { 392 395 #ifdef MOVER_DEBUG 393 396 std::cout << "Found an BLOB vseg" << std::endl; 394 397 #endif 395 398 blob_size = bin_size(filePath); 396 399 } 397 400 398 399 /**creating a new section */ 401 // creating a new section 400 402 sect = new elfpp::section(*m_generator, elfpp::SHT_PROGBITS); 401 403 402 404 sect->set_name(std::string(cur_vobj->name)); 403 405 sect->set_flags(elfpp::SHF_ALLOC | elfpp::SHF_WRITE); 404 sect->set_size(blob_size); //do the malloc for the get_content fonction406 sect->set_size(blob_size); //do the malloc for the get_content fonction 405 407 406 408 assert(sect->get_content());//check allocation … … 459 461 /** Initailising the header of the generator from the first binary, 460 462 ** 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); 462 464 m_ginit=true; 463 465 } … … 512 514 vSO->m_ident = vseg->ident; 513 515 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; 525 530 526 531 #ifdef MOVER_DEBUG … … 550 555 #endif 551 556 552 #ifdef DISTRIBUTED_SCHEDULERS553 char found;554 #endif555 556 557 for ( size_t cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ ) 557 558 { 558 559 #ifdef DISTRIBUTED_SCHEDULERS560 found = 0;561 #endif562 563 559 for ( size_t pseg_id = cluster[cluster_id].pseg_offset ; 564 560 pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs ; 565 561 pseg_id++ ) 566 562 { 567 //build pseg568 563 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 ); 579 568 m_psegh.m_pSegs.push_back(*ps); 580 581 569 } 582 570 } -
soft/giet_vm/memo/src/pseg.cpp
r227 r238 1 1 /* -*- c++ -*- 2 2 * 3 * SOCLIB_LGPL_HEADER_BEGIN3 * GIET_VM_LGPL_HEADER_BEGIN 4 4 * 5 5 * This file is part of SoCLib, GNU LGPLv2.1. … … 19 19 * 02110-1301 USA 20 20 * 21 * SOCLIB_LGPL_HEADER_END21 * GIET_VM_LGPL_HEADER_END 22 22 * 23 23 * Copyright (c) UPMC, Lip6, SoC … … 43 43 */ 44 44 45 ////////////////////////////////////// 45 46 const std::string & VSeg::name() const 46 47 { … … 48 49 } 49 50 51 ////////////////////////////////////// 50 52 const std::string & VSeg::file() const 51 53 { … … 53 55 } 54 56 57 /////////////////////////// 55 58 uintptr_t VSeg::vma() const 56 59 { … … 58 61 } 59 62 60 uintptr_t VSeg::lma() const 63 ///////////////////////// 64 paddr_t VSeg::lma() const 61 65 { 62 66 return m_lma; 63 67 } 64 68 69 /////////////////////////// 65 70 size_t VSeg::length() const 66 71 { … … 68 73 } 69 74 75 ///////////////////////// 70 76 size_t VSeg::type() const 71 77 { … … 73 79 } 74 80 81 ///////////////////////////////////////// 75 82 void VSeg::print( std::ostream &o ) const 76 83 { … … 79 86 << std::setw (8) << std::setfill('0') 80 87 << m_vma << ", to(paddr) 0x" 81 << std::setw ( 8) << std::setfill('0')88 << std::setw (16) << std::setfill('0') 82 89 << m_lma << ", size: 0x" 83 90 << std::setw (8) << std::setfill('0') … … 87 94 } 88 95 96 ///////////// 89 97 VSeg::~VSeg() 90 98 { 91 // std::cout << "Deleted VSeg " << *this << std::endl; 92 } 93 99 } 100 101 ///////////////////////////////////////// 94 102 VSeg & VSeg::operator=( const VSeg &ref ) 95 103 { … … 97 105 return *this; 98 106 99 //std::cout << "Copying " << ref << " to " << *this << std::endl;100 107 m_name = ref.m_name, 101 108 m_file = ref.m_file; … … 107 114 } 108 115 116 //////////// 109 117 VSeg::VSeg() 110 118 : m_name("No Name"), … … 115 123 m_ident(0) 116 124 { 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 //////////////////////////////////// 128 VSeg::VSeg(std::string& binaryName, 129 std::string& name, 130 uintptr_t vma, 131 size_t length, 132 bool loadable, 133 bool ident) 121 134 : m_name(name), 122 135 m_file(binaryName), … … 126 139 m_ident(ident) 127 140 { 128 //std::cout << "New VSeg " << *this << std::endl; 129 } 130 141 } 142 143 ///////////////////////////// 131 144 VSeg::VSeg( const VSeg &ref ) 132 145 : m_name("To be copied"), … … 137 150 m_ident(0) 138 151 { 139 //std::cout << "New VSeg " << *this << " copied from " << ref << std::endl;140 152 (*this) = ref; 141 153 } 142 143 144 154 145 155 … … 147 157 * PSeg 148 158 */ 149 uintptr_t PSeg::lma() const 159 160 ///////////////////////// 161 paddr_t PSeg::lma() const 150 162 { 151 163 return m_lma; 152 164 } 153 165 154 uintptr_t PSeg::limit() const 166 /////////////////////////// 167 paddr_t PSeg::limit() const 155 168 { 156 169 return m_limit; 157 170 } 158 171 159 size_t PSeg::length() const 172 ///////////////////////////// 173 paddr_t PSeg::length() const 160 174 { 161 175 return m_length; 162 176 } 163 177 178 ///////////////////////// 164 179 size_t PSeg::type() const 165 180 { … … 167 182 } 168 183 169 uintptr_t PSeg::nextLma() const 184 ///////////////////////////// 185 paddr_t PSeg::nextLma() const 170 186 { 171 187 return m_nextLma; 172 188 } 173 189 190 ////////////////////////////////////// 174 191 const std::string & PSeg::name() const 175 192 { … … 177 194 } 178 195 196 //////////////////////// initialisation used[][] ??? (AG) 179 197 void PSeg::check() const 180 198 { … … 184 202 185 203 std::vector<VSeg>::const_iterator it; 186 size_t size = m_vsegs.size();187 size_t used[size][2];//lma, lma+length188 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; 189 207 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++) 191 209 { 192 size_t it_limit = (*it).lma() + (*it).length();210 paddr_t it_limit = (*it).lma() + (*it).length(); 193 211 for(j=0; j< i; j++) 194 212 { 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 , 196 214 { 197 215 error = 1; 198 216 std::cout << "ok \n"; 199 217 } 200 if( (used[j][1] == it_limit /*and (*it).legth()?*/)) // and not the same limit218 if( used[j][1] == it_limit ) // and not the same limit 201 219 { 202 220 error = 2; 203 221 } 204 if( ((used[j][0] < (*it).lma()) and ((*it).lma() < used[j][1] )) ) //lma within the used slice222 if( (used[j][0] < (*it).lma()) and ((*it).lma() < used[j][1]) ) // lma within 205 223 { 206 224 error = 3; 207 225 } 208 if( ((used[j][0] < it_limit) and (it_limit < used[j][1] )) )//limit not within the used slice226 if( ((used[j][0] < it_limit) and (it_limit < used[j][1] )) ) // limit no within 209 227 { 210 228 error = 4; … … 228 246 } 229 247 248 ////////////////////////////////////// 230 249 void PSeg::setName(std::string& name ) 231 250 { … … 233 252 } 234 253 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 ///////////////////////////////////////////////////////// 255 paddr_t PSeg::align( paddr_t toAlign, unsigned alignPow2) 256 { 257 return ((toAlign + (1 << alignPow2) - 1 ) >> alignPow2) << alignPow2; 258 } 259 260 ////////////////////////////////////////// 261 paddr_t PSeg::pageAlign( paddr_t toAlign ) 242 262 { 243 263 size_t pgs = pageSize(); 244 264 size_t pageSizePow2 = __builtin_ctz(pgs); 245 265 246 return align(toAlign, pageSizePow2); //page aligned247 248 } 249 250 void PSeg::setLma( uintptr_t lma )266 return align(toAlign, pageSizePow2); 267 } 268 269 //////////////////////////////// 270 void PSeg::setLma( paddr_t lma ) 251 271 { 252 272 m_lma = lma; 253 273 254 m_nextLma = pageAlign(lma); //page aligned274 m_nextLma = pageAlign(lma); 255 275 256 276 m_pageLimit = pageAlign(m_lma+m_length); 257 277 258 278 m_limit = (m_lma + m_length); 259 260 } 261 262 void PSeg::setLength( size_t length )279 } 280 281 ///////////////////////////////////// 282 void PSeg::setLength( paddr_t length ) 263 283 { 264 284 m_length = length; … … 267 287 268 288 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 //////////////////////////// 274 292 void PSeg::add( VSeg& vseg ) 275 293 { 276 294 vseg.m_lma = m_nextLma; 277 incNextLma(vseg.length());//for the next vseg295 // incNextLma(vseg.length()); //for the next vseg 278 296 m_vsegs.push_back(vseg); 279 297 } 280 298 299 ///////////////////////////////// 281 300 void PSeg::addIdent( VSeg& vseg ) 282 301 { 283 302 vseg.m_lma = vseg.m_vma; 284 //incNextLma(vseg.length());//to keep track of space used285 303 m_vsegs.push_back(vseg); 286 304 } 287 305 288 void PSeg::setNextLma( uintptr_t nextLma) 306 ///////////////////////////////////////// 307 void PSeg::setNextLma( paddr_t nextLma) 289 308 { 290 309 m_nextLma = nextLma; 291 292 310 confNextLma(); 293 311 } 294 312 295 void PSeg::incNextLma( size_t inc_next) 296 { 297 298 m_nextLma += inc_next; 299 313 ////////////////////////////////// 314 void PSeg::incNextLma( size_t inc) 315 { 316 m_nextLma += inc; 300 317 confNextLma(); 301 318 } 302 319 320 //////////////////////// 303 321 void PSeg::confNextLma() 304 322 { … … 322 340 } 323 341 342 ///////////////////////////////// 324 343 void PSeg::setPageSize(size_t pg) 325 344 { … … 332 351 } 333 352 353 //////////////////////// 334 354 size_t& PSeg::pageSize() 335 355 { … … 338 358 } 339 359 360 ///////////////////////////////////////// 340 361 PSeg & PSeg::operator=( const PSeg &ref ) 341 362 { 342 363 if ( &ref == this ) 343 364 return *this; 344 345 //std::cout << "Copying " << ref << " to " << *this << std::endl;346 365 347 366 m_name = ref.m_name; … … 357 376 } 358 377 378 ////////////////////////////////////////// 359 379 void PSeg::print( std::ostream &o ) const 360 380 { … … 374 394 } 375 395 396 //////////////////////////////////// 376 397 PSeg::PSeg( const std::string &name, 377 uintptr_tlma,378 size_tlength,379 size_ttype)398 paddr_t lma, 399 paddr_t length, 400 size_t type) 380 401 { 381 402 m_name = name; … … 384 405 385 406 setLma(lma); 386 //std::cout <<"New PSeg :"<< *this ; 387 } 388 407 } 408 409 //////////////////////////////////// 389 410 PSeg::PSeg( const std::string &name): 390 411 m_lma(0), … … 396 417 } 397 418 398 PSeg::PSeg( uintptr_t lma): 419 //////////////////////// 420 PSeg::PSeg( paddr_t lma): 399 421 m_name("No name"), 400 422 m_lma(0), … … 406 428 } 407 429 408 430 //////////// 409 431 PSeg::PSeg() 410 432 : … … 415 437 m_limit(0) 416 438 { 417 //std::cout << "New empty PSeg " << *this << std::endl; 418 } 419 439 } 440 441 ///////////////////////////// 420 442 PSeg::PSeg( const PSeg &ref ) 421 443 : m_name("To be copied"), … … 425 447 m_limit(0) 426 448 { 427 //std::cout << "New PSeg " << *this << " copied from " << ref << std::endl;428 449 (*this) = ref; 429 450 } … … 431 452 PSeg::~PSeg() 432 453 { 433 // std::cout << "Deleted PSeg " << *this << std::endl;434 454 } 435 455 -
soft/giet_vm/memo/src/pseg_handler.cpp
r163 r238 1 1 /* -*- c++ -*- 2 2 * 3 * SOCLIB_LGPL_HEADER_BEGIN3 * GIET_VM_LGPL_HEADER_BEGIN 4 4 * 5 * This file is part of SoCLib, GNU LGPLv2.1.5 * This file is part of GIET_VM, GNU LGPLv2.1. 6 6 * 7 * SoCLibis free software; you can redistribute it and/or modify it7 * GIET_VM is free software; you can redistribute it and/or modify it 8 8 * under the terms of the GNU Lesser General Public License as published 9 9 * by the Free Software Foundation; version 2.1 of the License. 10 10 * 11 * SoCLibis distributed in the hope that it will be useful, but11 * GIET_VM is distributed in the hope that it will be useful, but 12 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with SoCLib; if not, write to the Free Software17 * License along with GIET_VM; if not, write to the Free Software 18 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 19 * 02110-1301 USA 20 20 * 21 * SOCLIB_LGPL_HEADER_END21 * GIET_VM_LGPL_HEADER_END 22 22 * 23 23 * Copyright (c) UPMC, Lip6, SoC … … 37 37 #include "exception.h" 38 38 39 40 41 39 /* 42 40 * PSegHandler 43 41 */ 44 42 43 ///////////////////////////////////// 45 44 PSeg& PSegHandler::get( size_t pos ) 46 45 { … … 55 54 } 56 55 56 ////////////////////////////////////////////////////////////// 57 57 const PSeg& PSegHandler::getByAddr(uintptr_t segAddress) const 58 58 { … … 60 60 for(it = m_pSegs.begin(); it < m_pSegs.end(); it++) 61 61 { 62 uintptr_t lma = (*it).lma();62 paddr_t lma = (*it).lma(); 63 63 if( lma == segAddress ) 64 64 return *it; … … 71 71 } 72 72 73 /////////////////////////////// 73 74 void PSegHandler::check() const 74 75 {
Note: See TracChangeset
for help on using the changeset viewer.