]>
git.proxmox.com Git - qemu.git/blob - target-microblaze/translate.c
2 * Xilinx MicroBlaze emulation for qemu: main translation routines.
4 * Copyright (c) 2009 Edgar E. Iglesias.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
32 #include "microblaze-decode.h"
33 #include "qemu-common.h"
41 #if DISAS_MB && !SIM_COMPAT
42 # define LOG_DIS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)
44 # define LOG_DIS(...) do { } while (0)
49 #define EXTRACT_FIELD(src, start, end) \
50 (((src) >> start) & ((1 << (end - start + 1)) - 1))
52 static TCGv env_debug
;
53 static TCGv_ptr cpu_env
;
54 static TCGv cpu_R
[32];
55 static TCGv cpu_SR
[18];
57 static TCGv env_btaken
;
58 static TCGv env_btarget
;
59 static TCGv env_iflags
;
61 #include "gen-icount.h"
63 /* This is the state at translation time. */
64 typedef struct DisasContext
{
67 target_ulong cache_pc
;
76 unsigned int cpustate_changed
;
77 unsigned int delayed_branch
;
78 unsigned int tb_flags
, synced_flags
; /* tb dependent flags. */
79 unsigned int clear_imm
;
84 #define JMP_INDIRECT 2
88 int abort_at_next_insn
;
90 struct TranslationBlock
*tb
;
91 int singlestep_enabled
;
94 const static char *regnames
[] =
96 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
97 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
98 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
99 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
102 const static char *special_regnames
[] =
104 "rpc", "rmsr", "sr2", "sr3", "sr4", "sr5", "sr6", "sr7",
105 "sr8", "sr9", "sr10", "sr11", "sr12", "sr13", "sr14", "sr15",
106 "sr16", "sr17", "sr18"
109 /* Sign extend at translation time. */
110 static inline int sign_extend(unsigned int val
, unsigned int width
)
122 static inline void t_sync_flags(DisasContext
*dc
)
124 /* Synch the tb dependant flags between translator and runtime. */
125 if (dc
->tb_flags
!= dc
->synced_flags
) {
126 tcg_gen_movi_tl(env_iflags
, dc
->tb_flags
);
127 dc
->synced_flags
= dc
->tb_flags
;
131 static inline void t_gen_raise_exception(DisasContext
*dc
, uint32_t index
)
133 TCGv_i32 tmp
= tcg_const_i32(index
);
136 tcg_gen_movi_tl(cpu_SR
[SR_PC
], dc
->pc
);
137 gen_helper_raise_exception(tmp
);
138 tcg_temp_free_i32(tmp
);
139 dc
->is_jmp
= DISAS_UPDATE
;
142 static void gen_goto_tb(DisasContext
*dc
, int n
, target_ulong dest
)
144 TranslationBlock
*tb
;
146 if ((tb
->pc
& TARGET_PAGE_MASK
) == (dest
& TARGET_PAGE_MASK
)) {
148 tcg_gen_movi_tl(cpu_SR
[SR_PC
], dest
);
149 tcg_gen_exit_tb((long)tb
+ n
);
151 tcg_gen_movi_tl(cpu_SR
[SR_PC
], dest
);
156 static inline TCGv
*dec_alu_op_b(DisasContext
*dc
)
159 if (dc
->tb_flags
& IMM_FLAG
)
160 tcg_gen_ori_tl(env_imm
, env_imm
, dc
->imm
);
162 tcg_gen_movi_tl(env_imm
, (int32_t)((int16_t)dc
->imm
));
165 return &cpu_R
[dc
->rb
];
168 static void dec_add(DisasContext
*dc
)
175 LOG_DIS("add%s%s%s r%d r%d r%d\n",
176 dc
->type_b
? "i" : "", k
? "k" : "", c
? "c" : "",
177 dc
->rd
, dc
->ra
, dc
->rb
);
179 if (k
&& !c
&& dc
->rd
)
180 tcg_gen_add_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)));
182 gen_helper_addkc(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)),
183 tcg_const_tl(k
), tcg_const_tl(c
));
185 TCGv d
= tcg_temp_new();
186 gen_helper_addkc(d
, cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)),
187 tcg_const_tl(k
), tcg_const_tl(c
));
192 static void dec_sub(DisasContext
*dc
)
194 unsigned int u
, cmp
, k
, c
;
199 cmp
= (dc
->imm
& 1) && (!dc
->type_b
) && k
;
202 LOG_DIS("cmp%s r%d, r%d ir=%x\n", u
? "u" : "", dc
->rd
, dc
->ra
, dc
->ir
);
205 gen_helper_cmpu(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], cpu_R
[dc
->rb
]);
207 gen_helper_cmp(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], cpu_R
[dc
->rb
]);
210 LOG_DIS("sub%s%s r%d, r%d r%d\n",
211 k
? "k" : "", c
? "c" : "", dc
->rd
, dc
->ra
, dc
->rb
);
217 gen_helper_subkc(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)),
218 tcg_const_tl(k
), tcg_const_tl(c
));
220 gen_helper_subkc(t
, cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)),
221 tcg_const_tl(k
), tcg_const_tl(c
));
225 tcg_gen_sub_tl(cpu_R
[dc
->rd
], *(dec_alu_op_b(dc
)), cpu_R
[dc
->ra
]);
229 static void dec_pattern(DisasContext
*dc
)
234 if ((dc
->tb_flags
& MSR_EE_FLAG
)
235 && !(dc
->env
->pvr
.regs
[2] & PVR2_ILL_OPCODE_EXC_MASK
)
236 && !((dc
->env
->pvr
.regs
[2] & PVR2_USE_PCMP_INSTR
))) {
237 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_ILLEGAL_OP
);
238 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
241 mode
= dc
->opcode
& 3;
245 LOG_DIS("pcmpbf r%d r%d r%d\n", dc
->rd
, dc
->ra
, dc
->rb
);
247 gen_helper_pcmpbf(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], cpu_R
[dc
->rb
]);
250 LOG_DIS("pcmpeq r%d r%d r%d\n", dc
->rd
, dc
->ra
, dc
->rb
);
252 TCGv t0
= tcg_temp_local_new();
253 l1
= gen_new_label();
254 tcg_gen_movi_tl(t0
, 1);
255 tcg_gen_brcond_tl(TCG_COND_EQ
,
256 cpu_R
[dc
->ra
], cpu_R
[dc
->rb
], l1
);
257 tcg_gen_movi_tl(t0
, 0);
259 tcg_gen_mov_tl(cpu_R
[dc
->rd
], t0
);
264 LOG_DIS("pcmpne r%d r%d r%d\n", dc
->rd
, dc
->ra
, dc
->rb
);
265 l1
= gen_new_label();
267 TCGv t0
= tcg_temp_local_new();
268 tcg_gen_movi_tl(t0
, 1);
269 tcg_gen_brcond_tl(TCG_COND_NE
,
270 cpu_R
[dc
->ra
], cpu_R
[dc
->rb
], l1
);
271 tcg_gen_movi_tl(t0
, 0);
273 tcg_gen_mov_tl(cpu_R
[dc
->rd
], t0
);
279 "unsupported pattern insn opcode=%x\n", dc
->opcode
);
284 static void dec_and(DisasContext
*dc
)
288 if (!dc
->type_b
&& (dc
->imm
& (1 << 10))) {
293 not = dc
->opcode
& (1 << 1);
294 LOG_DIS("and%s\n", not ? "n" : "");
300 TCGv t
= tcg_temp_new();
301 tcg_gen_not_tl(t
, *(dec_alu_op_b(dc
)));
302 tcg_gen_and_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], t
);
305 tcg_gen_and_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)));
308 static void dec_or(DisasContext
*dc
)
310 if (!dc
->type_b
&& (dc
->imm
& (1 << 10))) {
315 LOG_DIS("or r%d r%d r%d imm=%x\n", dc
->rd
, dc
->ra
, dc
->rb
, dc
->imm
);
317 tcg_gen_or_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)));
320 static void dec_xor(DisasContext
*dc
)
322 if (!dc
->type_b
&& (dc
->imm
& (1 << 10))) {
327 LOG_DIS("xor r%d\n", dc
->rd
);
329 tcg_gen_xor_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)));
332 static void read_carry(DisasContext
*dc
, TCGv d
)
334 tcg_gen_shri_tl(d
, cpu_SR
[SR_MSR
], 31);
337 static void write_carry(DisasContext
*dc
, TCGv v
)
339 TCGv t0
= tcg_temp_new();
340 tcg_gen_shli_tl(t0
, v
, 31);
341 tcg_gen_sari_tl(t0
, t0
, 31);
342 tcg_gen_mov_tl(env_debug
, t0
);
343 tcg_gen_andi_tl(t0
, t0
, (MSR_C
| MSR_CC
));
344 tcg_gen_andi_tl(cpu_SR
[SR_MSR
], cpu_SR
[SR_MSR
],
346 tcg_gen_or_tl(cpu_SR
[SR_MSR
], cpu_SR
[SR_MSR
], t0
);
351 static inline void msr_read(DisasContext
*dc
, TCGv d
)
353 tcg_gen_mov_tl(d
, cpu_SR
[SR_MSR
]);
356 static inline void msr_write(DisasContext
*dc
, TCGv v
)
358 dc
->cpustate_changed
= 1;
359 tcg_gen_mov_tl(cpu_SR
[SR_MSR
], v
);
360 /* PVR, we have a processor version register. */
361 tcg_gen_ori_tl(cpu_SR
[SR_MSR
], cpu_SR
[SR_MSR
], (1 << 10));
364 static void dec_msr(DisasContext
*dc
)
367 unsigned int sr
, to
, rn
;
368 int mem_index
= cpu_mmu_index(dc
->env
);
370 sr
= dc
->imm
& ((1 << 14) - 1);
371 to
= dc
->imm
& (1 << 14);
374 dc
->cpustate_changed
= 1;
376 /* msrclr and msrset. */
377 if (!(dc
->imm
& (1 << 15))) {
378 unsigned int clr
= dc
->ir
& (1 << 16);
380 LOG_DIS("msr%s r%d imm=%x\n", clr
? "clr" : "set",
383 if (!(dc
->env
->pvr
.regs
[2] & PVR2_USE_MSR_INSTR
)) {
388 if ((dc
->tb_flags
& MSR_EE_FLAG
)
389 && mem_index
== MMU_USER_IDX
&& (dc
->imm
!= 4 && dc
->imm
!= 0)) {
390 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_PRIVINSN
);
391 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
396 msr_read(dc
, cpu_R
[dc
->rd
]);
401 tcg_gen_mov_tl(t1
, *(dec_alu_op_b(dc
)));
404 tcg_gen_not_tl(t1
, t1
);
405 tcg_gen_and_tl(t0
, t0
, t1
);
407 tcg_gen_or_tl(t0
, t0
, t1
);
411 tcg_gen_movi_tl(cpu_SR
[SR_PC
], dc
->pc
+ 4);
412 dc
->is_jmp
= DISAS_UPDATE
;
417 if ((dc
->tb_flags
& MSR_EE_FLAG
)
418 && mem_index
== MMU_USER_IDX
) {
419 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_PRIVINSN
);
420 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
425 #if !defined(CONFIG_USER_ONLY)
426 /* Catch read/writes to the mmu block. */
427 if ((sr
& ~0xff) == 0x1000) {
429 LOG_DIS("m%ss sr%d r%d imm=%x\n", to
? "t" : "f", sr
, dc
->ra
, dc
->imm
);
431 gen_helper_mmu_write(tcg_const_tl(sr
), cpu_R
[dc
->ra
]);
433 gen_helper_mmu_read(cpu_R
[dc
->rd
], tcg_const_tl(sr
));
439 LOG_DIS("m%ss sr%x r%d imm=%x\n", to
? "t" : "f", sr
, dc
->ra
, dc
->imm
);
444 msr_write(dc
, cpu_R
[dc
->ra
]);
447 tcg_gen_mov_tl(cpu_SR
[SR_EAR
], cpu_R
[dc
->ra
]);
450 tcg_gen_mov_tl(cpu_SR
[SR_ESR
], cpu_R
[dc
->ra
]);
453 /* Ignored at the moment. */
456 cpu_abort(dc
->env
, "unknown mts reg %x\n", sr
);
460 LOG_DIS("m%ss r%d sr%x imm=%x\n", to
? "t" : "f", dc
->rd
, sr
, dc
->imm
);
464 tcg_gen_movi_tl(cpu_R
[dc
->rd
], dc
->pc
);
467 msr_read(dc
, cpu_R
[dc
->rd
]);
470 tcg_gen_mov_tl(cpu_R
[dc
->rd
], cpu_SR
[SR_EAR
]);
473 tcg_gen_mov_tl(cpu_R
[dc
->rd
], cpu_SR
[SR_ESR
]);
476 tcg_gen_movi_tl(cpu_R
[dc
->rd
], 0);
479 tcg_gen_mov_tl(cpu_R
[dc
->rd
], cpu_SR
[SR_BTR
]);
495 tcg_gen_ld_tl(cpu_R
[dc
->rd
],
496 cpu_env
, offsetof(CPUState
, pvr
.regs
[rn
]));
499 cpu_abort(dc
->env
, "unknown mfs reg %x\n", sr
);
505 /* 64-bit signed mul, lower result in d and upper in d2. */
506 static void t_gen_muls(TCGv d
, TCGv d2
, TCGv a
, TCGv b
)
510 t0
= tcg_temp_new_i64();
511 t1
= tcg_temp_new_i64();
513 tcg_gen_ext_i32_i64(t0
, a
);
514 tcg_gen_ext_i32_i64(t1
, b
);
515 tcg_gen_mul_i64(t0
, t0
, t1
);
517 tcg_gen_trunc_i64_i32(d
, t0
);
518 tcg_gen_shri_i64(t0
, t0
, 32);
519 tcg_gen_trunc_i64_i32(d2
, t0
);
521 tcg_temp_free_i64(t0
);
522 tcg_temp_free_i64(t1
);
525 /* 64-bit unsigned muls, lower result in d and upper in d2. */
526 static void t_gen_mulu(TCGv d
, TCGv d2
, TCGv a
, TCGv b
)
530 t0
= tcg_temp_new_i64();
531 t1
= tcg_temp_new_i64();
533 tcg_gen_extu_i32_i64(t0
, a
);
534 tcg_gen_extu_i32_i64(t1
, b
);
535 tcg_gen_mul_i64(t0
, t0
, t1
);
537 tcg_gen_trunc_i64_i32(d
, t0
);
538 tcg_gen_shri_i64(t0
, t0
, 32);
539 tcg_gen_trunc_i64_i32(d2
, t0
);
541 tcg_temp_free_i64(t0
);
542 tcg_temp_free_i64(t1
);
545 /* Multiplier unit. */
546 static void dec_mul(DisasContext
*dc
)
549 unsigned int subcode
;
551 if ((dc
->tb_flags
& MSR_EE_FLAG
)
552 && !(dc
->env
->pvr
.regs
[2] & PVR2_ILL_OPCODE_EXC_MASK
)
553 && !(dc
->env
->pvr
.regs
[0] & PVR0_USE_HW_MUL_MASK
)) {
554 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_ILLEGAL_OP
);
555 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
559 subcode
= dc
->imm
& 3;
560 d
[0] = tcg_temp_new();
561 d
[1] = tcg_temp_new();
564 LOG_DIS("muli r%d r%d %x\n", dc
->rd
, dc
->ra
, dc
->imm
);
565 t_gen_mulu(cpu_R
[dc
->rd
], d
[1], cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)));
569 /* mulh, mulhsu and mulhu are not available if C_USE_HW_MUL is < 2. */
570 if (subcode
>= 1 && subcode
<= 3
571 && !((dc
->env
->pvr
.regs
[2] & PVR2_USE_MUL64_MASK
))) {
577 LOG_DIS("mul r%d r%d r%d\n", dc
->rd
, dc
->ra
, dc
->rb
);
578 t_gen_mulu(cpu_R
[dc
->rd
], d
[1], cpu_R
[dc
->ra
], cpu_R
[dc
->rb
]);
581 LOG_DIS("mulh r%d r%d r%d\n", dc
->rd
, dc
->ra
, dc
->rb
);
582 t_gen_muls(d
[0], cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], cpu_R
[dc
->rb
]);
585 LOG_DIS("mulhsu r%d r%d r%d\n", dc
->rd
, dc
->ra
, dc
->rb
);
586 t_gen_muls(d
[0], cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], cpu_R
[dc
->rb
]);
589 LOG_DIS("mulhu r%d r%d r%d\n", dc
->rd
, dc
->ra
, dc
->rb
);
590 t_gen_mulu(d
[0], cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], cpu_R
[dc
->rb
]);
593 cpu_abort(dc
->env
, "unknown MUL insn %x\n", subcode
);
602 static void dec_div(DisasContext
*dc
)
609 if (!(dc
->env
->pvr
.regs
[2] & PVR2_ILL_OPCODE_EXC_MASK
)
610 && !((dc
->env
->pvr
.regs
[0] & PVR0_USE_DIV_MASK
))) {
611 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_ILLEGAL_OP
);
612 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
615 /* FIXME: support div by zero exceptions. */
617 gen_helper_divu(cpu_R
[dc
->rd
], *(dec_alu_op_b(dc
)), cpu_R
[dc
->ra
]);
619 gen_helper_divs(cpu_R
[dc
->rd
], *(dec_alu_op_b(dc
)), cpu_R
[dc
->ra
]);
621 tcg_gen_movi_tl(cpu_R
[dc
->rd
], 0);
624 static void dec_barrel(DisasContext
*dc
)
629 if ((dc
->tb_flags
& MSR_EE_FLAG
)
630 && !(dc
->env
->pvr
.regs
[2] & PVR2_ILL_OPCODE_EXC_MASK
)
631 && !(dc
->env
->pvr
.regs
[0] & PVR0_USE_BARREL_MASK
)) {
632 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_ILLEGAL_OP
);
633 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
637 s
= dc
->imm
& (1 << 10);
638 t
= dc
->imm
& (1 << 9);
640 LOG_DIS("bs%s%s r%d r%d r%d\n",
641 s
? "l" : "r", t
? "a" : "l", dc
->rd
, dc
->ra
, dc
->rb
);
645 tcg_gen_mov_tl(t0
, *(dec_alu_op_b(dc
)));
646 tcg_gen_andi_tl(t0
, t0
, 31);
649 tcg_gen_shl_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], t0
);
652 tcg_gen_sar_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], t0
);
654 tcg_gen_shr_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], t0
);
658 static void dec_bit(DisasContext
*dc
)
662 int mem_index
= cpu_mmu_index(dc
->env
);
664 op
= dc
->ir
& ((1 << 8) - 1);
670 LOG_DIS("src r%d r%d\n", dc
->rd
, dc
->ra
);
671 tcg_gen_andi_tl(t0
, cpu_R
[dc
->ra
], 1);
675 tcg_gen_shli_tl(t1
, t1
, 31);
677 tcg_gen_shri_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], 1);
678 tcg_gen_or_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->rd
], t1
);
691 LOG_DIS("srl r%d r%d\n", dc
->rd
, dc
->ra
);
694 tcg_gen_andi_tl(t0
, cpu_R
[dc
->ra
], 1);
699 tcg_gen_shri_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], 1);
701 tcg_gen_sari_tl(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
], 1);
705 LOG_DIS("ext8s r%d r%d\n", dc
->rd
, dc
->ra
);
706 tcg_gen_ext8s_i32(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
]);
709 LOG_DIS("ext16s r%d r%d\n", dc
->rd
, dc
->ra
);
710 tcg_gen_ext16s_i32(cpu_R
[dc
->rd
], cpu_R
[dc
->ra
]);
714 LOG_DIS("wdc r%d\n", dc
->ra
);
715 if ((dc
->tb_flags
& MSR_EE_FLAG
)
716 && mem_index
== MMU_USER_IDX
) {
717 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_PRIVINSN
);
718 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
724 LOG_DIS("wic r%d\n", dc
->ra
);
725 if ((dc
->tb_flags
& MSR_EE_FLAG
)
726 && mem_index
== MMU_USER_IDX
) {
727 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_PRIVINSN
);
728 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
733 cpu_abort(dc
->env
, "unknown bit oc=%x op=%x rd=%d ra=%d rb=%d\n",
734 dc
->pc
, op
, dc
->rd
, dc
->ra
, dc
->rb
);
739 static inline void sync_jmpstate(DisasContext
*dc
)
741 if (dc
->jmp
== JMP_DIRECT
) {
742 dc
->jmp
= JMP_INDIRECT
;
743 tcg_gen_movi_tl(env_btaken
, 1);
744 tcg_gen_movi_tl(env_btarget
, dc
->jmp_pc
);
748 static void dec_imm(DisasContext
*dc
)
750 LOG_DIS("imm %x\n", dc
->imm
<< 16);
751 tcg_gen_movi_tl(env_imm
, (dc
->imm
<< 16));
752 dc
->tb_flags
|= IMM_FLAG
;
756 static inline void gen_load(DisasContext
*dc
, TCGv dst
, TCGv addr
,
759 int mem_index
= cpu_mmu_index(dc
->env
);
762 tcg_gen_qemu_ld8u(dst
, addr
, mem_index
);
763 } else if (size
== 2) {
764 tcg_gen_qemu_ld16u(dst
, addr
, mem_index
);
765 } else if (size
== 4) {
766 tcg_gen_qemu_ld32u(dst
, addr
, mem_index
);
768 cpu_abort(dc
->env
, "Incorrect load size %d\n", size
);
771 static inline TCGv
*compute_ldst_addr(DisasContext
*dc
, TCGv
*t
)
773 unsigned int extimm
= dc
->tb_flags
& IMM_FLAG
;
775 /* Treat the fast cases first. */
778 tcg_gen_add_tl(*t
, cpu_R
[dc
->ra
], cpu_R
[dc
->rb
]);
784 return &cpu_R
[dc
->ra
];
787 tcg_gen_movi_tl(*t
, (int32_t)((int16_t)dc
->imm
));
788 tcg_gen_add_tl(*t
, cpu_R
[dc
->ra
], *t
);
791 tcg_gen_add_tl(*t
, cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)));
797 static void dec_load(DisasContext
*dc
)
802 size
= 1 << (dc
->opcode
& 3);
804 LOG_DIS("l %x %d\n", dc
->opcode
, size
);
806 addr
= compute_ldst_addr(dc
, &t
);
808 /* If we get a fault on a dslot, the jmpstate better be in sync. */
811 gen_load(dc
, cpu_R
[dc
->rd
], *addr
, size
);
813 gen_load(dc
, env_imm
, *addr
, size
);
820 static void gen_store(DisasContext
*dc
, TCGv addr
, TCGv val
,
823 int mem_index
= cpu_mmu_index(dc
->env
);
826 tcg_gen_qemu_st8(val
, addr
, mem_index
);
827 else if (size
== 2) {
828 tcg_gen_qemu_st16(val
, addr
, mem_index
);
829 } else if (size
== 4) {
830 tcg_gen_qemu_st32(val
, addr
, mem_index
);
832 cpu_abort(dc
->env
, "Incorrect store size %d\n", size
);
835 static void dec_store(DisasContext
*dc
)
840 size
= 1 << (dc
->opcode
& 3);
842 LOG_DIS("s%d%s\n", size
, dc
->type_b
? "i" : "");
844 /* If we get a fault on a dslot, the jmpstate better be in sync. */
846 addr
= compute_ldst_addr(dc
, &t
);
847 gen_store(dc
, *addr
, cpu_R
[dc
->rd
], size
);
852 static inline void eval_cc(DisasContext
*dc
, unsigned int cc
,
853 TCGv d
, TCGv a
, TCGv b
)
859 l1
= gen_new_label();
860 tcg_gen_movi_tl(env_btaken
, 1);
861 tcg_gen_brcond_tl(TCG_COND_EQ
, a
, b
, l1
);
862 tcg_gen_movi_tl(env_btaken
, 0);
866 l1
= gen_new_label();
867 tcg_gen_movi_tl(env_btaken
, 1);
868 tcg_gen_brcond_tl(TCG_COND_NE
, a
, b
, l1
);
869 tcg_gen_movi_tl(env_btaken
, 0);
873 l1
= gen_new_label();
874 tcg_gen_movi_tl(env_btaken
, 1);
875 tcg_gen_brcond_tl(TCG_COND_LT
, a
, b
, l1
);
876 tcg_gen_movi_tl(env_btaken
, 0);
880 l1
= gen_new_label();
881 tcg_gen_movi_tl(env_btaken
, 1);
882 tcg_gen_brcond_tl(TCG_COND_LE
, a
, b
, l1
);
883 tcg_gen_movi_tl(env_btaken
, 0);
887 l1
= gen_new_label();
888 tcg_gen_movi_tl(env_btaken
, 1);
889 tcg_gen_brcond_tl(TCG_COND_GE
, a
, b
, l1
);
890 tcg_gen_movi_tl(env_btaken
, 0);
894 l1
= gen_new_label();
895 tcg_gen_movi_tl(env_btaken
, 1);
896 tcg_gen_brcond_tl(TCG_COND_GT
, a
, b
, l1
);
897 tcg_gen_movi_tl(env_btaken
, 0);
901 cpu_abort(dc
->env
, "Unknown condition code %x.\n", cc
);
906 static void eval_cond_jmp(DisasContext
*dc
, TCGv pc_true
, TCGv pc_false
)
910 l1
= gen_new_label();
911 /* Conditional jmp. */
912 tcg_gen_mov_tl(cpu_SR
[SR_PC
], pc_false
);
913 tcg_gen_brcondi_tl(TCG_COND_EQ
, env_btaken
, 0, l1
);
914 tcg_gen_mov_tl(cpu_SR
[SR_PC
], pc_true
);
918 static void dec_bcc(DisasContext
*dc
)
923 cc
= EXTRACT_FIELD(dc
->ir
, 21, 23);
924 dslot
= dc
->ir
& (1 << 25);
925 LOG_DIS("bcc%s r%d %x\n", dslot
? "d" : "", dc
->ra
, dc
->imm
);
927 dc
->delayed_branch
= 1;
929 dc
->delayed_branch
= 2;
930 dc
->tb_flags
|= D_FLAG
;
931 tcg_gen_st_tl(tcg_const_tl(dc
->type_b
&& (dc
->tb_flags
& IMM_FLAG
)),
932 cpu_env
, offsetof(CPUState
, bimm
));
935 tcg_gen_movi_tl(env_btarget
, dc
->pc
);
936 tcg_gen_add_tl(env_btarget
, env_btarget
, *(dec_alu_op_b(dc
)));
937 eval_cc(dc
, cc
, env_btaken
, cpu_R
[dc
->ra
], tcg_const_tl(0));
938 dc
->jmp
= JMP_INDIRECT
;
941 static void dec_br(DisasContext
*dc
)
943 unsigned int dslot
, link
, abs
;
945 dslot
= dc
->ir
& (1 << 20);
946 abs
= dc
->ir
& (1 << 19);
947 link
= dc
->ir
& (1 << 18);
948 LOG_DIS("br%s%s%s%s imm=%x\n",
949 abs
? "a" : "", link
? "l" : "",
950 dc
->type_b
? "i" : "", dslot
? "d" : "",
953 dc
->delayed_branch
= 1;
955 dc
->delayed_branch
= 2;
956 dc
->tb_flags
|= D_FLAG
;
957 tcg_gen_st_tl(tcg_const_tl(dc
->type_b
&& (dc
->tb_flags
& IMM_FLAG
)),
958 cpu_env
, offsetof(CPUState
, bimm
));
961 tcg_gen_movi_tl(cpu_R
[dc
->rd
], dc
->pc
);
963 dc
->jmp
= JMP_INDIRECT
;
965 tcg_gen_movi_tl(env_btaken
, 1);
966 tcg_gen_mov_tl(env_btarget
, *(dec_alu_op_b(dc
)));
967 if (link
&& !(dc
->tb_flags
& IMM_FLAG
)
968 && (dc
->imm
== 8 || dc
->imm
== 0x18))
969 t_gen_raise_exception(dc
, EXCP_BREAK
);
971 t_gen_raise_exception(dc
, EXCP_DEBUG
);
973 if (dc
->tb_flags
& IMM_FLAG
) {
974 tcg_gen_movi_tl(env_btaken
, 1);
975 tcg_gen_movi_tl(env_btarget
, dc
->pc
);
976 tcg_gen_add_tl(env_btarget
, env_btarget
, *(dec_alu_op_b(dc
)));
978 dc
->jmp
= JMP_DIRECT
;
979 dc
->jmp_pc
= dc
->pc
+ (int32_t)((int16_t)dc
->imm
);
984 static inline void do_rti(DisasContext
*dc
)
989 tcg_gen_shri_tl(t0
, cpu_SR
[SR_MSR
], 1);
990 tcg_gen_ori_tl(t1
, cpu_SR
[SR_MSR
], MSR_IE
);
991 tcg_gen_andi_tl(t0
, t0
, (MSR_VM
| MSR_UM
));
993 tcg_gen_andi_tl(t1
, t1
, ~(MSR_VM
| MSR_UM
));
994 tcg_gen_or_tl(t1
, t1
, t0
);
998 dc
->tb_flags
&= ~DRTI_FLAG
;
1001 static inline void do_rtb(DisasContext
*dc
)
1004 t0
= tcg_temp_new();
1005 t1
= tcg_temp_new();
1006 tcg_gen_andi_tl(t1
, cpu_SR
[SR_MSR
], ~MSR_BIP
);
1007 tcg_gen_shri_tl(t0
, t1
, 1);
1008 tcg_gen_andi_tl(t0
, t0
, (MSR_VM
| MSR_UM
));
1010 tcg_gen_andi_tl(t1
, t1
, ~(MSR_VM
| MSR_UM
));
1011 tcg_gen_or_tl(t1
, t1
, t0
);
1015 dc
->tb_flags
&= ~DRTB_FLAG
;
1018 static inline void do_rte(DisasContext
*dc
)
1021 t0
= tcg_temp_new();
1022 t1
= tcg_temp_new();
1024 tcg_gen_ori_tl(t1
, cpu_SR
[SR_MSR
], MSR_EE
);
1025 tcg_gen_andi_tl(t1
, t1
, ~MSR_EIP
);
1026 tcg_gen_shri_tl(t0
, t1
, 1);
1027 tcg_gen_andi_tl(t0
, t0
, (MSR_VM
| MSR_UM
));
1029 tcg_gen_andi_tl(t1
, t1
, ~(MSR_VM
| MSR_UM
));
1030 tcg_gen_or_tl(t1
, t1
, t0
);
1034 dc
->tb_flags
&= ~DRTE_FLAG
;
1037 static void dec_rts(DisasContext
*dc
)
1039 unsigned int b_bit
, i_bit
, e_bit
;
1040 int mem_index
= cpu_mmu_index(dc
->env
);
1042 i_bit
= dc
->ir
& (1 << 21);
1043 b_bit
= dc
->ir
& (1 << 22);
1044 e_bit
= dc
->ir
& (1 << 23);
1046 dc
->delayed_branch
= 2;
1047 dc
->tb_flags
|= D_FLAG
;
1048 tcg_gen_st_tl(tcg_const_tl(dc
->type_b
&& (dc
->tb_flags
& IMM_FLAG
)),
1049 cpu_env
, offsetof(CPUState
, bimm
));
1052 LOG_DIS("rtid ir=%x\n", dc
->ir
);
1053 if ((dc
->tb_flags
& MSR_EE_FLAG
)
1054 && mem_index
== MMU_USER_IDX
) {
1055 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_PRIVINSN
);
1056 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
1058 dc
->tb_flags
|= DRTI_FLAG
;
1060 LOG_DIS("rtbd ir=%x\n", dc
->ir
);
1061 if ((dc
->tb_flags
& MSR_EE_FLAG
)
1062 && mem_index
== MMU_USER_IDX
) {
1063 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_PRIVINSN
);
1064 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
1066 dc
->tb_flags
|= DRTB_FLAG
;
1068 LOG_DIS("rted ir=%x\n", dc
->ir
);
1069 if ((dc
->tb_flags
& MSR_EE_FLAG
)
1070 && mem_index
== MMU_USER_IDX
) {
1071 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_PRIVINSN
);
1072 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
1074 dc
->tb_flags
|= DRTE_FLAG
;
1076 LOG_DIS("rts ir=%x\n", dc
->ir
);
1078 tcg_gen_movi_tl(env_btaken
, 1);
1079 tcg_gen_add_tl(env_btarget
, cpu_R
[dc
->ra
], *(dec_alu_op_b(dc
)));
1082 static void dec_fpu(DisasContext
*dc
)
1084 if ((dc
->tb_flags
& MSR_EE_FLAG
)
1085 && !(dc
->env
->pvr
.regs
[2] & PVR2_ILL_OPCODE_EXC_MASK
)
1086 && !((dc
->env
->pvr
.regs
[2] & PVR2_USE_FPU_MASK
))) {
1087 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_ILLEGAL_OP
);
1088 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
1092 qemu_log ("unimplemented FPU insn pc=%x opc=%x\n", dc
->pc
, dc
->opcode
);
1093 dc
->abort_at_next_insn
= 1;
1096 static void dec_null(DisasContext
*dc
)
1098 qemu_log ("unknown insn pc=%x opc=%x\n", dc
->pc
, dc
->opcode
);
1099 dc
->abort_at_next_insn
= 1;
1102 static struct decoder_info
{
1107 void (*dec
)(DisasContext
*dc
);
1115 {DEC_BARREL
, dec_barrel
},
1117 {DEC_ST
, dec_store
},
1129 static inline void decode(DisasContext
*dc
)
1134 if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP
)))
1135 tcg_gen_debug_insn_start(dc
->pc
);
1137 dc
->ir
= ir
= ldl_code(dc
->pc
);
1138 LOG_DIS("%8.8x\t", dc
->ir
);
1143 if ((dc
->tb_flags
& MSR_EE_FLAG
)
1144 && !(dc
->env
->pvr
.regs
[2] & PVR2_ILL_OPCODE_EXC_MASK
)
1145 && !(dc
->env
->pvr
.regs
[2] & PVR2_OPCODE_0x0_ILL_MASK
)) {
1146 tcg_gen_movi_tl(cpu_SR
[SR_ESR
], ESR_EC_ILLEGAL_OP
);
1147 t_gen_raise_exception(dc
, EXCP_HW_EXCP
);
1151 LOG_DIS("nr_nops=%d\t", dc
->nr_nops
);
1153 if (dc
->nr_nops
> 4)
1154 cpu_abort(dc
->env
, "fetching nop sequence\n");
1156 /* bit 2 seems to indicate insn type. */
1157 dc
->type_b
= ir
& (1 << 29);
1159 dc
->opcode
= EXTRACT_FIELD(ir
, 26, 31);
1160 dc
->rd
= EXTRACT_FIELD(ir
, 21, 25);
1161 dc
->ra
= EXTRACT_FIELD(ir
, 16, 20);
1162 dc
->rb
= EXTRACT_FIELD(ir
, 11, 15);
1163 dc
->imm
= EXTRACT_FIELD(ir
, 0, 15);
1165 /* Large switch for all insns. */
1166 for (i
= 0; i
< ARRAY_SIZE(decinfo
); i
++) {
1167 if ((dc
->opcode
& decinfo
[i
].mask
) == decinfo
[i
].bits
) {
1174 static void check_breakpoint(CPUState
*env
, DisasContext
*dc
)
1178 if (unlikely(!TAILQ_EMPTY(&env
->breakpoints
))) {
1179 TAILQ_FOREACH(bp
, &env
->breakpoints
, entry
) {
1180 if (bp
->pc
== dc
->pc
) {
1181 t_gen_raise_exception(dc
, EXCP_DEBUG
);
1182 dc
->is_jmp
= DISAS_UPDATE
;
1188 /* generate intermediate code for basic block 'tb'. */
1190 gen_intermediate_code_internal(CPUState
*env
, TranslationBlock
*tb
,
1193 uint16_t *gen_opc_end
;
1196 struct DisasContext ctx
;
1197 struct DisasContext
*dc
= &ctx
;
1198 uint32_t next_page_start
, org_flags
;
1203 qemu_log_try_set_file(stderr
);
1208 org_flags
= dc
->synced_flags
= dc
->tb_flags
= tb
->flags
;
1210 gen_opc_end
= gen_opc_buf
+ OPC_MAX_SIZE
;
1212 dc
->is_jmp
= DISAS_NEXT
;
1214 dc
->delayed_branch
= !!(dc
->tb_flags
& D_FLAG
);
1218 dc
->singlestep_enabled
= env
->singlestep_enabled
;
1219 dc
->cpustate_changed
= 0;
1220 dc
->abort_at_next_insn
= 0;
1224 cpu_abort(env
, "Microblaze: unaligned PC=%x\n", pc_start
);
1226 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM
)) {
1228 qemu_log("--------------\n");
1229 log_cpu_state(env
, 0);
1233 next_page_start
= (pc_start
& TARGET_PAGE_MASK
) + TARGET_PAGE_SIZE
;
1236 max_insns
= tb
->cflags
& CF_COUNT_MASK
;
1238 max_insns
= CF_COUNT_MASK
;
1244 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM
)) {
1245 tcg_gen_movi_tl(cpu_SR
[SR_PC
], dc
->pc
);
1249 check_breakpoint(env
, dc
);
1252 j
= gen_opc_ptr
- gen_opc_buf
;
1256 gen_opc_instr_start
[lj
++] = 0;
1258 gen_opc_pc
[lj
] = dc
->pc
;
1259 gen_opc_instr_start
[lj
] = 1;
1260 gen_opc_icount
[lj
] = num_insns
;
1264 LOG_DIS("%8.8x:\t", dc
->pc
);
1266 if (num_insns
+ 1 == max_insns
&& (tb
->cflags
& CF_LAST_IO
))
1272 dc
->tb_flags
&= ~IMM_FLAG
;
1277 if (dc
->delayed_branch
) {
1278 dc
->delayed_branch
--;
1279 if (!dc
->delayed_branch
) {
1280 if (dc
->tb_flags
& DRTI_FLAG
)
1282 if (dc
->tb_flags
& DRTB_FLAG
)
1284 if (dc
->tb_flags
& DRTE_FLAG
)
1286 /* Clear the delay slot flag. */
1287 dc
->tb_flags
&= ~D_FLAG
;
1288 /* If it is a direct jump, try direct chaining. */
1289 if (dc
->jmp
!= JMP_DIRECT
) {
1290 eval_cond_jmp(dc
, env_btarget
, tcg_const_tl(dc
->pc
));
1291 dc
->is_jmp
= DISAS_JUMP
;
1296 if (env
->singlestep_enabled
)
1298 } while (!dc
->is_jmp
&& !dc
->cpustate_changed
1299 && gen_opc_ptr
< gen_opc_end
1301 && (dc
->pc
< next_page_start
)
1302 && num_insns
< max_insns
);
1305 if (dc
->jmp
== JMP_DIRECT
) {
1306 if (dc
->tb_flags
& D_FLAG
) {
1307 dc
->is_jmp
= DISAS_UPDATE
;
1308 tcg_gen_movi_tl(cpu_SR
[SR_PC
], npc
);
1314 if (tb
->cflags
& CF_LAST_IO
)
1316 /* Force an update if the per-tb cpu state has changed. */
1317 if (dc
->is_jmp
== DISAS_NEXT
1318 && (dc
->cpustate_changed
|| org_flags
!= dc
->tb_flags
)) {
1319 dc
->is_jmp
= DISAS_UPDATE
;
1320 tcg_gen_movi_tl(cpu_SR
[SR_PC
], npc
);
1324 if (unlikely(env
->singlestep_enabled
)) {
1325 t_gen_raise_exception(dc
, EXCP_DEBUG
);
1326 if (dc
->is_jmp
== DISAS_NEXT
)
1327 tcg_gen_movi_tl(cpu_SR
[SR_PC
], npc
);
1329 switch(dc
->is_jmp
) {
1331 gen_goto_tb(dc
, 1, npc
);
1336 /* indicate that the hash table must be used
1337 to find the next TB */
1341 /* nothing more to generate */
1345 gen_icount_end(tb
, num_insns
);
1346 *gen_opc_ptr
= INDEX_op_end
;
1348 j
= gen_opc_ptr
- gen_opc_buf
;
1351 gen_opc_instr_start
[lj
++] = 0;
1353 tb
->size
= dc
->pc
- pc_start
;
1354 tb
->icount
= num_insns
;
1359 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM
)) {
1362 log_target_disas(pc_start
, dc
->pc
- pc_start
, 0);
1364 qemu_log("\nisize=%d osize=%zd\n",
1365 dc
->pc
- pc_start
, gen_opc_ptr
- gen_opc_buf
);
1369 assert(!dc
->abort_at_next_insn
);
1372 void gen_intermediate_code (CPUState
*env
, struct TranslationBlock
*tb
)
1374 gen_intermediate_code_internal(env
, tb
, 0);
1377 void gen_intermediate_code_pc (CPUState
*env
, struct TranslationBlock
*tb
)
1379 gen_intermediate_code_internal(env
, tb
, 1);
1382 void cpu_dump_state (CPUState
*env
, FILE *f
,
1383 int (*cpu_fprintf
)(FILE *f
, const char *fmt
, ...),
1391 cpu_fprintf(f
, "IN: PC=%x %s\n",
1392 env
->sregs
[SR_PC
], lookup_symbol(env
->sregs
[SR_PC
]));
1393 cpu_fprintf(f
, "rmsr=%x resr=%x debug[%x] imm=%x iflags=%x\n",
1394 env
->sregs
[SR_MSR
], env
->sregs
[SR_ESR
],
1395 env
->debug
, env
->imm
, env
->iflags
);
1396 cpu_fprintf(f
, "btaken=%d btarget=%x mode=%s(saved=%s)\n",
1397 env
->btaken
, env
->btarget
,
1398 (env
->sregs
[SR_MSR
] & MSR_UM
) ? "user" : "kernel",
1399 (env
->sregs
[SR_MSR
] & MSR_UMS
) ? "user" : "kernel");
1400 for (i
= 0; i
< 32; i
++) {
1401 cpu_fprintf(f
, "r%2.2d=%8.8x ", i
, env
->regs
[i
]);
1402 if ((i
+ 1) % 4 == 0)
1403 cpu_fprintf(f
, "\n");
1405 cpu_fprintf(f
, "\n\n");
1408 CPUState
*cpu_mb_init (const char *cpu_model
)
1411 static int tcg_initialized
= 0;
1414 env
= qemu_mallocz(sizeof(CPUState
));
1419 env
->pvr
.regs
[0] = PVR0_PVR_FULL_MASK \
1420 | PVR0_USE_BARREL_MASK \
1421 | PVR0_USE_DIV_MASK \
1422 | PVR0_USE_HW_MUL_MASK \
1423 | PVR0_USE_EXC_MASK \
1424 | PVR0_USE_ICACHE_MASK \
1425 | PVR0_USE_DCACHE_MASK \
1428 env
->pvr
.regs
[2] = PVR2_D_OPB_MASK \
1432 | PVR2_USE_MSR_INSTR \
1433 | PVR2_USE_PCMP_INSTR \
1434 | PVR2_USE_BARREL_MASK \
1435 | PVR2_USE_DIV_MASK \
1436 | PVR2_USE_HW_MUL_MASK \
1437 | PVR2_USE_MUL64_MASK \
1439 env
->pvr
.regs
[10] = 0x0c000000; /* Default to spartan 3a dsp family. */
1440 env
->pvr
.regs
[11] = PVR11_USE_MMU
;
1442 if (tcg_initialized
)
1445 tcg_initialized
= 1;
1447 cpu_env
= tcg_global_reg_new_ptr(TCG_AREG0
, "env");
1449 env_debug
= tcg_global_mem_new(TCG_AREG0
,
1450 offsetof(CPUState
, debug
),
1452 env_iflags
= tcg_global_mem_new(TCG_AREG0
,
1453 offsetof(CPUState
, iflags
),
1455 env_imm
= tcg_global_mem_new(TCG_AREG0
,
1456 offsetof(CPUState
, imm
),
1458 env_btarget
= tcg_global_mem_new(TCG_AREG0
,
1459 offsetof(CPUState
, btarget
),
1461 env_btaken
= tcg_global_mem_new(TCG_AREG0
,
1462 offsetof(CPUState
, btaken
),
1464 for (i
= 0; i
< ARRAY_SIZE(cpu_R
); i
++) {
1465 cpu_R
[i
] = tcg_global_mem_new(TCG_AREG0
,
1466 offsetof(CPUState
, regs
[i
]),
1469 for (i
= 0; i
< ARRAY_SIZE(cpu_SR
); i
++) {
1470 cpu_SR
[i
] = tcg_global_mem_new(TCG_AREG0
,
1471 offsetof(CPUState
, sregs
[i
]),
1472 special_regnames
[i
]);
1474 #define GEN_HELPER 2
1480 void cpu_reset (CPUState
*env
)
1482 if (qemu_loglevel_mask(CPU_LOG_RESET
)) {
1483 qemu_log("CPU Reset (CPU %d)\n", env
->cpu_index
);
1484 log_cpu_state(env
, 0);
1487 memset(env
, 0, offsetof(CPUMBState
, breakpoints
));
1490 env
->sregs
[SR_MSR
] = 0;
1491 #if defined(CONFIG_USER_ONLY)
1492 /* start in user mode with interrupts enabled. */
1493 env
->pvr
.regs
[10] = 0x0c000000; /* Spartan 3a dsp. */
1495 mmu_init(&env
->mmu
);
1499 void gen_pc_load(CPUState
*env
, struct TranslationBlock
*tb
,
1500 unsigned long searched_pc
, int pc_pos
, void *puc
)
1502 env
->sregs
[SR_PC
] = gen_opc_pc
[pc_pos
];