12 * @brief Abstraction of program file formats
14 * A single section of the program. Contains the data
15 * associated with a specific address range and location (Flash or Eeprom)
19 enum Type
{ NONE
, FLASH
, EEPROM
};
20 Section() : type(NONE
), addr(0), siz(0), d(0) {}
21 Section(Type type
, unsigned int address
, unsigned int size
);
25 void init(Type type
, unsigned int address
, unsigned int size
);
29 unsigned char *data() { return d
; }
30 unsigned int size() const { return siz
; }
31 unsigned int address() const { return addr
; }
32 bool isFlash() const { return type
== FLASH
; }
33 bool isEeprom() const { return type
== EEPROM
; }
45 * @brief Abstraction of a Program
47 * Abstraction of a Program, contains methods for
48 * loading files and reading sections.
49 * Additionally, it stores the symbols with the program
50 * and has convenient lookup functions for flash and data
59 * Opens and loads a file.
61 virtual void load(const char * filename
) = 0;
64 * Reads the next available section from the file
65 * and returns the data in \e sec.
67 * \returns false if no further sections are available.
69 virtual bool readNextSection(Section
& sec
) = 0;
72 const std::string
& functionName(int addr
) const;
73 const std::string
& dataName(int addr
) const;
75 int functionAddress(const std::string
& name
) const;
76 int dataAddress(const std::string
& name
) const;
79 void addSymbolFlash(int addr
, const char *name
);
80 void addSymbolEeprom(int addr
, const char *name
);
81 void addSymbolRam(int addr
, const char *name
);
84 typedef std::map
<int, std::string
> SymTable
;
85 SymTable flashSymbols
;
88 static const std::string empty
;
91 inline Section::Section(Type type
, unsigned int address
, unsigned int size
) {
92 init( type
, address
, size
);
95 inline Section::~Section() {
99 inline void Section::init(Type type
, unsigned int address
, unsigned int size
) {
101 this->addr
= address
;
104 this->d
= new unsigned char[size
];
107 inline void Section::clear() {
120 #endif /*AVR_PROGRAM_H*/