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

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

Avoid incremmentinting Pseg of "PERI" type, to permit multiple mapping.

File size: 3.3 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;//TODO:delete
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    elfpp::section* get_sect_by_name(elfpp::object *loader, std::string name);
78
79public:
80
81    MeMo( const std::string &name, const size_t pageSize = 4096);
82    ~MeMo();
83
84    void buildSoft(const std::string &filename);
85
86    void print( std::ostream &o ) const;
87
88    void print_mapping() const;
89
90    friend std::ostream &operator<<( std::ostream &o, const MeMo &s )
91    {
92        s.print(o);
93        return o;
94    }
95
96
97    //The following functions handle the map.bin structure
98    //inspired from the boot_init.c of the GIET
99    mapping_cluster_t* get_cluster_base( mapping_header_t* header );
100    mapping_pseg_t* get_pseg_base( mapping_header_t* header );
101    mapping_vspace_t* get_vspace_base( mapping_header_t* header );
102    mapping_vseg_t* get_vseg_base( mapping_header_t* header );
103    mapping_vobj_t* get_vobj_base( mapping_header_t* header );
104    void print_mapping_info(void* desc);
105    void vseg_map( mapping_vseg_t* vseg);
106    void buildMap(void* desc);
107
108};
109
110
111#endif /* _MEMO_H_ */
112
113// Local Variables:
114// tab-width: 4
115// c-basic-offset: 4
116// c-file-offsets:((innamespace . 0)(inline-open . 0))
117// indent-tabs-mode: nil
118// End:
119
120// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
121
Note: See TracBrowser for help on using the repository browser.