/* enable cpu_get_ticks() */ void cpu_enable_ticks(void) { if (!timers_state.cpu_ticks_enabled) { timers_state.cpu_ticks_offset -= cpu_get_real_ticks(); timers_state.cpu_clock_offset -= get_clock(); timers_state.cpu_ticks_enabled = 1; } }
static target_ulong h_xirr_x(PowerPCCPU *cpu, sPAPREnvironment *spapr, target_ulong opcode, target_ulong *args) { CPUState *cs = CPU(cpu); ICPState *ss = &spapr->icp->ss[cs->cpu_index]; uint32_t xirr = icp_accept(ss); args[0] = xirr; args[1] = cpu_get_real_ticks(); return H_SUCCESS; }
/* enable cpu_get_ticks() */ void cpu_enable_ticks(void) { if (!timers_state.cpu_ticks_enabled) { timers_state.cpu_ticks_offset -= cpu_get_real_ticks(); timers_state.cpu_clock_offset -= get_clock(); timers_state.cpu_ticks_enabled = 1; if (timers_state.clock_scale_enable) { //Fast-forward suspended clocks timers_state.cpu_clock_prev = get_clock() + timers_state.cpu_clock_offset; timers_state.cpu_clock_prev_scaled = timers_state.cpu_clock_prev; } } }
/* return the host CPU cycle counter and handle stop/restart */ int64_t cpu_get_ticks(void) { if (!timers_state.cpu_ticks_enabled) { return timers_state.cpu_ticks_offset; } else { int64_t ticks; ticks = cpu_get_real_ticks(); if (timers_state.cpu_ticks_prev > ticks) { /* Note: non increasing ticks may happen if the host uses software suspend */ timers_state.cpu_ticks_offset += timers_state.cpu_ticks_prev - ticks; } timers_state.cpu_ticks_prev = ticks; return ticks + timers_state.cpu_ticks_offset; } }
/* return the host CPU cycle counter and handle stop/restart */ int64_t cpu_get_ticks(void) { if (use_icount) { return cpu_get_icount(); } if (!timers_state.cpu_ticks_enabled) { return timers_state.cpu_ticks_offset; } else { int64_t ticks; ticks = cpu_get_real_ticks(); #ifndef CONFIG_COREMU if (timers_state.cpu_ticks_prev > ticks) { /* Note: non increasing ticks may happen if the host uses software suspend */ timers_state.cpu_ticks_offset += timers_state.cpu_ticks_prev - ticks; } timers_state.cpu_ticks_prev = ticks; #endif return ticks + timers_state.cpu_ticks_offset; } }
/* return the host CPU cycle counter and handle stop/restart */ int64_t cpu_get_ticks(void) { #ifdef MARSS_QEMU if(in_simulation) { return timers_state.cpu_sim_ticks_offset + sim_cycle; } #endif if (use_icount) { return cpu_get_icount(); } if (!timers_state.cpu_ticks_enabled) { return timers_state.cpu_ticks_offset; } else { int64_t ticks; ticks = cpu_get_real_ticks(); if (timers_state.cpu_ticks_prev > ticks) { /* Note: non increasing ticks may happen if the host uses software suspend */ timers_state.cpu_ticks_offset += timers_state.cpu_ticks_prev - ticks; } timers_state.cpu_ticks_prev = ticks; return ticks + timers_state.cpu_ticks_offset; } }
/* return non zero if the very first instruction is invalid so that the virtual CPU can trigger an exception. '*gen_code_size_ptr' contains the size of the generated code (host code). */ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr) { TCGContext *s = tcg_ctx_env; uint8_t *gen_code_buf; int gen_code_size; #ifdef CONFIG_PROFILER int64_t ti; #endif #ifdef CONFIG_PROFILER s->tb_count1++; /* includes aborted translations because of exceptions */ ti = profile_getclock(); #endif #if defined(CONFIG_HYBRID) int64_t start_cycle = 0, end_cycle = 0; if (llvm_profile_enabled) start_cycle = cpu_get_real_ticks(); #endif tcg_func_start(env, s); gen_intermediate_code(env, tb); /* generate machine code */ s->tb = tb; gen_code_buf = tb->tc_ptr; tb->tb_next_offset[0] = 0xffff; tb->tb_next_offset[1] = 0xffff; s->tb_next_offset = tb->tb_next_offset; #ifdef USE_DIRECT_JUMP s->tb_jmp_offset = tb->tb_jmp_offset; s->tb_next = NULL; #else s->tb_jmp_offset = NULL; s->tb_next = tb->tb_next; #endif #ifdef CONFIG_PROFILER s->tb_count++; s->interm_time += profile_getclock() - ti; s->code_time -= profile_getclock(); #endif #if defined(CONFIG_LLVM) && !defined(CONFIG_HYBRID) gen_code_size = llvm_gen_block(env, s, tb); #else gen_code_size = tcg_gen_code(s, gen_code_buf); #endif *gen_code_size_ptr = gen_code_size; #ifdef CONFIG_PROFILER s->code_time += profile_getclock(); s->code_in_len += tb->size; s->code_out_len += gen_code_size; #endif #if defined(CONFIG_HYBRID) if (llvm_profile_enabled) { end_cycle = cpu_get_real_ticks(); llvm_tb_record(tb, gen_code_size, end_cycle-start_cycle); } #endif #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) { qemu_log("OUT: [size=%d]\n", *gen_code_size_ptr); log_disas(tb->tc_ptr, *gen_code_size_ptr); qemu_log("\n"); qemu_log_flush(); } #endif return 0; }