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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [sim/] [erc32/] [interf.c] - Diff between revs 24 and 157

Only display areas with differences | Details | Blame | View Log

Rev 24 Rev 157
/*
/*
 * This file is part of SIS.
 * This file is part of SIS.
 *
 *
 * SIS, SPARC instruction simulator V1.6 Copyright (C) 1995 Jiri Gaisler,
 * SIS, SPARC instruction simulator V1.6 Copyright (C) 1995 Jiri Gaisler,
 * European Space Agency
 * European Space Agency
 *
 *
 * This program is free software; you can redistribute it and/or modify it under
 * 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 the Free
 * the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 * any later version.
 *
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * more details.
 *
 *
 * You should have received a copy of the GNU General Public License along with
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 675
 * this program; if not, write to the Free Software Foundation, Inc., 675
 * Mass Ave, Cambridge, MA 02139, USA.
 * Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 */
 */
 
 
#include <signal.h>
#include <signal.h>
#include <string.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <time.h>
#include <time.h>
#include <sys/fcntl.h>
#include <sys/fcntl.h>
#include "sis.h"
#include "sis.h"
#include "libiberty.h"
#include "libiberty.h"
#include "bfd.h"
#include "bfd.h"
#include <dis-asm.h>
#include <dis-asm.h>
#include "sim-config.h"
#include "sim-config.h"
 
 
#include "gdb/remote-sim.h"
#include "gdb/remote-sim.h"
#include "gdb/signals.h"
#include "gdb/signals.h"
 
 
#define PSR_CWP 0x7
#define PSR_CWP 0x7
 
 
#define VAL(x)  strtol(x,(char **)NULL,0)
#define VAL(x)  strtol(x,(char **)NULL,0)
 
 
extern struct disassemble_info dinfo;
extern struct disassemble_info dinfo;
extern struct pstate sregs;
extern struct pstate sregs;
extern struct estate ebase;
extern struct estate ebase;
 
 
extern int      current_target_byte_order;
extern int      current_target_byte_order;
extern int      ctrl_c;
extern int      ctrl_c;
extern int      nfp;
extern int      nfp;
extern int      ift;
extern int      ift;
extern int      rom8;
extern int      rom8;
extern int      wrp;
extern int      wrp;
extern int      uben;
extern int      uben;
extern int      sis_verbose;
extern int      sis_verbose;
extern char    *sis_version;
extern char    *sis_version;
extern struct estate ebase;
extern struct estate ebase;
extern struct evcell evbuf[];
extern struct evcell evbuf[];
extern struct irqcell irqarr[];
extern struct irqcell irqarr[];
extern int      irqpend, ext_irl;
extern int      irqpend, ext_irl;
extern int      sparclite;
extern int      sparclite;
extern int      dumbio;
extern int      dumbio;
extern int      sparclite_board;
extern int      sparclite_board;
extern int      termsave;
extern int      termsave;
extern char     uart_dev1[], uart_dev2[];
extern char     uart_dev1[], uart_dev2[];
 
 
int             sis_gdb_break = 1;
int             sis_gdb_break = 1;
 
 
host_callback *sim_callback;
host_callback *sim_callback;
 
 
int
int
run_sim(sregs, icount, dis)
run_sim(sregs, icount, dis)
    struct pstate  *sregs;
    struct pstate  *sregs;
    unsigned int    icount;
    unsigned int    icount;
    int             dis;
    int             dis;
{
{
    int             mexc, irq;
    int             mexc, irq;
 
 
    if (sis_verbose)
    if (sis_verbose)
        (*sim_callback->printf_filtered) (sim_callback, "resuming at %x\n",
        (*sim_callback->printf_filtered) (sim_callback, "resuming at %x\n",
                                          sregs->pc);
                                          sregs->pc);
   init_stdio();
   init_stdio();
   sregs->starttime = time(NULL);
   sregs->starttime = time(NULL);
   irq = 0;
   irq = 0;
   while (!sregs->err_mode & (icount > 0)) {
   while (!sregs->err_mode & (icount > 0)) {
 
 
        sregs->fhold = 0;
        sregs->fhold = 0;
        sregs->hold = 0;
        sregs->hold = 0;
        sregs->icnt = 1;
        sregs->icnt = 1;
 
 
        if (sregs->psr & 0x080)
        if (sregs->psr & 0x080)
            sregs->asi = 8;
            sregs->asi = 8;
        else
        else
            sregs->asi = 9;
            sregs->asi = 9;
 
 
#if 0   /* DELETE ME! for debugging purposes only */
#if 0   /* DELETE ME! for debugging purposes only */
        if (sis_verbose > 1)
        if (sis_verbose > 1)
            if (sregs->pc == 0 || sregs->npc == 0)
            if (sregs->pc == 0 || sregs->npc == 0)
                printf ("bogus pc or npc\n");
                printf ("bogus pc or npc\n");
#endif
#endif
        mexc = memory_read(sregs->asi, sregs->pc, &sregs->inst,
        mexc = memory_read(sregs->asi, sregs->pc, &sregs->inst,
                           2, &sregs->hold);
                           2, &sregs->hold);
#if 1   /* DELETE ME! for debugging purposes only */
#if 1   /* DELETE ME! for debugging purposes only */
        if (sis_verbose > 2)
        if (sis_verbose > 2)
            printf("pc %x, np %x, sp %x, fp %x, wm %x, cw %x, i %08x\n",
            printf("pc %x, np %x, sp %x, fp %x, wm %x, cw %x, i %08x\n",
                   sregs->pc, sregs->npc,
                   sregs->pc, sregs->npc,
                   sregs->r[(((sregs->psr & 7) << 4) + 14) & 0x7f],
                   sregs->r[(((sregs->psr & 7) << 4) + 14) & 0x7f],
                   sregs->r[(((sregs->psr & 7) << 4) + 30) & 0x7f],
                   sregs->r[(((sregs->psr & 7) << 4) + 30) & 0x7f],
                   sregs->wim,
                   sregs->wim,
                   sregs->psr & 7,
                   sregs->psr & 7,
                   sregs->inst);
                   sregs->inst);
#endif
#endif
        if (sregs->annul) {
        if (sregs->annul) {
            sregs->annul = 0;
            sregs->annul = 0;
            sregs->icnt = 1;
            sregs->icnt = 1;
            sregs->pc = sregs->npc;
            sregs->pc = sregs->npc;
            sregs->npc = sregs->npc + 4;
            sregs->npc = sregs->npc + 4;
        } else {
        } else {
            if (ext_irl) irq = check_interrupts(sregs);
            if (ext_irl) irq = check_interrupts(sregs);
            if (!irq) {
            if (!irq) {
                if (mexc) {
                if (mexc) {
                    sregs->trap = I_ACC_EXC;
                    sregs->trap = I_ACC_EXC;
                } else {
                } else {
                    if ((sis_gdb_break) && (sregs->inst == 0x91d02001)) {
                    if ((sis_gdb_break) && (sregs->inst == 0x91d02001)) {
                        if (sis_verbose)
                        if (sis_verbose)
                            (*sim_callback->printf_filtered) (sim_callback,
                            (*sim_callback->printf_filtered) (sim_callback,
                                                              "SW BP hit at %x\n", sregs->pc);
                                                              "SW BP hit at %x\n", sregs->pc);
                        sim_halt();
                        sim_halt();
                        restore_stdio();
                        restore_stdio();
                        clearerr(stdin);
                        clearerr(stdin);
                        return (BPT_HIT);
                        return (BPT_HIT);
                    } else
                    } else
                        dispatch_instruction(sregs);
                        dispatch_instruction(sregs);
                }
                }
                icount--;
                icount--;
            }
            }
            if (sregs->trap) {
            if (sregs->trap) {
                irq = 0;
                irq = 0;
                sregs->err_mode = execute_trap(sregs);
                sregs->err_mode = execute_trap(sregs);
            }
            }
        }
        }
        advance_time(sregs);
        advance_time(sregs);
        if (ctrl_c) {
        if (ctrl_c) {
            icount = 0;
            icount = 0;
        }
        }
    }
    }
    sim_halt();
    sim_halt();
    sregs->tottime += time(NULL) - sregs->starttime;
    sregs->tottime += time(NULL) - sregs->starttime;
    restore_stdio();
    restore_stdio();
    clearerr(stdin);
    clearerr(stdin);
    if (sregs->err_mode)
    if (sregs->err_mode)
        error_mode(sregs->pc);
        error_mode(sregs->pc);
    if (sregs->err_mode)
    if (sregs->err_mode)
        return (ERROR);
        return (ERROR);
    if (sregs->bphit) {
    if (sregs->bphit) {
        if (sis_verbose)
        if (sis_verbose)
            (*sim_callback->printf_filtered) (sim_callback,
            (*sim_callback->printf_filtered) (sim_callback,
                                              "HW BP hit at %x\n", sregs->pc);
                                              "HW BP hit at %x\n", sregs->pc);
        return (BPT_HIT);
        return (BPT_HIT);
    }
    }
    if (ctrl_c) {
    if (ctrl_c) {
        ctrl_c = 0;
        ctrl_c = 0;
        return (CTRL_C);
        return (CTRL_C);
    }
    }
    return (TIME_OUT);
    return (TIME_OUT);
}
}
 
 
void
void
sim_set_callbacks (ptr)
sim_set_callbacks (ptr)
     host_callback *ptr;
     host_callback *ptr;
{
{
  sim_callback = ptr;
  sim_callback = ptr;
}
}
 
 
void
void
sim_size (memsize)
sim_size (memsize)
     int memsize;
     int memsize;
{
{
}
}
 
 
SIM_DESC
SIM_DESC
sim_open (kind, callback, abfd, argv)
sim_open (kind, callback, abfd, argv)
     SIM_OPEN_KIND kind;
     SIM_OPEN_KIND kind;
     struct host_callback_struct *callback;
     struct host_callback_struct *callback;
     struct bfd *abfd;
     struct bfd *abfd;
     char **argv;
     char **argv;
{
{
 
 
    int             argc = 0;
    int             argc = 0;
    int             stat = 1;
    int             stat = 1;
    int             freq = 0;
    int             freq = 0;
 
 
    sim_callback = callback;
    sim_callback = callback;
 
 
    while (argv[argc])
    while (argv[argc])
      argc++;
      argc++;
    while (stat < argc) {
    while (stat < argc) {
        if (argv[stat][0] == '-') {
        if (argv[stat][0] == '-') {
            if (strcmp(argv[stat], "-v") == 0) {
            if (strcmp(argv[stat], "-v") == 0) {
                sis_verbose++;
                sis_verbose++;
            } else
            } else
            if (strcmp(argv[stat], "-nfp") == 0) {
            if (strcmp(argv[stat], "-nfp") == 0) {
                nfp = 1;
                nfp = 1;
            } else
            } else
            if (strcmp(argv[stat], "-ift") == 0) {
            if (strcmp(argv[stat], "-ift") == 0) {
                ift = 1;
                ift = 1;
            } else
            } else
            if (strcmp(argv[stat], "-sparclite") == 0) {
            if (strcmp(argv[stat], "-sparclite") == 0) {
                sparclite = 1;
                sparclite = 1;
            } else
            } else
            if (strcmp(argv[stat], "-sparclite-board") == 0) {
            if (strcmp(argv[stat], "-sparclite-board") == 0) {
                sparclite_board = 1;
                sparclite_board = 1;
            } else
            } else
            if (strcmp(argv[stat], "-dumbio") == 0) {
            if (strcmp(argv[stat], "-dumbio") == 0) {
                dumbio = 1;
                dumbio = 1;
            } else
            } else
            if (strcmp(argv[stat], "-wrp") == 0) {
            if (strcmp(argv[stat], "-wrp") == 0) {
                wrp = 1;
                wrp = 1;
            } else
            } else
            if (strcmp(argv[stat], "-rom8") == 0) {
            if (strcmp(argv[stat], "-rom8") == 0) {
                rom8 = 1;
                rom8 = 1;
            } else
            } else
            if (strcmp(argv[stat], "-uben") == 0) {
            if (strcmp(argv[stat], "-uben") == 0) {
                uben = 1;
                uben = 1;
            } else
            } else
            if (strcmp(argv[stat], "-uart1") == 0) {
            if (strcmp(argv[stat], "-uart1") == 0) {
                if ((stat + 1) < argc)
                if ((stat + 1) < argc)
                    strcpy(uart_dev1, argv[++stat]);
                    strcpy(uart_dev1, argv[++stat]);
            } else
            } else
            if (strcmp(argv[stat], "-uart2") == 0) {
            if (strcmp(argv[stat], "-uart2") == 0) {
                if ((stat + 1) < argc)
                if ((stat + 1) < argc)
                    strcpy(uart_dev2, argv[++stat]);
                    strcpy(uart_dev2, argv[++stat]);
            } else
            } else
            if (strcmp(argv[stat], "-nogdb") == 0) {
            if (strcmp(argv[stat], "-nogdb") == 0) {
                sis_gdb_break = 0;
                sis_gdb_break = 0;
            } else
            } else
            if (strcmp(argv[stat], "-freq") == 0) {
            if (strcmp(argv[stat], "-freq") == 0) {
                if ((stat + 1) < argc) {
                if ((stat + 1) < argc) {
                    freq = VAL(argv[++stat]);
                    freq = VAL(argv[++stat]);
                }
                }
            } else {
            } else {
                (*sim_callback->printf_filtered) (sim_callback,
                (*sim_callback->printf_filtered) (sim_callback,
                                                  "unknown option %s\n",
                                                  "unknown option %s\n",
                                                  argv[stat]);
                                                  argv[stat]);
            }
            }
        } else
        } else
            bfd_load(argv[stat]);
            bfd_load(argv[stat]);
        stat++;
        stat++;
    }
    }
 
 
    if (sis_verbose) {
    if (sis_verbose) {
        (*sim_callback->printf_filtered) (sim_callback, "\n SIS - SPARC instruction simulator %s\n", sis_version);
        (*sim_callback->printf_filtered) (sim_callback, "\n SIS - SPARC instruction simulator %s\n", sis_version);
        (*sim_callback->printf_filtered) (sim_callback, " Bug-reports to Jiri Gaisler ESA/ESTEC (jgais@wd.estec.esa.nl)\n");
        (*sim_callback->printf_filtered) (sim_callback, " Bug-reports to Jiri Gaisler ESA/ESTEC (jgais@wd.estec.esa.nl)\n");
        if (nfp)
        if (nfp)
          (*sim_callback->printf_filtered) (sim_callback, "no FPU\n");
          (*sim_callback->printf_filtered) (sim_callback, "no FPU\n");
        if (sparclite)
        if (sparclite)
          (*sim_callback->printf_filtered) (sim_callback, "simulating Sparclite\n");
          (*sim_callback->printf_filtered) (sim_callback, "simulating Sparclite\n");
        if (dumbio)
        if (dumbio)
          (*sim_callback->printf_filtered) (sim_callback, "dumb IO (no input, dumb output)\n");
          (*sim_callback->printf_filtered) (sim_callback, "dumb IO (no input, dumb output)\n");
        if (sis_gdb_break == 0)
        if (sis_gdb_break == 0)
          (*sim_callback->printf_filtered) (sim_callback, "disabling GDB trap handling for breakpoints\n");
          (*sim_callback->printf_filtered) (sim_callback, "disabling GDB trap handling for breakpoints\n");
        if (freq)
        if (freq)
          (*sim_callback->printf_filtered) (sim_callback, " ERC32 freq %d Mhz\n", freq);
          (*sim_callback->printf_filtered) (sim_callback, " ERC32 freq %d Mhz\n", freq);
    }
    }
 
 
    sregs.freq = freq ? freq : 15;
    sregs.freq = freq ? freq : 15;
    termsave = fcntl(0, F_GETFL, 0);
    termsave = fcntl(0, F_GETFL, 0);
    INIT_DISASSEMBLE_INFO(dinfo, stdout,(fprintf_ftype)fprintf);
    INIT_DISASSEMBLE_INFO(dinfo, stdout,(fprintf_ftype)fprintf);
    dinfo.endian = BFD_ENDIAN_BIG;
    dinfo.endian = BFD_ENDIAN_BIG;
    reset_all();
    reset_all();
    ebase.simtime = 0;
    ebase.simtime = 0;
    init_sim();
    init_sim();
    init_bpt(&sregs);
    init_bpt(&sregs);
    reset_stat(&sregs);
    reset_stat(&sregs);
 
 
    /* Fudge our descriptor for now.  */
    /* Fudge our descriptor for now.  */
    return (SIM_DESC) 1;
    return (SIM_DESC) 1;
}
}
 
 
void
void
sim_close(sd, quitting)
sim_close(sd, quitting)
     SIM_DESC sd;
     SIM_DESC sd;
     int quitting;
     int quitting;
{
{
 
 
    exit_sim();
    exit_sim();
    fcntl(0, F_SETFL, termsave);
    fcntl(0, F_SETFL, termsave);
 
 
};
};
 
 
SIM_RC
SIM_RC
sim_load(sd, prog, abfd, from_tty)
sim_load(sd, prog, abfd, from_tty)
     SIM_DESC sd;
     SIM_DESC sd;
     char *prog;
     char *prog;
     bfd *abfd;
     bfd *abfd;
     int from_tty;
     int from_tty;
{
{
    bfd_load (prog);
    bfd_load (prog);
    return SIM_RC_OK;
    return SIM_RC_OK;
}
}
 
 
SIM_RC
SIM_RC
sim_create_inferior(sd, abfd, argv, env)
sim_create_inferior(sd, abfd, argv, env)
     SIM_DESC sd;
     SIM_DESC sd;
     struct bfd *abfd;
     struct bfd *abfd;
     char **argv;
     char **argv;
     char **env;
     char **env;
{
{
    bfd_vma start_address = 0;
    bfd_vma start_address = 0;
    if (abfd != NULL)
    if (abfd != NULL)
      start_address = bfd_get_start_address (abfd);
      start_address = bfd_get_start_address (abfd);
 
 
    ebase.simtime = 0;
    ebase.simtime = 0;
    reset_all();
    reset_all();
    reset_stat(&sregs);
    reset_stat(&sregs);
    sregs.pc = start_address & ~3;
    sregs.pc = start_address & ~3;
    sregs.npc = sregs.pc + 4;
    sregs.npc = sregs.pc + 4;
    return SIM_RC_OK;
    return SIM_RC_OK;
}
}
 
 
int
int
sim_store_register(sd, regno, value, length)
sim_store_register(sd, regno, value, length)
    SIM_DESC sd;
    SIM_DESC sd;
    int             regno;
    int             regno;
    unsigned char  *value;
    unsigned char  *value;
    int length;
    int length;
{
{
    /* FIXME: Review the computation of regval.  */
    /* FIXME: Review the computation of regval.  */
    int regval;
    int regval;
    if (current_target_byte_order == BIG_ENDIAN)
    if (current_target_byte_order == BIG_ENDIAN)
        regval = (value[0] << 24) | (value[1] << 16)
        regval = (value[0] << 24) | (value[1] << 16)
                 | (value[2] << 8) | value[3];
                 | (value[2] << 8) | value[3];
    else
    else
        regval = (value[3] << 24) | (value[2] << 16)
        regval = (value[3] << 24) | (value[2] << 16)
                 | (value[1] << 8) | value[0];
                 | (value[1] << 8) | value[0];
    set_regi(&sregs, regno, regval);
    set_regi(&sregs, regno, regval);
    return -1;
    return -1;
}
}
 
 
 
 
int
int
sim_fetch_register(sd, regno, buf, length)
sim_fetch_register(sd, regno, buf, length)
     SIM_DESC sd;
     SIM_DESC sd;
    int             regno;
    int             regno;
    unsigned char  *buf;
    unsigned char  *buf;
     int length;
     int length;
{
{
    get_regi(&sregs, regno, buf);
    get_regi(&sregs, regno, buf);
    return -1;
    return -1;
}
}
 
 
int
int
sim_write(sd, mem, buf, length)
sim_write(sd, mem, buf, length)
     SIM_DESC sd;
     SIM_DESC sd;
    SIM_ADDR             mem;
    SIM_ADDR             mem;
    unsigned char  *buf;
    unsigned char  *buf;
    int             length;
    int             length;
{
{
    return (sis_memory_write(mem, buf, length));
    return (sis_memory_write(mem, buf, length));
}
}
 
 
int
int
sim_read(sd, mem, buf, length)
sim_read(sd, mem, buf, length)
     SIM_DESC sd;
     SIM_DESC sd;
     SIM_ADDR mem;
     SIM_ADDR mem;
     unsigned char *buf;
     unsigned char *buf;
     int length;
     int length;
{
{
    return (sis_memory_read(mem, buf, length));
    return (sis_memory_read(mem, buf, length));
}
}
 
 
void
void
sim_info(sd, verbose)
sim_info(sd, verbose)
     SIM_DESC sd;
     SIM_DESC sd;
     int verbose;
     int verbose;
{
{
    show_stat(&sregs);
    show_stat(&sregs);
}
}
 
 
int             simstat = OK;
int             simstat = OK;
 
 
void
void
sim_stop_reason(sd, reason, sigrc)
sim_stop_reason(sd, reason, sigrc)
     SIM_DESC sd;
     SIM_DESC sd;
     enum sim_stop * reason;
     enum sim_stop * reason;
     int *sigrc;
     int *sigrc;
{
{
 
 
    switch (simstat) {
    switch (simstat) {
        case CTRL_C:
        case CTRL_C:
        *reason = sim_stopped;
        *reason = sim_stopped;
        *sigrc = TARGET_SIGNAL_INT;
        *sigrc = TARGET_SIGNAL_INT;
        break;
        break;
    case OK:
    case OK:
    case TIME_OUT:
    case TIME_OUT:
    case BPT_HIT:
    case BPT_HIT:
        *reason = sim_stopped;
        *reason = sim_stopped;
        *sigrc = TARGET_SIGNAL_TRAP;
        *sigrc = TARGET_SIGNAL_TRAP;
        break;
        break;
    case ERROR:
    case ERROR:
        *sigrc = 0;
        *sigrc = 0;
        *reason = sim_exited;
        *reason = sim_exited;
    }
    }
    ctrl_c = 0;
    ctrl_c = 0;
    simstat = OK;
    simstat = OK;
}
}
 
 
/* Flush all register windows out to the stack.  Starting after the invalid
/* Flush all register windows out to the stack.  Starting after the invalid
   window, flush all windows up to, and including the current window.  This
   window, flush all windows up to, and including the current window.  This
   allows GDB to do backtraces and look at local variables for frames that
   allows GDB to do backtraces and look at local variables for frames that
   are still in the register windows.  Note that strictly speaking, this
   are still in the register windows.  Note that strictly speaking, this
   behavior is *wrong* for several reasons.  First, it doesn't use the window
   behavior is *wrong* for several reasons.  First, it doesn't use the window
   overflow handlers.  It therefore assumes standard frame layouts and window
   overflow handlers.  It therefore assumes standard frame layouts and window
   handling policies.  Second, it changes system state behind the back of the
   handling policies.  Second, it changes system state behind the back of the
   target program.  I expect this to mainly pose problems when debugging trap
   target program.  I expect this to mainly pose problems when debugging trap
   handlers.
   handlers.
*/
*/
 
 
static void
static void
flush_windows ()
flush_windows ()
{
{
  int invwin;
  int invwin;
  int cwp;
  int cwp;
  int win;
  int win;
  int ws;
  int ws;
 
 
  /* Keep current window handy */
  /* Keep current window handy */
 
 
  cwp = sregs.psr & PSR_CWP;
  cwp = sregs.psr & PSR_CWP;
 
 
  /* Calculate the invalid window from the wim. */
  /* Calculate the invalid window from the wim. */
 
 
  for (invwin = 0; invwin <= PSR_CWP; invwin++)
  for (invwin = 0; invwin <= PSR_CWP; invwin++)
    if ((sregs.wim >> invwin) & 1)
    if ((sregs.wim >> invwin) & 1)
      break;
      break;
 
 
  /* Start saving with the window after the invalid window. */
  /* Start saving with the window after the invalid window. */
 
 
  invwin = (invwin - 1) & PSR_CWP;
  invwin = (invwin - 1) & PSR_CWP;
 
 
  for (win = invwin; ; win = (win - 1) & PSR_CWP)
  for (win = invwin; ; win = (win - 1) & PSR_CWP)
    {
    {
      uint32 sp;
      uint32 sp;
      int i;
      int i;
 
 
      sp = sregs.r[(win * 16 + 14) & 0x7f];
      sp = sregs.r[(win * 16 + 14) & 0x7f];
#if 1
#if 1
      if (sis_verbose > 2) {
      if (sis_verbose > 2) {
        uint32 fp = sregs.r[(win * 16 + 30) & 0x7f];
        uint32 fp = sregs.r[(win * 16 + 30) & 0x7f];
        printf("flush_window: win %d, sp %x, fp %x\n", win, sp, fp);
        printf("flush_window: win %d, sp %x, fp %x\n", win, sp, fp);
      }
      }
#endif
#endif
 
 
      for (i = 0; i < 16; i++)
      for (i = 0; i < 16; i++)
        memory_write (11, sp + 4 * i, &sregs.r[(win * 16 + 16 + i) & 0x7f], 2,
        memory_write (11, sp + 4 * i, &sregs.r[(win * 16 + 16 + i) & 0x7f], 2,
                      &ws);
                      &ws);
 
 
      if (win == cwp)
      if (win == cwp)
        break;
        break;
    }
    }
}
}
 
 
void
void
sim_resume(SIM_DESC sd, int step, int siggnal)
sim_resume(SIM_DESC sd, int step, int siggnal)
{
{
    simstat = run_sim(&sregs, -1, 0);
    simstat = run_sim(&sregs, -1, 0);
 
 
    if (sis_gdb_break) flush_windows ();
    if (sis_gdb_break) flush_windows ();
}
}
 
 
int
int
sim_trace (sd)
sim_trace (sd)
     SIM_DESC sd;
     SIM_DESC sd;
{
{
  /* FIXME: unfinished */
  /* FIXME: unfinished */
  sim_resume (sd, 0, 0);
  sim_resume (sd, 0, 0);
  return 1;
  return 1;
}
}
 
 
void
void
sim_do_command(sd, cmd)
sim_do_command(sd, cmd)
     SIM_DESC sd;
     SIM_DESC sd;
    char           *cmd;
    char           *cmd;
{
{
    exec_cmd(&sregs, cmd);
    exec_cmd(&sregs, cmd);
}
}
 
 
#if 0 /* FIXME: These shouldn't exist.  */
#if 0 /* FIXME: These shouldn't exist.  */
 
 
int
int
sim_insert_breakpoint(int addr)
sim_insert_breakpoint(int addr)
{
{
    if (sregs.bptnum < BPT_MAX) {
    if (sregs.bptnum < BPT_MAX) {
        sregs.bpts[sregs.bptnum] = addr & ~0x3;
        sregs.bpts[sregs.bptnum] = addr & ~0x3;
        sregs.bptnum++;
        sregs.bptnum++;
        if (sis_verbose)
        if (sis_verbose)
            (*sim_callback->printf_filtered) (sim_callback, "inserted HW BP at %x\n", addr);
            (*sim_callback->printf_filtered) (sim_callback, "inserted HW BP at %x\n", addr);
        return 0;
        return 0;
    } else
    } else
        return 1;
        return 1;
}
}
 
 
int
int
sim_remove_breakpoint(int addr)
sim_remove_breakpoint(int addr)
{
{
    int             i = 0;
    int             i = 0;
 
 
    while ((i < sregs.bptnum) && (sregs.bpts[i] != addr))
    while ((i < sregs.bptnum) && (sregs.bpts[i] != addr))
        i++;
        i++;
    if (addr == sregs.bpts[i]) {
    if (addr == sregs.bpts[i]) {
        for (; i < sregs.bptnum - 1; i++)
        for (; i < sregs.bptnum - 1; i++)
            sregs.bpts[i] = sregs.bpts[i + 1];
            sregs.bpts[i] = sregs.bpts[i + 1];
        sregs.bptnum -= 1;
        sregs.bptnum -= 1;
        if (sis_verbose)
        if (sis_verbose)
            (*sim_callback->printf_filtered) (sim_callback, "removed HW BP at %x\n", addr);
            (*sim_callback->printf_filtered) (sim_callback, "removed HW BP at %x\n", addr);
        return 0;
        return 0;
    }
    }
    return 1;
    return 1;
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

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