]>
Commit | Line | Data |
---|---|---|
e89f2fbe SC |
1 | /* BFD library support routines for the i960 architecture. |
2 | Copyright (C) 1990-1991 Free Software Foundation, Inc. | |
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 | |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
21 | ||
22 | #include <sysdep.h> | |
23 | #include "bfd.h" | |
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 | |
32 | DEFUN(scan_960_mach, (ap, string), | |
33 | CONST bfd_arch_info_struct_type *ap AND | |
34 | CONST char *string) | |
35 | { | |
36 | unsigned long machine; | |
37 | ||
38 | /* Look for the string i960, or somesuch at the front of the string */ | |
39 | ||
40 | if (strncmp("i960",string) == 0) { | |
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; | |
78 | else | |
79 | return false; | |
80 | if (machine == ap->mach) return true; | |
81 | return false; | |
82 | } | |
83 | ||
84 | ||
85 | ||
86 | /* This routine is provided two arch_infos and works out the i960 | |
87 | machine which would be compatible with both and returns a pointer | |
88 | to its info structure */ | |
89 | ||
90 | CONST bfd_arch_info_struct_type * | |
91 | DEFUN(compatible,(a,b), | |
92 | CONST bfd_arch_info_struct_type *a AND | |
93 | CONST bfd_arch_info_struct_type *b) | |
94 | { | |
95 | ||
96 | /* The i960 has two distinct subspecies which may not interbreed: | |
97 | CORE CA | |
98 | CORE KA KB MC XA | |
99 | Any architecture on the same line is compatible, the one on | |
100 | the right is the least restrictive. | |
101 | ||
102 | We represent this information in an array, each machine to a side */ | |
103 | ||
104 | #define ERROR 0 | |
105 | #define CORE bfd_mach_i960_core /*1*/ | |
106 | #define KA bfd_mach_i960_ka_sa /*2*/ | |
107 | #define KB bfd_mach_i960_kb_sb /*3*/ | |
108 | #define MC bfd_mach_i960_mc /*4*/ | |
109 | #define XA bfd_mach_i960_xa /*5*/ | |
110 | #define CA bfd_mach_i960_ca /*6*/ | |
111 | ||
112 | ||
113 | static CONST char matrix[7][7] = | |
114 | { | |
115 | ERROR,CORE, KA, KB, MC, XA, CA, | |
116 | CORE, CORE, KA, KB, MC, XA, CA, | |
117 | KA, KA, KA, KB, MC, XA, ERROR, | |
118 | KB, KB, KB, KB, MC, XA, ERROR, | |
119 | MC, MC, MC, MC, MC, XA, ERROR, | |
120 | XA, XA, XA, XA, XA, XA, ERROR, | |
121 | CA, CA, ERROR, ERROR, ERROR, ERROR, CA | |
122 | }; | |
123 | ||
124 | ||
125 | if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR) | |
126 | { | |
127 | return (bfd_arch_info_struct_type *)NULL; | |
128 | } | |
129 | else | |
130 | { | |
131 | return (a->mach == matrix[a->mach][b->mach]) ? a : b; | |
132 | } | |
133 | } | |
134 | ||
135 | ||
136 | ||
137 | int bfd_default_scan_num_mach(); | |
138 | #define N(a,b,d) \ | |
139 | { 32, 32, 8,bfd_arch_i960,a,"i960",b,d,compatible,scan_960_mach,0,} | |
140 | ||
141 | static bfd_arch_info_struct_type arch_info_struct[] = | |
142 | { | |
143 | N(bfd_mach_i960_core,"i960:core",true), | |
144 | N(bfd_mach_i960_ka_sa,"i960:ka_sa",false), | |
145 | N(bfd_mach_i960_kb_sb,"i960:kb_sb",false), | |
146 | N(bfd_mach_i960_mc,"i960:mc",false), | |
147 | N(bfd_mach_i960_xa,"i960:xa",false), | |
148 | N(bfd_mach_i960_ca,"i960:ca",false) | |
149 | }; | |
150 | ||
151 | ||
152 | void DEFUN_VOID(bfd_i960_arch) | |
153 | { | |
154 | unsigned int i; | |
155 | for (i = 0; i < 6; i++) { | |
156 | bfd_arch_linkin(arch_info_struct + i); | |
157 | } | |
158 | } |