simulavr  1.1.0
memory.h
Go to the documentation of this file.
1  /*
2  ****************************************************************************
3  *
4  * simulavr - A simulator for the Atmel AVR family of microcontrollers.
5  * Copyright (C) 2001, 2002, 2003 Klaus Rudolph
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  ****************************************************************************
22  *
23  * $Id$
24  */
25 
26 #ifndef MEMORY
27 #define MEMORY
28 
29 #include <string>
30 #include <map>
31 
32 #include "decoder.h"
33 #include "avrmalloc.h"
34 
36 
38 class Memory {
39  protected:
40 
41  unsigned int size;
43  public:
44 
45  unsigned char *myMemory;
48  std::multimap<unsigned int, std::string> sym;
49 
53  Memory(int size);
54 
56  virtual ~Memory() { avr_free(myMemory); }
57 
66  std::string GetSymbolAtAddress(unsigned int add);
67 
77  unsigned int GetAddressAtSymbol(const std::string &s);
78 
82  void AddSymbol(std::pair<unsigned int, std::string> p) { sym.insert(p); }
83 
85  unsigned int GetSize() { return size; }
86 
88  virtual void WriteMem(const unsigned char*, unsigned int offset, unsigned int size) = 0;
89 };
90 
92 
95 class Data : public Memory {
96  public:
98  Data(): Memory(0) {}
99  void WriteMem(const unsigned char*, unsigned int offset, unsigned int size) {}
100 };
101 
102 #endif
std::string GetSymbolAtAddress(unsigned int add)
Definition: memory.cpp:67
unsigned char * myMemory
Definition: memory.h:45
void avr_free(void *ptr)
Free malloc&#39;d memory.
Definition: avrmalloc.cpp:182
Data()
Definition: memory.h:98
std::multimap< unsigned int, std::string > sym
Definition: memory.h:48
Memory(int size)
Definition: memory.cpp:109
void AddSymbol(std::pair< unsigned int, std::string > p)
Definition: memory.h:82
unsigned int GetSize()
Definition: memory.h:85
unsigned int size
Definition: memory.h:41
virtual void WriteMem(const unsigned char *, unsigned int offset, unsigned int size)=0
unsigned int GetAddressAtSymbol(const std::string &s)
Definition: memory.cpp:35
Hold a memory block and symbol informations.
Definition: memory.h:38
virtual ~Memory()
Definition: memory.h:56
Hold data memory block and symbol informations.
Definition: memory.h:95
void WriteMem(const unsigned char *, unsigned int offset, unsigned int size)
Definition: memory.h:99