1 |
2 |
cvs |
/* abstract.c -- Abstract entities header file
|
2 |
|
|
Copyright (C) 1999 Damjan Lampret, lampret@opencores.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 |
426 |
markom |
#include <stdio.h>
|
21 |
|
|
|
22 |
261 |
markom |
#define DEFAULT_MEMORY_START 0
|
23 |
|
|
#define DEFAULT_MEMORY_LEN 0x800000
|
24 |
|
|
#define STACK_SIZE 20
|
25 |
|
|
#define LABELNAME_LEN 50
|
26 |
|
|
#define INSNAME_LEN 15
|
27 |
26 |
lampret |
#define OPERANDNAME_LEN 50
|
28 |
2 |
cvs |
|
29 |
138 |
markom |
#define MAX_OPERANDS (4)
|
30 |
|
|
|
31 |
134 |
markom |
#define OP_MEM_ACCESS 0x80000000
|
32 |
|
|
|
33 |
429 |
markom |
/* Cache tag types. */
|
34 |
|
|
#define CT_NONE 0
|
35 |
|
|
#define CT_VIRTUAL 1
|
36 |
|
|
#define CT_PHYSICAL 2
|
37 |
|
|
|
38 |
134 |
markom |
/* This is an abstract memory type rather than physical memory type. It holds
|
39 |
|
|
disassembled instructions. */
|
40 |
2 |
cvs |
struct mem_entry {
|
41 |
123 |
markom |
unsigned char data;
|
42 |
2 |
cvs |
};
|
43 |
|
|
|
44 |
479 |
markom |
enum insn_type { it_unknown, it_exception, it_arith, it_shift, it_compare, it_branch,
|
45 |
|
|
it_jump, it_load, it_store, it_movimm, it_move, it_extend, it_nop, it_mac };
|
46 |
2 |
cvs |
|
47 |
|
|
/* Instruction queue */
|
48 |
|
|
struct iqueue_entry {
|
49 |
123 |
markom |
enum insn_type func_unit;
|
50 |
138 |
markom |
int insn_index;
|
51 |
|
|
unsigned long insn;
|
52 |
|
|
unsigned long op[2 * MAX_OPERANDS];
|
53 |
123 |
markom |
unsigned long insn_addr;
|
54 |
2 |
cvs |
};
|
55 |
|
|
|
56 |
30 |
lampret |
/* Memory regions assigned to devices */
|
57 |
|
|
struct dev_memarea {
|
58 |
221 |
markom |
struct dev_memarea *next;
|
59 |
261 |
markom |
/*unsigned long start;
|
60 |
|
|
unsigned long end; /* if start + size > end, this block is disabled; to enable it recalculate end addr. */
|
61 |
|
|
unsigned long addr_mask;
|
62 |
|
|
unsigned long addr_compare;
|
63 |
123 |
markom |
unsigned long size;
|
64 |
261 |
markom |
unsigned long size_mask; /* Address mask, calculated out of size */
|
65 |
235 |
erez |
unsigned long granularity; /* how many bytes read/write accepts: 1/2/4 */
|
66 |
424 |
markom |
int delayr; /* Read delay */
|
67 |
|
|
int delayw; /* Write delay */
|
68 |
261 |
markom |
|
69 |
|
|
int chip_select; /* Needed by memory controller; specifies chip select number for this memory area. */
|
70 |
426 |
markom |
FILE *log; /* log file if this device is to be logged, NULL otherwise */
|
71 |
261 |
markom |
|
72 |
235 |
erez |
unsigned long (*readfunc)(unsigned long);
|
73 |
|
|
void (*writefunc)(unsigned long, unsigned long);
|
74 |
221 |
markom |
/* private data */
|
75 |
|
|
unsigned long misc;
|
76 |
30 |
lampret |
};
|
77 |
|
|
|
78 |
2 |
cvs |
extern struct iqueue_entry iqueue[20];
|
79 |
138 |
markom |
extern struct iqueue_entry icomplet[20];
|
80 |
2 |
cvs |
extern unsigned long pc;
|
81 |
|
|
|
82 |
306 |
markom |
extern void dumpmemory(unsigned int from, unsigned int to, int disasm, int nl);
|
83 |
123 |
markom |
extern unsigned long eval_mem32(unsigned long memaddr,int*);
|
84 |
|
|
extern unsigned short eval_mem16(unsigned long memaddr,int*);
|
85 |
|
|
extern unsigned char eval_mem8(unsigned long memaddr,int*);
|
86 |
|
|
extern void set_mem32(unsigned long memaddr, unsigned long value,int*);
|
87 |
|
|
extern void set_mem16(unsigned long memaddr, unsigned short value,int*);
|
88 |
|
|
extern void set_mem8(unsigned long memaddr, unsigned char value,int*);
|
89 |
|
|
|
90 |
221 |
markom |
unsigned long evalsim_mem32(unsigned long);
|
91 |
|
|
unsigned short evalsim_mem16(unsigned long);
|
92 |
|
|
unsigned char evalsim_mem8(unsigned long);
|
93 |
123 |
markom |
void setsim_mem32(unsigned long,unsigned long);
|
94 |
|
|
void setsim_mem16(unsigned long,unsigned short);
|
95 |
|
|
void setsim_mem8(unsigned long,unsigned char);
|
96 |
|
|
|
97 |
424 |
markom |
void init_memory_table ();
|
98 |
221 |
markom |
|
99 |
424 |
markom |
/* Changes read/write memory in read/write only */
|
100 |
|
|
void lock_memory_table ();
|
101 |
|
|
|
102 |
426 |
markom |
/* Closes files, etc. */
|
103 |
|
|
void done_memory_table ();
|
104 |
|
|
|
105 |
427 |
markom |
/* Displays current memory configuration */
|
106 |
|
|
void memory_table_status ();
|
107 |
|
|
|
108 |
261 |
markom |
/* Register read and write function for a memory area.
|
109 |
|
|
addr is inside the area, if addr & addr_mask == addr_compare
|
110 |
|
|
(used also by peripheral devices like 16450 UART etc.) */
|
111 |
|
|
void register_memoryarea_mask(unsigned long addr_mask, unsigned long addr_compare,
|
112 |
|
|
unsigned long size, unsigned granularity,
|
113 |
|
|
unsigned long (readfunc)(unsigned long),
|
114 |
|
|
void (writefunc)(unsigned long, unsigned long));
|
115 |
|
|
|
116 |
|
|
/* Register read and write function for a memory area.
|
117 |
|
|
Memory areas should be aligned. Memory area is rounded up to
|
118 |
|
|
fit the nearest 2^n aligment.
|
119 |
|
|
(used also by peripheral devices like 16450 UART etc.) */
|
120 |
|
|
void register_memoryarea(unsigned long addr,
|
121 |
|
|
unsigned long size, unsigned granularity,
|
122 |
|
|
unsigned long (readfunc)(unsigned long),
|
123 |
|
|
void (writefunc)(unsigned long, unsigned long));
|
124 |
|
|
|
125 |
221 |
markom |
/* Check if access is to registered area of memory. */
|
126 |
|
|
struct dev_memarea *verify_memoryarea(unsigned long addr);
|
127 |
261 |
markom |
|
128 |
433 |
markom |
/* Outputs time in pretty form to dest string */
|
129 |
|
|
void generate_time_pretty (char *dest, long time_ps);
|
130 |
|
|
|
131 |
221 |
markom |
/* Temporary variable to increase speed. */
|
132 |
|
|
extern struct dev_memarea *cur_area;
|
133 |
|
|
|
134 |
123 |
markom |
/* Added by MM */
|
135 |
|
|
#ifndef LONGEST
|
136 |
|
|
#define LONGEST long long
|
137 |
|
|
#define ULONGEST unsigned long long
|
138 |
|
|
#endif /* ! LONGEST */
|
139 |
494 |
markom |
|
140 |
|
|
/* Instructions left to execute */
|
141 |
|
|
extern int cont_run;
|
142 |
|
|
|
143 |
|
|
/* History of execution */
|
144 |
|
|
#define HISTEXEC_LEN 200
|
145 |
|
|
extern int histexec[HISTEXEC_LEN];
|
146 |
|
|
|