Debian Codegraph @

unstable/mips64_cp0.h

raw
1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2005,2006 Christophe Fillot ([email protected])
4 */
5
6 #ifndef __CP0_H__
7 #define __CP0_H__
8
9 #include "utils.h"
10
11 #define TLB_ZONE_ADD 0
12 #define TLB_ZONE_DELETE 1
13
14 /* Update the Context register with a faulty address */
15 static inline
16 void mips64_cp0_update_context_reg(cpu_mips_t *cpu,m_uint64_t addr)
17 {
18 m_uint64_t badvpn2;
19
20 badvpn2 = addr & MIPS_CP0_CONTEXT_VPN2_MASK;
21 badvpn2 <<= MIPS_CP0_CONTEXT_BADVPN2_SHIFT;
22
23 cpu->cp0.reg[MIPS_CP0_CONTEXT] &= ~MIPS_CP0_CONTEXT_BADVPN2_MASK;
24 cpu->cp0.reg[MIPS_CP0_CONTEXT] |= badvpn2;
25 }
26
27 /* Update the XContext register with a faulty address */
28 static inline
29 void mips64_cp0_update_xcontext_reg(cpu_mips_t *cpu,m_uint64_t addr)
30 {
31 m_uint64_t rbadvpn2;
32
33 rbadvpn2 = addr & MIPS_CP0_XCONTEXT_VPN2_MASK;
34 rbadvpn2 <<= MIPS_CP0_XCONTEXT_BADVPN2_SHIFT;
35 rbadvpn2 |= ((addr >> 62) & 0x03) << MIPS_CP0_XCONTEXT_R_SHIFT;
36
37 cpu->cp0.reg[MIPS_CP0_XCONTEXT] &= ~MIPS_CP0_XCONTEXT_RBADVPN2_MASK;
38 cpu->cp0.reg[MIPS_CP0_XCONTEXT] |= rbadvpn2;
39 }
40
41 /* Get the CPU operating mode (User,Supervisor or Kernel) */
42 static forced_inline u_int mips64_cp0_get_mode(cpu_mips_t *cpu)
43 {
44 mips_cp0_t *cp0 = &cpu->cp0;
45 u_int cpu_mode;
46
47 cpu_mode = cp0->reg[MIPS_CP0_STATUS] >> MIPS_CP0_STATUS_KSU_SHIFT;
48 cpu_mode &= MIPS_CP0_STATUS_KSU_MASK;
49 return(cpu_mode);
50 }
51
52 /* Get the VPN2 mask */
53 static forced_inline m_uint64_t mips64_cp0_get_vpn2_mask(cpu_mips_t *cpu)
54 {
55 if (cpu->addr_mode == 64)
56 return(MIPS_TLB_VPN2_MASK_64);
57 else
58 return(MIPS_TLB_VPN2_MASK_32);
59 }
60
61 /* CP0 register names */
62 extern char *mips64_cp0_reg_names[];
63
64 /* Get cp0 register index given its name */
65 int mips64_cp0_get_reg_index(char *name);
66
67 /* Get the CPU operating mode (User,Supervisor or Kernel) */
68 u_int mips64_cp0_get_mode(cpu_mips_t *cpu);
69
70 /* Get a cp0 register */
71 m_uint64_t mips64_cp0_get_reg(cpu_mips_t *cpu,u_int cp0_reg);
72
73 /* DMFC0 */
74 fastcall void mips64_cp0_exec_dmfc0(cpu_mips_t *cpu,u_int gp_reg,
75 u_int cp0_reg);
76
77 /* DMTC0 */
78 fastcall void mips64_cp0_exec_dmtc0(cpu_mips_t *cpu,u_int gp_reg,
79 u_int cp0_reg);
80
81 /* MFC0 */
82 fastcall void mips64_cp0_exec_mfc0(cpu_mips_t *cpu,u_int gp_reg,u_int cp0_reg);
83
84 /* MTC0 */
85 fastcall void mips64_cp0_exec_mtc0(cpu_mips_t *cpu,u_int gp_reg,u_int cp0_reg);
86
87 /* CFC0 */
88 fastcall void mips64_cp0_exec_cfc0(cpu_mips_t *cpu,u_int gp_reg,u_int cp0_reg);
89
90 /* CTC0 */
91 fastcall void mips64_cp0_exec_ctc0(cpu_mips_t *cpu,u_int gp_reg,u_int cp0_reg);
92
93 /* TLB lookup */
94 int mips64_cp0_tlb_lookup(cpu_mips_t *cpu,m_uint64_t vaddr,u_int op_type,
95 mts_map_t *res);
96
97 /* TLBP: Probe a TLB entry */
98 fastcall void mips64_cp0_exec_tlbp(cpu_mips_t *cpu);
99
100 /* TLBR: Read Indexed TLB entry */
101 fastcall void mips64_cp0_exec_tlbr(cpu_mips_t *cpu);
102
103 /* TLBWI: Write Indexed TLB entry */
104 fastcall void mips64_cp0_exec_tlbwi(cpu_mips_t *cpu);
105
106 /* TLBWR: Write Random TLB entry */
107 fastcall void mips64_cp0_exec_tlbwr(cpu_mips_t *cpu);
108
109 /* Raw dump of the TLB */
110 void mips64_tlb_raw_dump(cpu_gen_t *cpu);
111
112 /* Dump the specified TLB entry */
113 void mips64_tlb_dump_entry(cpu_mips_t *cpu,u_int index);
114
115 /* Human-Readable dump of the TLB */
116 void mips64_tlb_dump(cpu_gen_t *cpu);
117
118 #endif