OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-6.8/] [pre-binutils-2.20.1-sync/] [sim/] [ppc/] [registers.c] - Diff between revs 157 and 223

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 157 Rev 223
/*  This file is part of the program psim.
/*  This file is part of the program psim.
 
 
    Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
    Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
 
 
    This program is free software; you can redistribute it and/or modify
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    (at your option) any later version.
 
 
    This program is distributed in the hope that it will be useful,
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    GNU General Public License for more details.
 
 
    You should have received a copy of the GNU General Public License
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 
    */
    */
 
 
 
 
#ifndef _REGISTERS_C_
#ifndef _REGISTERS_C_
#define _REGISTERS_C_
#define _REGISTERS_C_
 
 
#include <ctype.h>
#include <ctype.h>
 
 
#include "basics.h"
#include "basics.h"
#include "registers.h"
#include "registers.h"
 
 
#ifdef HAVE_STDLIB_H
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#include <stdlib.h>
#endif
#endif
 
 
#ifdef HAVE_STRING_H
#ifdef HAVE_STRING_H
#include <string.h>
#include <string.h>
#else
#else
#ifdef HAVE_STRINGS_H
#ifdef HAVE_STRINGS_H
#include <strings.h>
#include <strings.h>
#endif
#endif
#endif
#endif
 
 
 
 
INLINE_REGISTERS\
INLINE_REGISTERS\
(void)
(void)
registers_dump(registers *registers)
registers_dump(registers *registers)
{
{
  int i;
  int i;
  int j;
  int j;
  for (i = 0; i < 8; i++) {
  for (i = 0; i < 8; i++) {
    printf_filtered("GPR %2d:", i*4);
    printf_filtered("GPR %2d:", i*4);
    for (j = 0; j < 4; j++) {
    for (j = 0; j < 4; j++) {
      printf_filtered(" 0x%08lx", (long)registers->gpr[i*4 + j]);
      printf_filtered(" 0x%08lx", (long)registers->gpr[i*4 + j]);
    }
    }
    printf_filtered("\n");
    printf_filtered("\n");
  }
  }
}
}
 
 
STATIC_INLINE_REGISTERS\
STATIC_INLINE_REGISTERS\
(sprs)
(sprs)
find_spr(const char name[])
find_spr(const char name[])
{
{
  sprs spr;
  sprs spr;
  for (spr = 0; spr < nr_of_sprs; spr++)
  for (spr = 0; spr < nr_of_sprs; spr++)
    if (spr_is_valid(spr)
    if (spr_is_valid(spr)
        && !strcmp(name, spr_name(spr))
        && !strcmp(name, spr_name(spr))
        && spr_index(spr) == spr)
        && spr_index(spr) == spr)
      return spr;
      return spr;
  return nr_of_sprs;
  return nr_of_sprs;
}
}
 
 
STATIC_INLINE_REGISTERS\
STATIC_INLINE_REGISTERS\
(int)
(int)
are_digits(const char *digits)
are_digits(const char *digits)
{
{
  while (isdigit(*digits))
  while (isdigit(*digits))
    digits++;
    digits++;
  return *digits == '\0';
  return *digits == '\0';
}
}
 
 
 
 
INLINE_REGISTERS\
INLINE_REGISTERS\
(register_descriptions)
(register_descriptions)
register_description(const char reg[])
register_description(const char reg[])
{
{
  register_descriptions description;
  register_descriptions description;
 
 
  /* try for a general-purpose integer or floating point register */
  /* try for a general-purpose integer or floating point register */
  if (reg[0] == 'r' && are_digits(reg + 1)) {
  if (reg[0] == 'r' && are_digits(reg + 1)) {
    description.type = reg_gpr;
    description.type = reg_gpr;
    description.index = atoi(reg+1);
    description.index = atoi(reg+1);
    description.size = sizeof(gpreg);
    description.size = sizeof(gpreg);
  }
  }
  else if (reg[0] == 'f' && are_digits(reg + 1)) {
  else if (reg[0] == 'f' && are_digits(reg + 1)) {
    description.type = reg_fpr;
    description.type = reg_fpr;
    description.index = atoi(reg+1);
    description.index = atoi(reg+1);
    description.size = sizeof(fpreg);
    description.size = sizeof(fpreg);
  }
  }
  else if (!strcmp(reg, "pc") || !strcmp(reg, "nia")) {
  else if (!strcmp(reg, "pc") || !strcmp(reg, "nia")) {
    description.type = reg_pc;
    description.type = reg_pc;
    description.index = 0;
    description.index = 0;
    description.size = sizeof(unsigned_word);
    description.size = sizeof(unsigned_word);
  }
  }
  else if (!strcmp(reg, "sp")) {
  else if (!strcmp(reg, "sp")) {
    description.type = reg_gpr;
    description.type = reg_gpr;
    description.index = 1;
    description.index = 1;
    description.size = sizeof(gpreg);
    description.size = sizeof(gpreg);
  }
  }
  else if (!strcmp(reg, "toc")) {
  else if (!strcmp(reg, "toc")) {
    description.type = reg_gpr;
    description.type = reg_gpr;
    description.index = 2;
    description.index = 2;
    description.size = sizeof(gpreg);
    description.size = sizeof(gpreg);
  }
  }
  else if (!strcmp(reg, "cr") || !strcmp(reg, "cnd")) {
  else if (!strcmp(reg, "cr") || !strcmp(reg, "cnd")) {
    description.type = reg_cr;
    description.type = reg_cr;
    description.index = 0;
    description.index = 0;
    description.size = sizeof(creg); /* FIXME */
    description.size = sizeof(creg); /* FIXME */
  }
  }
  else if (!strcmp(reg, "msr") || !strcmp(reg, "ps")) {
  else if (!strcmp(reg, "msr") || !strcmp(reg, "ps")) {
    description.type = reg_msr;
    description.type = reg_msr;
    description.index = 0;
    description.index = 0;
    description.size = sizeof(msreg);
    description.size = sizeof(msreg);
  }
  }
  else if (!strcmp(reg, "fpscr")) {
  else if (!strcmp(reg, "fpscr")) {
    description.type = reg_fpscr;
    description.type = reg_fpscr;
    description.index = 0;
    description.index = 0;
    description.size = sizeof(fpscreg);
    description.size = sizeof(fpscreg);
  }
  }
  else if (!strncmp(reg, "sr", 2) && are_digits(reg + 2)) {
  else if (!strncmp(reg, "sr", 2) && are_digits(reg + 2)) {
    description.type = reg_sr;
    description.type = reg_sr;
    description.index = atoi(reg+2);
    description.index = atoi(reg+2);
    description.size = sizeof(sreg);
    description.size = sizeof(sreg);
  }
  }
  else if (!strcmp(reg, "cnt")) {
  else if (!strcmp(reg, "cnt")) {
    description.type = reg_spr;
    description.type = reg_spr;
    description.index = spr_ctr;
    description.index = spr_ctr;
    description.size = sizeof(spreg);
    description.size = sizeof(spreg);
  }
  }
  else if (!strcmp(reg, "insns")) {
  else if (!strcmp(reg, "insns")) {
    description.type = reg_insns;
    description.type = reg_insns;
    description.index = spr_ctr;
    description.index = spr_ctr;
    description.size = sizeof(unsigned_word);
    description.size = sizeof(unsigned_word);
  }
  }
  else if (!strcmp(reg, "stalls")) {
  else if (!strcmp(reg, "stalls")) {
    description.type = reg_stalls;
    description.type = reg_stalls;
    description.index = spr_ctr;
    description.index = spr_ctr;
    description.size = sizeof(unsigned_word);
    description.size = sizeof(unsigned_word);
  }
  }
  else if (!strcmp(reg, "cycles")) {
  else if (!strcmp(reg, "cycles")) {
    description.type = reg_cycles;
    description.type = reg_cycles;
    description.index = spr_ctr;
    description.index = spr_ctr;
    description.size = sizeof(unsigned_word);
    description.size = sizeof(unsigned_word);
  }
  }
#ifdef WITH_ALTIVEC
#ifdef WITH_ALTIVEC
  else if (reg[0] == 'v' && reg[1] == 'r' && are_digits(reg + 2)) {
  else if (reg[0] == 'v' && reg[1] == 'r' && are_digits(reg + 2)) {
    description.type = reg_vr;
    description.type = reg_vr;
    description.index = atoi(reg+2);
    description.index = atoi(reg+2);
    description.size = sizeof(vreg);
    description.size = sizeof(vreg);
  }
  }
   else if (!strcmp(reg, "vscr")) {
   else if (!strcmp(reg, "vscr")) {
    description.type = reg_vscr;
    description.type = reg_vscr;
    description.index = 0;
    description.index = 0;
    description.size = sizeof(vscreg);
    description.size = sizeof(vscreg);
  }
  }
#endif
#endif
#ifdef WITH_E500
#ifdef WITH_E500
  else if (reg[0] == 'e' && reg[1] == 'v' && are_digits(reg + 2)) {
  else if (reg[0] == 'e' && reg[1] == 'v' && are_digits(reg + 2)) {
    description.type = reg_evr;
    description.type = reg_evr;
    description.index = atoi(reg+2);
    description.index = atoi(reg+2);
    description.size = sizeof(unsigned64);
    description.size = sizeof(unsigned64);
  }
  }
  else if (reg[0] == 'r' && reg[1] == 'h' && are_digits(reg + 2)) {
  else if (reg[0] == 'r' && reg[1] == 'h' && are_digits(reg + 2)) {
    description.type = reg_gprh;
    description.type = reg_gprh;
    description.index = atoi(reg+2);
    description.index = atoi(reg+2);
    description.size = sizeof(gpreg);
    description.size = sizeof(gpreg);
  }
  }
  else if (!strcmp(reg, "acc")) {
  else if (!strcmp(reg, "acc")) {
    description.type = reg_acc;
    description.type = reg_acc;
    description.index = 0;
    description.index = 0;
    description.size = sizeof(unsigned64);
    description.size = sizeof(unsigned64);
  }
  }
#endif
#endif
  else {
  else {
    sprs spr = find_spr(reg);
    sprs spr = find_spr(reg);
    if (spr != nr_of_sprs) {
    if (spr != nr_of_sprs) {
      description.type = reg_spr;
      description.type = reg_spr;
      description.index = spr;
      description.index = spr;
      description.size = sizeof(spreg);
      description.size = sizeof(spreg);
    }
    }
    else {
    else {
      description.type = reg_invalid;
      description.type = reg_invalid;
      description.index = 0;
      description.index = 0;
      description.size = 0;
      description.size = 0;
    }
    }
  }
  }
  return description;
  return description;
}
}
 
 
#endif /* _REGISTERS_C_ */
#endif /* _REGISTERS_C_ */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.