]>
Commit | Line | Data |
---|---|---|
e89f2fbe | 1 | /* BFD library support routines for the i960 architecture. |
ae115e51 | 2 | Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc. |
e89f2fbe SC |
3 | Hacked by Steve Chamberlain of Cygnus Support. |
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 | |
ae115e51 | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
e89f2fbe SC |
20 | |
21 | ||
e89f2fbe | 22 | #include "bfd.h" |
ae115e51 | 23 | #include "sysdep.h" |
e89f2fbe SC |
24 | #include "libbfd.h" |
25 | ||
26 | ||
27 | /* This routine is provided a string, and tries to work out if it | |
28 | could possibly refer to the i960 machine pointed at in the | |
29 | info_struct pointer */ | |
30 | ||
31 | static boolean | |
ae115e51 | 32 | scan_960_mach (ap, string) |
cbe75cb6 ILT |
33 | const bfd_arch_info_type *ap; |
34 | const char *string; | |
e89f2fbe SC |
35 | { |
36 | unsigned long machine; | |
37 | ||
38 | /* Look for the string i960, or somesuch at the front of the string */ | |
39 | ||
ae115e51 | 40 | if (strncmp("i960",string,4) == 0) { |
e89f2fbe SC |
41 | string+=4; |
42 | } | |
43 | else { | |
44 | /* no match, can be us */ | |
45 | return false; | |
46 | } | |
47 | if (string[0] == 0) { | |
48 | /* i960 on it's own means core to us*/ | |
49 | if (ap->mach == bfd_mach_i960_core) return true; | |
50 | return false; | |
51 | } | |
52 | ||
53 | if (string[0] != ':') { | |
54 | return false; | |
55 | } | |
56 | string++; | |
57 | if (string[0] == '\0') | |
58 | return false; | |
59 | if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' && | |
60 | string[3] == 'e' && string[4] == '\0') | |
61 | machine = bfd_mach_i960_core; | |
62 | else if (string[1] == '\0' || string[2] != '\0') /* rest are 2-char */ | |
63 | return false; | |
64 | else if (string[0] == 'k' && string[1] == 'b') | |
65 | machine = bfd_mach_i960_kb_sb; | |
66 | else if (string[0] == 's' && string[1] == 'b') | |
67 | machine = bfd_mach_i960_kb_sb; | |
68 | else if (string[0] == 'm' && string[1] == 'c') | |
69 | machine = bfd_mach_i960_mc; | |
70 | else if (string[0] == 'x' && string[1] == 'a') | |
71 | machine = bfd_mach_i960_xa; | |
72 | else if (string[0] == 'c' && string[1] == 'a') | |
73 | machine = bfd_mach_i960_ca; | |
74 | else if (string[0] == 'k' && string[1] == 'a') | |
75 | machine = bfd_mach_i960_ka_sa; | |
76 | else if (string[0] == 's' && string[1] == 'a') | |
77 | machine = bfd_mach_i960_ka_sa; | |
ae115e51 ILT |
78 | /* start-sanitize-i960xl */ |
79 | else if (string[0] == 'x' && string[1] == 'l') | |
80 | machine = bfd_mach_i960_xl; | |
81 | /* end-sanitize-i960xl */ | |
cbe75cb6 ILT |
82 | else if (string[0] == 'h' && string[1] == 'x') |
83 | machine = bfd_mach_i960_hx; | |
e89f2fbe SC |
84 | else |
85 | return false; | |
86 | if (machine == ap->mach) return true; | |
87 | return false; | |
88 | } | |
89 | ||
90 | ||
91 | ||
92 | /* This routine is provided two arch_infos and works out the i960 | |
93 | machine which would be compatible with both and returns a pointer | |
94 | to its info structure */ | |
95 | ||
cbe75cb6 | 96 | static const bfd_arch_info_type * |
ae115e51 | 97 | compatible (a,b) |
cbe75cb6 ILT |
98 | const bfd_arch_info_type *a; |
99 | const bfd_arch_info_type *b; | |
e89f2fbe SC |
100 | { |
101 | ||
ae115e51 ILT |
102 | /* The i960 has distinct subspecies which may not interbreed: |
103 | CORE CA | |
104 | CORE KA KB MC XA | |
105 | start-sanitize-i960xl | |
106 | CORE XL | |
107 | end-sanitize-i960xl | |
e89f2fbe SC |
108 | Any architecture on the same line is compatible, the one on |
109 | the right is the least restrictive. | |
110 | ||
111 | We represent this information in an array, each machine to a side */ | |
112 | ||
113 | #define ERROR 0 | |
114 | #define CORE bfd_mach_i960_core /*1*/ | |
115 | #define KA bfd_mach_i960_ka_sa /*2*/ | |
116 | #define KB bfd_mach_i960_kb_sb /*3*/ | |
117 | #define MC bfd_mach_i960_mc /*4*/ | |
118 | #define XA bfd_mach_i960_xa /*5*/ | |
119 | #define CA bfd_mach_i960_ca /*6*/ | |
ae115e51 ILT |
120 | /* start-sanitize-i960xl */ |
121 | #define XL bfd_mach_i960_xl /*7*/ | |
ae115e51 | 122 | /* end-sanitize-i960xl */ |
cbe75cb6 ILT |
123 | #define HX bfd_mach_i960_hx /*8*/ |
124 | #define MAX_ARCH ((int)HX) | |
ae115e51 ILT |
125 | |
126 | static CONST unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] = | |
127 | { | |
cbe75cb6 ILT |
128 | { ERROR, CORE, KA, KB, MC, XA, CA, 7, HX }, |
129 | { CORE, CORE, KA, KB, MC, XA, CA, 7, HX }, | |
130 | { KA, KA, KA, KB, MC, XA, ERROR, ERROR, ERROR}, | |
131 | { KB, KB, KB, KB, MC, XA, ERROR, ERROR, ERROR}, | |
132 | { MC, MC, MC, MC, MC, XA, ERROR, ERROR, ERROR}, | |
133 | { XA, XA, XA, XA, XA, XA, ERROR, ERROR, ERROR}, | |
134 | { CA, CA, ERROR, ERROR, ERROR, ERROR, CA, ERROR, ERROR}, | |
135 | { 7, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR, 7 }, | |
136 | { HX, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR, 8 }, | |
ae115e51 | 137 | }; |
e89f2fbe SC |
138 | |
139 | ||
140 | if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR) | |
141 | { | |
ae115e51 | 142 | return NULL; |
e89f2fbe SC |
143 | } |
144 | else | |
145 | { | |
146 | return (a->mach == matrix[a->mach][b->mach]) ? a : b; | |
147 | } | |
148 | } | |
149 | ||
150 | ||
151 | ||
152 | int bfd_default_scan_num_mach(); | |
cbe75cb6 ILT |
153 | #define N(a,b,d,n) \ |
154 | { 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,} | |
e89f2fbe | 155 | |
cbe75cb6 | 156 | static const bfd_arch_info_type arch_info_struct[] = |
e89f2fbe | 157 | { |
cbe75cb6 ILT |
158 | N(bfd_mach_i960_ka_sa,"i960:ka_sa",false, &arch_info_struct[1]), |
159 | N(bfd_mach_i960_kb_sb,"i960:kb_sb",false, &arch_info_struct[2]), | |
160 | N(bfd_mach_i960_mc, "i960:mc", false, &arch_info_struct[3]), | |
161 | N(bfd_mach_i960_xa, "i960:xa", false, &arch_info_struct[4]), | |
162 | N(bfd_mach_i960_ca, "i960:ca", false, &arch_info_struct[5]), | |
ae115e51 | 163 | /* start-sanitize-i960xl */ |
cbe75cb6 | 164 | N(bfd_mach_i960_xl, "i960:xl", false, &arch_info_struct[6]), |
ae115e51 | 165 | /* end-sanitize-i960xl */ |
cbe75cb6 | 166 | N(bfd_mach_i960_hx, "i960:hx", false, 0), |
ae115e51 | 167 | }; |
e89f2fbe | 168 | |
cbe75cb6 ILT |
169 | const bfd_arch_info_type bfd_i960_arch = |
170 | N(bfd_mach_i960_core, "i960:core", true, &arch_info_struct[0]); |