3 #if !defined(NO_LABEL_VALUES) && (!defined(STACK_SIZE) || STACK_SIZE >= 4000) && __INT_MAX__ >= 2147483647
4 typedef unsigned int uint32
;
5 typedef signed int sint32
;
9 typedef unsigned long int host_addr_t
;
10 typedef uint32 target_addr_t
;
11 typedef sint32 target_saddr_t
;
17 unsigned int offset
:18;
18 unsigned int ignore
:4;
32 target_addr_t vaddr_tag
;
33 unsigned long int rigged_paddr
;
41 tlb_entry_t tlb_tab
[0x100];
57 simulator_kernel (int what
, environment_t
*env
)
59 register insn_t
*pc
= env
->pc
;
60 register reg_t
*regs
= env
->registers
;
64 register void *base_addr
= &&sim_base_addr
;
65 register tlb_entry_t
*tlb
= env
->tlb_tab
;
70 static void *op_map
[] =
75 insn_t
*program
= env
->program
;
76 for (i
= 0; i
< what
; i
++)
77 program
[i
].f1
.offset
= op_map
[program
[i
].f1
.offset
] - base_addr
;
83 r2
= (*(reg_t
*) (((char *) regs
) + (insn
.f1
.s2
<< 2)));
84 s1
= (insn
.f1
.s1
<< 2);
85 goto *(base_addr
+ insn
.f1
.offset
);
89 target_addr_t vaddr_page
= r2
/ 4096;
90 unsigned int x
= vaddr_page
% 0x100;
95 target_addr_t tag
= tlb
[x
].vaddr_tag
;
96 host_addr_t rigged_paddr
= tlb
[x
].rigged_paddr
;
98 if (tag
== vaddr_page
)
100 *(reg_t
*) (((char *) regs
) + s1
) = *(uint32
*) (rigged_paddr
+ r2
);
101 r2
= *(reg_t
*) (((char *) regs
) + (insn
.f1
.s2
<< 2));
102 s1
= insn
.f1
.s1
<< 2;
103 goto *(base_addr
+ insn
.f1
.offset
);
106 if (((target_saddr_t
) tag
< 0))
108 *(reg_t
*) (((char *) regs
) + s1
) = *(uint32
*) f ();
109 r2
= *(reg_t
*) (((char *) regs
) + (insn
.f1
.s2
<< 2));
110 s1
= insn
.f1
.s1
<< 2;
111 goto *(base_addr
+ insn
.f1
.offset
);
118 return (*(reg_t
*) (((char *) regs
) + s1
));
122 insn_t program
[2 + 1];
132 host_addr_t a_page
= (host_addr_t
) malloc (2 * 4096);
133 target_addr_t a_vaddr
= 0x123450;
134 target_addr_t vaddr_page
= a_vaddr
/ 4096;
135 a_page
= (a_page
+ 4096 - 1) & -4096;
137 env
.tlb_tab
[((vaddr_page
) % 0x100)].vaddr_tag
= vaddr_page
;
138 env
.tlb_tab
[((vaddr_page
) % 0x100)].rigged_paddr
= a_page
- vaddr_page
* 4096;
139 insn
.f1
.offset
= LOAD32_RR
;
140 env
.registers
[0] = 0;
141 env
.registers
[2] = a_vaddr
;
142 *(sint32
*) (a_page
+ a_vaddr
% 4096) = 88;
146 for (i
= 0; i
< 2; i
++)
149 insn
.f1
.offset
= METAOP_DONE
;
154 env
.program
= program
;
156 res
= simulator_kernel (2 + 1, &env
);