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

Subversion Repositories openrisc

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

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
#ifndef MEMORYLOAD__H
28
#define MEMORYLOAD__H
29
 
30
/* Package includes */
31
//#include "sim-config.h"
32
#include <stdint.h>
33
 
34
#include "coff.h"
35
#include "elf.h"
36
 
37
#include "OrpsocAccess.h"
38
 
39
//#define PRINTF(x...) fprintf(stdout,x)
40
#define PRINTF(x...)
41
 
42
/* Basic types for openrisc */
43 462 julius
typedef uint32_t oraddr_t;      /*!< Address as addressed by openrisc */
44
typedef uint32_t uorreg_t;      /*!< An unsigned register of openrisc */
45
typedef int32_t orreg_t;        /*!< A signed register of openrisc */
46 51 julius
 
47
/* From abstract.h */
48
#define DEFAULT_MEMORY_START         0
49 52 julius
//#define DEFAULT_MEMORY_LEN    0x800000
50 51 julius
#define STACK_SIZE                  20
51
#define LABELNAME_LEN               50
52
#define INSNAME_LEN                 15
53
#define OPERANDNAME_LEN             50
54
#define MAX_OPERANDS                 5
55
 
56
#define OP_MEM_ACCESS       0x80000000
57
 
58
/* Cache tag types.  */
59
#define CT_NONE                      0
60
#define CT_VIRTUAL                   1
61
#define CT_PHYSICAL                  2
62
 
63
/* History of execution */
64
#define HISTEXEC_LEN               200
65
 
66
/* Added by MM */
67
#ifndef LONGEST
68
#define LONGEST long long
69
#endif /* LONGEST */
70
 
71
#ifndef ULONGEST
72
#define ULONGEST unsigned long long
73
#endif /* ULONGEST */
74
 
75
#define PRIx32 "x"
76
#define PRIx16 "hx"
77
#define PRIx8 "hhx"
78
#define PRId32 "d"
79
 
80
/* Strings for printing OpenRISC types */
81
#define PRIxADDR  "08" PRIx32   /*!< print an openrisc address in hex */
82
#define PRIxREG   "08" PRIx32   /*!< print an openrisc register in hex */
83
#define PRIdREG   PRId32        /*!< print an openrisc register in decimals */
84
 
85
/* Endianness convenience macros */
86
#define LE16(x) bswap_16(x)
87
 
88
/*! Instruction queue */
89 462 julius
struct iqueue_entry {
90
        int insn_index;
91
        uint32_t insn;
92
        oraddr_t insn_addr;
93 51 julius
};
94
 
95
/*! Structure for holding one label per particular memory location */
96 462 julius
struct label_entry {
97
        char *name;
98
        oraddr_t addr;
99
        struct label_entry *next;
100 51 julius
};
101
 
102
/* from arch sim cpu/or1k/opcode/or32.h */
103
#define MAX_GPRS 32
104
#define PAGE_SIZE 8192
105
 
106 462 julius
class MemoryLoad {
107
public:
108 51 julius
 
109 462 julius
        // Constructor
110
        MemoryLoad(OrpsocAccess * _accessor);
111 51 julius
 
112 462 julius
        // Label access function
113
        struct label_entry *get_label(oraddr_t addr);
114 51 julius
 
115 462 julius
        uint32_t loadcode(char *filename,
116
                          oraddr_t startaddr, oraddr_t virtphy_transl);
117
 
118
private:
119
 
120
        //! The accessor for the Orpsoc instance
121
         OrpsocAccess * accessor;
122
 
123 51 julius
#define MEMORY_LEN  0x100000000ULL
124 462 julius
 
125
        /*!Whether to do immediate statistics. This seems to be for local debugging
126
           of parse.c */
127 51 julius
#define IMM_STATS 0
128 462 julius
 
129
        /*!Unused mem memory marker. It is used when allocating program and data
130
           memory during parsing */
131
        unsigned int freemem;
132
 
133
        /*!Translation table provided by microkernel. Only used if simulating
134
           microkernel. */
135
        oraddr_t transl_table;
136
 
137
        /*!Used to signal whether during loading of programs a translation fault
138
           occured. */
139
        uint32_t transl_error;
140
 
141 51 julius
#if IMM_STATS
142 462 julius
        int bcnt[33][3] = { 0 };
143
        int bsum[3] = { 0 };
144
        uint32_t movhi = 0;
145
#endif /* IMM_STATS */
146 51 julius
 
147 462 julius
        // A large number, for the Linux kernel (~8000 functions)
148 51 julius
#define LABELS_HASH_SIZE 10000
149 462 julius
        /* Local list of labels (symbols) */
150
        struct label_entry *label_hash[LABELS_HASH_SIZE];
151 51 julius
 
152 462 julius
        /* Function prototypes for external use */
153
        char *strstrip(char *dst, const char *src, int n);
154 51 julius
 
155 462 julius
        oraddr_t translate(oraddr_t laddr, int *breakpoint);
156 51 julius
 
157 462 julius
        int bits(uint32_t val);
158 51 julius
 
159 462 julius
        void check_insn(uint32_t insn);
160 51 julius
 
161 462 julius
        void addprogram(oraddr_t address, uint32_t insn);
162 51 julius
 
163 462 julius
        void readfile_coff(char *filename, short sections);
164 51 julius
 
165 462 julius
        void readsyms_coff(char *filename, uint32_t symptr, uint32_t syms);
166
 
167
        void readfile_elf(char *filename);
168
 
169
        void identifyfile(char *filename);
170
 
171
        void init_labels();
172
 
173
        void add_label(oraddr_t addr, char *name);
174
 
175
        struct label_entry *find_label(char *name);
176
        oraddr_t eval_label(char *name);
177
 
178 51 julius
};
179
 
180 462 julius
#endif /* MEMORYLOAD__H */

powered by: WebSVN 2.1.0

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