OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [or1ksim/] [cpu/] [or32/] [op-support.c] - Blame information for rev 146

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jeremybenn
/* op-support.c -- Support routines for micro operations
2
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
 
21
#include <stdlib.h>
22
 
23
#include "config.h"
24
 
25
#ifdef HAVE_INTTYPES_H
26
#include <inttypes.h>
27
#endif
28
 
29
#include "port.h"
30
#include "arch.h"
31
#include "opcode/or32.h"
32
#include "sim-config.h"
33
#include "spr-defs.h"
34
#include "except.h"
35
#include "immu.h"
36
#include "abstract.h"
37
#include "execute.h"
38
#include "sched.h"
39
#include "i386-regs.h"
40
#include "dyn-rec.h"
41
#include "op-support.h"
42
#include "simprintf.h"
43
 
44
 
45
/* Stuff that is really a `micro' operation but is rather big (or for some other
46
 * reason like calling exit()) */
47
 
48
void op_support_nop_exit(void)
49
{
50
  PRINTF("exit(%"PRIdREG")\n", cpu_state.reg[3]);
51
  fprintf(stderr, "@reset : cycles %lld, insn #%lld\n",
52
          runtime.sim.reset_cycles, runtime.cpu.reset_instructions);
53
  fprintf(stderr, "@exit  : cycles %lld, insn #%lld\n", runtime.sim.cycles,
54
          runtime.cpu.instructions);
55
  fprintf(stderr, " diff  : cycles %lld, insn #%lld\n",
56
          runtime.sim.cycles - runtime.sim.reset_cycles,
57
          runtime.cpu.instructions - runtime.cpu.reset_instructions);
58
  /* FIXME: Implement emulation of a stalled cpu
59
  if (config.debug.gdb_enabled)
60
    set_stall_state (1);
61
  else {
62
    handle_sim_command();
63
    sim_done();
64
  }
65
  */
66
  exit(0);
67
}
68
 
69
void op_support_nop_reset(void)
70
{
71
  PRINTF("****************** counters reset ******************\n");
72
  PRINTF("cycles %lld, insn #%lld\n", runtime.sim.cycles, runtime.cpu.instructions);
73
  PRINTF("****************** counters reset ******************\n");
74
  runtime.sim.reset_cycles = runtime.sim.cycles;
75
  runtime.cpu.reset_instructions = runtime.cpu.instructions;
76
}
77
 
78
void op_support_nop_printf(void)
79
{
80
  simprintf(cpu_state.reg[4], cpu_state.reg[3]);
81
}
82
 
83
void op_support_nop_report(void)
84
{
85
  PRINTF("report(0x%"PRIxREG");\n", cpu_state.reg[3]);
86
}
87
 
88
void op_support_nop_report_imm(int imm)
89
{
90
  PRINTF("report %i (0x%"PRIxREG");\n", imm, cpu_state.reg[3]);
91
}
92
 
93
/* Handles a jump */
94
/* addr is a VIRTUAL address */
95
/* NOTE: We can't use env since this code is compiled like the rest of the
96
 * simulator (most likely without -fomit-frame-pointer) and thus env will point
97
 * to some bogus value. */
98
void do_jump(oraddr_t addr)
99
{
100
  cpu_state.pc = addr;
101
  longjmp(cpu_state.excpt_loc, 0);
102
}
103
 
104
/* Wrapper around analysis() that contains all the recompiler specific stuff */
105
void op_support_analysis(void)
106
{
107
  oraddr_t off = (cpu_state.pc & immu_state->page_offset_mask) >> 2;
108
  runtime.cpu.instructions++;
109
  cpu_state.iqueue.insn_index = cpu_state.curr_page->insn_indexs[off];
110
  cpu_state.iqueue.insn = cpu_state.curr_page->insns[off];
111
  cpu_state.iqueue.insn_addr = cpu_state.pc;
112
  analysis(&cpu_state.iqueue);
113
}
114
 

powered by: WebSVN 2.1.0

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