cp0.h
4.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
/*
* 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.
*
*/
/*****************************************************************
* cp0.h
*
* Definitions for CP0 - TLB and exception handling
* Written for BIG ENDIAN!!!
*
* $Author: blythe $
* $Date: 2002/05/29 01:09:10 $
*****************************************************************/
#ifndef MIPSY_CP0_H
#define MIPSY_CP0_H
#include "simtypes.h"
#include "mips_arch.h"
#include "addr_layout.h"
#include "mipsy.h"
#include "list.h"
/* Global CP0 Functions */
extern void MipsyInitTLBHashTable(CPUState *P);
extern void EXCEPTION(CPUState *P, int);
extern int ExecuteC0Instruction(CPUState *P, Inst instr);
extern void EnableInterruptCheck(CPUState *P, int interval);
extern Result TranslateVirtual(CPUState *P,VA, PA *, uint *tlbFlavor, void **bdoorAddr);
extern Result TranslateVirtualNoSideeffect(CPUState *P, VA, PA *);
extern void MipsyCheckForInterrupts(CPUState *P);
extern void MipsyCacheError(int cpuNum, bool isAsync);
/* Global CP0 Constants */
#define TLB_CACHED 0x00000000
#define TLB_BDOOR 0x00000001
#define TLB_UNCACHED 0x00000002
/* Make sure that you can do a (value&TLB_BDOOR) */
#define TLB_BDOOR_DATA 0x00000011
#define TLB_BDOOR_FUNC 0x00000021
/* jump to a backdoor function -- only used in compatibility mode */
#define TLB_BDOOR_FUNC_COMPAT 0x00000031
#define TLB_READING 0x0
#define TLB_WRITING 0x00000004
#define TLB_DFETCH 0x0
#define TLB_IFETCH 0x00000008
#define TLB_PREFETCH 0x00000040
#define TLB_ACCELERATED 0x00000010
#ifdef HWBCOPY
#define TLB_MSG_SPACE 0x00000020
#endif
/* Return values for a cop0 instruction */
#define C0_SUCCESS 0
#define C0_ILLEGAL_INST 1
#define C0_CONTINUE 2
#define TLB_IS_IFETCH(_flag) (_flag & TLB_IFETCH)
#define TLB_IS_PREFETCH(_flag) (_flag & TLB_PREFETCH)
#define TLB_IS_WRITE(_flag) (_flag & TLB_WRITING)
/*****************************************************************
* Hash table support for mipsy's TLB - From Emmett's mshade
* This uses the List_Links package from Sprite -
*****************************************************************/
/*
* Exception handling routines.
*/
#define _MIPSY_RECORD_EXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) { \
(_P)->CP0[C0_BADVADDR] = (_badaddr); \
(_P)->CP0[C0_TLBHI] = (_hireg); \
(_P)->CP0[C0_CTXT] = (_ctxtreg); \
(_P)->CP0[C0_XCTXT] = (_xctxtreg); \
EXCEPTION((_P), (_cause)); \
}
#define _MIPSY_RECORD_UTLBEXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) { \
(_P)->CP0[C0_BADVADDR] = (_badaddr); \
(_P)->CP0[C0_TLBHI] = (_hireg); \
(_P)->CP0[C0_CTXT] = (_ctxtreg); \
(_P)->CP0[C0_XCTXT] = (_xctxtreg); \
UTLB_EXCEPTION((_P), (_cause)); \
}
#ifdef MIPSY_MXS
#define _MXS_RECORD_EXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) { \
(_P)->lastException = (((_P)->lastException+1) % MAX_NUM_EXCEPTIONS); \
(_P)->exception[(_P)->lastException].cause = (_cause); \
(_P)->exception[(_P)->lastException].vec = (_vec); \
(_P)->exception[(_P)->lastException].badaddr = (_badaddr); \
(_P)->exception[(_P)->lastException].hireg = (_hireg); \
(_P)->exception[(_P)->lastException].ctxtreg = (_ctxtreg); \
(_P)->exception[(_P)->lastException].xctxtreg = (_xctxtreg); }
#define RECORD_EXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) \
if ((_P)->inMXS) \
_MXS_RECORD_EXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) \
else \
_MIPSY_RECORD_EXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg)
#define RECORD_UTLBEXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) \
if ((_P)->inMXS) \
_MXS_RECORD_EXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) \
else \
_MIPSY_RECORD_UTLBEXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg)
#endif /* MIPSY_MXS */
#ifndef RECORD_EXCEPTION
#define RECORD_EXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) \
_MIPSY_RECORD_EXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg)
#define RECORD_UTLBEXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg) \
_MIPSY_RECORD_UTLBEXCEPTION(_P, _cause, _vec, _badaddr, _hireg, _ctxtreg,_xctxtreg)
#endif /* RECORD_EXCEPTION */
#endif /* !MIPSY_CP0_H */