1 |
19 |
jeremybenn |
/* execute.h -- Header file for architecture dependent execute.c
|
2 |
|
|
|
3 |
|
|
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
|
4 |
|
|
Copyright (C) 2008 Embecosm Limited
|
5 |
|
|
|
6 |
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
7 |
|
|
|
8 |
|
|
This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
|
9 |
|
|
|
10 |
|
|
This program is free software; you can redistribute it and/or modify it
|
11 |
|
|
under the terms of the GNU General Public License as published by the Free
|
12 |
|
|
Software Foundation; either version 3 of the License, or (at your option)
|
13 |
|
|
any later version.
|
14 |
|
|
|
15 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
16 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
17 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
18 |
|
|
more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License along
|
21 |
|
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
22 |
|
|
|
23 |
|
|
/* This program is commented throughout in a fashion suitable for processing
|
24 |
|
|
with Doxygen. */
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
#ifndef EXECUTE__H
|
28 |
|
|
#define EXECUTE__H
|
29 |
|
|
|
30 |
|
|
#include "spr-defs.h"
|
31 |
|
|
#include "opcode/or32.h"
|
32 |
|
|
#include "abstract.h"
|
33 |
|
|
|
34 |
|
|
#if DYNAMIC_EXECUTION
|
35 |
|
|
#include "setjmp.h"
|
36 |
|
|
#include "dyn-rec.h"
|
37 |
|
|
#endif
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
#define CURINSN(INSN) (strcmp(cur->insn, (INSN)) == 0)
|
41 |
|
|
|
42 |
112 |
jeremybenn |
/*! Sets a new SPR_SR_OV value, based on a three register operation. */
|
43 |
|
|
#define SET_OV_FLAG_FN(value) \
|
44 |
19 |
jeremybenn |
if((value) & 0x80000000) \
|
45 |
|
|
cpu_state.sprs[SPR_SR] |= SPR_SR_OV; \
|
46 |
|
|
else \
|
47 |
|
|
cpu_state.sprs[SPR_SR] &= ~SPR_SR_OV
|
48 |
|
|
|
49 |
|
|
/*!The main structure holding the current execution state of the CPU
|
50 |
|
|
|
51 |
|
|
Not to be confused with @c runtime, which holds the state of the
|
52 |
|
|
simulation.
|
53 |
|
|
|
54 |
|
|
@c insn_ea field is only used to get dump_exe_log() correct.
|
55 |
|
|
|
56 |
|
|
@c iqueue and @c icomplet fields are only used in analysis().
|
57 |
|
|
|
58 |
|
|
The micro-operation queue, @c opqs, is only used to speed up
|
59 |
|
|
recompile_page(). */
|
60 |
|
|
struct cpu_state {
|
61 |
|
|
uorreg_t reg[MAX_GPRS]; /*!< General purpose registers */
|
62 |
|
|
uorreg_t sprs[MAX_SPRS]; /*!< Special purpose registers */
|
63 |
|
|
oraddr_t insn_ea; /*!< EA of instrs that have an EA */
|
64 |
|
|
int delay_insn; /*!< Is current instr in delay slot */
|
65 |
|
|
int npc_not_valid; /*!< NPC updated while stalled */
|
66 |
|
|
oraddr_t pc; /*!< PC (and translated PC) */
|
67 |
|
|
oraddr_t pc_delay; /*!< Delay instr EA register */
|
68 |
|
|
uint32_t pic_lines; /*!< State of PIC lines */
|
69 |
|
|
struct iqueue_entry iqueue; /*!< Decode of just executed instr */
|
70 |
|
|
struct iqueue_entry icomplet; /*!< Decode of instr before this */
|
71 |
|
|
|
72 |
|
|
#if DYNAMIC_EXECUTION
|
73 |
|
|
jmp_buf excpt_loc; /*!< Longjump here for exception */
|
74 |
|
|
struct dyn_page *curr_page; /*!< Current page in execution */
|
75 |
|
|
struct dyn_page **dyn_pages; /*!< Pointers to recompiled pages */
|
76 |
|
|
int32_t cycles_dec;
|
77 |
|
|
struct op_queue *opqs; /*!< Micro-operation queue */
|
78 |
|
|
#endif
|
79 |
|
|
};
|
80 |
|
|
|
81 |
|
|
/*! History of execution */
|
82 |
|
|
struct hist_exec
|
83 |
|
|
{
|
84 |
|
|
oraddr_t addr;
|
85 |
|
|
struct hist_exec *prev;
|
86 |
|
|
struct hist_exec *next;
|
87 |
|
|
};
|
88 |
|
|
|
89 |
|
|
/* Globally visible data structures */
|
90 |
|
|
extern struct cpu_state cpu_state;
|
91 |
|
|
extern oraddr_t pcnext;
|
92 |
|
|
extern int sbuf_wait_cyc;
|
93 |
|
|
extern int sbuf_total_cyc;
|
94 |
|
|
extern int do_stats;
|
95 |
|
|
extern struct hist_exec *hist_exec_tail;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
/* Prototypes for external use */
|
99 |
|
|
extern void dumpreg ();
|
100 |
|
|
extern void dump_exe_log ();
|
101 |
|
|
extern int cpu_clock ();
|
102 |
|
|
extern void cpu_reset ();
|
103 |
|
|
extern uorreg_t evalsim_reg (unsigned int regno);
|
104 |
|
|
extern void setsim_reg (unsigned int regno,
|
105 |
|
|
uorreg_t value);
|
106 |
|
|
extern uorreg_t eval_operand_val (uint32_t insn,
|
107 |
|
|
struct insn_op_struct *opd);
|
108 |
|
|
extern void analysis (struct iqueue_entry *current);
|
109 |
|
|
extern void cpu_reset ();
|
110 |
|
|
extern int cpu_clock ();
|
111 |
|
|
extern void exec_main ();
|
112 |
|
|
extern int depend_operands (struct iqueue_entry *prev,
|
113 |
|
|
struct iqueue_entry *next);
|
114 |
|
|
#endif /* EXECUTE__H */
|