mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 06:45:33 +00:00
target-i386: Introduce cpu_x86_update_dr7
This moves the last of the iteration over breakpoints into the bpt_helper.c file. This also allows us to make several breakpoint functions static. Backports commit 93d00d0fbe4711061834730fb70525d167b6f908 from qemu
This commit is contained in:
parent
c5c44f3a8a
commit
0ad95f8341
|
@ -20,8 +20,8 @@
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "exec/helper-proto.h"
|
#include "exec/helper-proto.h"
|
||||||
|
|
||||||
|
#ifndef CONFIG_USER_ONLY
|
||||||
void hw_breakpoint_insert(CPUX86State *env, int index)
|
static void hw_breakpoint_insert(CPUX86State *env, int index)
|
||||||
{
|
{
|
||||||
CPUState *cs = CPU(x86_env_get_cpu(env));
|
CPUState *cs = CPU(x86_env_get_cpu(env));
|
||||||
int type = 0, err = 0;
|
int type = 0, err = 0;
|
||||||
|
@ -55,7 +55,7 @@ void hw_breakpoint_insert(CPUX86State *env, int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hw_breakpoint_remove(CPUX86State *env, int index)
|
static void hw_breakpoint_remove(CPUX86State *env, int index)
|
||||||
{
|
{
|
||||||
CPUState *cs;
|
CPUState *cs;
|
||||||
|
|
||||||
|
@ -79,6 +79,20 @@ void hw_breakpoint_remove(CPUX86State *env, int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cpu_x86_update_dr7(CPUX86State *env, uint32_t new_dr7)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < DR7_MAX_BP; i++) {
|
||||||
|
hw_breakpoint_remove(env, i);
|
||||||
|
}
|
||||||
|
env->dr[7] = new_dr7;
|
||||||
|
for (i = 0; i < DR7_MAX_BP; i++) {
|
||||||
|
hw_breakpoint_insert(env, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool check_hw_breakpoints(CPUX86State *env, bool force_dr6_update)
|
static bool check_hw_breakpoints(CPUX86State *env, bool force_dr6_update)
|
||||||
{
|
{
|
||||||
target_ulong dr6;
|
target_ulong dr6;
|
||||||
|
@ -161,20 +175,12 @@ void helper_single_step(CPUX86State *env)
|
||||||
void helper_movl_drN_T0(CPUX86State *env, int reg, target_ulong t0)
|
void helper_movl_drN_T0(CPUX86State *env, int reg, target_ulong t0)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
int i;
|
|
||||||
|
|
||||||
if (reg < 4) {
|
if (reg < 4) {
|
||||||
hw_breakpoint_remove(env, reg);
|
hw_breakpoint_remove(env, reg);
|
||||||
env->dr[reg] = t0;
|
env->dr[reg] = t0;
|
||||||
hw_breakpoint_insert(env, reg);
|
hw_breakpoint_insert(env, reg);
|
||||||
} else if (reg == 7) {
|
} else if (reg == 7) {
|
||||||
for (i = 0; i < DR7_MAX_BP; i++) {
|
cpu_x86_update_dr7(env, t0);
|
||||||
hw_breakpoint_remove(env, i);
|
|
||||||
}
|
|
||||||
env->dr[7] = t0;
|
|
||||||
for (i = 0; i < DR7_MAX_BP; i++) {
|
|
||||||
hw_breakpoint_insert(env, i);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
env->dr[reg] = t0;
|
env->dr[reg] = t0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,6 +236,7 @@
|
||||||
#define DR7_TYPE_SHIFT 16
|
#define DR7_TYPE_SHIFT 16
|
||||||
#define DR7_LEN_SHIFT 18
|
#define DR7_LEN_SHIFT 18
|
||||||
#define DR7_FIXED_1 0x00000400
|
#define DR7_FIXED_1 0x00000400
|
||||||
|
#define DR7_GLOBAL_BP_MASK 0xaa
|
||||||
#define DR7_LOCAL_BP_MASK 0x55
|
#define DR7_LOCAL_BP_MASK 0x55
|
||||||
#define DR7_MAX_BP 4
|
#define DR7_MAX_BP 4
|
||||||
#define DR7_TYPE_BP_INST 0x0
|
#define DR7_TYPE_BP_INST 0x0
|
||||||
|
@ -1157,14 +1158,13 @@ static inline int hw_breakpoint_len(unsigned long dr7, int index)
|
||||||
return (len == 2) ? 8 : len + 1;
|
return (len == 2) ? 8 : len + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hw_breakpoint_insert(CPUX86State *env, int index);
|
|
||||||
void hw_breakpoint_remove(CPUX86State *env, int index);
|
|
||||||
void breakpoint_handler(CPUState *cs);
|
void breakpoint_handler(CPUState *cs);
|
||||||
|
|
||||||
/* will be suppressed */
|
/* will be suppressed */
|
||||||
void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0);
|
void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0);
|
||||||
void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3);
|
void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3);
|
||||||
void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4);
|
void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4);
|
||||||
|
void cpu_x86_update_dr7(CPUX86State *env, uint32_t new_dr7);
|
||||||
|
|
||||||
/* hw/pc.c */
|
/* hw/pc.c */
|
||||||
void cpu_smm_update(CPUX86State *env);
|
void cpu_smm_update(CPUX86State *env);
|
||||||
|
|
|
@ -488,13 +488,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_selector,
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
/* reset local breakpoints */
|
/* reset local breakpoints */
|
||||||
if (env->dr[7] & DR7_LOCAL_BP_MASK) {
|
if (env->dr[7] & DR7_LOCAL_BP_MASK) {
|
||||||
for (i = 0; i < DR7_MAX_BP; i++) {
|
cpu_x86_update_dr7(env, env->dr[7] & ~DR7_LOCAL_BP_MASK);
|
||||||
if (hw_local_breakpoint_enabled(env->dr[7], i) &&
|
|
||||||
!hw_global_breakpoint_enabled(env->dr[7], i)) {
|
|
||||||
hw_breakpoint_remove(env, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
env->dr[7] &= ~DR7_LOCAL_BP_MASK;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue