cpu-msp430.c 4.2 KB

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