alpha.h
4.93 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
* Copyright (C) 1998 by the Board of Trustees
* of Leland Stanford Junior University.
* Copyright (C) 1998 Digital Equipment Corporation
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
#ifndef _ALPHA_H
#define _ALPHA_H
#include <alpha/inst.h>
#include "alpha_regs.h"
#if 0
#include "alpha_ipr.h"
#endif
#include "syslimits.h"
#include "cpu_interface.h"
#define ZERO_REGISTER 31
#define ZERO_REDIRECT(x) (x==31?32:x)
extern int alphaLateInitDone;
extern void ExecuteGamma(void);
extern void ExecuteDelta(void);
extern void ExecuteEpsilon(void);
extern void ExecuteKappa(void);
typedef enum MMUStatus {
MMU_SUCCESS,
MMU_EXCEPTION,
MMU_UNCACHED,
MMU_LL,
MMU_SC
} MMUStatus;
/**********************************************************************
* Interrupt levels
* ********************************************************************/
#define INTLEVEL_SOFTWARE_MIN 4
#define INTLEVEL_SOFTWARE_MAX 19
#define INTLEVEL_EXTERNAL_MIN 20
#define INTLEVEL_EXTERNAL_MAX 34
#define INTLEVEL_IRQ0 20
#define INTLEVEL_IRQ1 21
#define INTLEVEL_IRQ2 22
#define INTLEVEL_IRQ3 23
#define INTLEVEL_SERIAL 33
typedef enum {
ATR_EXC_ADDR,
ATR_EXC_SUM,
ATR_EXC_MASK,
ATR_MM_STAT,
ATR_VA,
ATR_VA_FORM,
ATR_IVA,
ATR_ITB_TAG,
ATR_IVA_F,
ATR_IPL,
ATR_ISR,
ATR_INTID,
ATR_MAX
} AlphaTrapStateRegisters;
typedef struct AlphaTrapState {
Reg atr[ATR_MAX];
long lockedRegisters;
int useShadowRegisters;
struct AlphaTrapState *prev;
} AlphaTrapState;
typedef struct AlphaState {
int cpuState;
/* Processor state */
Reg_s reg[33]; /* General-purpose registers */
double fp[33]; /* Floating point registers */
Reg_s shadowRegs[16]; /* 2 sets of shadow register values */
Reg fpcr; /* The Floating point control register */
VA PC;
unsigned lockedRegisters; /* latch VA on next trap? */
int dtbNLU, itbNLU; /* TB replacement */
struct TBState *tb; /* TB State, managed by tb.c */
Reg *ipr; /* Keep only a pointer since there are a LOT of them */
AlphaTrapState *trapState; /* Keep a pointer so we can have speculative traps */
int alt_flag; /* HW LD/ST alt mode - always 0 between instructions*/
int lock_flag; /* LL/SC */
PA locked_addr; /* LL/SC */
/* Interrupt state */
Reg pending_irq;
int pending_irq_count[INTLEVEL_EXTERNAL_MAX];
int takeInterrupt;
int takeInterruptAtRei;
/*
* derived information
*/
int useShadowRegisters;
/*
* common state
*/
int myNum;
struct QCTable *curIQC;
struct QCTable *curDQC;
struct QCTable *altDQC;
struct QCTable *palDQC;
/*
* The following is used only by GAMMA
*/
union alpha_instruction instr; /*current instruction */
/*
* The following are only used by the DELTA simulator
*/
struct AlphaState * nextCPU;
void ** constantsPtr;
SimTime cycleCount;
int64 cycleCountDown;
int64 timeQuantum;
VA llAddr;
Reg llValue;
/*
* SOLO only
*/
struct thread *aintThread;
} AlphaState;
extern AlphaState *PE[];
extern AlphaState *curPE;
/* **************************************************
* following hardcoded constants should be replaced by
* genassym
* **************************************************/
/* *************************************************
* Privileged stuff, most likley implementation independent
* The implementation part is in ev5_ipr.h
* *************************************************/
#define PAL_BASE 0x4000
#define IS_PAL(_p) ((_p)->PC&0x1)
#define BITMASK(_i) ((1LL<<(_i))-1)
#define ALIGN4(_i) ((_i)&~3)
/* ***********************************************************
* Page converstion macros:
* the VPN is the bit 13-63 of the vAddr (shifted down 13)
* the tag is the bit 13-(VA)BITS-1) of the vAddr (shifted down 13)
* ***********************************************************/
#define _SEXT64(_x,_bit) ((uint64) ( ((int64)((_x)<<(64-(_bit))))>>(64-(_bit))))
#define PAGE_BITS 13
#define PAGE2ADDR(_x) ((_x)<<PAGE_BITS)
#define VADDR2VPN(_x) (((int64)(_x)) >> PAGE_BITS)
#define VADDR2TAG(_vA) (((_vA)&VA_MASK)>>PAGE_BITS)
#define TAG2VADDR(_tag) _SEXT64(PAGE2ADDR(tag),VA_BITS)
#define VA_BITS 43
#define PA_BITS 40
#define VA_MASK BITMASK(VA_BITS)
#define PA_MASK BITMASK(PA_BITS)
#define PA_BITS_32 30
#define PA_MASK_32 BITMASK(PA_BITS_32)
/* ****************************************************************************
* Priviledged opcodes, not in /usr/include/alpha/inst.h
* ****************************************************************************/
#define PRIV_OP_HW_LD op_pal1b
#define PRIV_OP_HW_ST op_pal1f
#define PRIV_OP_REI op_pal1e
#define PRIV_OP_MFPR op_pal19
#define PRIV_OP_MTPR op_pal1d
/*
* random
*/
#define PAGE_NUMBER(_x) ((_x)/PAGE_SIZE)
#endif /* ALPHA_H */