| 1 | /* BFD library support routines for the i960 architecture.
|
|---|
| 2 | Copyright 1990, 1991, 1993, 1994, 1996, 1999, 2000
|
|---|
| 3 | Free Software Foundation, Inc.
|
|---|
| 4 | Hacked by Steve Chamberlain of Cygnus Support.
|
|---|
| 5 |
|
|---|
| 6 | This file is part of BFD, the Binary File Descriptor library.
|
|---|
| 7 |
|
|---|
| 8 | This program is free software; you can redistribute it and/or modify
|
|---|
| 9 | it under the terms of the GNU General Public License as published by
|
|---|
| 10 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 11 | (at your option) any later version.
|
|---|
| 12 |
|
|---|
| 13 | This program is distributed in the hope that it will be useful,
|
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 16 | GNU General Public License for more details.
|
|---|
| 17 |
|
|---|
| 18 | You should have received a copy of the GNU General Public License
|
|---|
| 19 | along with this program; if not, write to the Free Software
|
|---|
| 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 21 |
|
|---|
| 22 | #include "bfd.h"
|
|---|
| 23 | #include "sysdep.h"
|
|---|
| 24 | #include "libbfd.h"
|
|---|
| 25 |
|
|---|
| 26 | /* This routine is provided a string, and tries to work out if it
|
|---|
| 27 | could possibly refer to the i960 machine pointed at in the
|
|---|
| 28 | info_struct pointer */
|
|---|
| 29 |
|
|---|
| 30 | static boolean
|
|---|
| 31 | scan_960_mach (ap, string)
|
|---|
| 32 | const bfd_arch_info_type *ap;
|
|---|
| 33 | const char *string;
|
|---|
| 34 | {
|
|---|
| 35 | unsigned long machine;
|
|---|
| 36 | int i;
|
|---|
| 37 | int fail_because_not_80960 = false;
|
|---|
| 38 |
|
|---|
| 39 | for (i = 0; i < strlen (string); i ++)
|
|---|
| 40 | string[i] = tolower (string[i]);
|
|---|
| 41 |
|
|---|
| 42 | /* Look for the string i960 at the front of the string. */
|
|---|
| 43 | if (strncmp ("i960", string, 4) == 0)
|
|---|
| 44 | {
|
|---|
| 45 | string += 4;
|
|---|
| 46 |
|
|---|
| 47 | /* i960 on it's own means core to us. */
|
|---|
| 48 | if (* string == 0)
|
|---|
| 49 | return ap->mach == bfd_mach_i960_core;
|
|---|
| 50 |
|
|---|
| 51 | /* "i960:*" is valid, anything else is not. */
|
|---|
| 52 | if (* string != ':')
|
|---|
| 53 | return false;
|
|---|
| 54 |
|
|---|
| 55 | string ++;
|
|---|
| 56 | }
|
|---|
| 57 | /* In some bfds the cpu-id is written as "80960KA", "80960KB",
|
|---|
| 58 | "80960CA" or "80960MC". */
|
|---|
| 59 | else if (strncmp ("80960", string, 5) == 0)
|
|---|
| 60 | {
|
|---|
| 61 | string += 5;
|
|---|
| 62 |
|
|---|
| 63 | /* Sett his to true here. If a correct matching postfix
|
|---|
| 64 | is detected below it will be reset to false. */
|
|---|
| 65 | fail_because_not_80960 = true;
|
|---|
| 66 | }
|
|---|
| 67 | /* No match, can't be us. */
|
|---|
| 68 | else
|
|---|
| 69 | return false;
|
|---|
| 70 |
|
|---|
| 71 | if (* string == '\0')
|
|---|
| 72 | return false;
|
|---|
| 73 |
|
|---|
| 74 | if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' &&
|
|---|
| 75 | string[3] == 'e' && string[4] == '\0')
|
|---|
| 76 | machine = bfd_mach_i960_core;
|
|---|
| 77 | else if (strcmp (string, "ka_sa") == 0)
|
|---|
| 78 | machine = bfd_mach_i960_ka_sa;
|
|---|
| 79 | else if (strcmp (string, "kb_sb") == 0)
|
|---|
| 80 | machine = bfd_mach_i960_kb_sb;
|
|---|
| 81 | else if (string[1] == '\0' || string[2] != '\0') /* rest are 2-char. */
|
|---|
| 82 | return false;
|
|---|
| 83 | else if (string[0] == 'k' && string[1] == 'b')
|
|---|
| 84 | { machine = bfd_mach_i960_kb_sb; fail_because_not_80960 = false; }
|
|---|
| 85 | else if (string[0] == 's' && string[1] == 'b')
|
|---|
| 86 | machine = bfd_mach_i960_kb_sb;
|
|---|
| 87 | else if (string[0] == 'm' && string[1] == 'c')
|
|---|
| 88 | { machine = bfd_mach_i960_mc; fail_because_not_80960 = false; }
|
|---|
| 89 | else if (string[0] == 'x' && string[1] == 'a')
|
|---|
| 90 | machine = bfd_mach_i960_xa;
|
|---|
| 91 | else if (string[0] == 'c' && string[1] == 'a')
|
|---|
| 92 | { machine = bfd_mach_i960_ca; fail_because_not_80960 = false; }
|
|---|
| 93 | else if (string[0] == 'k' && string[1] == 'a')
|
|---|
| 94 | { machine = bfd_mach_i960_ka_sa; fail_because_not_80960 = false; }
|
|---|
| 95 | else if (string[0] == 's' && string[1] == 'a')
|
|---|
| 96 | machine = bfd_mach_i960_ka_sa;
|
|---|
| 97 | else if (string[0] == 'j' && string[1] == 'x')
|
|---|
| 98 | machine = bfd_mach_i960_jx;
|
|---|
| 99 | else if (string[0] == 'h' && string[1] == 'x')
|
|---|
| 100 | machine = bfd_mach_i960_hx;
|
|---|
| 101 | else
|
|---|
| 102 | return false;
|
|---|
| 103 |
|
|---|
| 104 | if (fail_because_not_80960)
|
|---|
| 105 | return false;
|
|---|
| 106 |
|
|---|
| 107 | if (machine == ap->mach)
|
|---|
| 108 | return true;
|
|---|
| 109 |
|
|---|
| 110 | return false;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | /* This routine is provided two arch_infos and works out the i960
|
|---|
| 114 | machine which would be compatible with both and returns a pointer
|
|---|
| 115 | to its info structure */
|
|---|
| 116 |
|
|---|
| 117 | static const bfd_arch_info_type *
|
|---|
| 118 | compatible (a,b)
|
|---|
| 119 | const bfd_arch_info_type *a;
|
|---|
| 120 | const bfd_arch_info_type *b;
|
|---|
| 121 | {
|
|---|
| 122 |
|
|---|
| 123 | /* The i960 has distinct subspecies which may not interbreed:
|
|---|
| 124 | CORE CA
|
|---|
| 125 | CORE KA KB MC XA
|
|---|
| 126 | CORE HX JX
|
|---|
| 127 | Any architecture on the same line is compatible, the one on
|
|---|
| 128 | the right is the least restrictive.
|
|---|
| 129 |
|
|---|
| 130 | We represent this information in an array, each machine to a side */
|
|---|
| 131 |
|
|---|
| 132 | #define ERROR 0
|
|---|
| 133 | #define CORE bfd_mach_i960_core /*1*/
|
|---|
| 134 | #define KA bfd_mach_i960_ka_sa /*2*/
|
|---|
| 135 | #define KB bfd_mach_i960_kb_sb /*3*/
|
|---|
| 136 | #define MC bfd_mach_i960_mc /*4*/
|
|---|
| 137 | #define XA bfd_mach_i960_xa /*5*/
|
|---|
| 138 | #define CA bfd_mach_i960_ca /*6*/
|
|---|
| 139 | #define JX bfd_mach_i960_jx /*7*/
|
|---|
| 140 | #define HX bfd_mach_i960_hx /*8*/
|
|---|
| 141 | #define MAX_ARCH ((int)HX)
|
|---|
| 142 |
|
|---|
| 143 | static CONST unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
|
|---|
| 144 | {
|
|---|
| 145 | { ERROR, CORE, KA, KB, MC, XA, CA, JX, HX },
|
|---|
| 146 | { CORE, CORE, KA, KB, MC, XA, CA, JX, HX },
|
|---|
| 147 | { KA, KA, KA, KB, MC, XA, ERROR, ERROR, ERROR},
|
|---|
| 148 | { KB, KB, KB, KB, MC, XA, ERROR, ERROR, ERROR},
|
|---|
| 149 | { MC, MC, MC, MC, MC, XA, ERROR, ERROR, ERROR},
|
|---|
| 150 | { XA, XA, XA, XA, XA, XA, ERROR, ERROR, ERROR},
|
|---|
| 151 | { CA, CA, ERROR, ERROR, ERROR, ERROR, CA, ERROR, ERROR},
|
|---|
| 152 | { JX, JX, ERROR, ERROR, ERROR, ERROR, ERROR, JX, HX },
|
|---|
| 153 | { HX, HX, ERROR, ERROR, ERROR, ERROR, ERROR, HX, HX },
|
|---|
| 154 | };
|
|---|
| 155 |
|
|---|
| 156 | if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR)
|
|---|
| 157 | {
|
|---|
| 158 | return NULL;
|
|---|
| 159 | }
|
|---|
| 160 | else
|
|---|
| 161 | {
|
|---|
| 162 | return (a->mach == matrix[a->mach][b->mach]) ? a : b;
|
|---|
| 163 | }
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | int bfd_default_scan_num_mach();
|
|---|
| 167 | #define N(a,b,d,n) \
|
|---|
| 168 | { 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,}
|
|---|
| 169 |
|
|---|
| 170 | static const bfd_arch_info_type arch_info_struct[] =
|
|---|
| 171 | {
|
|---|
| 172 | N(bfd_mach_i960_ka_sa,"i960:ka_sa",false, &arch_info_struct[1]),
|
|---|
| 173 | N(bfd_mach_i960_kb_sb,"i960:kb_sb",false, &arch_info_struct[2]),
|
|---|
| 174 | N(bfd_mach_i960_mc, "i960:mc", false, &arch_info_struct[3]),
|
|---|
| 175 | N(bfd_mach_i960_xa, "i960:xa", false, &arch_info_struct[4]),
|
|---|
| 176 | N(bfd_mach_i960_ca, "i960:ca", false, &arch_info_struct[5]),
|
|---|
| 177 | N(bfd_mach_i960_jx, "i960:jx", false, &arch_info_struct[6]),
|
|---|
| 178 | N(bfd_mach_i960_hx, "i960:hx", false, 0),
|
|---|
| 179 | };
|
|---|
| 180 |
|
|---|
| 181 | const bfd_arch_info_type bfd_i960_arch =
|
|---|
| 182 | N(bfd_mach_i960_core, "i960:core", true, &arch_info_struct[0]);
|
|---|