--- np2/i386c/ia32/instructions/system_inst.c 2004/03/23 13:32:50 1.26 +++ np2/i386c/ia32/instructions/system_inst.c 2008/01/25 18:02:18 1.32 @@ -1,4 +1,4 @@ -/* $Id: system_inst.c,v 1.26 2004/03/23 13:32:50 yui Exp $ */ +/* $Id: system_inst.c,v 1.32 2008/01/25 18:02:18 monaka Exp $ */ /* * Copyright (c) 2003 NONAKA Kimihiro @@ -12,8 +12,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -142,7 +140,8 @@ SLDT_Ew(UINT32 op) void LTR_Ew(UINT32 op) { - UINT32 src, madr; + UINT32 madr; + UINT16 src; if (CPU_STAT_PM && !CPU_STAT_VM86) { if (CPU_STAT_CPL == 0) { @@ -154,7 +153,7 @@ LTR_Ew(UINT32 op) madr = calc_ea_dst(op); src = cpu_vmemoryread_w(CPU_INST_SEGREG_INDEX, madr); } - load_tr((UINT16)src); + load_tr(src); return; } VERBOSE(("LTR: CPL(%d) != 0", CPU_STAT_CPL)); @@ -286,18 +285,18 @@ MOV_CdRd(void) } reg = CPU_CR0; - src &= 0xe005003f; -#ifndef USE_FPU + src &= CPU_CR0_ALL; +#if defined(USE_FPU) + src |= CPU_CR0_ET; /* FPU present */ +#else src |= CPU_CR0_EM | CPU_CR0_NE; src &= ~(CPU_CR0_MP | CPU_CR0_ET); -#else - src |= CPU_CR0_ET; /* FPU present */ #endif CPU_CR0 = src; VERBOSE(("MOV_CdRd: %04x:%08x: cr0: 0x%08x <- 0x%08x(%s)", CPU_CS, CPU_PREV_EIP, reg, CPU_CR0, reg32_str[op & 7])); if ((reg ^ CPU_CR0) & (CPU_CR0_PE|CPU_CR0_PG)) { - tlb_flush(FALSE); + tlb_flush(TRUE); } if ((reg ^ CPU_CR0) & CPU_CR0_PE) { if (CPU_CR0 & CPU_CR0_PE) { @@ -337,7 +336,6 @@ MOV_CdRd(void) VERBOSE(("MOV_CdRd: %04x:%08x: cr3: 0x%08x <- 0x%08x(%s)", CPU_CS, CPU_PREV_EIP, reg, CPU_CR3, reg32_str[op & 7])); break; -#if CPU_FAMILY >= 5 case 4: /* CR4 */ /* * 10 = OSXMMEXCPT (support non masking exception by OS) @@ -352,7 +350,11 @@ MOV_CdRd(void) * 1 = PVI (protected mode virtual interrupt) * 0 = VME (VM8086 mode extention) */ - reg = 0; /* allow */ + reg = 0 /* allow bit */ +#if (CPU_FEATURES & CPU_FEATURE_PGE) == CPU_FEATURE_PGE + | CPU_CR4_PGE +#endif + ; if (src & ~reg) { if (src & 0xfffffc00) { EXCEPTION(GP_EXCEPTION, 0); @@ -365,10 +367,9 @@ MOV_CdRd(void) VERBOSE(("MOV_CdRd: %04x:%08x: cr4: 0x%08x <- 0x%08x(%s)", CPU_CS, CPU_PREV_EIP, reg, CPU_CR4, reg32_str[op & 7])); if ((reg ^ CPU_CR4) & (CPU_CR4_PSE|CPU_CR4_PGE|CPU_CR4_PAE)) { - tlb_flush(FALSE); + tlb_flush(TRUE); } break; -#endif /* CPU_FAMILY >= 5 */ default: ia32_panic("MOV_CdRd: CR reg index (%d)", idx); @@ -411,11 +412,9 @@ MOV_RdCd(void) *out = CPU_CR3; break; -#if CPU_FAMILY >= 5 case 4: *out = CPU_CR4; break; -#endif /* CPU_FAMILY >= 5 */ default: ia32_panic("MOV_RdCd: CR reg index (%d)", idx); @@ -990,8 +989,6 @@ INVD(void) VERBOSE(("INVD: VM86(%s) or CPL(%d) != 0", CPU_STAT_VM86 ? "true" : "false", CPU_STAT_CPL)); EXCEPTION(GP_EXCEPTION, 0); } - - tlb_flush(TRUE); } void @@ -1003,8 +1000,6 @@ WBINVD(void) VERBOSE(("WBINVD: VM86(%s) or CPL(%d) != 0", CPU_STAT_VM86 ? "true" : "false", CPU_STAT_CPL)); EXCEPTION(GP_EXCEPTION, 0); } - - tlb_flush(TRUE); } void @@ -1077,9 +1072,6 @@ HLT(void) CPU_HALT(); CPU_EIP--; -#if defined(IA32_SUPPORT_PREFETCH_QUEUE) - CPU_PREFETCHQ_REMAIN++; -#endif CPU_STAT_HLT = 1; } @@ -1120,7 +1112,7 @@ WRMSR(void) idx = CPU_ECX; switch (idx) { - /* MTRR への書き込み時 tlb_flush(FALSE); */ + /* MTRR への書き込み時 tlb_flush(TRUE); */ default: EXCEPTION(GP_EXCEPTION, 0);