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 |
1319 |
phoenix |
#define MAX_OPERANDS (5)
|
30 |
138 |
markom |
|
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 |
2 |
cvs |
/* Instruction queue */
|
39 |
|
|
struct iqueue_entry {
|
40 |
138 |
markom |
int insn_index;
|
41 |
1350 |
nogj |
uint32_t insn;
|
42 |
|
|
oraddr_t insn_addr;
|
43 |
2 |
cvs |
};
|
44 |
|
|
|
45 |
30 |
lampret |
/* Memory regions assigned to devices */
|
46 |
|
|
struct dev_memarea {
|
47 |
221 |
markom |
struct dev_memarea *next;
|
48 |
261 |
markom |
/*unsigned long start;
|
49 |
1308 |
phoenix |
unsigned long end;*/ /* if start + size > end, this block is disabled; to enable it recalculate end addr. */
|
50 |
1350 |
nogj |
oraddr_t addr_mask;
|
51 |
|
|
oraddr_t addr_compare;
|
52 |
|
|
uint32_t size;
|
53 |
|
|
uint32_t size_mask; /* Address mask, calculated out of size */
|
54 |
|
|
unsigned int granularity; /* how many bytes read/write accepts: 1/2/4 */
|
55 |
424 |
markom |
int delayr; /* Read delay */
|
56 |
|
|
int delayw; /* Write delay */
|
57 |
261 |
markom |
|
58 |
1350 |
nogj |
int chip_select; /* Needed by memory controller; specifies chip
|
59 |
|
|
* select number for this memory area. */
|
60 |
543 |
simons |
int valid; /* This bit reflect the memory controler valid bit */
|
61 |
426 |
markom |
FILE *log; /* log file if this device is to be logged, NULL otherwise */
|
62 |
261 |
markom |
|
63 |
1359 |
nogj |
uint32_t (*readfunc)(oraddr_t, void *);
|
64 |
|
|
void (*writefunc)(oraddr_t, uint32_t, void *);
|
65 |
221 |
markom |
/* private data */
|
66 |
1359 |
nogj |
void *priv_dat;
|
67 |
30 |
lampret |
};
|
68 |
|
|
|
69 |
2 |
cvs |
extern struct iqueue_entry iqueue[20];
|
70 |
138 |
markom |
extern struct iqueue_entry icomplet[20];
|
71 |
1350 |
nogj |
extern oraddr_t pc;
|
72 |
537 |
markom |
extern int mem_cycles; /* Number of memory cycles in during this instruction execution */
|
73 |
|
|
extern int cycles; /* Total number of cycles executed so far */
|
74 |
2 |
cvs |
|
75 |
1350 |
nogj |
extern void dumpmemory(oraddr_t from, oraddr_t to, int disasm, int nl);
|
76 |
|
|
extern uint32_t eval_mem32(oraddr_t memaddr,int*);
|
77 |
|
|
extern uint16_t eval_mem16(oraddr_t memaddr,int*);
|
78 |
|
|
extern uint8_t eval_mem8(oraddr_t memaddr,int*);
|
79 |
|
|
void set_mem32(oraddr_t memaddr, uint32_t value,int*);
|
80 |
|
|
extern void set_mem16(oraddr_t memaddr, uint16_t value,int*);
|
81 |
|
|
extern void set_mem8(oraddr_t memaddr, uint8_t value,int*);
|
82 |
123 |
markom |
|
83 |
1350 |
nogj |
uint32_t evalsim_mem32(oraddr_t);
|
84 |
|
|
uint16_t evalsim_mem16(oraddr_t);
|
85 |
|
|
uint8_t evalsim_mem8(oraddr_t);
|
86 |
1319 |
phoenix |
|
87 |
1350 |
nogj |
uint32_t evalsim_mem32_atomic(oraddr_t, int);
|
88 |
|
|
uint16_t evalsim_mem16_atomic(oraddr_t, int);
|
89 |
|
|
uint8_t evalsim_mem8_atomic(oraddr_t, int);
|
90 |
1319 |
phoenix |
|
91 |
1350 |
nogj |
void setsim_mem32(oraddr_t, uint32_t);
|
92 |
|
|
void setsim_mem16(oraddr_t, uint16_t);
|
93 |
|
|
void setsim_mem8(oraddr_t, uint8_t);
|
94 |
123 |
markom |
|
95 |
1350 |
nogj |
void setsim_mem32_atomic(oraddr_t, uint32_t, int);
|
96 |
|
|
void setsim_mem16_atomic(oraddr_t, uint16_t, int);
|
97 |
|
|
void setsim_mem8_atomic(oraddr_t, uint8_t, int);
|
98 |
1319 |
phoenix |
|
99 |
424 |
markom |
void init_memory_table ();
|
100 |
221 |
markom |
|
101 |
424 |
markom |
/* Changes read/write memory in read/write only */
|
102 |
|
|
void lock_memory_table ();
|
103 |
|
|
|
104 |
426 |
markom |
/* Closes files, etc. */
|
105 |
|
|
void done_memory_table ();
|
106 |
|
|
|
107 |
427 |
markom |
/* Displays current memory configuration */
|
108 |
|
|
void memory_table_status ();
|
109 |
|
|
|
110 |
261 |
markom |
/* Register read and write function for a memory area.
|
111 |
|
|
addr is inside the area, if addr & addr_mask == addr_compare
|
112 |
|
|
(used also by peripheral devices like 16450 UART etc.) */
|
113 |
1350 |
nogj |
void register_memoryarea_mask(oraddr_t addr_mask, oraddr_t addr_compare,
|
114 |
|
|
uint32_t size, unsigned granularity, unsigned mc_dev,
|
115 |
1359 |
nogj |
uint32_t (readfunc)(oraddr_t, void *),
|
116 |
|
|
void (writefunc)(oraddr_t, uint32_t, void *),
|
117 |
|
|
void *dat);
|
118 |
261 |
markom |
|
119 |
|
|
/* Register read and write function for a memory area.
|
120 |
|
|
Memory areas should be aligned. Memory area is rounded up to
|
121 |
|
|
fit the nearest 2^n aligment.
|
122 |
970 |
simons |
(used also by peripheral devices like 16450 UART etc.)
|
123 |
|
|
If mc_dev is 1, this means that this device will be checked first for match
|
124 |
|
|
and will be accessed in case in overlaping memory spaces.
|
125 |
|
|
Only one device can have this set to 1 (used for memory controller) */
|
126 |
1350 |
nogj |
void register_memoryarea(oraddr_t addr, uint32_t size, unsigned granularity,
|
127 |
1359 |
nogj |
unsigned mc_dev, uint32_t (readfunc)(oraddr_t, void *),
|
128 |
|
|
void (writefunc)(oraddr_t, uint32_t, void *),
|
129 |
|
|
void *dat);
|
130 |
261 |
markom |
|
131 |
882 |
simons |
/* Finds the memory area for the address and adjust the read and write delays for it. */
|
132 |
1350 |
nogj |
void adjust_rw_delay(oraddr_t memaddr, unsigned int delayr, unsigned int delayw);
|
133 |
882 |
simons |
|
134 |
221 |
markom |
/* Check if access is to registered area of memory. */
|
135 |
1350 |
nogj |
struct dev_memarea *verify_memoryarea(oraddr_t addr);
|
136 |
261 |
markom |
|
137 |
1308 |
phoenix |
/* Outputs time in pretty form to dest string. */
|
138 |
897 |
markom |
char *generate_time_pretty (char *dest, long time_ps);
|
139 |
433 |
markom |
|
140 |
1308 |
phoenix |
/* Returns 32-bit values from mem array. */
|
141 |
1350 |
nogj |
uint32_t eval_insn(oraddr_t, int *);
|
142 |
1308 |
phoenix |
|
143 |
1398 |
nogj |
uint8_t eval_direct8(oraddr_t memaddr, int *breakpoint, int through_mmu, int through_dc);
|
144 |
|
|
uint16_t eval_direct16(oraddr_t memaddr, int *breakpoint, int through_mmu, int through_dc);
|
145 |
1350 |
nogj |
uint32_t eval_direct32(oraddr_t addr, int *breakpoint, int through_mmu, int through_dc);
|
146 |
1308 |
phoenix |
|
147 |
1350 |
nogj |
void set_direct32(uint32_t addr, uint32_t value, int *breakpoint, int through_mmu, int through_dc);
|
148 |
1308 |
phoenix |
|
149 |
221 |
markom |
/* Temporary variable to increase speed. */
|
150 |
|
|
extern struct dev_memarea *cur_area;
|
151 |
|
|
|
152 |
970 |
simons |
/* Virtual address of current access. */
|
153 |
1350 |
nogj |
extern oraddr_t cur_vadd;
|
154 |
970 |
simons |
|
155 |
638 |
simons |
/* These are set by mmu if cache inhibit bit is set for current acces. */
|
156 |
|
|
extern int data_ci, insn_ci;
|
157 |
|
|
|
158 |
123 |
markom |
/* Added by MM */
|
159 |
|
|
#ifndef LONGEST
|
160 |
|
|
#define LONGEST long long
|
161 |
|
|
#define ULONGEST unsigned long long
|
162 |
|
|
#endif /* ! LONGEST */
|
163 |
494 |
markom |
|
164 |
|
|
/* Instructions left to execute */
|
165 |
|
|
extern int cont_run;
|
166 |
|
|
|
167 |
|
|
/* History of execution */
|
168 |
|
|
#define HISTEXEC_LEN 200
|
169 |
1352 |
nogj |
struct hist_exec {
|
170 |
|
|
oraddr_t addr;
|
171 |
|
|
struct hist_exec *prev;
|
172 |
|
|
struct hist_exec *next;
|
173 |
|
|
};
|
174 |
494 |
markom |
|
175 |
1352 |
nogj |
extern struct hist_exec *hist_exec_tail;
|