/* -*- c++ -*- * * SOCLIB_LGPL_HEADER_BEGIN * * This file is part of SoCLib, GNU LGPLv2.1. * * SoCLib is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; version 2.1 of the License. * * SoCLib is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with SoCLib; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA * * SOCLIB_LGPL_HEADER_END * * Copyright (c) UPMC, Lip6, SoC * Mohamed Lamine Karaoui , 2012 * */ #ifndef _MEMO_H_ #define _MEMO_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "stdint.h" #include "mapping_info.h" #include "pseg_handler.h" #include "path_handler.h" class MeMo { std::string m_path; //map_info path name std::string m_wd; //map_info path to directory TODO: make the name defined in the map_info relative to this wd. std::string m_simpleName; //map_info filename TODO void* m_data; //map_info structure uintptr_t m_addr; //map_info address (virtual) size_t m_size; //size of the structure mutable std::map m_loaders; PSegHandler m_psegh; PathHandler m_pathHandler; bool m_ginit; elfpp::object* m_generator; size_t load_bin(std::string filename, void* buffer); size_t bin_size(std::string filename); elfpp::section* get_sect_by_addr(elfpp::object *loader, unsigned int addr); public: MeMo( const std::string &name, const size_t pageSize = 4096); ~MeMo(); void buildSoft(const std::string &filename); void print( std::ostream &o ) const; void print_mapping() const; friend std::ostream &operator<<( std::ostream &o, const MeMo &s ) { s.print(o); return o; } //The following functions handle the map.bin structure //inspired from the boot_init.c of the GIET mapping_cluster_t* get_cluster_base( mapping_header_t* header ); mapping_pseg_t* get_pseg_base( mapping_header_t* header ); mapping_vspace_t* get_vspace_base( mapping_header_t* header ); mapping_vseg_t* get_vseg_base( mapping_header_t* header ); mapping_vobj_t* get_vobj_base( mapping_header_t* header ); void print_mapping_info(void* desc); void vseg_map( mapping_vseg_t* vseg); void buildMap(void* desc); }; #endif /* _MEMO_H_ */ // Local Variables: // tab-width: 4 // c-basic-offset: 4 // c-file-offsets:((innamespace . 0)(inline-open . 0)) // indent-tabs-mode: nil // End: // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4