source: soft/giet_vm/memo/include/pseg.h @ 195

Last change on this file since 195 was 163, checked in by karaoui, 13 years ago

changing mover to memo
changing soft.bin to soft.elf
...

File size: 3.6 KB
RevLine 
[163]1/* -*- c++ -*-
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
22 *
23 * Copyright (c) UPMC, Lip6, SoC
24 *         Mohamed Lamine Karaoui <Mohamed.Karaoui@lip6.fr>, 2012
25 *         
26 */
27#ifndef SOCLIB_PSEG_H_
28#define SOCLIB_PSEG_H_
29
30#include <string>
31#include <vector>
32#include <ios>
33#include <elfpp/section>
34
35#include "stdint.h"
36
37
38class MeMo;
39
40class VSeg
41{
42    friend class PSegHandler;
43    friend class PSeg;
44    friend class MeMo;
45
46    std::string m_name;
47    std::string m_file;
48    uintptr_t m_vma;   //The address of the section to load in the binary file.
49    uintptr_t m_lma;   //Physical address to which we load the seg (getted from the associated PSeg), setted by PSeg::add/addIdent.
50    size_t m_length;
51    bool m_loadable;     // wether this is a loadable vseg ( code, data...)
52
53public:
54    bool m_ident;//Indicate if the idententy mapping is activited. used by PSegHandler::makeIdent()
55
56    const std::string& name() const;
57    const std::string& file() const;
58    uintptr_t vma() const;
59    uintptr_t lma() const;
60    size_t length() const;
61    //void add( VObj& vobj );//add a VObj
62
63    void print( std::ostream &o ) const;
64    friend std::ostream &operator<<( std::ostream &o, const VSeg &s )
65    {
66        s.print(o);
67        return o;
68    }
69
70    VSeg& operator=( const VSeg &ref );
71
72    VSeg();
73    VSeg( const VSeg &ref );
74    VSeg(std::string& binaryName, std::string& name, uintptr_t vma, size_t length, bool loadable, bool ident);
75
76    ~VSeg();
77};
78
79
80class PSeg
81{
82    std::string m_name;
83    uintptr_t m_lma;
84    size_t m_length;
85
86    uintptr_t m_pageLimit;  //The end (m_lma + m_length)  address of the segment pageSize aligned
87    uintptr_t m_nextLma;    //next free base
88   
89    void confNextLma();     //check that m_nextLma has a correct value: whithin the seg limits
90
91public:
92    std::vector<VSeg> m_vsegs;
93    uintptr_t m_limit;// m_lma + m_length
94
95
96    const std::string& name() const;
97    uintptr_t lma() const;
98    size_t length() const;
99    uintptr_t limit() const;
100    uintptr_t nextLma() const;
101
102    void check() const;
103
104    void setName(std::string& name);
105    void setLma( uintptr_t lma);
106    void setLength(size_t length);
107
108    static size_t align( unsigned toAlign, unsigned alignPow2);
109    static size_t pageAlign( size_t toAlign );
110    static void setPageSize(size_t pg);
111    static size_t& pageSize();
112
113    void add( VSeg& vseg );//add a VSeg
114    void addIdent( VSeg& vseg );
115
116    void setNextLma( uintptr_t nextLma);
117    void incNextLma( size_t inc_next);
118
119    void print( std::ostream &o ) const;
120
121    friend std::ostream &operator<<( std::ostream &o, const PSeg &s )
122    {
123        s.print(o);
124        return o;
125    }
126    PSeg & operator=( const PSeg &ref );
127
128    PSeg();
129    PSeg( const PSeg &ref );
130    PSeg( const std::string &name);
131    PSeg( const uintptr_t lma);
132    PSeg( const std::string &name,
133                     uintptr_t lma,
134             size_t length);
135    ~PSeg();
136};
137
138
139#endif /* SOCLIB_PSEG_H_ */
Note: See TracBrowser for help on using the repository browser.