OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [wxwin/] [memmap.h] - Blame information for rev 502

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####COPYRIGHTBEGIN####
2
//                                                                          
3
// ----------------------------------------------------------------------------
4
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5
//
6
// This program is part of the eCos host tools.
7
//
8
// This program is free software; you can redistribute it and/or modify it 
9
// under the terms of the GNU General Public License as published by the Free 
10
// Software Foundation; either version 2 of the License, or (at your option) 
11
// any later version.
12
// 
13
// This program is distributed in the hope that it will be useful, but WITHOUT 
14
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
15
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
16
// more details.
17
// 
18
// You should have received a copy of the GNU General Public License along with
19
// this program; if not, write to the Free Software Foundation, Inc., 
20
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
//
22
// ----------------------------------------------------------------------------
23
//                                                                          
24
//####COPYRIGHTEND####
25
//=================================================================
26
//
27
//        memmap.h
28
//
29
//        Memory Layout Tool map data structure manipulation interface
30
//
31
//=================================================================
32
//=================================================================
33
//#####DESCRIPTIONBEGIN####
34
//
35
// Author(s):     John Dallaway
36
// Contact(s):    jld
37
// Date:          1998/07/29 $RcsDate$ {or whatever}
38
// Version:       0.00+  $RcsVersion$ {or whatever}
39
// Purpose:       Provides an interface to create and destroy memory
40
//                regions and sections within the memory map. Exposes
41
//                data structures for the presentation of this data
42
//                by external code.
43
// See also:      memmap.cpp
44
// Known bugs:    <UPDATE_ME_AT_RELEASE_TIME>
45
// WARNING:       Do not modify data structures other than by using the
46
//                provided functions
47
// Usage:         #include "memmap.h"
48
//                ...
49
//                status = set_map_size (0x8000);
50
//
51
//####DESCRIPTIONEND####
52
 
53
#if !defined(AFX_MEMMAP_H__75497C90_17F4_11D2_BFBB_00A0C9554250__INCLUDED_)
54
#define AFX_MEMMAP_H__75497C90_17F4_11D2_BFBB_00A0C9554250__INCLUDED_
55
 
56
/*
57
 
58
#if _MSC_VER >= 1000
59
#pragma once
60
#endif // _MSC_VER >= 1000
61
 
62
#ifdef _AFXDLL
63
#include "stdafx.h"
64
    #define INCLUDEFILE <list>
65
    #include "IncludeSTL.h"
66
    #define INCLUDEFILE <map>
67
    #include "IncludeSTL.h"
68
    #define INCLUDEFILE <string>
69
    #include "IncludeSTL.h"
70
    #define INCLUDEFILE <algorithm>
71
    #include "IncludeSTL.h"
72
#else
73
    #include <list>
74
    #include <map>
75
    #include <string>
76
    #include <algorithm>
77
#endif
78
 
79
*/
80
 
81
#include <time.h>
82
 
83
#define ERR_MEMMAP_REGION_NONAME 1
84
#define ERR_MEMMAP_REGION_MAPSIZE 2
85
#define ERR_MEMMAP_REGION_INTERSECT 3 /* region name returned in error_info */
86
#define ERR_MEMMAP_REGION_NAMEINUSE 4
87
#define ERR_MEMMAP_REGION_NOTFOUND 5
88
#define ERR_MEMMAP_REGION_SIZE 6
89
#define ERR_MEMMAP_ALLOC 7
90
#define ERR_MEMMAP_SECTION_NONAME 8
91
#define ERR_MEMMAP_SECTION_NAMEINUSE 9
92
#define ERR_MEMMAP_SECTION_LMA_NOTINREGION 10
93
#define ERR_MEMMAP_SECTION_VMA_NOTINREGION 11
94
#define ERR_MEMMAP_SECTION_LMA_ANCHORNOTFOUND 12
95
#define ERR_MEMMAP_SECTION_LMA_ANCHORNOTAVAIL 13
96
#define ERR_MEMMAP_SECTION_VMA_ANCHORNOTFOUND 14
97
#define ERR_MEMMAP_SECTION_VMA_ANCHORNOTAVAIL 15
98
#define ERR_MEMMAP_SECTION_NOTFOUND 17
99
#define ERR_MEMMAP_SECTION_VMA_READONLY 18
100
#define ERR_MEMMAP_SECTION_LMA_READWRITE 19
101
#define ERR_MEMMAP_SECTION_ILLEGAL_RELOCATION 20
102
 
