Joerg Desch wrote on Freitag, 2. Juni 2006 13:35 :
> First of all I want to say thanks to Björn Haase for his 256x patches.
>
> I've built the avr toolchain today. I'm using Ubuntu Warty (nearly the
> same as debian sarge) as host system. The toolchain is built with gcc
> 3.3.4 (default of warty).
>
> The patches I used are:
> mega_256x_avrlibc_5.patch.txt
The most recent versions carry the suffix "_6". The header files for 256x 
should rather be taken from Anatoly's (aesok) post than from my the _5 patch:

http://savannah.nongnu.org/patch/?func=detailitem&item_id=4461

Additionally, I found one issue in libm where some error return function pops 
2 bytes in order to simulate the effect of one "ret". (Patch attached).

> mega_256x_binutils_5.patch.txt
There should no longer be any need for patching binutils. It's already 
commited to mainline cvs.

> mega_256x_gcc_5.patch.txt
Here also patch _6 is the newest.

Concerning the way, varargs are supposed to be used, I cannot answer your 
question right now. In fact, I don't have any idea on how this is 
implemented.
For your printf tests, did you use the pmem variant or the ram variant? It 
might be that the register responsible for the high byte of the address 
(RAMPZ ?) for lpm instructions does not contain the correct value.? 

Unfortunately I am extremely busy right now, so that I cannot spend time on 
testing.

Bjoern.
Index: fp_split.S
===================================================================
RCS file: /sources/avr-libc/avr-libc/libm/fplib/fp_split.S,v
retrieving revision 1.9
diff -U12 -r1.9 fp_split.S
--- fp_split.S	5 Dec 2005 22:05:53 -0000	1.9
+++ fp_split.S	26 May 2006 17:19:59 -0000
@@ -80,24 +80,27 @@
     ADD     rA2,rA2        ; MSB of exponent to carry
     adc     rA3,rA3        ; whole exponent in rA3, sign in C
     CPI     rA3,0xFF       ; if no jump then C as hidden one is set
     BREQ    .L_fp_split_nan
     CLR     rAE            ; clear fraction extension
     cp      rAE,rA3        ; set C if nonzero exponent.  -MM 2000-11-25
     brcs    1f
     ldi     rA3,1          ; zero exponent really means 1 with hidden bit = 0
 1:
     ROR     rA2            ; sets hidden bit
     RET
 .L_fp_split_nan:
+#ifdef __AVR_3_BYTE_PC__
+    POP     rA3
+#endif    
     POP     rA3
     POP     rA3            ; pop return adress
  #ifdef __ERRNO__
     LDI     rA3,EDOM       ; NaN is argument domain error !
  #endif
     clr     r1
     RJMP    _U(__fp_nan)
 
           ENDFUNC
 
 /*
  *----------------------------------------------------------------------------------------------
@@ -119,24 +122,27 @@
 	adc	rA3, rA3	; whole exponent in rA3, sign in C
 	CPI	rA3, 0xFF	; if no jump then C as hidden one is set
 	BREQ	.L_fp_split_a_nan
 	CLR	rAE		; clear fraction extension
 	CP	rAE, rA3	; set C if nonzero exponent.  
 	BRCS	1f
 	LDI	rA3, 1		; zero exponent really means 1 with hidden bit = 0
 1:
 	ROR	rA2		; sets hidden bit
 	RET
 	
 .L_fp_split_a_nan:
+#ifdef __AVR_3_BYTE_PC__
+        POP     rA3
+#endif    
 	POP	rA3
 	POP	rA3		; pop return adress
  #ifdef __ERRNO__
 	LDI	rA3, EDOM	; NaN is argument domain error !
  #endif
 	CLR	r1
 	RJMP	_U(__fp_nan)
 
 	ENDFUNC
 
 
 #endif /* not __DOXYGEN__ */
Index: libgcc.S
===================================================================
--- libgcc.S	(revision 113395)
+++ libgcc.S	(working copy)
@@ -593,7 +593,12 @@
 	out	__SP_H__,r29
 	out	__SREG__,__tmp_reg__
 	out	__SP_L__,r28
+#if defined (__AVR_3_BYTE_PC__)
+	eijmp
+#else
 	ijmp
