mingw: make simavr compilable with MinGW
[simavr] / simavr / sim / sim_elf.h
1 /*
2         sim_elf.h
3
4         Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5
6         This file is part of simavr.
7
8         simavr is free software: you can redistribute it and/or modify
9         it under the terms of the GNU General Public License as published by
10         the Free Software Foundation, either version 3 of the License, or
11         (at your option) any later version.
12
13         simavr is distributed in the hope that it will be useful,
14         but WITHOUT ANY WARRANTY; without even the implied warranty of
15         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16         GNU General Public License for more details.
17
18         You should have received a copy of the GNU General Public License
19         along with simavr.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #ifndef __SIM_ELF_H__
23 #define __SIM_ELF_H__
24
25 #include "avr/avr_mcu_section.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #ifndef ELF_SYMBOLS
32 #define ELF_SYMBOLS 1
33 #endif
34
35 /* these are the addresses the gnu linker uses to 
36  * "fake" a non-Harvard addressing space for the AVR
37  */
38 #define AVR_SEGMENT_OFFSET_FLASH 0
39 #define AVR_SEGMENT_OFFSET_EEPROM 0x00810000
40
41 #include "sim_avr.h"
42
43 typedef struct elf_firmware_t {
44         char  mmcu[64];
45         uint32_t        frequency;
46         uint32_t        vcc,avcc,aref;
47
48         char            tracename[128]; // trace filename
49         uint32_t        traceperiod;
50         int                     tracecount;
51         struct {
52                 uint8_t mask;
53                 uint16_t addr;
54                 char    name[64];
55         } trace[32];
56         
57         // register to listen to for commands from the firmware
58         uint16_t        command_register_addr;
59         uint16_t        console_register_addr;
60
61         uint32_t        flashbase;      // base address
62         uint8_t *       flash;
63         uint32_t        flashsize;
64         uint32_t        datasize;
65         uint32_t        bsssize;
66         // read the .eeprom section of the elf, too
67         uint8_t *       eeprom;
68         uint32_t        eesize;
69
70 #if ELF_SYMBOLS
71         avr_symbol_t **  codeline;
72         uint32_t                codesize;       // in elements
73 #endif
74 } elf_firmware_t ;
75
76 int elf_read_firmware(const char * file, elf_firmware_t * firmware);
77
78 void avr_load_firmware(avr_t * avr, elf_firmware_t * firmware);
79
80 #ifdef __cplusplus
81 };
82 #endif
83
84 #endif /*__SIM_ELF_H__*/