1 |
24 |
jeremybenn |
/* BFD library support routines for the AVR architecture.
|
2 |
|
|
Copyright 1999, 2000, 2002, 2006, 2007 Free Software Foundation, Inc.
|
3 |
|
|
Contributed by Denis Chertykov <denisc@overta.ru>
|
4 |
|
|
|
5 |
|
|
This file is part of BFD, the Binary File Descriptor library.
|
6 |
|
|
|
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 3 of the License, or
|
10 |
|
|
(at your option) any later version.
|
11 |
|
|
|
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.
|
16 |
|
|
|
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,
|
20 |
|
|
MA 02110-1301, USA. */
|
21 |
|
|
|
22 |
|
|
#include "sysdep.h"
|
23 |
|
|
#include "bfd.h"
|
24 |
|
|
#include "libbfd.h"
|
25 |
|
|
|
26 |
|
|
/* This routine is provided two arch_infos and works out which AVR
|
27 |
|
|
machine which would be compatible with both and returns a pointer
|
28 |
|
|
to its info structure. */
|
29 |
|
|
|
30 |
|
|
static const bfd_arch_info_type *
|
31 |
|
|
compatible (const bfd_arch_info_type * a,
|
32 |
|
|
const bfd_arch_info_type * b)
|
33 |
|
|
{
|
34 |
|
|
/* If a & b are for different architectures we can do nothing. */
|
35 |
|
|
if (a->arch != b->arch)
|
36 |
|
|
return NULL;
|
37 |
|
|
|
38 |
|
|
/* Special case for ATmega[16]03 (avr:3) and ATmega83 (avr:4). */
|
39 |
|
|
if ((a->mach == bfd_mach_avr3 && b->mach == bfd_mach_avr4)
|
40 |
|
|
|| (a->mach == bfd_mach_avr4 && b->mach == bfd_mach_avr3))
|
41 |
|
|
return NULL;
|
42 |
|
|
|
43 |
|
|
/* So far all newer AVR architecture cores are supersets of previous
|
44 |
|
|
cores. */
|
45 |
|
|
if (a->mach <= b->mach)
|
46 |
|
|
return b;
|
47 |
|
|
|
48 |
|
|
if (a->mach >= b->mach)
|
49 |
|
|
return a;
|
50 |
|
|
|
51 |
|
|
/* Never reached! */
|
52 |
|
|
return NULL;
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
#define N(addr_bits, machine, print, default, next) \
|
56 |
|
|
{ \
|
57 |
|
|
8, /* 8 bits in a word. */ \
|
58 |
|
|
addr_bits, /* bits in an address. */ \
|
59 |
|
|
8, /* 8 bits in a byte. */ \
|
60 |
|
|
bfd_arch_avr, \
|
61 |
|
|
machine, /* Machine number. */ \
|
62 |
|
|
"avr", /* Architecture name. */ \
|
63 |
|
|
print, /* Printable name. */ \
|
64 |
|
|
1, /* Section align power. */ \
|
65 |
|
|
default, /* Is this the default ? */ \
|
66 |
|
|
compatible, \
|
67 |
|
|
bfd_default_scan, \
|
68 |
|
|
next \
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
static const bfd_arch_info_type arch_info_struct[] =
|
72 |
|
|
{
|
73 |
|
|
/* AT90S1200, ATtiny1x, ATtiny28. */
|
74 |
|
|
N (16, bfd_mach_avr1, "avr:1", FALSE, & arch_info_struct[1]),
|
75 |
|
|
|
76 |
|
|
/* AT90S2xxx, AT90S4xxx, AT90S8xxx, ATtiny22. */
|
77 |
|
|
N (16, bfd_mach_avr2, "avr:2", FALSE, & arch_info_struct[2]),
|
78 |
|
|
|
79 |
|
|
/* ATmega103, ATmega603. */
|
80 |
|
|
N (22, bfd_mach_avr3, "avr:3", FALSE, & arch_info_struct[3]),
|
81 |
|
|
|
82 |
|
|
/* ATmega83, ATmega85. */
|
83 |
|
|
N (16, bfd_mach_avr4, "avr:4", FALSE, & arch_info_struct[4]),
|
84 |
|
|
|
85 |
|
|
/* ATmega161, ATmega163, ATmega32, AT94K. */
|
86 |
|
|
N (22, bfd_mach_avr5, "avr:5", FALSE, & arch_info_struct[5]),
|
87 |
|
|
|
88 |
|
|
/* ATmega256x. */
|
89 |
|
|
N (22, bfd_mach_avr6, "avr:6", FALSE, NULL)
|
90 |
|
|
};
|
91 |
|
|
|
92 |
|
|
const bfd_arch_info_type bfd_avr_arch =
|
93 |
|
|
N (16, bfd_mach_avr2, "avr", TRUE, & arch_info_struct[0]);
|