diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-06-20 13:01:25 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-06-20 13:01:25 +0000 |
commit | ffddfee3793240d91e9d23fd436fb9e8d66d1069 (patch) | |
tree | b31035673af792d358d9b264f10d413a382dc3c6 /target-i386 | |
parent | a2f659ee48edc5de6f7ca1064a4f2af6227323a6 (diff) |
added cpu_reset()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@940 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-i386')
-rw-r--r-- | target-i386/cpu.h | 1 | ||||
-rw-r--r-- | target-i386/helper2.c | 66 |
2 files changed, 38 insertions, 29 deletions
diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 94f621cd10..2a1e736058 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -352,6 +352,7 @@ typedef struct CPUX86State { CPUTLBEntry tlb_read[2][CPU_TLB_SIZE]; CPUTLBEntry tlb_write[2][CPU_TLB_SIZE]; + /* from this point: preserved by CPU reset */ /* ice debug support */ uint32_t breakpoints[MAX_BREAKPOINTS]; int nb_breakpoints; diff --git a/target-i386/helper2.c b/target-i386/helper2.c index 1d5bdc17e4..03e3db30ad 100644 --- a/target-i386/helper2.c +++ b/target-i386/helper2.c @@ -45,7 +45,6 @@ _syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount) CPUX86State *cpu_x86_init(void) { CPUX86State *env; - int i; static int inited; cpu_exec_init(); @@ -54,10 +53,46 @@ CPUX86State *cpu_x86_init(void) if (!env) return NULL; memset(env, 0, sizeof(CPUX86State)); + /* init various static tables */ + if (!inited) { + inited = 1; + optimize_flags_init(); + } +#ifdef USE_CODE_COPY + /* testing code for code copy case */ + { + struct modify_ldt_ldt_s ldt; - /* init to reset state */ + ldt.entry_number = 1; + ldt.base_addr = (unsigned long)env; + ldt.limit = (sizeof(CPUState) + 0xfff) >> 12; + ldt.seg_32bit = 1; + ldt.contents = MODIFY_LDT_CONTENTS_DATA; + ldt.read_exec_only = 0; + ldt.limit_in_pages = 1; + ldt.seg_not_present = 0; + ldt.useable = 1; + modify_ldt(1, &ldt, sizeof(ldt)); /* write ldt entry */ + + asm volatile ("movl %0, %%fs" : : "r" ((1 << 3) | 7)); + cpu_single_env = env; + } +#endif + cpu_reset(env); + return env; +} + +/* NOTE: must be called outside the CPU execute loop */ +void cpu_reset(CPUX86State *env) +{ + int i; + + memset(env, 0, offsetof(CPUX86State, breakpoints)); tlb_flush(env, 1); + + /* init to reset state */ + #ifdef CONFIG_SOFTMMU env->hflags |= HF_SOFTMMU_MASK; #endif @@ -89,33 +124,6 @@ CPUX86State *cpu_x86_init(void) for(i = 0;i < 8; i++) env->fptags[i] = 1; env->fpuc = 0x37f; - - /* init various static tables */ - if (!inited) { - inited = 1; - optimize_flags_init(); - } -#ifdef USE_CODE_COPY - /* testing code for code copy case */ - { - struct modify_ldt_ldt_s ldt; - - ldt.entry_number = 1; - ldt.base_addr = (unsigned long)env; - ldt.limit = (sizeof(CPUState) + 0xfff) >> 12; - ldt.seg_32bit = 1; - ldt.contents = MODIFY_LDT_CONTENTS_DATA; - ldt.read_exec_only = 0; - ldt.limit_in_pages = 1; - ldt.seg_not_present = 0; - ldt.useable = 1; - modify_ldt(1, &ldt, sizeof(ldt)); /* write ldt entry */ - - asm volatile ("movl %0, %%fs" : : "r" ((1 << 3) | 7)); - cpu_single_env = env; - } -#endif - return env; } void cpu_x86_close(CPUX86State *env) |