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