1
/***************************************************************************
5
Common MIPS III/IV definitions and functions
7
***************************************************************************/
11
#ifndef __MIPS3COM_H__
12
#define __MIPS3COM_H__
18
/***************************************************************************
20
***************************************************************************/
25
#define MIPS3_MIN_PAGE_SHIFT 12
26
#define MIPS3_MIN_PAGE_SIZE (1 << MIPS3_MIN_PAGE_SHIFT)
27
#define MIPS3_MIN_PAGE_MASK (MIPS3_MIN_PAGE_SIZE - 1)
28
#define MIPS3_MAX_PADDR_SHIFT 32
29
#define MIPS3_MAX_TLB_ENTRIES 48
31
/* cycle parameters */
32
#define MIPS3_COUNT_READ_CYCLES 250
33
#define MIPS3_CAUSE_READ_CYCLES 250
38
/* MIPS III variants */
45
/* MIPS IV variants */
51
typedef enum _mips3_flavor mips3_flavor;
54
#define TLB_GLOBAL 0x01
55
#define TLB_VALID 0x02
56
#define TLB_DIRTY 0x04
57
#define TLB_PRESENT 0x08
62
#define COP0_EntryLo 2
63
#define COP0_EntryLo0 2
64
#define COP0_EntryLo1 3
65
#define COP0_Context 4
66
#define COP0_PageMask 5
68
#define COP0_BadVAddr 8
70
#define COP0_EntryHi 10
71
#define COP0_Compare 11
72
#define COP0_Status 12
76
#define COP0_Config 16
77
#define COP0_LLAddr 17
78
#define COP0_XContext 20
80
#define COP0_CacheErr 27
83
#define COP0_ErrorPC 30
85
/* Status register bits */
86
#define SR_IE 0x00000001
87
#define SR_EXL 0x00000002
88
#define SR_ERL 0x00000004
89
#define SR_KSU_MASK 0x00000018
90
#define SR_KSU_KERNEL 0x00000000
91
#define SR_KSU_SUPERVISOR 0x00000008
92
#define SR_KSU_USER 0x00000010
93
#define SR_IMSW0 0x00000100
94
#define SR_IMSW1 0x00000200
95
#define SR_IMEX0 0x00000400
96
#define SR_IMEX1 0x00000800
97
#define SR_IMEX2 0x00001000
98
#define SR_IMEX3 0x00002000
99
#define SR_IMEX4 0x00004000
100
#define SR_IMEX5 0x00008000
101
#define SR_DE 0x00010000
102
#define SR_CE 0x00020000
103
#define SR_CH 0x00040000
104
#define SR_SR 0x00100000
105
#define SR_TS 0x00200000
106
#define SR_BEV 0x00400000
107
#define SR_ITS 0x01000000 /* VR4300 only, Application Note doesn't give purpose */
108
#define SR_RE 0x02000000
109
#define SR_FR 0x04000000
110
#define SR_RP 0x08000000
111
#define SR_COP0 0x10000000
112
#define SR_COP1 0x20000000
113
#define SR_COP2 0x40000000
114
#define SR_COP3 0x80000000
116
/* exception types */
117
#define EXCEPTION_INTERRUPT 0
118
#define EXCEPTION_TLBMOD 1
119
#define EXCEPTION_TLBLOAD 2
120
#define EXCEPTION_TLBSTORE 3
121
#define EXCEPTION_ADDRLOAD 4
122
#define EXCEPTION_ADDRSTORE 5
123
#define EXCEPTION_BUSINST 6
124
#define EXCEPTION_BUSDATA 7
125
#define EXCEPTION_SYSCALL 8
126
#define EXCEPTION_BREAK 9
127
#define EXCEPTION_INVALIDOP 10
128
#define EXCEPTION_BADCOP 11
129
#define EXCEPTION_OVERFLOW 12
130
#define EXCEPTION_TRAP 13
131
#define EXCEPTION_TLBLOAD_FILL 16
132
#define EXCEPTION_TLBSTORE_FILL 17
133
#define EXCEPTION_COUNT 18
137
/***************************************************************************
139
***************************************************************************/
144
#define RSREG ((op >> 21) & 31)
145
#define RTREG ((op >> 16) & 31)
146
#define RDREG ((op >> 11) & 31)
147
#define SHIFT ((op >> 6) & 31)
149
#define FRREG ((op >> 21) & 31)
150
#define FTREG ((op >> 16) & 31)
151
#define FSREG ((op >> 11) & 31)
152
#define FDREG ((op >> 6) & 31)
154
#define IS_SINGLE(o) (((o) & (1 << 21)) == 0)
155
#define IS_DOUBLE(o) (((o) & (1 << 21)) != 0)
156
#define IS_FLOAT(o) (((o) & (1 << 23)) == 0)
157
#define IS_INTEGRAL(o) (((o) & (1 << 23)) != 0)
159
#define SIMMVAL ((INT16)op)
160
#define UIMMVAL ((UINT16)op)
161
#define LIMMVAL (op & 0x03ffffff)
165
/***************************************************************************
166
STRUCTURES & TYPEDEFS
167
***************************************************************************/
169
/* MIPS3 TLB entry */
170
typedef struct _mips3_tlb_entry mips3_tlb_entry;
171
struct _mips3_tlb_entry
179
/* forward declaration of implementation-specific state */
180
typedef struct _mips3imp_state mips3imp_state;
184
typedef struct _mips3_state mips3_state;
199
device_irq_callback irq_callback;
200
legacy_cpu_device * device;
201
address_space *program;
202
direct_read_data *direct;
205
UINT64 count_zero_time;
206
UINT32 compare_armed;
207
emu_timer * compare_int_timer;
209
/* derived info based on flavor */
213
/* memory accesses */
215
data_accessors memory;
223
mips3_tlb_entry tlb[MIPS3_MAX_TLB_ENTRIES];
225
/* for use by specific implementations */
226
mips3imp_state *impstate;
231
/***************************************************************************
233
***************************************************************************/
235
void mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, legacy_cpu_device *device, device_irq_callback irqcallback);
236
void mips3com_exit(mips3_state *mips);
238
void mips3com_reset(mips3_state *mips);
239
offs_t mips3com_dasm(mips3_state *mips, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
240
void mips3com_update_cycle_counting(mips3_state *mips);
242
void mips3com_asid_changed(mips3_state *mips);
243
int mips3com_translate_address(mips3_state *mips, address_spacenum space, int intention, offs_t *address);
244
void mips3com_tlbr(mips3_state *mips);
245
void mips3com_tlbwi(mips3_state *mips);
246
void mips3com_tlbwr(mips3_state *mips);
247
void mips3com_tlbp(mips3_state *mips);
249
void mips3com_set_info(mips3_state *mips, UINT32 state, cpuinfo *info);
250
void mips3com_get_info(mips3_state *mips, UINT32 state, cpuinfo *info);
254
/***************************************************************************
256
***************************************************************************/
258
/*-------------------------------------------------
259
mips3com_set_irq_line - set or clear the given
261
-------------------------------------------------*/
263
INLINE void mips3com_set_irq_line(mips3_state *mips, int irqline, int state)
265
if (state != CLEAR_LINE)
266
mips->cpr[0][COP0_Cause] |= 0x400 << irqline;
268
mips->cpr[0][COP0_Cause] &= ~(0x400 << irqline);
271
#endif /* __MIPS3COM_H__ */