-
Notifications
You must be signed in to change notification settings - Fork 21
/
data_memory.h
73 lines (57 loc) · 2.16 KB
/
data_memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// data_memory.h -- May 9, 2009
// by geohot
// part of "The Embedded Disassembler"
// released under GPLv3, see http://gplv3.fsf.org/
//
// This is the main EDA database class
#ifndef EDA_DATAMEMORY_H_
#define EDA_DATAMEMORY_H_
#include "data.h"
namespace eda {
// The main EDA database store
class Memory {
// The destruction of a Memory object is too much for EDA
public:
// Create an empty chunk of memory
Address* AllocateSegment(const string& name_first, int length);
Address* AllocateSegment(uint32_t address_32, int length);
// Save and Load from file
// These are going to be very hard to write
// They should call Serialize and Deserialize functions in every subclass
// These will be written closer to the end
void LoadFromFile(const string& filename);
void SaveToFile(const string& filename);
// Resolve a memory access
// Does a lookup in the space_ map
Address* get_address_by_location(uint32_t address_32);
Address* get_address_by_name(const string& name);
// Rename an Address
// Could move to Address, but then it would need to know what Memory owns it
void Rename(Address* address, const std::string& name);
// Commit a changelist to Memory
// Also add it to the history
void Commit(Changelist* change);
// Resolve a complicated string
// Output is filled
uint32_t ResolveToNumber(int changelist_number, const string& stateless);
Address* ResolveToAddress(int changelist_number, const string& stateless);
// The entire history of this memory
// Not sure what to do about the publicness of this
History history_;
private:
// This is the actual backend store for memory segments
// A pointer to these elements exists in either space_ or named_
// This could be used for garbage collection
// If the addresses actually lived inside the vector,
// We couldn't resize segments
vector<vector<Address*>* > segments_;
// Creates a segment but makes it inaccessible
// That's why it's private
vector<Address*>* AllocateSegment(int length);
// An address can exist in either of these or both
// Registers do not exist in space_, just named_
map<uint32_t, vector<Address*>* > space_;
map<string, Address* > named_;
};
}
#endif