source: soft/giet_vm/memo/include/memo.h @ 756

Last change on this file since 756 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.6 KB
Line 
1/* -*- c++ -*-
2 *
3 * GIET_VM_LGPL_HEADER_BEGIN
4 *
5 * This file is part of GIET_VM, GNU LGPLv2.1.
6 *
7 * 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 * 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 GIET_VM; 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
28#ifndef GIET_VM_MEMO_H
29#define GIET_VM_MEMO_H
30
31#include  <stdlib.h>
32#include  <cstdlib>
33#include  <fcntl.h>
34#include  <unistd.h>
35#include  <cstdio>
36#include  <string.h>
37
38#include <string>
39#include <ios>
40#include <vector>
41#include <map>
42#include <fstream>
43
44#include <dpp/foreach>
45
46#include <elfpp/object>
47#include <elfpp/symbol>
48#include <elfpp/section>
49#include <elfpp/segment>
50#include <elfpp/elfpp_bits.hh>
51
52#include "stdint.h"
53#include "mapping_info.h"
54#include "pseg_handler.h"
55#include "path_handler.h"
56
57
58class MeMo
59{
60// TODO: make the name defined in the map_info relative to this wd.
61
62    std::string                                   m_path;       // map_info path name
63    std::string                                   m_wd;         // map_info directory TODO
64    std::string                                   m_simpleName; // map_info filename TODO
65    void*                                         m_data;       // map_info structure
66    uintptr_t                                     m_addr;       // map_info address (virtual)
67    size_t                                        m_size;       // size of the structure
68    mutable std::map<std::string, elfpp::object*> m_loaders;
69    PSegHandler                                   m_psegh;
70    PathHandler                                   m_pathHandler;
71    bool                                          m_ginit;
72    elfpp::object*                                m_generator;
73
74    size_t load_bin(std::string filename, void* buffer);   
75    size_t bin_size(std::string filename);
76
77    elfpp::section* get_sect_by_addr(elfpp::object *loader, unsigned int addr);
78
79public:
80
81    MeMo( const std::string   &name, 
82          const size_t        pageSize = 4096);
83
84    ~MeMo();
85
86    void buildSoft(const std::string &filename);
87
88    void print( std::ostream &o ) const;
89
90    void print_mapping() const;
91
92    friend std::ostream &operator<<( std::ostream &o, const MeMo &s )
93    {
94        s.print(o);
95        return o;
96    }
97
98    // The following functions handle the map.bin structure
99    // They must keep synchronised with functions defined in boot_init.c.
100
101    mapping_cluster_t* get_cluster_base( mapping_header_t* header );
102    mapping_pseg_t* get_pseg_base( mapping_header_t* header );
103    mapping_vspace_t* get_vspace_base( mapping_header_t* header );
104    mapping_vseg_t* get_vseg_base( mapping_header_t* header );
105    mapping_vobj_t* get_vobj_base( mapping_header_t* header );
106    void print_mapping_info(void* desc);
107    void vseg_map( mapping_vseg_t* vseg);
108    void buildMap(void* desc);
109
110};
111
112
113#endif /* GIET_VM_MEMO_H */
114
115// Local Variables:
116// tab-width: 4
117// c-basic-offset: 4
118// c-file-offsets:((innamespace . 0)(inline-open . 0))
119// indent-tabs-mode: nil
120// End:
121
122// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
123
Note: See TracBrowser for help on using the repository browser.