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

Last change on this file since 234 was 212, checked in by karaoui, 12 years ago

add the support for replication of code to MeMo?

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