| 1 | /* BFD library support routines for the MSP architecture. | 
|---|
| 2 | Copyright (C) 2002 Free Software Foundation, Inc. | 
|---|
| 3 | Contributed by Dmitry Diky <diwil@mail.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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ | 
|---|
| 20 |  | 
|---|
| 21 | #include "bfd.h" | 
|---|
| 22 | #include "sysdep.h" | 
|---|
| 23 | #include "libbfd.h" | 
|---|
| 24 |  | 
|---|
| 25 | static const bfd_arch_info_type *compatible | 
|---|
| 26 | PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *)); | 
|---|
| 27 |  | 
|---|
| 28 | #define N(addr_bits, machine, print, default, next)             \ | 
|---|
| 29 | {                                                               \ | 
|---|
| 30 | 16,                           /* 16 bits in a word.  */       \ | 
|---|
| 31 | addr_bits,                    /* Bits in an address.  */      \ | 
|---|
| 32 | 8,                            /* 8 bits in a byte.  */        \ | 
|---|
| 33 | bfd_arch_msp430,                                              \ | 
|---|
| 34 | machine,                      /* Machine number.  */          \ | 
|---|
| 35 | "msp430",                     /* Architecture 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 |  | 
|---|
| 44 | static const bfd_arch_info_type arch_info_struct[] = | 
|---|
| 45 | { | 
|---|
| 46 | /* msp430x11x.  */ | 
|---|
| 47 | N (16, bfd_mach_msp11, "msp:11", FALSE, & arch_info_struct[1]), | 
|---|
| 48 |  | 
|---|
| 49 | /* msp430x12x.  */ | 
|---|
| 50 | N (16, bfd_mach_msp12, "msp:12", FALSE, & arch_info_struct[2]), | 
|---|
| 51 |  | 
|---|
| 52 | /* msp430x13x.  */ | 
|---|
| 53 | N (16, bfd_mach_msp13, "msp:13", FALSE, & arch_info_struct[3]), | 
|---|
| 54 |  | 
|---|
| 55 | /* msp430x14x.  */ | 
|---|
| 56 | N (16, bfd_mach_msp14, "msp:14", FALSE, & arch_info_struct[4]), | 
|---|
| 57 |  | 
|---|
| 58 | /* msp430x31x.  */ | 
|---|
| 59 | N (16, bfd_mach_msp31, "msp:31", FALSE, & arch_info_struct[5]), | 
|---|
| 60 |  | 
|---|
| 61 | /* msp430x32x.  */ | 
|---|
| 62 | N (16, bfd_mach_msp32, "msp:32", FALSE, & arch_info_struct[6]), | 
|---|
| 63 |  | 
|---|
| 64 | /* msp430x33x.  */ | 
|---|
| 65 | N (16, bfd_mach_msp33, "msp:33", FALSE, & arch_info_struct[7]), | 
|---|
| 66 |  | 
|---|
| 67 | /* msp430x41x.  */ | 
|---|
| 68 | N (16, bfd_mach_msp41, "msp:41", FALSE, & arch_info_struct[8]), | 
|---|
| 69 |  | 
|---|
| 70 | /* msp430x43x.  */ | 
|---|
| 71 | N (16, bfd_mach_msp43, "msp:43", FALSE, & arch_info_struct[9]), | 
|---|
| 72 |  | 
|---|
| 73 | /* msp430x44x.  */ | 
|---|
| 74 | N (16, bfd_mach_msp43, "msp:44", FALSE, & arch_info_struct[10]), | 
|---|
| 75 |  | 
|---|
| 76 | /* msp430x15x.  */ | 
|---|
| 77 | N (16, bfd_mach_msp15, "msp:15", FALSE, & arch_info_struct[11]), | 
|---|
| 78 |  | 
|---|
| 79 | /* msp430x16x.  */ | 
|---|
| 80 | N (16, bfd_mach_msp16, "msp:16", FALSE, & arch_info_struct[12]), | 
|---|
| 81 |  | 
|---|
| 82 | /* msp430x11x1.  */ | 
|---|
| 83 | N (16, bfd_mach_msp110, "msp:110", FALSE, NULL) | 
|---|
| 84 |  | 
|---|
| 85 | }; | 
|---|
| 86 |  | 
|---|
| 87 | const bfd_arch_info_type bfd_msp430_arch = | 
|---|
| 88 | N (16, bfd_mach_msp14, "msp:14", TRUE, & arch_info_struct[0]); | 
|---|
| 89 |  | 
|---|
| 90 | /* This routine is provided two arch_infos and works out which MSP | 
|---|
| 91 | machine which would be compatible with both and returns a pointer | 
|---|
| 92 | to its info structure.  */ | 
|---|
| 93 |  | 
|---|
| 94 | static const bfd_arch_info_type * | 
|---|
| 95 | compatible (a,b) | 
|---|
| 96 | const bfd_arch_info_type * a; | 
|---|
| 97 | const bfd_arch_info_type * b; | 
|---|
| 98 | { | 
|---|
| 99 | /* If a & b are for different architectures we can do nothing.  */ | 
|---|
| 100 | if (a->arch != b->arch) | 
|---|
| 101 | return NULL; | 
|---|
| 102 |  | 
|---|
| 103 | if (a->mach <= b->mach) | 
|---|
| 104 | return b; | 
|---|
| 105 |  | 
|---|
| 106 | return a; | 
|---|
| 107 | } | 
|---|