Commit ffddfee3793240d91e9d23fd436fb9e8d66d1069
1 parent
a2f659ee
added cpu_reset()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@940 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
38 additions
and
29 deletions
target-i386/cpu.h
| ... | ... | @@ -352,6 +352,7 @@ typedef struct CPUX86State { |
| 352 | 352 | CPUTLBEntry tlb_read[2][CPU_TLB_SIZE]; |
| 353 | 353 | CPUTLBEntry tlb_write[2][CPU_TLB_SIZE]; |
| 354 | 354 | |
| 355 | + /* from this point: preserved by CPU reset */ | |
| 355 | 356 | /* ice debug support */ |
| 356 | 357 | uint32_t breakpoints[MAX_BREAKPOINTS]; |
| 357 | 358 | int nb_breakpoints; | ... | ... |
target-i386/helper2.c
| ... | ... | @@ -45,7 +45,6 @@ _syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount) |
| 45 | 45 | CPUX86State *cpu_x86_init(void) |
| 46 | 46 | { |
| 47 | 47 | CPUX86State *env; |
| 48 | - int i; | |
| 49 | 48 | static int inited; |
| 50 | 49 | |
| 51 | 50 | cpu_exec_init(); |
| ... | ... | @@ -54,10 +53,46 @@ CPUX86State *cpu_x86_init(void) |
| 54 | 53 | if (!env) |
| 55 | 54 | return NULL; |
| 56 | 55 | memset(env, 0, sizeof(CPUX86State)); |
| 56 | + /* init various static tables */ | |
| 57 | + if (!inited) { | |
| 58 | + inited = 1; | |
| 59 | + optimize_flags_init(); | |
| 60 | + } | |
| 61 | +#ifdef USE_CODE_COPY | |
| 62 | + /* testing code for code copy case */ | |
| 63 | + { | |
| 64 | + struct modify_ldt_ldt_s ldt; | |
| 57 | 65 | |
| 58 | - /* init to reset state */ | |
| 66 | + ldt.entry_number = 1; | |
| 67 | + ldt.base_addr = (unsigned long)env; | |
| 68 | + ldt.limit = (sizeof(CPUState) + 0xfff) >> 12; | |
| 69 | + ldt.seg_32bit = 1; | |
| 70 | + ldt.contents = MODIFY_LDT_CONTENTS_DATA; | |
| 71 | + ldt.read_exec_only = 0; | |
| 72 | + ldt.limit_in_pages = 1; | |
| 73 | + ldt.seg_not_present = 0; | |
| 74 | + ldt.useable = 1; | |
| 75 | + modify_ldt(1, &ldt, sizeof(ldt)); /* write ldt entry */ | |
| 76 | + | |
| 77 | + asm volatile ("movl %0, %%fs" : : "r" ((1 << 3) | 7)); | |
| 78 | + cpu_single_env = env; | |
| 79 | + } | |
| 80 | +#endif | |
| 81 | + cpu_reset(env); | |
| 82 | + return env; | |
| 83 | +} | |
| 84 | + | |
| 85 | +/* NOTE: must be called outside the CPU execute loop */ | |
| 86 | +void cpu_reset(CPUX86State *env) | |
| 87 | +{ | |
| 88 | + int i; | |
| 89 | + | |
| 90 | + memset(env, 0, offsetof(CPUX86State, breakpoints)); | |
| 59 | 91 | |
| 60 | 92 | tlb_flush(env, 1); |
| 93 | + | |
| 94 | + /* init to reset state */ | |
| 95 | + | |
| 61 | 96 | #ifdef CONFIG_SOFTMMU |
| 62 | 97 | env->hflags |= HF_SOFTMMU_MASK; |
| 63 | 98 | #endif |
| ... | ... | @@ -89,33 +124,6 @@ CPUX86State *cpu_x86_init(void) |
| 89 | 124 | for(i = 0;i < 8; i++) |
| 90 | 125 | env->fptags[i] = 1; |
| 91 | 126 | env->fpuc = 0x37f; |
| 92 | - | |
| 93 | - /* init various static tables */ | |
| 94 | - if (!inited) { | |
| 95 | - inited = 1; | |
| 96 | - optimize_flags_init(); | |
| 97 | - } | |
| 98 | -#ifdef USE_CODE_COPY | |
| 99 | - /* testing code for code copy case */ | |
| 100 | - { | |
| 101 | - struct modify_ldt_ldt_s ldt; | |
| 102 | - | |
| 103 | - ldt.entry_number = 1; | |
| 104 | - ldt.base_addr = (unsigned long)env; | |
| 105 | - ldt.limit = (sizeof(CPUState) + 0xfff) >> 12; | |
| 106 | - ldt.seg_32bit = 1; | |
| 107 | - ldt.contents = MODIFY_LDT_CONTENTS_DATA; | |
| 108 | - ldt.read_exec_only = 0; | |
| 109 | - ldt.limit_in_pages = 1; | |
| 110 | - ldt.seg_not_present = 0; | |
| 111 | - ldt.useable = 1; | |
| 112 | - modify_ldt(1, &ldt, sizeof(ldt)); /* write ldt entry */ | |
| 113 | - | |
| 114 | - asm volatile ("movl %0, %%fs" : : "r" ((1 << 3) | 7)); | |
| 115 | - cpu_single_env = env; | |
| 116 | - } | |
| 117 | -#endif | |
| 118 | - return env; | |
| 119 | 127 | } |
| 120 | 128 | |
| 121 | 129 | void cpu_x86_close(CPUX86State *env) | ... | ... |