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

Last change on this file since 600 was 255, checked in by meunier, 11 years ago
  • Added a syscall and some user functions to manipulate the Simulation Helper
  • Changed the the way the Vseg -> Pseg mapping is made during the boot to better utilize the address space (+ adaptation of the algorithm in memo)
  • Fixed a bug in boot_init (vobj_init): the vobj initialization could only be made for the first application (ptpr was not changed)
File size: 3.5 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    int32_t     m_align;    // alignment of the first vobj
61    bool        m_ident;    // identity mapping required if true
62
63    const std::string& name() const;
64    const std::string& file() const;
65    uintptr_t vma() const;
66    paddr_t lma() const;
67    size_t length() const;
68    size_t type() const;
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    static size_t m_pageSize;
100
101public:
102
103    std::vector<VSeg> m_vsegs;
104
105    const std::string& name() const;
106    paddr_t lma() const;
107    paddr_t length() const;
108    size_t type() const;
109
110    void check() const;
111
112    void setName(std::string& name);
113    void setLma(paddr_t lma);
114    void setLength(paddr_t length);
115
116    static paddr_t align(paddr_t toAlign, unsigned alignPow2);
117    static paddr_t pageAlign(paddr_t toAlign);
118
119    static void setPageSize(size_t pg) {
120       m_pageSize = pg;
121    }
122    static size_t pageSize() {
123       return m_pageSize;
124    }
125
126    void add(VSeg& vseg);    //add a VSeg
127    void addIdent(VSeg& vseg);
128
129
130    void print(std::ostream &o) const;
131
132    friend std::ostream &operator<<(std::ostream &o, const PSeg &s )
133    {
134        s.print(o);
135        return o;
136    }
137    PSeg & operator=(const PSeg &ref);
138
139    PSeg();
140    PSeg(const PSeg &ref );
141    PSeg(const std::string &name);
142    PSeg(const std::string &name,
143         paddr_t lma,
144         paddr_t length,
145         size_t type);
146    ~PSeg();
147};
148
149
150#endif /* GIET_MEMO_PSEG_H */
Note: See TracBrowser for help on using the repository browser.