daily update
[deliverable/binutils-gdb.git] / bfd / cpu-avr.c
CommitLineData
adde6300 1/* BFD library support routines for the AVR architecture.
b34976b6 2 Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
adde6300
AM
3 Contributed by Denis Chertykov <denisc@overta.ru>
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
3e110533 19Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
adde6300
AM
20
21#include "bfd.h"
22#include "sysdep.h"
23#include "libbfd.h"
24
adde6300
AM
25static const bfd_arch_info_type *compatible
26 PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
27
adde6300
AM
28#define N(addr_bits, machine, print, default, next) \
29{ \
30 8, /* 8 bits in a word */ \
31 addr_bits, /* bits in an address */ \
32 8, /* 8 bits in a byte */ \
33 bfd_arch_avr, \
34 machine, /* machine */ \
35 "avr", /* arch_name */ \
36 print, /* printable name */ \
37 1, /* section align power */ \
38 default, /* the default machine */ \
39 compatible, \
40 bfd_default_scan, \
41 next \
42}
43
44static const bfd_arch_info_type arch_info_struct[] =
45{
65aa24b6 46 /* AT90S1200, ATtiny1x, ATtiny28 */
b34976b6 47 N (16, bfd_mach_avr1, "avr:1", FALSE, & arch_info_struct[1]),
adde6300 48
65aa24b6 49 /* AT90S2xxx, AT90S4xxx, AT90S8xxx, ATtiny22 */
b34976b6 50 N (16, bfd_mach_avr2, "avr:2", FALSE, & arch_info_struct[2]),
adde6300
AM
51
52 /* ATmega103, ATmega603 */
b34976b6 53 N (22, bfd_mach_avr3, "avr:3", FALSE, & arch_info_struct[3]),
adde6300 54
65aa24b6 55 /* ATmega83, ATmega85 */
b34976b6 56 N (16, bfd_mach_avr4, "avr:4", FALSE, & arch_info_struct[4]),
65aa24b6
NC
57
58 /* ATmega161, ATmega163, ATmega32, AT94K */
b34976b6 59 N (22, bfd_mach_avr5, "avr:5", FALSE, NULL)
adde6300
AM
60};
61
62const bfd_arch_info_type bfd_avr_arch =
b34976b6 63 N (16, bfd_mach_avr2, "avr", TRUE, & arch_info_struct[0]);
adde6300
AM
64
65/* This routine is provided two arch_infos and works out which AVR
66 machine which would be compatible with both and returns a pointer
67 to its info structure. */
68
69static const bfd_arch_info_type *
70compatible (a,b)
71 const bfd_arch_info_type * a;
72 const bfd_arch_info_type * b;
73{
74 /* If a & b are for different architectures we can do nothing. */
75 if (a->arch != b->arch)
76 return NULL;
77
65aa24b6 78 /* Special case for ATmega[16]03 (avr:3) and ATmega83 (avr:4). */
37f45cf8
AM
79 if ((a->mach == bfd_mach_avr3 && b->mach == bfd_mach_avr4)
80 || (a->mach == bfd_mach_avr4 && b->mach == bfd_mach_avr3))
adde6300
AM
81 return NULL;
82
83 /* So far all newer AVR architecture cores are supersets of previous
84 cores. */
85 if (a->mach <= b->mach)
86 return b;
87
65aa24b6
NC
88 if (a->mach >= b->mach)
89 return a;
90
adde6300
AM
91 /* Never reached! */
92 return NULL;
93}
This page took 0.280359 seconds and 4 git commands to generate.