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