OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [win32/] [memmap.h] - Blame information for rev 790

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

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