Changeset 238 for soft/giet_vm/memo/src/memo.cpp
- Timestamp:
- May 29, 2013, 1:24:09 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.