Received: from eggs.gnu.org ([208.118.235.92]:43688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv1uO-0002pn-JO for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tv1uN-00014o-6C for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:12 -0500 Received: from cantor2.suse.de ([195.135.220.15]:38330 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv1uM-00014W-To for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:11 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 15 Jan 2013 09:29:55 +0100 Message-Id: <1358238598-31451-2-git-send-email-afaerber@suse.de> In-Reply-To: <1358238598-31451-1-git-send-email-afaerber@suse.de> References: <1358238598-31451-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v6 1/4] target-i386: Define DR7 bit field constants List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , lig.fnst@cn.fujitsu.com From: liguang Implicit use of dr7 bit field is a little hard to understand, so define constants for them and use them consistently. Signed-off-by: liguang Signed-off-by: Andreas F=C3=A4rber --- target-i386/cpu.h | 6 ++++++ target-i386/helper.c | 18 +++++++++--------- target-i386/machine.c | 5 +++-- target-i386/misc_helper.c | 4 ++-- target-i386/seg_helper.c | 6 +++--- 5 Dateien ge=C3=A4ndert, 23 Zeilen hinzugef=C3=BCgt(+), 16 Zeilen entfer= nt(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index e4a7c50..6682022 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -231,6 +231,12 @@ #define DR7_TYPE_SHIFT 16 #define DR7_LEN_SHIFT 18 #define DR7_FIXED_1 0x00000400 +#define DR7_LOCAL_BP_MASK 0x55 +#define DR7_MAX_BP 4 +#define DR7_TYPE_BP_INST 0x0 +#define DR7_TYPE_DATA_WR 0x1 +#define DR7_TYPE_IO_RW 0x2 +#define DR7_TYPE_DATA_RW 0x3 =20 #define PG_PRESENT_BIT 0 #define PG_RW_BIT 1 diff --git a/target-i386/helper.c b/target-i386/helper.c index fa622e1..1fceb91 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -969,18 +969,18 @@ void hw_breakpoint_insert(CPUX86State *env, int ind= ex) int type, err =3D 0; =20 switch (hw_breakpoint_type(env->dr[7], index)) { - case 0: + case DR7_TYPE_BP_INST: if (hw_breakpoint_enabled(env->dr[7], index)) err =3D cpu_breakpoint_insert(env, env->dr[index], BP_CPU, &env->cpu_breakpoint[index]); break; - case 1: + case DR7_TYPE_DATA_WR: type =3D BP_CPU | BP_MEM_WRITE; goto insert_wp; - case 2: + case DR7_TYPE_IO_RW: /* No support for I/O watchpoints yet */ break; - case 3: + case DR7_TYPE_DATA_RW: type =3D BP_CPU | BP_MEM_ACCESS; insert_wp: err =3D cpu_watchpoint_insert(env, env->dr[index], @@ -997,15 +997,15 @@ void hw_breakpoint_remove(CPUX86State *env, int ind= ex) if (!env->cpu_breakpoint[index]) return; switch (hw_breakpoint_type(env->dr[7], index)) { - case 0: + case DR7_TYPE_BP_INST: if (hw_breakpoint_enabled(env->dr[7], index)) cpu_breakpoint_remove_by_ref(env, env->cpu_breakpoint[index]= ); break; - case 1: - case 3: + case DR7_TYPE_DATA_WR: + case DR7_TYPE_DATA_RW: cpu_watchpoint_remove_by_ref(env, env->cpu_watchpoint[index]); break; - case 2: + case DR7_TYPE_IO_RW: /* No support for I/O watchpoints yet */ break; } @@ -1018,7 +1018,7 @@ int check_hw_breakpoints(CPUX86State *env, int forc= e_dr6_update) int hit_enabled =3D 0; =20 dr6 =3D env->dr[6] & ~0xf; - for (reg =3D 0; reg < 4; reg++) { + for (reg =3D 0; reg < DR7_MAX_BP; reg++) { type =3D hw_breakpoint_type(env->dr[7], reg); if ((type =3D=3D 0 && env->dr[reg] =3D=3D env->eip) || ((type & 1) && env->cpu_watchpoint[reg] && diff --git a/target-i386/machine.c b/target-i386/machine.c index 8354572..8df6a6b 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -265,10 +265,11 @@ static int cpu_post_load(void *opaque, int version_= id) =20 cpu_breakpoint_remove_all(env, BP_CPU); cpu_watchpoint_remove_all(env, BP_CPU); - for (i =3D 0; i < 4; i++) + for (i =3D 0; i < DR7_MAX_BP; i++) { hw_breakpoint_insert(env, i); - + } tlb_flush(env, 1); + return 0; } =20 diff --git a/target-i386/misc_helper.c b/target-i386/misc_helper.c index 719cacd..b3f4e4f 100644 --- a/target-i386/misc_helper.c +++ b/target-i386/misc_helper.c @@ -197,11 +197,11 @@ void helper_movl_drN_T0(CPUX86State *env, int reg, = target_ulong t0) env->dr[reg] =3D t0; hw_breakpoint_insert(env, reg); } else if (reg =3D=3D 7) { - for (i =3D 0; i < 4; i++) { + for (i =3D 0; i < DR7_MAX_BP; i++) { hw_breakpoint_remove(env, i); } env->dr[7] =3D t0; - for (i =3D 0; i < 4; i++) { + for (i =3D 0; i < DR7_MAX_BP; i++) { hw_breakpoint_insert(env, i); } } else { diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index c2a99ee..c40bd96 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -465,13 +465,13 @@ static void switch_tss(CPUX86State *env, int tss_se= lector, =20 #ifndef CONFIG_USER_ONLY /* reset local breakpoints */ - if (env->dr[7] & 0x55) { - for (i =3D 0; i < 4; i++) { + if (env->dr[7] & DR7_LOCAL_BP_MASK) { + for (i =3D 0; i < DR7_MAX_BP; i++) { if (hw_breakpoint_enabled(env->dr[7], i) =3D=3D 0x1) { hw_breakpoint_remove(env, i); } } - env->dr[7] &=3D ~0x55; + env->dr[7] &=3D ~DR7_LOCAL_BP_MASK; } #endif } --=20 1.7.10.4