+#endif
+
 .endfunc
 #endif /* defined (L_prologue) */
 
@@ -672,13 +677,22 @@
 	lpm	__tmp_reg__, Z+
 	lpm	r31, Z
 	mov	r30, __tmp_reg__
+
+#if defined (__AVR_3_BYTE_PC__)
+	eijmp
+#else
 	ijmp
+#endif
+
 #else
 	lpm
 	adiw	r30, 1
 	push	r0
 	lpm
 	push	r0
+#if defined (__AVR_3_BYTE_PC__)
+        push    __zero_reg__
+#endif
 	ret
 #endif
 	.endfunc
Index: avr.md
===================================================================
--- avr.md	(revision 113395)
+++ avr.md	(working copy)
@@ -2101,22 +2101,47 @@
   "(register_operand (operands[0], HImode) || CONSTANT_P (operands[0]))"
   "*{
   if (which_alternative==0)
-     return \"icall\";
+    {
+      if (AVR_3_BYTE_PC)
+        return \"eicall\";
+      else
+        return \"icall\";
+    }
   else if (which_alternative==1)
     {
       if (AVR_ENHANCED)
-	return (AS2 (movw, r30, %0) CR_TAB
-		\"icall\");
+        {
+          if (AVR_3_BYTE_PC)
+            return (AS2 (movw, r30, %0) CR_TAB
+                    \"eicall\");
+          else
+            return (AS2 (movw, r30, %0) CR_TAB
+                    \"icall\");
+        }
       else
-	return (AS2 (mov, r30, %A0) CR_TAB
-		AS2 (mov, r31, %B0) CR_TAB
-		\"icall\");
+        {
+          if (AVR_3_BYTE_PC)
+	    return (AS2 (mov, r30, %A0) CR_TAB
+                    AS2 (mov, r31, %B0) CR_TAB
+                    \"eicall\");
+          else
+	    return (AS2 (mov, r30, %A0) CR_TAB
+                    AS2 (mov, r31, %B0) CR_TAB
+                    \"icall\");
+        }
     }
   else if (which_alternative==2)
     return AS1(%~call,%c0);
-  return (AS2 (ldi,r30,lo8(%0)) CR_TAB
-          AS2 (ldi,r31,hi8(%0)) CR_TAB
-          \"icall\");
+
+
+  if (AVR_3_BYTE_PC)
+    return (AS2 (ldi,r30,lo8(%0)) CR_TAB
+            AS2 (ldi,r31,hi8(%0)) CR_TAB
+            \"eicall\");
+  else
+    return (AS2 (ldi,r30,lo8(%0)) CR_TAB
+            AS2 (ldi,r31,hi8(%0)) CR_TAB
+            \"icall\");
 }"
   [(set_attr "cc" "clobber,clobber,clobber,clobber")
    (set_attr_alternative "length"
@@ -2138,22 +2163,46 @@
   "(register_operand (operands[0], VOIDmode) || CONSTANT_P (operands[0]))"
   "*{
   if (which_alternative==0)
-     return \"icall\";
+    {
+      if (AVR_3_BYTE_PC)
+        return \"eicall\";
+      else
+        return \"icall\";
+    }
   else if (which_alternative==1)
     {
       if (AVR_ENHANCED)
-	return (AS2 (movw, r30, %1) CR_TAB
-		\"icall\");
+        {
+          if (AVR_3_BYTE_PC)
+            return (AS2 (movw, r30, %1) CR_TAB
+                    \"eicall\");
+          else
+            return (AS2 (movw, r30, %1) CR_TAB
+                    \"icall\");
+        }
       else
-	return (AS2 (mov, r30, %A1) CR_TAB
-		AS2 (mov, r31, %B1) CR_TAB
-		\"icall\");
+        {
+          if (AVR_3_BYTE_PC)
+            return (AS2 (mov, r30, %A1) CR_TAB
+                    AS2 (mov, r31, %B1) CR_TAB
+                    \"eicall\");
+          else
+            return (AS2 (mov, r30, %A1) CR_TAB
+                    AS2 (mov, r31, %B1) CR_TAB
+                    \"icall\");
+        }
     }
   else if (which_alternative==2)
     return AS1(%~call,%c1);
-  return (AS2 (ldi, r30, lo8(%1)) CR_TAB
-          AS2 (ldi, r31, hi8(%1)) CR_TAB
-          \"icall\");
+
+  if (AVR_3_BYTE_PC)
+    return (AS2 (ldi, r30, lo8(%1)) CR_TAB
+            AS2 (ldi, r31, hi8(%1)) CR_TAB
+            \"eicall\");
+  else
+    return (AS2 (ldi, r30, lo8(%1)) CR_TAB
+            AS2 (ldi, r31, hi8(%1)) CR_TAB
+            \"icall\");
 }"
   [(set_attr "cc" "clobber,clobber,clobber,clobber")
    (set_attr_alternative "length"
@@ -2183,13 +2232,20 @@
 ; indirect jump
 (define_insn "indirect_jump"
   [(set (pc) (match_operand:HI 0 "register_operand" "!z,*r"))]
-  ""
+  "AVR_2_BYTE_PC"
   "@
 	ijmp
 	push %A0\;push %B0\;ret"
   [(set_attr "length" "1,3")
    (set_attr "cc" "none,none")])
 
+(define_insn "*indirect_jump_avr6"
+  [(set (pc) (match_operand:HI 0 "register_operand" "z"))]
+  "AVR_3_BYTE_PC"
+  "eijmp"
+  [(set_attr "length" "1")
+   (set_attr "cc" "none")])
+
 ;; table jump
 
 ;; Table made from "rjmp" instructions for <=8K devices.
@@ -2198,7 +2254,7 @@
 			UNSPEC_INDEX_JMP))
    (use (label_ref (match_operand 1 "" "")))
    (clobber (match_dup 0))]
-  "!AVR_MEGA"
+  "(!AVR_MEGA) && (AVR_2_BYTE_PC)"
   "@
 	ijmp
 	push %A0\;push %B0\;ret"
@@ -2216,12 +2272,27 @@
   [(set_attr "length" "2")
    (set_attr "cc" "clobber")])
 
+(define_insn "*tablejump_avr6"
+  [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
+                        UNSPEC_INDEX_JMP))
+   (use (label_ref (match_operand 1 "" "")))
+   (clobber (match_dup 0))]
+  "AVR_MEGA && AVR_ENHANCED && AVR_3_BYTE_PC"
+  "lsl r30
+        rol r31
+        lpm __tmp_reg__,Z+
+        lpm r31,Z
+        mov r30,__tmp_reg__
+        eijmp"
+  [(set_attr "length" "6")
+   (set_attr "cc" "clobber")])
+
 (define_insn "*tablejump_enh"
   [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
 			UNSPEC_INDEX_JMP))
    (use (label_ref (match_operand 1 "" "")))
    (clobber (match_dup 0))]
-  "AVR_MEGA && AVR_ENHANCED"
+  "AVR_MEGA && AVR_ENHANCED && AVR_2_BYTE_PC"
   "lsl r30
 	rol r31
 	lpm __tmp_reg__,Z+
@@ -2236,7 +2307,7 @@
 			UNSPEC_INDEX_JMP))
    (use (label_ref (match_operand 1 "" "")))
    (clobber (match_dup 0))]
-  "AVR_MEGA"
+  "AVR_MEGA && AVR_2_BYTE_PC"
   "lsl r30
 	rol r31
 	lpm
Index: avr.c
===================================================================
--- avr.c	(revision 113395)
+++ avr.c	(working copy)
@@ -126,20 +126,26 @@
 /* Assembler only.  */
 int avr_asm_only_p = 0;
 
+/* Usually holds the value 2, but could be 3 for the larger devices with a
+   3-byte program counter.  */
+int avr_pc_size = 2;
+
 struct base_arch_s {
   int asm_only;
   int enhanced;
   int mega;
+  int three_byte_pc;
   const char *const macro;
 };
 
 static const struct base_arch_s avr_arch_types[] = {
-  { 1, 0, 0, NULL },  /* unknown device specified */
-  { 1, 0, 0, "__AVR_ARCH__=1" },
-  { 0, 0, 0, "__AVR_ARCH__=2" },
-  { 0, 0, 1, "__AVR_ARCH__=3" },
-  { 0, 1, 0, "__AVR_ARCH__=4" },
-  { 0, 1, 1, "__AVR_ARCH__=5" }
+  { 1, 0, 0, 0, NULL },  /* unknown device specified */
+  { 1, 0, 0, 0, "__AVR_ARCH__=1" },
+  { 0, 0, 0, 0, "__AVR_ARCH__=2" },
+  { 0, 0, 1, 0, "__AVR_ARCH__=3" },
+  { 0, 1, 0, 0, "__AVR_ARCH__=4" },
+  { 0, 1, 1, 0, "__AVR_ARCH__=5" },
+  { 0, 1, 1, 1, "__AVR_ARCH__=6" }
 };
 
 struct mcu_type_s {
@@ -209,6 +215,10 @@
   { "atmega128", 5, "__AVR_ATmega128__" },
   { "at90can128", 5, "__AVR_AT90CAN128__" },
   { "at94k",     5, "__AVR_AT94K__" },
+    /* 3-Byte PC */
+  { "avr6",      6, NULL },
+  { "atmega2560",     6, "__AVR_ATmega2560__" },
+  { "atmega2561",     6, "__AVR_ATmega2561__" },
     /* Assembler only.  */
   { "avr1",      1, NULL },
   { "at90s1200", 1, "__AVR_AT90S1200__" },
@@ -291,6 +301,11 @@
   avr_base_arch_macro = base->macro;
   avr_extra_arch_macro = t->macro;
 
+  if (base->three_byte_pc)
+    avr_pc_size = 3;
+  else
+    avr_pc_size = 2;
+
   if (optimize && !TARGET_NO_TABLEJUMP)
     avr_case_values_threshold = (!AVR_MEGA || TARGET_CALL_PROLOGUES) ? 8 : 17;
 
@@ -419,7 +434,7 @@
       int offset = frame_pointer_needed ? 2 : 0;
 
       offset += avr_regs_to_save (NULL);
-      return get_frame_size () + 2 + 1 + offset;
+      return get_frame_size () + (avr_pc_size) + 1 + offset;
     }
 }
 
@@ -603,7 +618,6 @@
   int reg;
   int interrupt_func_p;
   int signal_func_p;
-  int main_p;
   int live_seq;
   int minimize;
 
@@ -621,7 +635,6 @@
 
   interrupt_func_p = interrupt_function_p (current_function_decl);
   signal_func_p = signal_function_p (current_function_decl);
-  main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
   live_seq = sequent_regs_live ();
   minimize = (TARGET_CALL_PROLOGUES
 	      && !interrupt_func_p && !signal_func_p && live_seq);
@@ -641,25 +654,14 @@
 	       AS1 (clr,__zero_reg__)    "\n");
       prologue_size += 5;
     }
-  if (main_p)
+  if (minimize && (frame_pointer_needed || live_seq > 6)) 
     {
-      fprintf (file, ("\t" 
-		      AS1 (ldi,r28) ",lo8(%s - " HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
-		      AS1 (ldi,r29) ",hi8(%s - " HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
-		      AS2 (out,__SP_H__,r29)     CR_TAB
-		      AS2 (out,__SP_L__,r28) "\n"),
-	       avr_init_stack, size, avr_init_stack, size);
-      
-      prologue_size += 4;
-    }
-  else if (minimize && (frame_pointer_needed || live_seq > 6)) 
-    {
       fprintf (file, ("\t"
 		      AS1 (ldi, r26) ",lo8(" HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
 		      AS1 (ldi, r27) ",hi8(" HOST_WIDE_INT_PRINT_DEC ")" CR_TAB), size, size);
 
-      fputs ((AS2 (ldi,r30,pm_lo8(1f)) CR_TAB
-	      AS2 (ldi,r31,pm_hi8(1f)) CR_TAB), file);
+      fputs ((AS2 (ldi,r30,lo8(gs(1f))) CR_TAB
+	      AS2 (ldi,r31,lo8(gs(1f))) CR_TAB), file);
       
       prologue_size += 4;
       
@@ -730,7 +732,6 @@
   int reg;
   int interrupt_func_p;
   int signal_func_p;
-  int main_p;
   int function_size;
   int live_seq;
   int minimize;
@@ -762,28 +763,13 @@
 
   interrupt_func_p = interrupt_function_p (current_function_decl);
   signal_func_p = signal_function_p (current_function_decl);
-  main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
+
   live_seq = sequent_regs_live ();
   minimize = (TARGET_CALL_PROLOGUES
 	      && !interrupt_func_p && !signal_func_p && live_seq);
   
-  if (main_p)
+  if (minimize && (frame_pointer_needed || live_seq > 4))
     {
-      /* Return value from main() is already in the correct registers
-	 (r25:r24) as the exit() argument.  */
-      if (AVR_MEGA)
-	{
-	  fputs ("\t" AS1 (jmp,exit) "\n", file);
-	  epilogue_size += 2;
-	}
-      else
-	{
-	  fputs ("\t" AS1 (rjmp,exit) "\n", file);
-	  ++epilogue_size;
-	}
-    }
-  else if (minimize && (frame_pointer_needed || live_seq > 4))
-    {
       fprintf (file, ("\t" AS2 (ldi, r30, %d) CR_TAB), live_seq);
       ++epilogue_size;
       if (frame_pointer_needed)
@@ -1040,7 +1026,7 @@
 	  && ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (addr))
 	      || GET_CODE (addr) == LABEL_REF))
 	{
-	  fprintf (file, "pm(");
+	  fprintf (file, "gs(");
 	  output_addr_const (file,addr);
 	  fprintf (file ,")");
 	}
@@ -4461,7 +4447,7 @@
       && ((GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (x))
 	  || GET_CODE (x) == LABEL_REF))
     {
-      fputs ("\t.word\tpm(", asm_out_file);
+      fputs ("\t.word\tgs(", asm_out_file);
       output_addr_const (asm_out_file, x);
       fputs (")\n", asm_out_file);
       return true;
@@ -5833,7 +5819,7 @@
 {
   switch_to_section (progmem_section);
   if (AVR_MEGA)
-    fprintf (stream, "\t.word pm(.L%d)\n", value);
+    fprintf (stream, "\t.word gs(.L%d)\n", value);
   else
     fprintf (stream, "\trjmp .L%d\n", value);
 
Index: t-avr
===================================================================
--- t-avr	(revision 113395)
+++ t-avr	(working copy)
@@ -37,8 +37,8 @@
 
 FPBIT = fp-bit.c
 
-MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr3/mmcu=avr4/mmcu=avr5
-MULTILIB_DIRNAMES = avr2 avr3 avr4 avr5
+MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr3/mmcu=avr4/mmcu=avr5/mmcu=avr6
+MULTILIB_DIRNAMES = avr2 avr3 avr4 avr5 avr6
 
 # The many avr2 matches are not listed here - this is the default.
 MULTILIB_MATCHES = \
@@ -56,7 +56,8 @@
 	mmcu?avr5=mmcu?atmega325 mmcu?avr5=mmcu?atmega3250 \
 	mmcu?avr5=mmcu?atmega64  mmcu?avr5=mmcu?atmega128 \
 	mmcu?avr5=mmcu?atmega645 mmcu?avr5=mmcu?atmega6450 \
-	mmcu?avr5=mmcu?at94k mmcu?avr5=mmcu?at90can128
+	mmcu?avr5=mmcu?at94k mmcu?avr5=mmcu?at90can128 \
+	mmcu?avr6=mmcu?atmega2560 mmcu?avr6=mmcu?atmega2561
 
 MULTILIB_EXCEPTIONS =
 
Index: avr.h
===================================================================
--- avr.h	(revision 113395)
+++ avr.h	(working copy)
@@ -33,6 +33,10 @@
 	builtin_define (avr_extra_arch_macro);	\
       if (avr_asm_only_p)			\
 	builtin_define ("__AVR_ASM_ONLY__");	\
+      if (avr_pc_size == 2)			\
+	builtin_define ("__AVR_2_BYTE_PC__");	\
+      if (avr_pc_size == 3)			\
+	builtin_define ("__AVR_3_BYTE_PC__");	\
       if (avr_enhanced_p)			\
 	builtin_define ("__AVR_ENHANCED__");	\
       if (avr_mega_p)				\
@@ -47,6 +51,8 @@
 extern int avr_mega_p;
 extern int avr_enhanced_p;
 extern int avr_asm_only_p;
+extern int avr_pc_size;
+
 #ifndef IN_LIBGCC2
 extern GTY(()) section *progmem_section;
 #endif
@@ -54,6 +60,9 @@
 #define AVR_MEGA (avr_mega_p && !TARGET_SHORT_CALLS)
 #define AVR_ENHANCED (avr_enhanced_p)
 
+#define AVR_3_BYTE_PC (avr_pc_size == 3)
+#define AVR_2_BYTE_PC (avr_pc_size == 2)
+
 #define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");
 
 #define OVERRIDE_OPTIONS avr_override_options ()
@@ -708,12 +717,13 @@
 
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
 
-#define CC1_SPEC "%{profile:-p}"
+#define CC1_SPEC "%{profile:-p} -fno-delete-null-pointer-checks"
 
 #define CC1PLUS_SPEC "%{!frtti:-fno-rtti} \
     %{!fenforce-eh-specs:-fno-enforce-eh-specs} \
-    %{!fexceptions:-fno-exceptions}"
-/* A C string constant that tells the GCC drvier program options to
+    %{!fexceptions:-fno-exceptions} \
+    -fno-delete-null-pointer-checks"
+/* A C string constant that tells the GCC driver program options to
    pass to `cc1plus'.  */
 
 #define ASM_SPEC "%{mmcu=*:-mmcu=%*}"
@@ -723,6 +733,8 @@
 %{mmcu=attiny22|mmcu=attiny26|mmcu=at90s2*|mmcu=at90s4*|mmcu=at90s8*|mmcu=at90c8*|mmcu=at86rf401|mmcu=attiny13|mmcu=attiny2313:-m avr2}\
 %{mmcu=atmega103|mmcu=atmega603|mmcu=at43*|mmcu=at76*:-m avr3}\
 %{mmcu=atmega8*|mmcu=atmega48:-m avr4}\
+%{mmcu=atmega2560|mmcu=atmega2561:-m avr6}\
+%{mmcu=atmega2560|mmcu=atmega2561: -Tdata 0x800200}\
 %{mmcu=atmega16*|mmcu=atmega32*|mmcu=atmega64*|mmcu=atmega128|mmcu=at90can128|mmcu=at94k:-m avr5}\
 %{mmcu=atmega325|mmcu=atmega3250|mmcu=atmega48|mmcu=atmega88|mmcu=atmega64|mmcu=atmega645|mmcu=atmega6450|mmcu=atmega128|mmcu=at90can128|mmcu=at90can128|mmcu=atmega162|mmcu=atmega165|mmcu=atmega168|mmcu=atmega169: -Tdata 0x800100} "
 
@@ -786,7 +798,9 @@
 %{mmcu=atmega6450:crtm6450.o%s} \
 %{mmcu=atmega128:crtm128.o%s} \
 %{mmcu=at90can128:crtcan128.o%s} \
-%{mmcu=at94k:crtat94k.o%s}"
+%{mmcu=at94k:crtat94k.o%s}\
+%{mmcu=atmega2560:crtm2560.o%s} \
+%{mmcu=atmega2561:crtm2561.o%s}"
 
 #define EXTRA_SPECS {"crt_binutils", CRT_BINUTILS_SPECS},
 
? build
? genpatch
? crt1/.gcrt1.S.swp
? include/avr/iom2560.h
? include/avr/iom2561.h
Index: configure.ac
===================================================================
RCS file: /sources/avr-libc/avr-libc/configure.ac,v
retrieving revision 1.32
diff -U12 -r1.32 configure.ac
--- configure.ac	22 Apr 2006 08:41:44 -0000	1.32
+++ configure.ac	12 May 2006 21:25:51 -0000
@@ -531,24 +531,36 @@
 CHECK_AVR_DEVICE(at90usb646)
 AM_CONDITIONAL(HAS_at90usb646, test "x$HAS_at90usb646" = "xyes")
 
 CHECK_AVR_DEVICE(at90usb647)
 AM_CONDITIONAL(HAS_at90usb647, test "x$HAS_at90usb647" = "xyes")
 
 CHECK_AVR_DEVICE(at90usb1286)
 AM_CONDITIONAL(HAS_at90usb1286, test "x$HAS_at90usb1286" = "xyes")
 
 CHECK_AVR_DEVICE(at90usb1287)
 AM_CONDITIONAL(HAS_at90usb1287, test "x$HAS_at90usb1287" = "xyes")
 
+# avr6
+AM_CONDITIONAL(HAS_avr6, true)
+AM_CONDITIONAL(HAS_atmega2560, true)
+AM_CONDITIONAL(HAS_atmega2561, true)
+
+CHECK_AVR_DEVICE(atmega2560)
+AM_CONDITIONAL(HAS_atmega2560, test "x$HAS_atmega2560" = "xyes")
+
+CHECK_AVR_DEVICE(atmega2561)
+AM_CONDITIONAL(HAS_atmega2561, test "x$HAS_atmega2561" = "xyes")
+
+
 # Generate all files from *.in sources.
 
 AC_CONFIG_FILES([
 	Makefile
 	avr-libc.spec
 	avr/Makefile
 	avr/lib/Makefile
 	common/Makefile
 	crt1/Makefile
 	doc/Makefile
 	doc/api/Makefile
 	doc/examples/Makefile
@@ -656,13 +668,19 @@
 	avr/lib/avr5/atmega1280/Makefile
 	avr/lib/avr5/atmega1281/Makefile
 	avr/lib/avr5/at90can32/Makefile
 	avr/lib/avr5/at90can64/Makefile
 	avr/lib/avr5/at90can128/Makefile
 	avr/lib/avr5/at90usb646/Makefile
 	avr/lib/avr5/at90usb647/Makefile
 	avr/lib/avr5/at90usb1286/Makefile
 	avr/lib/avr5/at90usb1287/Makefile
 	avr/lib/avr5/at94k/Makefile
 ])
 
+#avr6
+AC_CONFIG_FILES([
+	avr/lib/avr6/Makefile
+	avr/lib/avr6/atmega2560/Makefile
+	avr/lib/avr6/atmega2561/Makefile
+])
 AC_OUTPUT
Index: crt1/gcrt1.S
===================================================================
RCS file: /sources/avr-libc/avr-libc/crt1/gcrt1.S,v
retrieving revision 1.8
diff -U12 -r1.8 gcrt1.S
--- crt1/gcrt1.S	10 Nov 2005 21:12:09 -0000	1.8
+++ crt1/gcrt1.S	12 May 2006 21:25:52 -0000
@@ -141,24 +141,29 @@
 	.set	__heap_end, 0
 
 	.section .init2,"ax",@progbits
 	clr	__zero_reg__
 	out	_SFR_IO_ADDR(SREG), __zero_reg__
 	ldi	r28,lo8(__stack)
 #ifdef SPH
 	ldi	r29,hi8(__stack)
 	out	_SFR_IO_ADDR(SPH), r29
 #endif
 	out	_SFR_IO_ADDR(SPL), r28
 
+#ifdef __AVR_3_BYTE_PC__
+        ldi  r16,hh8(pm(__vectors))
+	out	_SFR_IO_ADDR(EIND),r16
+#endif
+
 #if BIG_CODE
 	/* Only for >64K devices with RAMPZ, replaces the default code
 	   provided by libgcc.S which is only linked in if necessary.  */
 
 	.section .init4,"ax",@progbits
 	.global __do_copy_data
 __do_copy_data:
 	ldi	r17, hi8(__data_end)
 	ldi	r26, lo8(__data_start)
 	ldi	r27, hi8(__data_start)
 	ldi	r30, lo8(__data_load_start)
 	ldi	r31, hi8(__data_load_start)
@@ -187,15 +192,16 @@
 	brcs	.L__do_copy_data_carry
 #endif
 .L__do_copy_data_start:
 	cpi	r26, lo8(__data_end)
 	cpc	r27, r17
 	brne	.L__do_copy_data_loop
 #endif /* BIG_CODE */
 
 	.set	__stack, RAMEND
 #endif /* !__AVR_ASM_ONLY__ */
 
 	.section .init9,"ax",@progbits
-	XJMP	main
+	XCALL   main
+	XJMP    exit
 ;	.endfunc
 
Index: devtools/gen-avr-lib-tree.sh
===================================================================
RCS file: /sources/avr-libc/avr-libc/devtools/gen-avr-lib-tree.sh,v
retrieving revision 1.18
diff -U12 -r1.18 gen-avr-lib-tree.sh
--- devtools/gen-avr-lib-tree.sh	22 Apr 2006 08:41:44 -0000	1.18
+++ devtools/gen-avr-lib-tree.sh	12 May 2006 21:25:53 -0000
@@ -204,31 +204,37 @@
 atmega1280:crtm1280.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 atmega1281:crtm1281.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 at90can32:crtcan32.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 at90can64:crtcan64.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 at90can128:crtcan128.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 at90usb646:crtusb646.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 at90usb647:crtusb647.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 at90usb1286:crtusb1286.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 at90usb1287:crtusb1287.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
 at94k:crtat94k.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS}\
 "
 
+AVR6_DEV_INFO="\
+atmega2560:crtm2560.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS};\
+atmega2561:crtm2561.o:${DEV_DEFS}:${CFLAGS_SPEED}:${DEV_ASFLAGS}\
+"
+
 LIB_DEFS="-D__COMPILING_AVR_LIBC__"
 
 AVR_ARH_INFO="\
 avr2:AVR12_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
 avr3:AVR3_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPEED}:${ASFLAGS_SPEED};\
 avr4:AVR4_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPACE}:${DEV_ASFLAGS};\
-avr5:AVR5_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPEED}:${ASFLAGS_SPEED}\
+avr5:AVR5_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPEED}:${ASFLAGS_SPEED};\
+avr6:AVR6_DEV_INFO:${LIB_DEFS}:${CFLAGS_SPEED}:${ASFLAGS_SPEED}\
 "
 
 echo "Generating source directories:"
 
 IFS=';'
 ARH_SUBDIRS="SUBDIRS ="
 
 for ath_lib in $AVR_ARH_INFO
 do
 	arh=$(echo $ath_lib | awk -F: '{print $1}')
 	dev_info=$(echo $ath_lib | awk -F: '{print $2}')
 	lib_defs=$(echo $ath_lib | awk -F: '{print $3}')
Index: include/avr/io.h
===================================================================
RCS file: /sources/avr-libc/avr-libc/include/avr/io.h,v
retrieving revision 1.32
diff -U12 -r1.32 io.h
--- include/avr/io.h	22 Apr 2006 08:41:44 -0000	1.32
+++ include/avr/io.h	12 May 2006 21:25:54 -0000
@@ -175,24 +175,28 @@
 #elif defined (__AVR_AT43USB355__)
 #  include <avr/io43u35x.h>
 #elif defined (__AVR_AT76C711__)
 #  include <avr/io76c711.h>
 #elif defined (__AVR_AT86RF401__)
 #  include <avr/io86r401.h>
 #elif defined (__AVR_AT90PWM2__)
 #  include <avr/io90pwmx.h>
 #elif defined (__AVR_AT90PWM3__)
 #  include <avr/io90pwmx.h>
 #elif defined (__AVR_ATmega128__)
 #  include <avr/iom128.h>
+#elif defined (__AVR_ATmega2561__)
+#  include <avr/iom2561.h>
+#elif defined (__AVR_ATmega2560__)
+#  include <avr/iom2560.h>
 #elif defined (__AVR_ATmega1280__)
 #  include <avr/iom1280.h>
 #elif defined (__AVR_ATmega1281__)
 #  include <avr/iom1281.h>
 #elif defined (__AVR_AT90CAN32__)
 #  include <avr/iocan32.h>
 #elif defined (__AVR_AT90CAN64__)
 #  include <avr/iocan64.h>
 #elif defined (__AVR_AT90CAN128__)
 #  include <avr/iocan128.h>
 #elif defined (__AVR_AT90USB646__)
 #  include <avr/iousb646.h>
_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to