Back to index

cell-binutils  2.17cvs20070401
cpu-avr.c
Go to the documentation of this file.
00001 /* BFD library support routines for the AVR architecture.
00002    Copyright 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
00003    Contributed by Denis Chertykov <denisc@overta.ru>
00004 
00005    This file is part of BFD, the Binary File Descriptor library.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 #include "bfd.h"
00022 #include "sysdep.h"
00023 #include "libbfd.h"
00024 
00025 /* This routine is provided two arch_infos and works out which AVR
00026    machine which would be compatible with both and returns a pointer
00027    to its info structure.  */
00028 
00029 static const bfd_arch_info_type *
00030 compatible (const bfd_arch_info_type * a,
00031            const bfd_arch_info_type * b)
00032 {
00033   /* If a & b are for different architectures we can do nothing.  */
00034   if (a->arch != b->arch)
00035     return NULL;
00036 
00037   /* Special case for ATmega[16]03 (avr:3) and ATmega83 (avr:4).  */
00038   if ((a->mach == bfd_mach_avr3 && b->mach == bfd_mach_avr4)
00039       || (a->mach == bfd_mach_avr4 && b->mach == bfd_mach_avr3))
00040     return NULL;
00041 
00042   /* So far all newer AVR architecture cores are supersets of previous
00043      cores.  */
00044   if (a->mach <= b->mach)
00045     return b;
00046 
00047   if (a->mach >= b->mach)
00048     return a;
00049 
00050   /* Never reached!  */
00051   return NULL;
00052 }
00053 
00054 #define N(addr_bits, machine, print, default, next)            \
00055 {                                                       \
00056   8,                        /* 8 bits in a word.  */    \
00057   addr_bits,                /* bits in an address.  */  \
00058   8,                        /* 8 bits in a byte.  */    \
00059   bfd_arch_avr,                                                \
00060   machine,                  /* Machine number.  */             \
00061   "avr",                    /* Architecture name.   */  \
00062   print,                    /* Printable name.  */             \
00063   1,                        /* Section align power.  */ \
00064   default,                  /* Is this the default ?  */       \
00065   compatible,                                           \
00066   bfd_default_scan,                                     \
00067   next                                                  \
00068 }
00069 
00070 static const bfd_arch_info_type arch_info_struct[] =
00071 {
00072   /* AT90S1200, ATtiny1x, ATtiny28.  */
00073   N (16, bfd_mach_avr1, "avr:1", FALSE, & arch_info_struct[1]),
00074 
00075   /* AT90S2xxx, AT90S4xxx, AT90S8xxx, ATtiny22.  */
00076   N (16, bfd_mach_avr2, "avr:2", FALSE, & arch_info_struct[2]),
00077 
00078   /* ATmega103, ATmega603.  */
00079   N (22, bfd_mach_avr3, "avr:3", FALSE, & arch_info_struct[3]),
00080 
00081   /* ATmega83, ATmega85.  */
00082   N (16, bfd_mach_avr4, "avr:4", FALSE, & arch_info_struct[4]),
00083 
00084   /* ATmega161, ATmega163, ATmega32, AT94K.  */
00085   N (22, bfd_mach_avr5, "avr:5", FALSE, & arch_info_struct[5]),
00086 
00087   /* ATmega256x.  */
00088   N (22, bfd_mach_avr6, "avr:6", FALSE, NULL)
00089 };
00090 
00091 const bfd_arch_info_type bfd_avr_arch =
00092   N (16, bfd_mach_avr2, "avr", TRUE, & arch_info_struct[0]);