From 50caf5d4a20ae4de23f5f588da46906d4ef046eb Mon Sep 17 00:00:00 2001
From: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Date: Tue, 27 Nov 2012 18:27:56 +0000
Subject: [PATCH 1/3] add new architecture AVR4 (atmega8)

Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
---
 src/Makefile  |   20 +++++++++++++++++---
 src/common.mk |    6 ++++++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index c203a61..24d2040 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -33,9 +33,9 @@
 
 include common.mk
 
-all: avr5-lib avr3-lib avr2-lib
+all: avr5-lib avr4-lib avr3-lib avr2-lib
 
-install: avr5-lib-install avr3-lib-install avr2-lib-install
+install: avr5-lib-install avr4-lib-install avr3-lib-install avr2-lib-install
 	install -m644 avr-thread.h ${includedir}
 
 avr2-lib: avr2-debug avr2
@@ -50,6 +50,12 @@ avr3-lib: avr3-debug avr3
 	cp common.mk avr3
 	cd avr3; $(MAKE) -f ../Makefile AVR_ARCH=3 DEBUG_STACK_USAGE=0 libavr-thread.a
 
+avr4-lib: avr4-debug avr4
+	cp common.mk avr4-debug
+	cd avr4-debug; $(MAKE) -f ../Makefile AVR_ARCH=4 DEBUG_STACK_USAGE=1 libavr-thread-debug.a
+	cp common.mk avr4
+	cd avr4; $(MAKE) -f ../Makefile AVR_ARCH=4 DEBUG_STACK_USAGE=0 libavr-thread.a
+
 avr5-lib: avr5-debug avr5
 	cp common.mk avr5-debug
 	cd avr5-debug; $(MAKE) -f ../Makefile AVR_ARCH=5 DEBUG_STACK_USAGE=1 libavr-thread-debug.a
@@ -64,6 +70,10 @@ avr3-lib-install: avr3-lib
 	install -m644 avr3-debug/libavr-thread-debug.a ${libdir}/avr3
 	install -m644 avr3/libavr-thread.a ${libdir}/avr3
 
+avr4-lib-install: avr4-lib
+	install -m644 avr4-debug/libavr-thread-debug.a ${libdir}/avr4
+	install -m644 avr4/libavr-thread.a ${libdir}/avr4
+
 avr5-lib-install: avr5-lib
 	install -m644 avr5-debug/libavr-thread-debug.a ${libdir}/avr5
 	install -m644 avr5/libavr-thread.a ${libdir}/avr5
@@ -76,13 +86,17 @@ avr3:
 	mkdir $@
 avr3-debug:
 	mkdir $@
+avr4:
+	mkdir $@
+avr4-debug:
+	mkdir $@
 avr5:
 	mkdir $@
 avr5-debug:
 	mkdir $@
 
 clean distclean:
-	-rm -rf avr2-debug avr2 avr3-debug avr3 avr5-debug avr5
+	-rm -rf avr2-debug avr2 avr3-debug avr3 avr4-debug avr4 avr5-debug avr5
 
 %.o : %.c ; $(CC) $(CFLAGS) -c -o $*.o $<
 
diff --git a/src/common.mk b/src/common.mk
index 5ca1cc3..9dc8a5d 100755
--- a/src/common.mk
+++ b/src/common.mk
@@ -69,6 +69,11 @@ ifeq ($(AVR_ARCH),3)
     FLAGS += -O2
     VPATH=..
 else
+ifeq ($(AVR_ARCH),4)
+    PART = atmega8
+    FLAGS += -Os
+    VPATH=..
+else
 ifeq ($(AVR_ARCH),5)
     PART = atmega128
     FLAGS += -Os
@@ -80,6 +85,7 @@ endif
 endif
 endif
 endif
+endif
 
 FLAGS += -mmcu=$(PART) -I..
 
-- 
1.7.8.6


From bc3483a49f1f9ab4b74b66462bfafdb3e507122a Mon Sep 17 00:00:00 2001
From: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Date: Tue, 27 Nov 2012 18:30:44 +0000
Subject: [PATCH 2/3] add one more architecture AVR51 (atmega1284p)

Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
---
 src/Makefile  |   20 +++++++++++++++++---
 src/common.mk |    6 ++++++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 24d2040..40df829 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -33,9 +33,9 @@
 
 include common.mk
 
-all: avr5-lib avr4-lib avr3-lib avr2-lib
+all: avr51-lib avr5-lib avr4-lib avr3-lib avr2-lib
 
-install: avr5-lib-install avr4-lib-install avr3-lib-install avr2-lib-install
+install: avr51-lib-install avr5-lib-install avr4-lib-install avr3-lib-install avr2-lib-install
 	install -m644 avr-thread.h ${includedir}
 
 avr2-lib: avr2-debug avr2
