Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/opcodes/arc-ext.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    1 /* ARC target-dependent stuff. Extension structure access functions 
     1/* ARC target-dependent stuff. Extension structure access functions
    22   Copyright 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
    33
     
    1818   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    1919
     20#include "sysdep.h"
    2021#include <stdlib.h>
    2122#include <stdio.h>
     
    3031
    3132const char *
    32 arcExtMap_instName(int opcode, int minor, int *flags) 
    33 {
    34     if (opcode == 3) 
     33arcExtMap_instName(int opcode, int minor, int *flags)
     34{
     35    if (opcode == 3)
    3536      {
    3637        /* FIXME: ??? need to also check 0/1/2 in bit0 for (3f) brk/sleep/swi  */
     
    5455
    5556const char *
    56 arcExtMap_coreRegName(int value) 
     57arcExtMap_coreRegName(int value)
    5758{
    5859  if (value < 32)
     
    6465
    6566const char *
    66 arcExtMap_condCodeName(int value) 
     67arcExtMap_condCodeName(int value)
    6768{
    6869  if (value < 16)
     
    8990   the list is empty.  */
    9091
    91 static void 
     92static void
    9293clean_aux_registers(struct ExtAuxRegister *r)
    9394{
     
    99100      r ->next = NULL;
    100101    }
    101   else 
     102  else
    102103    free(r -> name);
    103104}
    104              
     105
    105106/* Free memory that has been allocated for the extensions.  */
    106107
    107 static void 
    108 cleanup_ext_map(void) 
     108static void
     109cleanup_ext_map(void)
    109110{
    110111  struct ExtAuxRegister *r;
     
    114115  /* clean aux reg structure  */
    115116  r = arc_extension_map.auxRegisters;
    116   if (r) 
     117  if (r)
    117118    {
    118119      (clean_aux_registers(r));
    119120      free(r);
    120121    }
    121  
     122
    122123  /* clean instructions  */
    123   for (i = 0; i < NUM_EXT_INST; i++) 
     124  for (i = 0; i < NUM_EXT_INST; i++)
    124125    {
    125126      insn = arc_extension_map.instructions[i];
     
    127128        free(insn->name);
    128129    }
    129  
     130
    130131  /* clean core reg struct  */
    131   for (i = 0; i < NUM_EXT_CORE; i++) 
     132  for (i = 0; i < NUM_EXT_CORE; i++)
    132133    {
    133134      if (arc_extension_map.coreRegisters[i])
    134135        free(arc_extension_map.coreRegisters[i]);
    135136    }
    136  
     137
    137138  for (i = 0; i < NUM_EXT_COND; i++) {
    138139    if (arc_extension_map.condCodes[i])
    139140      free(arc_extension_map.condCodes[i]);
    140141  }
    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
     146int
     147arcExtMap_add(void *base, unsigned long length)
    147148{
    148149  unsigned char *block = base;
    149150  unsigned char *p = block;
    150  
     151
    151152  /* Clean up and reset everything if needed.  */
    152153  cleanup_ext_map();
    153154
    154   while (p && p < (block + length)) 
     155  while (p && p < (block + length))
    155156    {
    156157      /* p[0] == length of record
     
    171172      if (p[0] == 0)
    172173        return -1;
    173      
     174
    174175      switch (p[1])
    175176        {
     
    179180            char minor  = p[3];
    180181            char * insn_name = (char *) xmalloc(( (int)*p-5) * sizeof(char));
    181             struct ExtInstruction * insn = 
     182            struct ExtInstruction * insn =
    182183              (struct ExtInstruction *) xmalloc(sizeof(struct ExtInstruction));
    183            
     184
    184185            if (opcode==3)
    185186              opcode = 0x1f - 0x10 + minor - 0x09 + 1;
     
    192193          }
    193194          break;
    194        
    195         case EXT_CORE_REGISTER: 
     195
     196        case EXT_CORE_REGISTER:
    196197          {
    197198            char * core_name = (char *) xmalloc(((int)*p-3) * sizeof(char));
     
    201202          }
    202203          break;
    203          
    204         case EXT_COND_CODE: 
     204
     205        case EXT_COND_CODE:
    205206          {
    206207            char * cc_name = (char *) xmalloc( ((int)*p-3) * sizeof(char));
    207208            strcpy(cc_name, (p+3));
    208209            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:
    213214          {
    214215            /* trickier -- need to store linked list to these  */
    215             struct ExtAuxRegister *newAuxRegister = 
     216            struct ExtAuxRegister *newAuxRegister =
    216217              (struct ExtAuxRegister *)malloc(sizeof(struct ExtAuxRegister));
    217218            char * aux_name = (char *) xmalloc ( ((int)*p-6) * sizeof(char));
     
    224225          }
    225226          break;
    226          
     227
    227228        default:
    228229          return -1;
    229          
     230
    230231        }
    231232      p += p[0]; /* move to next record  */
    232233    }
    233  
     234
    234235  return 0;
    235236}
Note: See TracChangeset for help on using the changeset viewer.