simmisc.h
5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*****************************************************************
* simmisc.h
*
* Plethora of misc. definitions which don't fit anywhere else.
* Dan Teodosiu, 07/96
*
****************************************************************/
#if !defined(_SIM_MISC_H) && (defined(SIM_MIPS32) || defined(SIM_MIPS64))
#define _SIM_MISC_H
#include "syslimits.h"
#include "simtypes.h"
#include "file_formats.h"
#define SIMCP0_KUSEG_ADDR 0x0
#define SIMCP0_KUSEG_SIZE K0BASE
#define SIMCP0_KSEG0_ADDR K0BASE
#define SIMCP0_KSEG0_SIZE 0x20000000
#define SIMCP0_KSEG1_ADDR K1BASE
#define SIMCP0_KSEG1_SIZE 0x20000000
#define SIMCP0_KSEG2_ADDR K2BASE
#define SIMCP0_KSEG2_SIZE 0x40000000
/* Added for R4k port */
#define SIMCP0_KSEG3_ADDR 0x68000000
#define SIMCP0_KSEG3_SIZE 0x10000000
#define SIM_PAGE_SIZE 4096
/*
* BASESIMMEMADDR definitions
* This is the starting address of the simulated memory for the first machine.
* Each other machine's memory starts after the end of the previous one.
* Use the SIM_MEM_ADDR(MachNo) to get the start address for a particular machine.
*/
#if defined(sgi) || defined(sun) || defined(i386)
/* SGI, SUN or i386 */
#ifdef LARGE_SIMULATION
#define BASESIMMEMADDR ((MA)0x50000000)
#else
#if defined(__linux__)
#define BASESIMMEMADDR ((MA)0x50000000)
#else
#define BASESIMMEMADDR ((MA)0x40000000)
#endif
#endif /* LARGE_SIMULATION */
#elif defined(linux)
/* Linux */
#define BASESIMMEMADDR ((MA)0x50000000)
#elif defined(__alpha)
/* Alpha */
#define BASESIMMEMADDR ((MA)0x200000000)
#endif
#ifndef LANGUAGE_ASSEMBLY
/*
* Macro for converting a KSEG0 address into an access to the
* simulated memory.
*/
extern int IsValidPA(int machNo, PA paddr);
extern MA PhysToMemAddr(int machNo, PA paddr);
extern PA MemToPhysAddr(int machNo, MA maddr);
#ifdef IRIX6_4
#define PHYS_TO_MEMADDR(_m, _x) PhysToMemAddr((_m), (_x))
#define MEMADDR_TO_PHYS(_m, _x) MemToPhysAddr((_m), (_x))
#define IS_VALID_PA(_m, _x) IsValidPA((_m), (_x))
#define IS_VALID_MA(_m, _x) ((((MA)(_x)) >= SIM_MEM_ADDR(_m)) && \
(((MA)(_x)) < (SIM_MEM_ADDR(_m) + MEM_SIZE(_m))))
#else
#define PHYS_TO_MEMADDR(_m, _x) ((MA)(SIM_MEM_ADDR(_m) + (PA)(_x)))
#define MEMADDR_TO_PHYS(_m, _x) ((PA)((MA)(_x) - SIM_MEM_ADDR(_m)))
#define IS_VALID_PA(_m, _x) (((MA)(_x)) < ((MA)MEM_SIZE(_m)))
#define IS_VALID_MA(_m, _x) ((((MA)(_x)) >= SIM_MEM_ADDR(_m)) && \
(((MA)(_x)) < (SIM_MEM_ADDR(_m) + MEM_SIZE(_m))))
#endif
#define K0_TO_MEMADDR(_m, _x) (PHYS_TO_MEMADDR((_m),K0_TO_PHYS((VA)(_x))))
#define MEMADDR_TO_K0(_m, _x) ((VA)PHYS_TO_K0((PA)MEMADDR_TO_PHYS((_m),(_x))))
/*
* Macro to test whether Flashlite is being used.
*/
#define USE_MAGIC() (memsysVec.type == FLASHLITE)
/*
* Macros to test for various options.
*/
#define DEBUG_INTR() (sim_misc.debug_intr)
/*
* Miscellaneous definitions
*/
#define MAXBOOTARGS 32 /* max. args to kernel */
#define KNAME_MAX 64 /* max. kernel name length */
#define MAXBOOTARGBYTES 256 /* max. length of boot command line */
/* This is probably not needed any longer and should be removed */
#define SLAVELOOP_CONTINUE 0x4015
/* offset (starting from the beginning of a cell's memory range) of
* page which is used for passing bootline arguments to the kernel.
* NOTE: currently, kernels are compiled so that they leave 5 free
* pages at the beginning of the cell's memory range. The 5 pages are
* used as follows:
* - page 0: remap area
* - page 1: OSPC area (fake for 32-bit SimOS)
* - page 2: bootline arguments
* - page 3,4: unused
*/
#ifdef IRIX6_4
#define ARGZONE_OFFS 0x00034000
#else
#define ARGZONE_OFFS 0x00002000 /* third page */
#endif
/* Name of file containing FPROM image */
extern char* FPromFile;
typedef struct Header {
union header {
FILHDR coffHeader;
Elf32_Ehdr elfHeader;
Elf64_Ehdr elf64Header;
} hb;
} HeaderBuf;
/*
* This data structure holds several not necessarily related pieces
* of information. The reasons for this being a single data structure
* are historical.
*/
typedef struct SimMisc {
CPUType enterThisCPU; /* notify the simulator to switch to this CPU type */
CPUType myCPUType;
void* launchAddr[SIM_MAXCPUS]; /* launch address for slaves */
int launchArg[SIM_MAXCPUS][4]; /* launch args (A0-A3) for slaves */
char* fprom[SIM_MAXCPUS]; /* fprom */
char* fram[SIM_MAXCPUS]; /* fram */
char* incoherentPages; /* array indicating incoherent pages
-- lost in low-level recovery */
int debug_intr; /* debug interrupts? */
} SimMisc;
extern SimMisc sim_misc;
extern void SimMiscInit(int debug_intr);
extern void SimPromEnter(void);
extern void SimulatorEnter(CPUType simulator, int restoreCkpt, int swtch);
extern void SimulatorSwitch(CPUType oldSimulator, CPUType newSimulator);
typedef void (*aout_entryfunc)(int, char**, char**);
typedef void (*bdload_sectionfilter)(char* startaddr, unsigned nbytes);
extern int LaunchSlave(int cpu, VA pc, Reg a0, Reg a1, Reg a2, Reg a3);
extern int ResetCPUs(int firstcpu, int lastcpu);
extern void SimHalt(void);
#endif /* !LANGUAGE_ASSEMBLY */
#endif /* _SIM_MISC_H */