103
#define LD_ILLEGAL_CHARS _T(" ,.")
104
#define MLT_FILE_VERSION 0
105
#define MLT_GENERATED_WARNING "// This is a generated file - do not edit"
106
 
107
typedef unsigned long mem_address; // FIXME: is a 32-bit memory address sufficient?
108
typedef struct tag_mem_location mem_location; // forward declaration for struct tag_mem_location
109
 
110
// the location of each section is specified either relative to another
111
// section or using an absolute memory address, either the start or end
112
// address may be specified
113
 
114
typedef enum mem_anchor {relative, absolute};
115
 
116
// each section view item may represent either the initial location of
117
// the section, the final location, or both locations if the section does
118
// not relocate
119
 
120
typedef enum section_location_type {initial_location, final_location, fixed_location};
121
 
122
// a memory region may be either ROM (read-only) or RAM (read-write).
123
 
124
typedef enum mem_type {read_only, read_write};
125
 
126
// the memory section structure describes the initial and final locations
127
// of a section, its size and relocation information
128
 
129
class mem_section
130
{
131
public:
132
    std::string name; // the name of the section
133
    bool relocates; // if the memory section relocates
134
    bool linker_defined; // if the memory section is linker-defined
135
    mem_address alignment; // the section alignment
136
    mem_address size; // memory section size (zero if unknown)
137
    mem_location * final_location; // the final memory section location (always defined)
138
    mem_location * initial_location; // the initial memory section location (always defined)
139
    std::string note; // comment lines
140
    mem_section ();
141
    ~mem_section ();
142
};
143
 
144
// the memory location structure describes the way in which the section is
145
// anchored, the absolute address of the anchor (if any) and the names of
146
// the preceding and following relative sections (if any)
147
 
148
typedef struct tag_mem_location
149
{
150
    mem_anchor anchor; // type of anchor
151
    mem_address address; // the absolute anchor address (if any)
152
    std::list <mem_section>::iterator following_section; // the section declared as following this one
153
} mem_location;
154
 
155
// the section view structure consists of the section name (which is used
156
// as a key to look up section information in the section map) and an enum
157
// describing the state of the section which it represents
158
 
159
typedef struct tag_mem_section_view
160
{
161
    std::list <mem_section>::iterator section; // unused section if NULL
162
    section_location_type section_location;
163
} mem_section_view;
164
 
165
// the memory region structure describes the region name, size, address,
166
// RAM/ROM status and a list of section views which reside in the region
167
 
168
typedef struct tag_mem_region
169
{
170
    std::string name; // the name of the region
171
    mem_address size; // the size of the memory region in bytes
172
    mem_address address; // the absolute location of the memory region
173
    mem_type type; // ROM or RAM
174
    std::list <mem_section_view> section_view_list;
175
    std::string note; // comment lines
176
} mem_region;
177
 
178
 
