/* -*- c++ -*- * * GIET-VM_LGPL_HEADER_BEGIN * * This file is part of the GIET-VMS, GNU LGPLv2.1. * * The GIET-VM 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. * * THe GIET-VM 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 * * GIET-VM_LGPL_HEADER_END * * Copyright (c) UPMC, Lip6, SoC * Mohamed Lamine Karaoui , 2012 * */ #ifndef GIET_MEMO_PSEG_H #define GIET_MEMO_PSEG_H #include #include #include #include #include "stdint.h" #include "mapping_info.h" class MeMo; ////////// class VSeg { friend class PSegHandler; friend class PSeg; friend class MeMo; typedef unsigned long long paddr_t; std::string m_name; // vseg name std::string m_file; // file name uintptr_t m_vma; // Virtual address of the section to load in the binary file. paddr_t m_lma; // Physical address size_t m_length; size_t m_type; bool m_loadable; // loadable vseg ( code, data...) public: bool m_ident; // identity mapping required if true const std::string& name() const; const std::string& file() const; uintptr_t vma() const; paddr_t lma() const; size_t length() const; size_t type() const; //void add( VObj& vobj );//add a VObj void print( std::ostream &o ) const; friend std::ostream &operator<<( std::ostream &o, const VSeg &s ) { s.print(o); return o; } VSeg& operator=( const VSeg &ref ); VSeg(); VSeg( const VSeg &ref ); VSeg(std::string& binaryName, std::string& name, uintptr_t vma, size_t length, bool loadable, bool ident); ~VSeg(); }; ////////// class PSeg { std::string m_name; paddr_t m_lma; paddr_t m_length; size_t m_type; paddr_t m_pageLimit; // m_lma + m_length aligned on page size paddr_t m_nextLma; // next free base void confNextLma(); // check m_nextLma is whithin the seg limits public: std::vector m_vsegs; paddr_t m_limit; // m_lma + m_length const std::string& name() const; paddr_t lma() const; paddr_t length() const; size_t type() const; paddr_t limit() const; paddr_t nextLma() const; void check() const; void setName(std::string& name); void setLma( paddr_t lma); void setLength(paddr_t length); static paddr_t align( paddr_t toAlign, unsigned alignPow2); static paddr_t pageAlign( paddr_t toAlign ); static void setPageSize(size_t pg); static size_t& pageSize(); void add( VSeg& vseg ); //add a VSeg void addIdent( VSeg& vseg ); void setNextLma( paddr_t nextLma); void incNextLma( size_t inc); void print( std::ostream &o ) const; friend std::ostream &operator<<( std::ostream &o, const PSeg &s ) { s.print(o); return o; } PSeg & operator=( const PSeg &ref ); PSeg(); PSeg( const PSeg &ref ); PSeg( const std::string &name); PSeg( const paddr_t lma); PSeg( const std::string &name, paddr_t lma, paddr_t length, size_t type); ~PSeg(); }; #endif /* GIET_MEMO_PSEG_H */