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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [include/] [MemoryLoad.h] - Blame information for rev 114

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

Line No. Rev Author Line
1 51 julius
/* MemoryLoad.h -- Header file for parse.c
2
 
3
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
4
   Copyright (C) 2008 Embecosm Limited
5
   Copyright (C) 2009 Julius Baxter, julius@orsoc.se
6
 
7
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
   This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
10
 
11
   This program is free software; you can redistribute it and/or modify it
12
   under the terms of the GNU General Public License as published by the Free
13
   Software Foundation; either version 3 of the License, or (at your option)
14
   any later version.
15
 
16
   This program is distributed in the hope that it will be useful, but WITHOUT
17
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
   more details.
20
 
21
   You should have received a copy of the GNU General Public License along
22
   with this program.  If not, see <http://www.gnu.org/licenses/>.  */
23
 
24
/* Here we define some often used caharcters in assembly files.  This wil
25
   probably go into architecture dependent directory. */
26
 
27
 
28
#ifndef MEMORYLOAD__H
29
#define MEMORYLOAD__H
30
 
31
/* Package includes */
32
//#include "sim-config.h"
33
#include <stdint.h>
34
 
35
#include "coff.h"
36
#include "elf.h"
37
 
38
#include "OrpsocAccess.h"
39
 
40
//#define PRINTF(x...) fprintf(stdout,x)
41
#define PRINTF(x...)
42
 
43
/* Basic types for openrisc */
44
typedef uint32_t  oraddr_t;     /*!< Address as addressed by openrisc */
45
typedef uint32_t  uorreg_t;     /*!< An unsigned register of openrisc */
46
typedef int32_t   orreg_t;      /*!< A signed register of openrisc */
47
 
48
/* From abstract.h */
49
#define DEFAULT_MEMORY_START         0
50 52 julius
//#define DEFAULT_MEMORY_LEN    0x800000
51 51 julius
#define STACK_SIZE                  20
52
#define LABELNAME_LEN               50
53
#define INSNAME_LEN                 15
54
#define OPERANDNAME_LEN             50
55
#define MAX_OPERANDS                 5
56
 
57
#define OP_MEM_ACCESS       0x80000000
58
 
59
/* Cache tag types.  */
60
#define CT_NONE                      0
61
#define CT_VIRTUAL                   1
62
#define CT_PHYSICAL                  2
63
 
64
/* History of execution */
65
#define HISTEXEC_LEN               200
66
 
67
/* Added by MM */
68
#ifndef LONGEST
69
#define LONGEST long long
70
#endif /* LONGEST */
71
 
72
#ifndef ULONGEST
73
#define ULONGEST unsigned long long
74
#endif /* ULONGEST */
75
 
76
 
77
 
78
#define PRIx32 "x"
79
#define PRIx16 "hx"
80
#define PRIx8 "hhx"
81
#define PRId32 "d"
82
 
83
/* Strings for printing OpenRISC types */
84
#define PRIxADDR  "08" PRIx32   /*!< print an openrisc address in hex */
85
#define PRIxREG   "08" PRIx32   /*!< print an openrisc register in hex */
86
#define PRIdREG   PRId32        /*!< print an openrisc register in decimals */
87
 
88
/* Endianness convenience macros */
89
#define LE16(x) bswap_16(x)
90
 
91
/*! Instruction queue */
92
struct iqueue_entry
93
{
94
  int       insn_index;
95
  uint32_t  insn;
96
  oraddr_t  insn_addr;
97
};
98
 
99
/*! Structure for holding one label per particular memory location */
100
struct label_entry
101
{
102
  char               *name;
103
  oraddr_t            addr;
104
  struct label_entry *next;
105
};
106
 
107
/* from arch sim cpu/or1k/opcode/or32.h */
108
#define MAX_GPRS 32
109
#define PAGE_SIZE 8192
110
 
111
 
112
 
113
class MemoryLoad
114
{
115
 public:
116
 
117
  // Constructor
118
  MemoryLoad(OrpsocAccess            *_accessor);
119
 
120
  // Label access function
121
  struct label_entry* get_label (oraddr_t addr);
122
 
123
  uint32_t  loadcode (char     *filename,
124
                      oraddr_t  startaddr,
125
                      oraddr_t  virtphy_transl);
126
 
127
 
128
 private:
129
 
130
  //! The accessor for the Orpsoc instance
131
  OrpsocAccess *accessor;
132
 
133
#define MEMORY_LEN  0x100000000ULL
134
 
135
  /*!Whether to do immediate statistics. This seems to be for local debugging
136
  of parse.c */
137
#define IMM_STATS 0
138
 
139
  /*!Unused mem memory marker. It is used when allocating program and data
140
  memory during parsing */
141
  unsigned int  freemem;
142
 
143
   /*!Translation table provided by microkernel. Only used if simulating
144
   microkernel. */
145
  oraddr_t  transl_table;
146
 
147
  /*!Used to signal whether during loading of programs a translation fault
148
  occured. */
149
  uint32_t  transl_error;
150
 
151
#if IMM_STATS
152
  int       bcnt[33][3] = { 0 };
153
  int       bsum[3]     = { 0 };
154
  uint32_t  movhi       = 0;
155
#endif  /* IMM_STATS */
156
 
157
  // A large number, for the Linux kernel (~8000 functions)
158
#define LABELS_HASH_SIZE 10000
159
  /* Local list of labels (symbols) */
160
  struct label_entry *label_hash[LABELS_HASH_SIZE];
161
 
162
 
163
  /* Function prototypes for external use */
164
  char     *strstrip (char       *dst,
165
                      const char *src,
166
                      int         n);
167
 
168
  oraddr_t translate (oraddr_t  laddr,
169
                      int      *breakpoint);
170
 
171
 
172
  int bits (uint32_t val);
173
 
174
  void check_insn (uint32_t insn);
175
 
176
  void addprogram (oraddr_t  address,
177
                   uint32_t  insn,
178
                   int      *breakpoint);
179
 
180
  void readfile_coff (char  *filename,
181
                      short  sections);
182
 
183
  void readsyms_coff (char *filename,
184
                      uint32_t symptr,
185
                      uint32_t syms);
186
 
187
  void readfile_elf (char *filename);
188
 
189
  void identifyfile (char *filename);
190
 
191
  void init_labels ();
192
 
193
  void add_label (oraddr_t addr, char *name);
194
 
195
  struct label_entry* find_label (char *name);
196
  oraddr_t eval_label (char *name);
197
 
198
 
199
 
200
 
201
};
202
 
203
#endif  /* MEMORYLOAD__H */

powered by: WebSVN 2.1.0

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