179
class mem_map
180
{
181
public:
182
        bool delete_memory_section (std::string name);
183
    int edit_memory_section (std::string old_name,
184
        std::string new_name,
185
        mem_address section_size,
186
        mem_address section_alignment,
187
        mem_anchor initial_section_anchor,
188
        std::string initial_anchor_section_name,
189
        mem_address initial_anchor_address,
190
        mem_anchor final_section_anchor,
191
        std::string final_anchor_section_name,
192
        mem_address final_anchor_address,
193
        bool relocates,
194
        bool anchor_to_initial_location,
195
        bool linker_defined,
196
        std::string note);
197
    int create_memory_section (std::string section_name,
198
        mem_address section_size,
199
        mem_address section_alignment,
200
        mem_anchor initial_section_anchor,
201
        std::string initial_anchor_section_name,
202
        mem_address initial_anchor_address,
203
        mem_anchor final_section_anchor,
204
        std::string final_anchor_section_name,
205
        mem_address final_anchor_address,
206
        bool relocates,
207
        bool anchor_to_initial_location,
208
        bool linker_defined,
209
        std::string note);
210
        bool set_map_size (mem_address size);
211
        bool delete_memory_region (std::string name);
212
    bool get_memory_region (std::string region_name,
213
        mem_address * region_address,
214
        mem_address * region_size,
215
        mem_type * region_type,
216
        std::string * note);
217
        int create_memory_region (std::string name, mem_address location,
218
        mem_address size, mem_type type, std::string note);
219
    int edit_memory_region (std::string old_name, std::string new_name, mem_address new_location,
220
        mem_address new_size, mem_type new_type, std::string note);
221
    bool delete_all_memory_sections ();
222
    bool export_files (const wxChar* script_name, const wxChar* header_name);
223
    bool import_linker_defined_sections (const wxChar* filename);
224
    bool save_memory_layout (const wxChar* filename);
225
    bool load_memory_layout (const wxChar* filename);
226
    bool new_memory_layout ();
227
        bool map_modified () { return map_modified_flag; };
228
    bool section_exists (std::string section_name);
229
    std::list <mem_section>::iterator find_memory_section (std::string section_name);
230
    std::list <mem_section>::iterator find_preceding_section (std::list <mem_section>::iterator section, bool initial_location);
231
    std::string error_info;
232
    std::list <mem_region> region_list; // ordered list of memory regions
233
    std::list <mem_section> section_list; // list of memory sections
234
    std::list <std::string> linker_defined_section_list; // list of linker-defined sections
235
 
236
        mem_map();
237
        virtual ~mem_map();
238
 
239
private:
240
    std::list <mem_region>::iterator find_memory_region (std::string);
241
    std::list <mem_region>::iterator find_region_by_address (mem_address);
242
    std::list <mem_region>::iterator find_region_by_section (std::list <mem_section>::iterator section, section_location_type location_type);
243
    mem_address map_size; // total size of memory map
244
    bool add_absolute_section_to_list (std::list <mem_region>::iterator region,
245
        std::list <mem_section>::iterator additional_section,
246
        section_location_type location_type);
247
    bool add_relative_sections_to_list (std::list <mem_region>::iterator region,
248
        std::list <mem_section_view>::iterator section_view,
249
        section_location_type location_type);
250
    bool calc_section_list (std::list <mem_region>::iterator region);
251
    bool calc_section_lists ();
252
    bool at_start_of_region (std::list <mem_section>::iterator section,
253
        std::list <mem_region>::iterator region);
254
    bool at_end_of_region (std::list <mem_section>::iterator section,
255
        std::list <mem_region>::iterator region);
256
        bool absolute_sections_meet (std::list <mem_section>::iterator section1,
257
        std::list <mem_section>::iterator section2);
258
    bool load_memory_section_1 (FILE * stream);
259
    bool load_memory_section_2 (FILE * stream);
260
    bool export_sections (FILE *, FILE *, mem_type);
261
        bool map_modified_flag;
262
    std::string encode_note (std::string);
263
    std::string decode_note (std::string);
264
    std::string encode_section_name (std::string);
265
    std::string decode_section_name (std::string);
266
};
267
 
268
#endif // !defined(AFX_MEMMAP_H__75497C90_17F4_11D2_BFBB_00A0C9554250__INCLUDED_)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.