Changeset 609 for branches/GNU/src/binutils/opcodes/arc-ext.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/opcodes/arc-ext.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 /* ARC target-dependent stuff. Extension structure access functions 1 /* ARC target-dependent stuff. Extension structure access functions 2 2 Copyright 1995, 1997, 2000, 2001 Free Software Foundation, Inc. 3 3 … … 18 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 19 19 20 #include "sysdep.h" 20 21 #include <stdlib.h> 21 22 #include <stdio.h> … … 30 31 31 32 const char * 32 arcExtMap_instName(int opcode, int minor, int *flags) 33 { 34 if (opcode == 3) 33 arcExtMap_instName(int opcode, int minor, int *flags) 34 { 35 if (opcode == 3) 35 36 { 36 37 /* FIXME: ??? need to also check 0/1/2 in bit0 for (3f) brk/sleep/swi */ … … 54 55 55 56 const char * 56 arcExtMap_coreRegName(int value) 57 arcExtMap_coreRegName(int value) 57 58 { 58 59 if (value < 32) … … 64 65 65 66 const char * 66 arcExtMap_condCodeName(int value) 67 arcExtMap_condCodeName(int value) 67 68 { 68 69 if (value < 16) … … 89 90 the list is empty. */ 90 91 91 static void 92 static void 92 93 clean_aux_registers(struct ExtAuxRegister *r) 93 94 { … … 99 100 r ->next = NULL; 100 101 } 101 else 102 else 102 103 free(r -> name); 103 104 } 104 105 105 106 /* Free memory that has been allocated for the extensions. */ 106 107 107 static void 108 cleanup_ext_map(void) 108 static void 109 cleanup_ext_map(void) 109 110 { 110 111 struct ExtAuxRegister *r; … … 114 115 /* clean aux reg structure */ 115 116 r = arc_extension_map.auxRegisters; 116 if (r) 117 if (r) 117 118 { 118 119 (clean_aux_registers(r)); 119 120 free(r); 120 121 } 121 122 122 123 /* clean instructions */ 123 for (i = 0; i < NUM_EXT_INST; i++) 124 for (i = 0; i < NUM_EXT_INST; i++) 124 125 { 125 126 insn = arc_extension_map.instructions[i]; … … 127 128 free(insn->name); 128 129 } 129 130 130 131 /* clean core reg struct */ 131 for (i = 0; i < NUM_EXT_CORE; i++) 132 for (i = 0; i < NUM_EXT_CORE; i++) 132 133 { 133 134 if (arc_extension_map.coreRegisters[i]) 134 135 free(arc_extension_map.coreRegisters[i]); 135 136 } 136 137 137 138 for (i = 0; i < NUM_EXT_COND; i++) { 138 139 if (arc_extension_map.condCodes[i]) 139 140 free(arc_extension_map.condCodes[i]); 140 141 } 141 142 memset(&arc_extension_map, 0, sizeof(struct arcExtMap)); 143 } 144 145 int 146 arcExtMap_add(void *base, unsigned long length) 142 143 memset(&arc_extension_map, 0, sizeof(struct arcExtMap)); 144 } 145 146 int 147 arcExtMap_add(void *base, unsigned long length) 147 148 { 148 149 unsigned char *block = base; 149 150 unsigned char *p = block; 150 151 151 152 /* Clean up and reset everything if needed. */ 152 153 cleanup_ext_map(); 153 154 154 while (p && p < (block + length)) 155 while (p && p < (block + length)) 155 156 { 156 157 /* p[0] == length of record … … 171 172 if (p[0] == 0) 172 173 return -1; 173 174 174 175 switch (p[1]) 175 176 { … … 179 180 char minor = p[3]; 180 181 char * insn_name = (char *) xmalloc(( (int)*p-5) * sizeof(char)); 181 struct ExtInstruction * insn = 182 struct ExtInstruction * insn = 182 183 (struct ExtInstruction *) xmalloc(sizeof(struct ExtInstruction)); 183 184 184 185 if (opcode==3) 185 186 opcode = 0x1f - 0x10 + minor - 0x09 + 1; … … 192 193 } 193 194 break; 194 195 case EXT_CORE_REGISTER: 195 196 case EXT_CORE_REGISTER: 196 197 { 197 198 char * core_name = (char *) xmalloc(((int)*p-3) * sizeof(char)); … … 201 202 } 202 203 break; 203 204 case EXT_COND_CODE: 204 205 case EXT_COND_CODE: 205 206 { 206 207 char * cc_name = (char *) xmalloc( ((int)*p-3) * sizeof(char)); 207 208 strcpy(cc_name, (p+3)); 208 209 arc_extension_map.condCodes[p[2]-16] = cc_name; 209 } 210 break; 211 212 case EXT_AUX_REGISTER: 210 } 211 break; 212 213 case EXT_AUX_REGISTER: 213 214 { 214 215 /* trickier -- need to store linked list to these */ 215 struct ExtAuxRegister *newAuxRegister = 216 struct ExtAuxRegister *newAuxRegister = 216 217 (struct ExtAuxRegister *)malloc(sizeof(struct ExtAuxRegister)); 217 218 char * aux_name = (char *) xmalloc ( ((int)*p-6) * sizeof(char)); … … 224 225 } 225 226 break; 226 227 227 228 default: 228 229 return -1; 229 230 230 231 } 231 232 p += p[0]; /* move to next record */ 232 233 } 233 234 234 235 return 0; 235 236 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.