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

Last change on this file since 238 was 238, checked in by alain, 11 years ago

Major evolution to support physical addresses larger than 32 bits.
The map.xml format has been modified: the vsegs associated to schedulers
are now explicitely defined and mapped in the page tables.

File size: 3.8 KB
Line 
1/* -*- c++ -*-
2 *
3 * GIET-VM_LGPL_HEADER_BEGIN
4 *
5 * This file is part of the GIET-VMS, GNU LGPLv2.1.
6 *
7 * The GIET-VM 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 * THe GIET-VM 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 * GIET-VM_LGPL_HEADER_END
22 *
23 * Copyright (c) UPMC, Lip6, SoC
24 *         Mohamed Lamine Karaoui <Mohamed.Karaoui@lip6.fr>, 2012
25 *         
26 */
27#ifndef GIET_MEMO_PSEG_H
28#define GIET_MEMO_PSEG_H
29
30#include <string>
31#include <vector>
32#include <ios>
33#include <elfpp/section>
34
35#include "stdint.h"
36#include "mapping_info.h"
37
38
39class MeMo;
40
41//////////
42class VSeg
43{
44    friend class PSegHandler;
45    friend class PSeg;
46    friend class MeMo;
47
48    typedef unsigned long long paddr_t;
49
50    std::string m_name;     // vseg name
51    std::string m_file;     // file name
52    uintptr_t   m_vma;      // Virtual address of the section to load in the binary file.
53    paddr_t     m_lma;      // Physical address 
54    size_t      m_length;
55    size_t      m_type;
56    bool        m_loadable; // loadable vseg ( code, data...)
57
58public:
59
60    bool        m_ident;    // identity mapping required if true
61
62    const std::string& name() const;
63    const std::string& file() const;
64    uintptr_t vma() const;
65    paddr_t lma() const;
66    size_t length() const;
67    size_t type() const;
68    //void add( VObj& vobj );//add a VObj
69
70    void print( std::ostream &o ) const;
71    friend std::ostream &operator<<( std::ostream &o, const VSeg &s )
72    {
73        s.print(o);
74        return o;
75    }
76
77    VSeg& operator=( const VSeg &ref );
78
79    VSeg();
80    VSeg( const VSeg &ref );
81    VSeg(std::string&   binaryName, 
82         std::string&   name, 
83         uintptr_t      vma, 
84         size_t         length, 
85         bool           loadable, 
86         bool           ident);
87
88    ~VSeg();
89};
90
91//////////
92class PSeg
93{
94    std::string   m_name;
95    paddr_t       m_lma;
96    paddr_t       m_length;
97    size_t        m_type;
98
99    paddr_t       m_pageLimit;  // m_lma + m_length aligned on page size
100    paddr_t       m_nextLma;    // next free base
101   
102    void confNextLma();         // check m_nextLma is whithin the seg limits
103
104public:
105
106    std::vector<VSeg> m_vsegs;
107
108    paddr_t     m_limit;        // m_lma + m_length
109
110    const std::string& name() const;
111    paddr_t lma() const;
112    paddr_t length() const;
113    size_t type() const;
114    paddr_t limit() const;
115    paddr_t nextLma() const;
116
117    void check() const;
118
119    void setName(std::string& name);
120    void setLma( paddr_t lma);
121    void setLength(paddr_t length);
122
123    static paddr_t align( paddr_t toAlign, unsigned alignPow2);
124    static paddr_t pageAlign( paddr_t toAlign );
125
126    static void setPageSize(size_t pg);
127
128    static size_t& pageSize();
129
130    void add( VSeg& vseg );    //add a VSeg
131    void addIdent( VSeg& vseg );
132
133    void setNextLma( paddr_t nextLma);
134    void incNextLma( size_t inc);
135
136    void print( std::ostream &o ) const;
137
138    friend std::ostream &operator<<( std::ostream &o, const PSeg &s )
139    {
140        s.print(o);
141        return o;
142    }
143    PSeg & operator=( const PSeg &ref );
144
145    PSeg();
146    PSeg( const PSeg &ref );
147    PSeg( const std::string &name);
148    PSeg( const paddr_t lma);
149    PSeg( const std::string &name,
150          paddr_t lma,
151          paddr_t length,
152          size_t type);
153    ~PSeg();
154};
155
156
157#endif /* GIET_MEMO_PSEG_H */
Note: See TracBrowser for help on using the repository browser.