Changeset 173 for soft/giet_vm
- Timestamp:
- Jul 18, 2012, 4:59:19 PM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/boot/reset.S
r165 r173 178 178 boot_lf_string: .asciiz "\n" 179 179 180 180 .set reorder 181 181 182 182 -
soft/giet_vm/giet_config.h
r170 r173 12 12 /* Debug parameters */ 13 13 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 */ 18 18 19 19 -
soft/giet_vm/map.xml
r171 r173 81 81 ident = "1" > 82 82 <vobj name = "seg_mapping" 83 type = " ELF"83 type = "BLOB" 84 84 length = "0x00004000" 85 85 binpath = "map.bin" /> -
soft/giet_vm/memo/Makefile
r165 r173 11 11 g++ -Wall -g $(SRCS) $(INCLUDES) -o memo.x 12 12 13 debug: $(SRCS) $(HDRS) 14 g++ -Wall -DMOVER_DEBUG -g $(SRCS) $(INCLUDES) -o debug.x 15 16 check: 17 test/check.sh 18 13 19 clean: 14 rm memo.x20 rm *.x -
soft/giet_vm/memo/include/exception.h
r163 r173 1 1 /* -*- c++ -*- 2 2 * 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 22 8 * 23 * Copyright (c) UPMC, Lip6, Asim24 * Nicolas Pouillon <nipo@ssji.net>, 200725 *26 * Maintainers: nipo27 9 */ 28 10 29 #ifndef SOCLIB_EXCEPTION_H_30 #define SOCLIB_EXCEPTION_H_11 #ifndef _EXCEPTION_H_ 12 #define _EXCEPTION_H_ 31 13 32 14 #include <exception> … … 34 16 #include <iostream> 35 17 36 namespace soclib { namespaceexception {18 namespace exception { 37 19 38 20 class Exception … … 96 78 }; 97 79 98 } }80 } 99 81 100 82 #endif /* SOCLIB_EXCEPTION_H_ */ -
soft/giet_vm/memo/include/libelfpp/elfpp/elfpp_section.hh
r163 r173 110 110 111 111 /** @this sets pointer to section content buffer */ 112 inlinevoid set_content(void* a);112 void set_content(void* a); 113 113 /** @this gets pointer to section content buffer */ 114 114 inline uint8_t *get_content() const; -
soft/giet_vm/memo/include/libelfpp/elfpp/elfpp_section.hxx
r163 r173 23 23 24 24 #include <stdexcept> 25 25 26 26 27 namespace elfpp … … 130 131 } 131 132 132 void section::set_content(void* a)133 {134 content_ = (uint8_t*) a;135 }136 137 133 uint8_t * section::get_content() const 138 134 { -
soft/giet_vm/memo/include/memo.h
r163 r173 71 71 elfpp::object* m_generator;//TODO:delete 72 72 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 74 76 elfpp::section* get_sect_by_addr(elfpp::object *loader, unsigned int addr); 75 77 elfpp::section* get_sect_by_name(elfpp::object *loader, std::string name); -
soft/giet_vm/memo/src/libelfpp/elfpp_section.cc
r163 r173 23 23 #include <stdlib.h> 24 24 #include <cstring> 25 #include <stdlib.h> 26 25 27 26 28 #include <dpp/foreach> … … 81 83 82 84 size_ = size; 85 } 86 87 void section::set_content(void* a) 88 { 89 if(content_) 90 free(content_); 91 content_ = (uint8_t*) a; 83 92 } 84 93 -
soft/giet_vm/memo/src/memo.cpp
r165 r173 51 51 PSeg::setPageSize(pageSize); 52 52 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 54 70 55 71 #ifdef MOVER_DEBUG … … 107 123 } 108 124 109 //TODO:delete110 elfpp::section* MeMo::get_sect_by_name(elfpp::object *loader, std::string name)111 {112 #ifdef MOVER_DEBUG113 std::cout << "get_sect_by_name " << name << std::endl;114 #endif115 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_DEBUG123 std::cout << "Trying " << sect->get_name() << std::endl;124 #endif125 if(!(sect->get_name()).compare(name))126 {127 return (&*sect);128 }129 }130 return NULL;131 }132 125 133 126 void MeMo::buildSoft(const std::string &filename) 134 127 { 135 128 if(!m_ginit) 136 throw soclib::exception::RunTimeError(std::string("Can't get generator! ") );129 throw exception::RunTimeError(std::string("Can't get generator! ") ); 137 130 138 131 m_generator->write(filename); … … 140 133 } 141 134 135 /* Load the content of filename in buffer, and send the size */ 136 //////////////////////////////////////////////////////// 137 size_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 */ 142 165 ////////////////////////////////////////// 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);166 size_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); 151 174 152 175 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); 154 177 155 178 input.seekg( 0, std::ifstream::end ); 156 m_size = input.tellg();179 size_t size = input.tellg(); 157 180 input.seekg( 0, std::ifstream::beg ); 158 181 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 168 187 169 188 ///////////// … … 171 190 { 172 191 //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 174 193 std::map<std::string, elfpp::object*>::iterator l; 175 194 for(l = m_loaders.begin(); l != m_loaders.end(); l++) … … 322 341 323 342 ////////////////////////////////////////// 324 void MeMo::vseg_map( mapping_vseg_t* vseg) 325 { 326 mapping_vobj_t* vobj = get_vobj_base( (mapping_header_t*) m_data ); 343 void MeMo::vseg_map( mapping_vseg_t* vseg) 344 { 345 mapping_vobj_t* vobj = get_vobj_base( (mapping_header_t*) m_data ); 327 346 PSeg *ps = &(m_psegh.get(vseg->psegid));// get physical segment pointer(PSegHandler::get) 328 347 elfpp::section* sect = NULL; … … 343 362 mapping_vobj_t* cur_vobj; 344 363 size_t simple_size = 0; //for debug 345 364 346 365 #ifdef MOVER_DEBUG 347 366 std::cout << "--------------------vseg_map "<< vseg->name <<"---------------------" << std::endl; 348 367 #endif 349 368 350 369 for ( size_t vobj_id = vseg->vobj_offset ; vobj_id < (vseg->vobj_offset + vseg->vobjs) ; vobj_id++ ) 351 370 { … … 353 372 354 373 #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 << ")" 356 375 << " size: "<< cur_vobj->length << " type: " << cur_vobj->type << std::endl; 357 376 #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")); 363 437 364 438 size_t elf_size; … … 366 440 #ifdef MOVER_DEBUG 367 441 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) 370 458 { 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; 384 463 } 385 else386 {387 #ifdef MOVER_DEBUG388 std::cout << "Found an ELF vseg" << std::endl;389 #endif390 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: delete395 //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 binarys411 * */412 m_generator->copy_info(*loader);413 m_ginit=true;414 }415 }416 464 417 465 if(elf_size > cur_vobj->length) 466 { 418 467 std::cout << "Warning, specified elf type vobj ("<< 419 468 cur_vobj->name <<") size is "<< cur_vobj->length << ", the actual size is " 420 469 << 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 } 421 473 422 474 cur_vobj->length = elf_size;//set the true size of this ELF vobj 423 475 424 476 vSO->m_file = filePath; 425 vSO->m_loadable = true; 426 } 427 first = false; 477 vSO->m_loadable = true; 478 } 428 479 429 480 //aligning the vobj->paddr if necessary 481 // 430 482 if(cur_vobj->align) 431 483 { … … 437 489 cur_paddr += cur_vobj->length; 438 490 simple_size += cur_vobj->length; 491 first = false; 439 492 } 440 493 … … 449 502 std::cout << "vseg base "<< std::hex << ps->nextLma() 450 503 <<(ps->nextLma()+simple_size) <<" size " << std::dec << simple_size << 451 std::endl; 504 std::endl; 452 505 453 506 std::cout << "vseg aligned to: base: " << std::hex << ps->nextLma() … … 456 509 } 457 510 #endif 458 459 vSO->m_ident = vseg->ident; 511 512 vSO->m_ident = vseg->ident; 460 513 461 514 //set the lma … … 464 517 else 465 518 ps->add( *vSO ); 466 519 467 520 if(!sect) 468 521 return; … … 476 529 477 530 } // end vseg_map() 478 531 479 532 480 533 /////////////////////////////// -
soft/giet_vm/memo/src/pseg.cpp
r163 r173 208 208 err << " Error" << error << " ,ovelapping Buffers:" << std::endl 209 209 << *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() ); 211 211 } 212 212 -
soft/giet_vm/xml/mapping_info.h
r167 r173 55 55 #define OUT_MAPPING_SIGNATURE 0xBABEF00D 56 56 57 enum 57 enum 58 58 { 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 66 67 }; 67 68 -
soft/giet_vm/xml/xml_driver.c
r165 r173 25 25 { 26 26 "ELF", 27 "BLOB", 27 28 "PTAB", //page table 28 29 "PERI", //hardware component -
soft/giet_vm/xml/xml_parser.c
r167 r173 380 380 } 381 381 } 382 else if (ok && (strcmp(str, "BLOB") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BLOB; 382 383 else if (ok && (strcmp(str, "PTAB") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PTAB; 383 384 else if (ok && (strcmp(str, "PERI") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PERI;
Note: See TracChangeset
for help on using the changeset viewer.