source: soft/giet_vm/mover/include/mover.h @ 160

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

giet-vm new version

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 SOCLIB_VLOADER_H_
28#define SOCLIB_VLOADER_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 "pseg_handler.h"
53#include "path_handler.h"
54
55
56
57class Mover
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_pathh;
69   
70    bool m_ginit;
71    elfpp::object* m_generator;//TODO:delete
72
73    void* load_bin(std::string name);
74    elfpp::section* get_sect_by_addr(elfpp::object *loader, unsigned int addr);
75
76public:
77
78    Mover( const std::string &name, const size_t pageSize = 4096);
79    ~Mover();
80
81    void buildSoft(const std::string &filename);
82
83    void print( std::ostream &o ) const;
84
85    void print_mapping() const;
86
87    friend std::ostream &operator<<( std::ostream &o, const Mover &s )
88    {
89        s.print(o);
90        return o;
91    }
92
93
94    //The following functions handle the map.bin structure
95    //inspired from the boot_handler.c of the GIET
96    mapping_pseg_t* get_pseg_base( mapping_header_t* header );
97    mapping_vspace_t* get_vspace_base( mapping_header_t* header );
98    mapping_vseg_t* get_vseg_base( mapping_header_t* header );
99    mapping_vobj_t* get_vobj_base( mapping_header_t* header );
100    void print_mapping_info(void* desc);
101    void pseg_map( mapping_pseg_t* pseg);
102    void vseg_map( mapping_vseg_t* vseg);
103    void buildMap(void* desc);
104
105};
106
107
108#endif /* SOCLIB_VLOADER_H_ */
109
110// Local Variables:
111// tab-width: 4
112// c-basic-offset: 4
113// c-file-offsets:((innamespace . 0)(inline-open . 0))
114// indent-tabs-mode: nil
115// End:
116
117// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
118
Note: See TracBrowser for help on using the repository browser.