00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "bfd.h"
00023 #include "sysdep.h"
00024 #include "libbfd.h"
00025
00026 static bfd_boolean scan_960_mach
00027 PARAMS ((const bfd_arch_info_type *, const char *));
00028 static const bfd_arch_info_type *compatible
00029 PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
00030
00031
00032
00033
00034
00035 static bfd_boolean
00036 scan_960_mach (ap, string)
00037 const bfd_arch_info_type *ap;
00038 const char *string;
00039 {
00040 unsigned long machine;
00041 int fail_because_not_80960 = FALSE;
00042
00043
00044 if (strncasecmp ("i960", string, 4) == 0)
00045 {
00046 string += 4;
00047
00048
00049 if (* string == 0)
00050 return ap->mach == bfd_mach_i960_core;
00051
00052
00053 if (* string != ':')
00054 return FALSE;
00055
00056 string ++;
00057 }
00058
00059
00060 else if (strncmp ("80960", string, 5) == 0)
00061 {
00062 string += 5;
00063
00064
00065
00066 fail_because_not_80960 = TRUE;
00067 }
00068
00069 else
00070 return FALSE;
00071
00072 if (* string == '\0')
00073 return FALSE;
00074
00075 if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' &&
00076 string[3] == 'e' && string[4] == '\0')
00077 machine = bfd_mach_i960_core;
00078 else if (strcasecmp (string, "ka_sa") == 0)
00079 machine = bfd_mach_i960_ka_sa;
00080 else if (strcasecmp (string, "kb_sb") == 0)
00081 machine = bfd_mach_i960_kb_sb;
00082 else if (string[1] == '\0' || string[2] != '\0')
00083 return FALSE;
00084 else if (string[0] == 'k' && string[1] == 'b')
00085 { machine = bfd_mach_i960_kb_sb; fail_because_not_80960 = FALSE; }
00086 else if (string[0] == 's' && string[1] == 'b')
00087 machine = bfd_mach_i960_kb_sb;
00088 else if (string[0] == 'm' && string[1] == 'c')
00089 { machine = bfd_mach_i960_mc; fail_because_not_80960 = FALSE; }
00090 else if (string[0] == 'x' && string[1] == 'a')
00091 machine = bfd_mach_i960_xa;
00092 else if (string[0] == 'c' && string[1] == 'a')
00093 { machine = bfd_mach_i960_ca; fail_because_not_80960 = FALSE; }
00094 else if (string[0] == 'k' && string[1] == 'a')
00095 { machine = bfd_mach_i960_ka_sa; fail_because_not_80960 = FALSE; }
00096 else if (string[0] == 's' && string[1] == 'a')
00097 machine = bfd_mach_i960_ka_sa;
00098 else if (string[0] == 'j' && string[1] == 'x')
00099 machine = bfd_mach_i960_jx;
00100 else if (string[0] == 'h' && string[1] == 'x')
00101 machine = bfd_mach_i960_hx;
00102 else
00103 return FALSE;
00104
00105 if (fail_because_not_80960)
00106 return FALSE;
00107
00108 if (machine == ap->mach)
00109 return TRUE;
00110
00111 return FALSE;
00112 }
00113
00114
00115
00116
00117
00118 static const bfd_arch_info_type *
00119 compatible (a,b)
00120 const bfd_arch_info_type *a;
00121 const bfd_arch_info_type *b;
00122 {
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 #define ERROR 0
00134 #define CORE bfd_mach_i960_core
00135 #define KA bfd_mach_i960_ka_sa
00136 #define KB bfd_mach_i960_kb_sb
00137 #define MC bfd_mach_i960_mc
00138 #define XA bfd_mach_i960_xa
00139 #define CA bfd_mach_i960_ca
00140 #define JX bfd_mach_i960_jx
00141 #define HX bfd_mach_i960_hx
00142 #define MAX_ARCH ((int)HX)
00143
00144 static const unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
00145 {
00146 { ERROR, CORE, KA, KB, MC, XA, CA, JX, HX },
00147 { CORE, CORE, KA, KB, MC, XA, CA, JX, HX },
00148 { KA, KA, KA, KB, MC, XA, ERROR, ERROR, ERROR},
00149 { KB, KB, KB, KB, MC, XA, ERROR, ERROR, ERROR},
00150 { MC, MC, MC, MC, MC, XA, ERROR, ERROR, ERROR},
00151 { XA, XA, XA, XA, XA, XA, ERROR, ERROR, ERROR},
00152 { CA, CA, ERROR, ERROR, ERROR, ERROR, CA, ERROR, ERROR},
00153 { JX, JX, ERROR, ERROR, ERROR, ERROR, ERROR, JX, HX },
00154 { HX, HX, ERROR, ERROR, ERROR, ERROR, ERROR, HX, HX },
00155 };
00156
00157 if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR)
00158 {
00159 return NULL;
00160 }
00161 else
00162 {
00163 return (a->mach == matrix[a->mach][b->mach]) ? a : b;
00164 }
00165 }
00166
00167 #define N(a,b,d,n) \
00168 { 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,}
00169
00170 static const bfd_arch_info_type arch_info_struct[] =
00171 {
00172 N(bfd_mach_i960_ka_sa,"i960:ka_sa",FALSE, &arch_info_struct[1]),
00173 N(bfd_mach_i960_kb_sb,"i960:kb_sb",FALSE, &arch_info_struct[2]),
00174 N(bfd_mach_i960_mc, "i960:mc", FALSE, &arch_info_struct[3]),
00175 N(bfd_mach_i960_xa, "i960:xa", FALSE, &arch_info_struct[4]),
00176 N(bfd_mach_i960_ca, "i960:ca", FALSE, &arch_info_struct[5]),
00177 N(bfd_mach_i960_jx, "i960:jx", FALSE, &arch_info_struct[6]),
00178 N(bfd_mach_i960_hx, "i960:hx", FALSE, 0),
00179 };
00180
00181 const bfd_arch_info_type bfd_i960_arch =
00182 N(bfd_mach_i960_core, "i960:core", TRUE, &arch_info_struct[0]);