1*3d8817e4Smiod /* BFD library support routines for the MSP architecture.
2*3d8817e4Smiod Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3*3d8817e4Smiod Contributed by Dmitry Diky <diwil@mail.ru>
4*3d8817e4Smiod
5*3d8817e4Smiod This file is part of BFD, the Binary File Descriptor library.
6*3d8817e4Smiod
7*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
8*3d8817e4Smiod it under the terms of the GNU General Public License as published by
9*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or
10*3d8817e4Smiod (at your option) any later version.
11*3d8817e4Smiod
12*3d8817e4Smiod This program is distributed in the hope that it will be useful,
13*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
14*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15*3d8817e4Smiod GNU General Public License for more details.
16*3d8817e4Smiod
17*3d8817e4Smiod You should have received a copy of the GNU General Public License
18*3d8817e4Smiod along with this program; if not, write to the Free Software
19*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20*3d8817e4Smiod
21*3d8817e4Smiod #include "bfd.h"
22*3d8817e4Smiod #include "sysdep.h"
23*3d8817e4Smiod #include "libbfd.h"
24*3d8817e4Smiod
25*3d8817e4Smiod static const bfd_arch_info_type *compatible
26*3d8817e4Smiod PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
27*3d8817e4Smiod
28*3d8817e4Smiod #define N(addr_bits, machine, print, default, next) \
29*3d8817e4Smiod { \
30*3d8817e4Smiod 16, /* 16 bits in a word. */ \
31*3d8817e4Smiod addr_bits, /* Bits in an address. */ \
32*3d8817e4Smiod 8, /* 8 bits in a byte. */ \
33*3d8817e4Smiod bfd_arch_msp430, \
34*3d8817e4Smiod machine, /* Machine number. */ \
35*3d8817e4Smiod "msp430", /* Architecture name. */ \
36*3d8817e4Smiod print, /* Printable name. */ \
37*3d8817e4Smiod 1, /* Section align power. */ \
38*3d8817e4Smiod default, /* The default machine. */ \
39*3d8817e4Smiod compatible, \
40*3d8817e4Smiod bfd_default_scan, \
41*3d8817e4Smiod next \
42*3d8817e4Smiod }
43*3d8817e4Smiod
44*3d8817e4Smiod static const bfd_arch_info_type arch_info_struct[] =
45*3d8817e4Smiod {
46*3d8817e4Smiod /* msp430x11x. */
47*3d8817e4Smiod N (16, bfd_mach_msp11, "msp:11", FALSE, & arch_info_struct[1]),
48*3d8817e4Smiod
49*3d8817e4Smiod /* msp430x11x1. */
50*3d8817e4Smiod N (16, bfd_mach_msp110, "msp:110", FALSE, & arch_info_struct[2]),
51*3d8817e4Smiod
52*3d8817e4Smiod /* msp430x12x. */
53*3d8817e4Smiod N (16, bfd_mach_msp12, "msp:12", FALSE, & arch_info_struct[3]),
54*3d8817e4Smiod
55*3d8817e4Smiod /* msp430x13x. */
56*3d8817e4Smiod N (16, bfd_mach_msp13, "msp:13", FALSE, & arch_info_struct[4]),
57*3d8817e4Smiod
58*3d8817e4Smiod /* msp430x14x. */
59*3d8817e4Smiod N (16, bfd_mach_msp14, "msp:14", FALSE, & arch_info_struct[5]),
60*3d8817e4Smiod
61*3d8817e4Smiod /* msp430x15x. */
62*3d8817e4Smiod N (16, bfd_mach_msp15, "msp:15", FALSE, & arch_info_struct[6]),
63*3d8817e4Smiod
64*3d8817e4Smiod /* msp430x16x. */
65*3d8817e4Smiod N (16, bfd_mach_msp16, "msp:16", FALSE, & arch_info_struct[7]),
66*3d8817e4Smiod
67*3d8817e4Smiod /* msp430x21x. */
68*3d8817e4Smiod N (16, bfd_mach_msp21, "msp:21", FALSE, & arch_info_struct[8]),
69*3d8817e4Smiod
70*3d8817e4Smiod /* msp430x31x. */
71*3d8817e4Smiod N (16, bfd_mach_msp31, "msp:31", FALSE, & arch_info_struct[9]),
72*3d8817e4Smiod
73*3d8817e4Smiod /* msp430x32x. */
74*3d8817e4Smiod N (16, bfd_mach_msp32, "msp:32", FALSE, & arch_info_struct[10]),
75*3d8817e4Smiod
76*3d8817e4Smiod /* msp430x33x. */
77*3d8817e4Smiod N (16, bfd_mach_msp33, "msp:33", FALSE, & arch_info_struct[11]),
78*3d8817e4Smiod
79*3d8817e4Smiod /* msp430x41x. */
80*3d8817e4Smiod N (16, bfd_mach_msp41, "msp:41", FALSE, & arch_info_struct[12]),
81*3d8817e4Smiod
82*3d8817e4Smiod /* msp430x42x. */
83*3d8817e4Smiod N (16, bfd_mach_msp42, "msp:42", FALSE, & arch_info_struct[13]),
84*3d8817e4Smiod
85*3d8817e4Smiod /* msp430x43x. */
86*3d8817e4Smiod N (16, bfd_mach_msp43, "msp:43", FALSE, & arch_info_struct[14]),
87*3d8817e4Smiod
88*3d8817e4Smiod /* msp430x44x. */
89*3d8817e4Smiod N (16, bfd_mach_msp43, "msp:44", FALSE, NULL)
90*3d8817e4Smiod };
91*3d8817e4Smiod
92*3d8817e4Smiod const bfd_arch_info_type bfd_msp430_arch =
93*3d8817e4Smiod N (16, bfd_mach_msp14, "msp:14", TRUE, & arch_info_struct[0]);
94*3d8817e4Smiod
95*3d8817e4Smiod /* This routine is provided two arch_infos and works out which MSP
96*3d8817e4Smiod machine which would be compatible with both and returns a pointer
97*3d8817e4Smiod to its info structure. */
98*3d8817e4Smiod
99*3d8817e4Smiod static const bfd_arch_info_type *
compatible(a,b)100*3d8817e4Smiod compatible (a,b)
101*3d8817e4Smiod const bfd_arch_info_type * a;
102*3d8817e4Smiod const bfd_arch_info_type * b;
103*3d8817e4Smiod {
104*3d8817e4Smiod /* If a & b are for different architectures we can do nothing. */
105*3d8817e4Smiod if (a->arch != b->arch)
106*3d8817e4Smiod return NULL;
107*3d8817e4Smiod
108*3d8817e4Smiod if (a->mach <= b->mach)
109*3d8817e4Smiod return b;
110*3d8817e4Smiod
111*3d8817e4Smiod return a;
112*3d8817e4Smiod }
113