@@ -62,6 +62,12 @@ avr5-lib: avr5-debug avr5
 	cp common.mk avr5
 	cd avr5; $(MAKE) -f ../Makefile AVR_ARCH=5 DEBUG_STACK_USAGE=0 libavr-thread.a
 
+avr51-lib: avr51-debug avr51
+	cp common.mk avr51-debug
+	cd avr51-debug; $(MAKE) -f ../Makefile AVR_ARCH=51 DEBUG_STACK_USAGE=1 libavr-thread-debug.a
+	cp common.mk avr51
+	cd avr51; $(MAKE) -f ../Makefile AVR_ARCH=51 DEBUG_STACK_USAGE=0 libavr-thread.a
+
 avr2-lib-install: avr2-lib
 	install -m644 avr2-debug/libavr-thread-debug.a ${libdir}
 	install -m644 avr2/libavr-thread.a ${libdir}
@@ -78,6 +84,10 @@ avr5-lib-install: avr5-lib
 	install -m644 avr5-debug/libavr-thread-debug.a ${libdir}/avr5
 	install -m644 avr5/libavr-thread.a ${libdir}/avr5
 
+avr51-lib-install: avr51-lib
+	install -m644 avr51-debug/libavr-thread-debug.a ${libdir}/avr51
+	install -m644 avr51/libavr-thread.a ${libdir}/avr51
+
 avr2:
 	mkdir $@
 avr2-debug:
@@ -94,9 +104,13 @@ avr5:
 	mkdir $@
 avr5-debug:
 	mkdir $@
+avr51:
+	mkdir $@
+avr51-debug:
+	mkdir $@
 
 clean distclean:
-	-rm -rf avr2-debug avr2 avr3-debug avr3 avr4-debug avr4 avr5-debug avr5
+	-rm -rf avr2-debug avr2 avr3-debug avr3 avr4-debug avr4 avr5-debug avr5 avr51-debug avr51
 
 %.o : %.c ; $(CC) $(CFLAGS) -c -o $*.o $<
 
diff --git a/src/common.mk b/src/common.mk
index 9dc8a5d..a75a4b7 100755
--- a/src/common.mk
+++ b/src/common.mk
@@ -79,6 +79,11 @@ ifeq ($(AVR_ARCH),5)
     FLAGS += -Os
     VPATH=..
 else
+ifeq ($(AVR_ARCH),51)
+    PART = atmega1284p
+    FLAGS += -Os
+    VPATH=..
+else
 ifdef AVR_ARCH 
     $(error Unsupported architecture: $(AVR_ARCH))
 endif
@@ -86,6 +91,7 @@ endif
 endif
 endif
 endif
+endif
 
 FLAGS += -mmcu=$(PART) -I..
 
-- 
1.7.8.6


From 87b274fdc6d1190051b87396b6a1eb967fd4b0ed Mon Sep 17 00:00:00 2001
From: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Date: Tue, 27 Nov 2012 22:08:41 +0000
Subject: [PATCH 3/3] extend support for AVR51 (atmega1284p)

Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
---
 src/avr-thread-isr.S    |    4 ++--
 src/avr-thread-switch.S |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/avr-thread-isr.S b/src/avr-thread-isr.S
index 9849a20..58f5f99 100755
--- a/src/avr-thread-isr.S
+++ b/src/avr-thread-isr.S
@@ -159,7 +159,7 @@ avr_thread_isr_end:
 	in tmp_reg,_SFR_IO_ADDR(SREG)
         push tmp_reg
 	cli
-#if __AVR_ARCH__ == 3 || __AVR_ARCH__ == 5
+#if __AVR_ARCH__ == 3 || __AVR_ARCH__ == 5 || __AVR_ARCH__ == 51
 	call avr_thread_find_next
 #else
 	rcall avr_thread_find_next
@@ -186,7 +186,7 @@ avr_thread_isr_end:
 	in tmp_reg,_SFR_IO_ADDR(SREG)
         push tmp_reg
 	cli
-#if __AVR_ARCH__ == 3 || __AVR_ARCH__ == 5
+#if __AVR_ARCH__ == 3 || __AVR_ARCH__ == 5 || __AVR_ARCH__ == 51
 	call avr_thread_tick_only
 #else
 	rcall avr_thread_tick_only
diff --git a/src/avr-thread-switch.S b/src/avr-thread-switch.S
index d6b3e9b..22538ed 100755
--- a/src/avr-thread-switch.S
+++ b/src/avr-thread-switch.S
@@ -97,7 +97,7 @@ avr_thread_switch:
 	in tmp_reg,_SFR_IO_ADDR(SREG)
         push tmp_reg
 	cli
-#if __AVR_ARCH__ == 3 || __AVR_ARCH__ == 5
+#if __AVR_ARCH__ == 3 || __AVR_ARCH__ == 5 || __AVR_ARCH__ == 51
 	call avr_thread_find_next
 #else
 	rcall avr_thread_find_next
-- 
1.7.8.6

