From: Thiemo Seufer <ths@networkno.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Coding style and mask value fix
Date: Tue, 21 Feb 2006 19:27:06 +0000 [thread overview]
Message-ID: <20060221192706.GC4110@networkno.de> (raw)
Hello All,
this drops some leading zeroes in masks, fixes the masks for Context
and EntryHi, gets rid of some magic constants, simplifies some
conditionals, and remove a bogus do_raise_exception which broke delay
slot handling.
Thiemo
Index: qemu-work/target-mips/helper.c
===================================================================
--- qemu-work.orig/target-mips/helper.c 2006-02-18 00:52:55.000000000 +0000
+++ qemu-work/target-mips/helper.c 2006-02-19 16:23:21.000000000 +0000
@@ -40,8 +40,8 @@
int ret;
ret = -2;
- tag = (address & 0xFFFFE000);
- ASID = env->CP0_EntryHi & 0x000000FF;
+ tag = address & 0xFFFFE000;
+ ASID = env->CP0_EntryHi & 0xFF;
for (i = 0; i < MIPS_TLB_NB; i++) {
tlb = &env->tlb[i];
/* Check ASID, virtual page number & size */
@@ -74,7 +74,7 @@
int ret;
/* User mode can only access useg */
- user_mode = ((env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM) ? 1 : 0;
+ user_mode = (env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM;
#if 0
if (logfile) {
fprintf(logfile, "user mode %d h %08x\n",
@@ -231,7 +231,7 @@
env->CP0_Context = (env->CP0_Context & 0xff800000) |
((address >> 9) & 0x007ffff0);
env->CP0_EntryHi =
- (env->CP0_EntryHi & 0x000000FF) | (address & 0xFFFFF000);
+ (env->CP0_EntryHi & 0xFF) | (address & 0xFFFFE000);
env->exception_index = exception;
env->error_code = error_code;
ret = 1;
Index: qemu-work/target-mips/op_helper.c
===================================================================
--- qemu-work.orig/target-mips/op_helper.c 2006-02-18 00:40:31.000000000 +0000
+++ qemu-work/target-mips/op_helper.c 2006-02-19 16:23:20.000000000 +0000
@@ -331,19 +331,19 @@
rn = "Index";
break;
case 2:
- val = T0 & 0x03FFFFFFF;
+ val = T0 & 0x3FFFFFFF;
old = env->CP0_EntryLo0;
env->CP0_EntryLo0 = val;
rn = "EntryLo0";
break;
case 3:
- val = T0 & 0x03FFFFFFF;
+ val = T0 & 0x3FFFFFFF;
old = env->CP0_EntryLo1;
env->CP0_EntryLo1 = val;
rn = "EntryLo1";
break;
case 4:
- val = (env->CP0_Context & 0xFF000000) | (T0 & 0x00FFFFF0);
+ val = (env->CP0_Context & 0xFF800000) | (T0 & 0x007FFFF0);
old = env->CP0_Context;
env->CP0_Context = val;
rn = "Context";
@@ -367,7 +367,7 @@
rn = "Count";
break;
case 10:
- val = T0 & 0xFFFFF0FF;
+ val = T0 & 0xFFFFE0FF;
old = env->CP0_EntryHi;
env->CP0_EntryHi = val;
/* If the ASID changes, flush qemu's TLB. */
@@ -404,20 +404,17 @@
old, val, env->CP0_Cause, old & mask, val & mask,
env->CP0_Cause & mask);
}
-#if 1
if ((val & (1 << CP0St_IE)) && !(old & (1 << CP0St_IE)) &&
!(env->hflags & MIPS_HFLAG_EXL) &&
!(env->hflags & MIPS_HFLAG_ERL) &&
- !(env->hflags & MIPS_HFLAG_DM) &&
+ !(env->hflags & MIPS_HFLAG_DM) &&
(env->CP0_Status & env->CP0_Cause & mask)) {
if (logfile)
fprintf(logfile, "Raise pending IRQs\n");
env->interrupt_request |= CPU_INTERRUPT_HARD;
- do_raise_exception(EXCP_EXT_INTERRUPT);
- } else if (!(val & 0x00000001) && (old & 0x00000001)) {
+ } else if (!(val & (1 << CP0St_IE)) && (old & (1 << CP0St_IE))) {
env->interrupt_request &= ~CPU_INTERRUPT_HARD;
}
-#endif
rn = "Status";
break;
case 13:
@@ -606,9 +603,9 @@
uint8_t ASID;
int i;
- tag = (env->CP0_EntryHi & 0xFFFFE000);
- ASID = env->CP0_EntryHi & 0x000000FF;
- for (i = 0; i < MIPS_TLB_NB; i++) {
+ tag = env->CP0_EntryHi & 0xFFFFE000;
+ ASID = env->CP0_EntryHi & 0xFF;
+ for (i = 0; i < MIPS_TLB_NB; i++) {
tlb = &env->tlb[i];
/* Check ASID, virtual page number & size */
if ((tlb->G == 1 || tlb->ASID == ASID) && tlb->VPN == tag) {
Index: qemu-work/target-mips/translate.c
===================================================================
--- qemu-work.orig/target-mips/translate.c 2006-02-19 01:30:55.000000000 +0000
+++ qemu-work/target-mips/translate.c 2006-02-19 16:18:43.000000000 +0000
@@ -1614,7 +1614,7 @@
#if defined(CONFIG_USER_ONLY)
ctx.mem_idx = 0;
#else
- ctx.mem_idx = (ctx.hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM ? 0 : 1;
+ ctx.mem_idx = !((ctx.hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM);
#endif
ctx.CP0_Status = env->CP0_Status;
#ifdef DEBUG_DISAS
reply other threads:[~2006-02-21 19:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060221192706.GC4110@networkno.de \
--to=ths@networkno.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.