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

Last change on this file since 419 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
RevLine 
[163]1/* -*- c++ -*-
2 *
[238]3 * GIET-VM_LGPL_HEADER_BEGIN
[163]4 *
[238]5 * This file is part of the GIET-VMS, GNU LGPLv2.1.
[163]6 *
[238]7 * The GIET-VM is free software; you can redistribute it and/or modify it
[163]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 *
[238]11 * THe GIET-VM is distributed in the hope that it will be useful, but
[163]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 *
[238]21 * GIET-VM_LGPL_HEADER_END
[163]22 *
23 * Copyright (c) UPMC, Lip6, SoC
24 *         Mohamed Lamine Karaoui <Mohamed.Karaoui@lip6.fr>, 2012
25 *         
26 */
[238]27#ifndef GIET_MEMO_PSEG_H
28#define GIET_MEMO_PSEG_H
[163]29
30#include <string>
31#include <vector>
32#include <ios>
33#include <elfpp/section>
34
35#include "stdint.h"
[210]36#include "mapping_info.h"
[163]37
38
39class MeMo;
40
[238]41//////////
[163]42class VSeg
43{
44    friend class PSegHandler;
45    friend class PSeg;
46    friend class MeMo;
47
[238]48    typedef unsigned long long paddr_t;
[163]49
[238]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
[163]58public:
59
[255]60    int32_t     m_align;    // alignment of the first vobj
[238]61    bool        m_ident;    // identity mapping required if true
62
[163]63    const std::string& name() const;
64    const std::string& file() const;
65    uintptr_t vma() const;
[238]66    paddr_t lma() const;
[163]67    size_t length() const;
[210]68    size_t type() const;
[163]69
[255]70    void print(std::ostream &o) const;
[163]71    friend std::ostream &operator<<( std::ostream &o, const VSeg &s )
72    {
73        s.print(o);
74        return o;
75    }
76
[255]77    VSeg& operator=(const VSeg &ref);
[163]78
79    VSeg();
[255]80    VSeg(const VSeg &ref);
[238]81    VSeg(std::string&   binaryName, 
82         std::string&   name, 
83         uintptr_t      vma, 
84         size_t         length, 
85         bool           loadable, 
86         bool           ident);
[163]87
88    ~VSeg();
89};
90
[238]91//////////
[163]92class PSeg
93{
[238]94    std::string   m_name;
95    paddr_t       m_lma;
96    paddr_t       m_length;
97    size_t        m_type;
[163]98
[255]99    static size_t m_pageSize;
[163]100
101public:
[238]102
[163]103    std::vector<VSeg> m_vsegs;
104
105    const std::string& name() const;
[238]106    paddr_t lma() const;
107    paddr_t length() const;
[210]108    size_t type() const;
[163]109
110    void check() const;
111
112    void setName(std::string& name);
[255]113    void setLma(paddr_t lma);
[238]114    void setLength(paddr_t length);
[163]115
[255]116    static paddr_t align(paddr_t toAlign, unsigned alignPow2);
117    static paddr_t pageAlign(paddr_t toAlign);
[238]118
[255]119    static void setPageSize(size_t pg) {
120       m_pageSize = pg;
121    }
122    static size_t pageSize() {
123       return m_pageSize;
124    }
[238]125
[255]126    void add(VSeg& vseg);    //add a VSeg
127    void addIdent(VSeg& vseg);
[163]128
129
[255]130    void print(std::ostream &o) const;
[163]131
[255]132    friend std::ostream &operator<<(std::ostream &o, const PSeg &s )
[163]133    {
134        s.print(o);
135        return o;
136    }
[255]137    PSeg & operator=(const PSeg &ref);
[163]138
139    PSeg();
[255]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);
[163]146    ~PSeg();
147};
148
149
[238]150#endif /* GIET_MEMO_PSEG_H */
Note: See TracBrowser for help on using the repository browser.