From: Stephan Veigl Date: Fri, 30 Nov 2012 09:35:06 +0000 (+0100) Subject: cores: No standard include paths X-Git-Tag: v1.1~26^2~1 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=e8f6b397420f9d862e37f667982a7807fb79a18d;p=sx%2Fsimavr.git cores: No standard include paths There are problems with standard includes since the paths are ambiguous between host and AVR. Using absolute includes does not work for multi-platform projects. The solution is to remove all standard includes of the host system for the core files since there is no reason why a core definition should require standard includes from the host system. User interaction (status messages) is the job of the simulator and not the core definitions. - add CORE_CFLAGS (-nostdinc) to Makefile.common - remove from core definition files - move init message from core definition files to avr_init() in sim_avr.c Signed-off-by: Stephan Veigl --- diff --git a/Makefile.common b/Makefile.common index 3658ae5..813901f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -41,6 +41,7 @@ ARCH = ${shell $(CC) -dumpmachine | sed -e 's/^x/i/' -e 's/\(.\).*/\1/'} CFLAGS += -O2 -Wall CFLAGS += -g +CORE_CFLAGS = -nostdinc ifeq (${shell uname}, Darwin) # gcc 4.2 from MacOS is really not up to scratch anymore @@ -119,11 +120,11 @@ endif # this rule has precedence ${OBJ}/sim_%.o : cores/sim_%.c ifeq ($(V),1) - $(CC) $(CPPFLAGS) $(CFLAGS) -MMD \ + $(CC) $(CPPFLAGS) $(CFLAGS) $(CORE_CFLAGS) -MMD \ ${AVR_CPPFLAGS} \ $< -c -o $@ else - @$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS) -MMD \ + @$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS) $(CORE_CFLAGS) -MMD \ ${AVR_CPPFLAGS} \ $< -c -o $@ @echo CORE $< diff --git a/simavr/cores/sim_90usb162.c b/simavr/cores/sim_90usb162.c index 9d70076..3cdc647 100644 --- a/simavr/cores/sim_90usb162.c +++ b/simavr/cores/sim_90usb162.c @@ -19,7 +19,6 @@ along with simavr. If not, see . */ -#include #include "sim_avr.h" #include "sim_core_declare.h" #include "avr_eeprom.h" diff --git a/simavr/cores/sim_mega128.c b/simavr/cores/sim_mega128.c index a182255..355b941 100644 --- a/simavr/cores/sim_mega128.c +++ b/simavr/cores/sim_mega128.c @@ -19,7 +19,6 @@ along with simavr. If not, see . */ -#include #include "sim_avr.h" #include "sim_core_declare.h" #include "avr_eeprom.h" @@ -493,8 +492,6 @@ avr_kind_t mega128 = { void m128_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - - printf("%s init\n", avr->mmcu); avr_eeprom_init(avr, &mcu->eeprom); avr_flash_init(avr, &mcu->selfprog); diff --git a/simavr/cores/sim_mega1280.c b/simavr/cores/sim_mega1280.c index d2f7cc6..9ed040c 100644 --- a/simavr/cores/sim_mega1280.c +++ b/simavr/cores/sim_mega1280.c @@ -19,7 +19,6 @@ along with simavr. If not, see . */ -#include #include "sim_avr.h" #include "sim_core_declare.h" #include "avr_eeprom.h" @@ -776,8 +775,6 @@ avr_kind_t mega1280 = { void m1280_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - - //printf("%s init\n", avr->mmcu); avr_eeprom_init(avr, &mcu->eeprom); avr_flash_init(avr, &mcu->selfprog); diff --git a/simavr/cores/sim_mega1281.c b/simavr/cores/sim_mega1281.c index bf42988..a8a80bb 100644 --- a/simavr/cores/sim_mega1281.c +++ b/simavr/cores/sim_mega1281.c @@ -19,7 +19,6 @@ along with simavr. If not, see . */ -#include #include "sim_avr.h" #include "sim_core_declare.h" #include "avr_eeprom.h" @@ -521,8 +520,6 @@ avr_kind_t mega1281 = { void m1281_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - - printf("%s init\n", avr->mmcu); avr_eeprom_init(avr, &mcu->eeprom); avr_flash_init(avr, &mcu->selfprog); diff --git a/simavr/cores/sim_megax.c b/simavr/cores/sim_megax.c index a9e3ca5..80528e0 100644 --- a/simavr/cores/sim_megax.c +++ b/simavr/cores/sim_megax.c @@ -19,7 +19,6 @@ along with simavr. If not, see . */ -#include #include "sim_avr.h" @@ -29,8 +28,6 @@ void mx_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - printf("%s init\n", avr->mmcu); - avr_eeprom_init(avr, &mcu->eeprom); avr_flash_init(avr, &mcu->selfprog); avr_watchdog_init(avr, &mcu->watchdog); diff --git a/simavr/cores/sim_megax4.c b/simavr/cores/sim_megax4.c index efd5ede..58500bd 100644 --- a/simavr/cores/sim_megax4.c +++ b/simavr/cores/sim_megax4.c @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with simavr. If not, see . */ -#include + #include "sim_avr.h" #include "sim_megax4.h" @@ -26,8 +26,6 @@ void mx4_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - - printf("%s init\n", avr->mmcu); avr_eeprom_init(avr, &mcu->eeprom); avr_flash_init(avr, &mcu->selfprog); diff --git a/simavr/cores/sim_megax8.c b/simavr/cores/sim_megax8.c index 423622f..46a3519 100644 --- a/simavr/cores/sim_megax8.c +++ b/simavr/cores/sim_megax8.c @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with simavr. If not, see . */ -#include + #include "sim_avr.h" #include "sim_megax8.h" @@ -27,8 +27,6 @@ void mx8_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - printf("%s init\n", avr->mmcu); - avr_eeprom_init(avr, &mcu->eeprom); avr_flash_init(avr, &mcu->selfprog); avr_watchdog_init(avr, &mcu->watchdog); diff --git a/simavr/cores/sim_megaxm1.c b/simavr/cores/sim_megaxm1.c index 1e2d669..ceefd53 100644 --- a/simavr/cores/sim_megaxm1.c +++ b/simavr/cores/sim_megaxm1.c @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with simavr. If not, see . */ -#include + #include "sim_avr.h" #include "sim_megaxm1.h" @@ -27,8 +27,6 @@ void mxm1_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - printf("%s init\n", avr->mmcu); - avr_eeprom_init(avr, &mcu->eeprom); avr_flash_init(avr, &mcu->selfprog); avr_watchdog_init(avr, &mcu->watchdog); @@ -47,6 +45,6 @@ void mxm1_init(struct avr_t * avr) void mxm1_reset(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - printf("%s reset\n", avr->mmcu); + avr->data[ mcu->lin.r_linbtr] = 0x20; } diff --git a/simavr/cores/sim_tiny13.c b/simavr/cores/sim_tiny13.c index 796a4dc..0df8739 100644 --- a/simavr/cores/sim_tiny13.c +++ b/simavr/cores/sim_tiny13.c @@ -20,7 +20,6 @@ along with simavr. If not, see . */ -#include #include "sim_avr.h" #include "sim_core_declare.h" #include "avr_eeprom.h" @@ -134,8 +133,6 @@ static void init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - printf("%s init\n", avr->mmcu); - avr_eeprom_init(avr, &mcu->eeprom); avr_watchdog_init(avr, &mcu->watchdog); avr_extint_init(avr, &mcu->extint); diff --git a/simavr/cores/sim_tiny2313.c b/simavr/cores/sim_tiny2313.c index 54b9e7c..54d2a46 100644 --- a/simavr/cores/sim_tiny2313.c +++ b/simavr/cores/sim_tiny2313.c @@ -19,7 +19,6 @@ along with simavr. If not, see . */ -#include #include "sim_core_declare.h" #include "avr_eeprom.h" #include "avr_watchdog.h" @@ -226,8 +225,6 @@ static void init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - printf("%s init\n", avr->mmcu); - avr_eeprom_init(avr, &mcu->eeprom); avr_watchdog_init(avr, &mcu->watchdog); avr_extint_init(avr, &mcu->extint); diff --git a/simavr/cores/sim_tinyx4.c b/simavr/cores/sim_tinyx4.c index f9669bc..33d44c6 100644 --- a/simavr/cores/sim_tinyx4.c +++ b/simavr/cores/sim_tinyx4.c @@ -20,7 +20,6 @@ along with simavr. If not, see . */ -#include #include "sim_avr.h" #include "sim_tinyx4.h" @@ -29,8 +28,6 @@ void tx4_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - printf("%s init\n", avr->mmcu); - avr_eeprom_init(avr, &mcu->eeprom); avr_watchdog_init(avr, &mcu->watchdog); avr_extint_init(avr, &mcu->extint); diff --git a/simavr/cores/sim_tinyx5.c b/simavr/cores/sim_tinyx5.c index 13b7366..d698caa 100644 --- a/simavr/cores/sim_tinyx5.c +++ b/simavr/cores/sim_tinyx5.c @@ -20,7 +20,6 @@ along with simavr. If not, see . */ -#include #include "sim_avr.h" #include "sim_tinyx5.h" @@ -29,8 +28,6 @@ void tx5_init(struct avr_t * avr) { struct mcu_t * mcu = (struct mcu_t*)avr; - printf("%s init\n", avr->mmcu); - avr_eeprom_init(avr, &mcu->eeprom); avr_watchdog_init(avr, &mcu->watchdog); avr_extint_init(avr, &mcu->extint); diff --git a/simavr/sim/avr_usb.h b/simavr/sim/avr_usb.h index fe9337b..17e5c0d 100644 --- a/simavr/sim/avr_usb.h +++ b/simavr/sim/avr_usb.h @@ -43,7 +43,7 @@ enum { struct avr_io_usb { uint8_t pipe; //[in] - size_t sz; //[in/out] + uint32_t sz; //[in/out] uint8_t * buf; //[in/out] }; #define AVR_IOCTL_USB_NAK -2 diff --git a/simavr/sim/sim_avr.c b/simavr/sim/sim_avr.c index 1bc169d..0eb7c9e 100644 --- a/simavr/sim/sim_avr.c +++ b/simavr/sim/sim_avr.c @@ -43,6 +43,8 @@ int avr_init(avr_t * avr) #ifdef CONFIG_SIMAVR_TRACE avr->trace_data = calloc(1, sizeof(struct avr_trace_data_t)); #endif + + printf("%s init\n", avr->mmcu); // cpu is in limbo before init is finished. avr->state = cpu_Limbo; @@ -81,6 +83,8 @@ void avr_terminate(avr_t * avr) void avr_reset(avr_t * avr) { + printf("%s reset\n", avr->mmcu); + memset(avr->data, 0x0, avr->ramend + 1); _avr_sp_set(avr, avr->ramend); avr->pc = 0;