cores: No standard include paths
authorStephan Veigl <veigl@gmx.net>
Fri, 30 Nov 2012 09:35:06 +0000 (10:35 +0100)
committerStephan Veigl <veigl@gmx.net>
Fri, 30 Nov 2012 09:35:06 +0000 (10:35 +0100)
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 <stdio.h> from core definition files
- move init message from core definition files to avr_init() in sim_avr.c

Signed-off-by: Stephan Veigl <veigl@gmx.net>
15 files changed:
Makefile.common
simavr/cores/sim_90usb162.c
simavr/cores/sim_mega128.c
simavr/cores/sim_mega1280.c
simavr/cores/sim_mega1281.c
simavr/cores/sim_megax.c
simavr/cores/sim_megax4.c
simavr/cores/sim_megax8.c
simavr/cores/sim_megaxm1.c
simavr/cores/sim_tiny13.c
simavr/cores/sim_tiny2313.c
simavr/cores/sim_tinyx4.c
simavr/cores/sim_tinyx5.c
simavr/sim/avr_usb.h
simavr/sim/sim_avr.c

index 3658ae5..813901f 100644 (file)
@@ -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 $<
index 9d70076..3cdc647 100644 (file)
@@ -19,7 +19,6 @@
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
 #include "sim_avr.h"
 #include "sim_core_declare.h"
 #include "avr_eeprom.h"
index a182255..355b941 100644 (file)
@@ -19,7 +19,6 @@
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
 #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);
index d2f7cc6..9ed040c 100644 (file)
@@ -19,7 +19,6 @@
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
 #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);
index bf42988..a8a80bb 100644 (file)
@@ -19,7 +19,6 @@
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
 #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);
index a9e3ca5..80528e0 100644 (file)
@@ -19,7 +19,6 @@
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
 #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);
index efd5ede..58500bd 100644 (file)
@@ -18,7 +18,7 @@
        You should have received a copy of the GNU General Public License
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdio.h>
+
 #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);
index 423622f..46a3519 100644 (file)
@@ -18,7 +18,7 @@
        You should have received a copy of the GNU General Public License
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdio.h>
+
 #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);
index 1e2d669..ceefd53 100644 (file)
@@ -18,7 +18,7 @@
        You should have received a copy of the GNU General Public License
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdio.h>
+
 #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;
 }
index 796a4dc..0df8739 100644 (file)
@@ -20,7 +20,6 @@
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include </usr/include/stdio.h>
 #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);
index 54b9e7c..54d2a46 100644 (file)
@@ -19,7 +19,6 @@
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include </usr/include/stdio.h>
 #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);
index f9669bc..33d44c6 100644 (file)
@@ -20,7 +20,6 @@
     along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
 #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);
index 13b7366..d698caa 100644 (file)
@@ -20,7 +20,6 @@
        along with simavr.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
 #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);
index fe9337b..17e5c0d 100644 (file)
@@ -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
index 1bc169d..0eb7c9e 100644 (file)
@@ -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;