Commit 9656f324d25895ec16ebc5eaf624e28a96c1f1be

Authored by pbrook
1 parent a5cdf952

Move interrupt_request and user_mode_only to common cpu state.

Save and restore env->interrupt_request and env->halted.



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4817 c046a42c-6fe2-441c-8c8c-71466251a162
cpu-defs.h
@@ -153,7 +153,8 @@ typedef struct icount_decr_u16 { @@ -153,7 +153,8 @@ typedef struct icount_decr_u16 {
153 accessed */ \ 153 accessed */ \
154 target_ulong mem_io_vaddr; /* target virtual addr at which the \ 154 target_ulong mem_io_vaddr; /* target virtual addr at which the \
155 memory was accessed */ \ 155 memory was accessed */ \
156 - int halted; /* TRUE if the CPU is in suspend state */ \ 156 + uint32_t halted; /* Nonzero if the CPU is in suspend state */ \
  157 + uint32_t interrupt_request; \
157 /* The meaning of the MMU modes is defined in the target code. */ \ 158 /* The meaning of the MMU modes is defined in the target code. */ \
158 CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ 159 CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \
159 target_phys_addr_t iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \ 160 target_phys_addr_t iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \
@@ -188,6 +189,8 @@ typedef struct icount_decr_u16 { @@ -188,6 +189,8 @@ typedef struct icount_decr_u16 {
188 jmp_buf jmp_env; \ 189 jmp_buf jmp_env; \
189 int exception_index; \ 190 int exception_index; \
190 \ 191 \
  192 + int user_mode_only; \
  193 + \
191 void *next_cpu; /* next CPU sharing TB cache */ \ 194 void *next_cpu; /* next CPU sharing TB cache */ \
192 int cpu_index; /* CPU index (informative) */ \ 195 int cpu_index; /* CPU index (informative) */ \
193 int running; /* Nonzero if cpu is currently running(usermode). */ \ 196 int running; /* Nonzero if cpu is currently running(usermode). */ \
@@ -443,6 +443,33 @@ void cpu_exec_init_all(unsigned long tb_size) @@ -443,6 +443,33 @@ void cpu_exec_init_all(unsigned long tb_size)
443 #endif 443 #endif
444 } 444 }
445 445
  446 +#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
  447 +
  448 +#define CPU_COMMON_SAVE_VERSION 1
  449 +
  450 +static void cpu_common_save(QEMUFile *f, void *opaque)
  451 +{
  452 + CPUState *env = opaque;
  453 +
  454 + qemu_put_be32s(f, &env->halted);
  455 + qemu_put_be32s(f, &env->interrupt_request);
  456 +}
  457 +
  458 +static int cpu_common_load(QEMUFile *f, void *opaque, int version_id)
  459 +{
  460 + CPUState *env = opaque;
  461 +
  462 + if (version_id != CPU_COMMON_SAVE_VERSION)
  463 + return -EINVAL;
  464 +
  465 + qemu_get_be32s(f, &env->halted);
  466 + qemu_put_be32s(f, &env->interrupt_request);
  467 + tlb_flush(env, 1);
  468 +
  469 + return 0;
  470 +}
  471 +#endif
  472 +
446 void cpu_exec_init(CPUState *env) 473 void cpu_exec_init(CPUState *env)
447 { 474 {
448 CPUState **penv; 475 CPUState **penv;
@@ -459,6 +486,8 @@ void cpu_exec_init(CPUState *env) @@ -459,6 +486,8 @@ void cpu_exec_init(CPUState *env)
459 env->nb_watchpoints = 0; 486 env->nb_watchpoints = 0;
460 *penv = env; 487 *penv = env;
461 #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) 488 #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
  489 + register_savevm("cpu_common", cpu_index, CPU_COMMON_SAVE_VERSION,
  490 + cpu_common_save, cpu_common_load, env);
462 register_savevm("cpu", cpu_index, CPU_SAVE_VERSION, 491 register_savevm("cpu", cpu_index, CPU_SAVE_VERSION,
463 cpu_save, cpu_load, env); 492 cpu_save, cpu_load, env);
464 #endif 493 #endif
target-alpha/cpu.h
@@ -282,11 +282,9 @@ struct CPUAlphaState { @@ -282,11 +282,9 @@ struct CPUAlphaState {
282 /* Those resources are used only in Qemu core */ 282 /* Those resources are used only in Qemu core */
283 CPU_COMMON 283 CPU_COMMON
284 284
285 - int user_mode_only; /* user mode only simulation */  
286 uint32_t hflags; 285 uint32_t hflags;
287 286
288 int error_code; 287 int error_code;
289 - int interrupt_request;  
290 288
291 uint32_t features; 289 uint32_t features;
292 uint32_t amask; 290 uint32_t amask;
target-arm/cpu.h
@@ -156,10 +156,6 @@ typedef struct CPUARMState { @@ -156,10 +156,6 @@ typedef struct CPUARMState {
156 int (*get_irq_vector)(struct CPUARMState *); 156 int (*get_irq_vector)(struct CPUARMState *);
157 void *irq_opaque; 157 void *irq_opaque;
158 158
159 - /* exception/interrupt handling */  
160 - int interrupt_request;  
161 - int user_mode_only;  
162 -  
163 /* VFP coprocessor state. */ 159 /* VFP coprocessor state. */
164 struct { 160 struct {
165 float64 regs[32]; 161 float64 regs[32];
target-cris/cpu.h
@@ -125,7 +125,6 @@ typedef struct CPUCRISState { @@ -125,7 +125,6 @@ typedef struct CPUCRISState {
125 /* X flag at the time of cc snapshot. */ 125 /* X flag at the time of cc snapshot. */
126 int cc_x; 126 int cc_x;
127 127
128 - int interrupt_request;  
129 int interrupt_vector; 128 int interrupt_vector;
130 int fault_vector; 129 int fault_vector;
131 int trap_vector; 130 int trap_vector;
@@ -156,8 +155,6 @@ typedef struct CPUCRISState { @@ -156,8 +155,6 @@ typedef struct CPUCRISState {
156 uint32_t lo; 155 uint32_t lo;
157 } tlbsets[2][4][16]; 156 } tlbsets[2][4][16];
158 157
159 - int user_mode_only;  
160 -  
161 CPU_COMMON 158 CPU_COMMON
162 } CPUCRISState; 159 } CPUCRISState;
163 160
target-i386/cpu.h
@@ -567,8 +567,6 @@ typedef struct CPUX86State { @@ -567,8 +567,6 @@ typedef struct CPUX86State {
567 target_ulong exception_next_eip; 567 target_ulong exception_next_eip;
568 target_ulong dr[8]; /* debug registers */ 568 target_ulong dr[8]; /* debug registers */
569 uint32_t smbase; 569 uint32_t smbase;
570 - int interrupt_request;  
571 - int user_mode_only; /* user mode only simulation */  
572 int old_exception; /* exception in flight */ 570 int old_exception; /* exception in flight */
573 571
574 CPU_COMMON 572 CPU_COMMON
@@ -726,7 +724,7 @@ static inline int cpu_get_time_fast(void) @@ -726,7 +724,7 @@ static inline int cpu_get_time_fast(void)
726 #define cpu_signal_handler cpu_x86_signal_handler 724 #define cpu_signal_handler cpu_x86_signal_handler
727 #define cpu_list x86_cpu_list 725 #define cpu_list x86_cpu_list
728 726
729 -#define CPU_SAVE_VERSION 5 727 +#define CPU_SAVE_VERSION 6
730 728
731 /* MMU modes definitions */ 729 /* MMU modes definitions */
732 #define MMU_MODE0_SUFFIX _kernel 730 #define MMU_MODE0_SUFFIX _kernel
target-i386/machine.c
@@ -123,7 +123,6 @@ void cpu_save(QEMUFile *f, void *opaque) @@ -123,7 +123,6 @@ void cpu_save(QEMUFile *f, void *opaque)
123 123
124 qemu_put_be64s(f, &env->pat); 124 qemu_put_be64s(f, &env->pat);
125 qemu_put_be32s(f, &env->hflags2); 125 qemu_put_be32s(f, &env->hflags2);
126 - qemu_put_be32s(f, (uint32_t *)&env->halted);  
127 126
128 qemu_put_be64s(f, &env->vm_hsave); 127 qemu_put_be64s(f, &env->vm_hsave);
129 qemu_put_be64s(f, &env->vm_vmcb); 128 qemu_put_be64s(f, &env->vm_vmcb);
@@ -169,7 +168,8 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) @@ -169,7 +168,8 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
169 uint16_t fpus, fpuc, fptag, fpregs_format; 168 uint16_t fpus, fpuc, fptag, fpregs_format;
170 int32_t a20_mask; 169 int32_t a20_mask;
171 170
172 - if (version_id != 3 && version_id != 4 && version_id != 5) 171 + if (version_id != 3 && version_id != 4 && version_id != 5
  172 + && version_id != 6)
173 return -EINVAL; 173 return -EINVAL;
174 for(i = 0; i < CPU_NB_REGS; i++) 174 for(i = 0; i < CPU_NB_REGS; i++)
175 qemu_get_betls(f, &env->regs[i]); 175 qemu_get_betls(f, &env->regs[i]);
@@ -279,7 +279,8 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) @@ -279,7 +279,8 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
279 if (version_id >= 5) { 279 if (version_id >= 5) {
280 qemu_get_be64s(f, &env->pat); 280 qemu_get_be64s(f, &env->pat);
281 qemu_get_be32s(f, &env->hflags2); 281 qemu_get_be32s(f, &env->hflags2);
282 - qemu_get_be32s(f, (uint32_t *)&env->halted); 282 + if (version_id < 6)
  283 + qemu_get_be32s(f, &env->halted);
283 284
284 qemu_get_be64s(f, &env->vm_hsave); 285 qemu_get_be64s(f, &env->vm_hsave);
285 qemu_get_be64s(f, &env->vm_vmcb); 286 qemu_get_be64s(f, &env->vm_vmcb);
target-m68k/cpu.h
@@ -103,10 +103,6 @@ typedef struct CPUM68KState { @@ -103,10 +103,6 @@ typedef struct CPUM68KState {
103 /* ??? remove this. */ 103 /* ??? remove this. */
104 uint32_t t1; 104 uint32_t t1;
105 105
106 - /* exception/interrupt handling */  
107 - int interrupt_request;  
108 - int user_mode_only;  
109 -  
110 int pending_vector; 106 int pending_vector;
111 int pending_level; 107 int pending_level;
112 108
target-mips/cpu.h
@@ -411,9 +411,7 @@ struct CPUMIPSState { @@ -411,9 +411,7 @@ struct CPUMIPSState {
411 /* We waste some space so we can handle shadow registers like TCs. */ 411 /* We waste some space so we can handle shadow registers like TCs. */
412 TCState tcs[MIPS_SHADOW_SET_MAX]; 412 TCState tcs[MIPS_SHADOW_SET_MAX];
413 /* Qemu */ 413 /* Qemu */
414 - int interrupt_request;  
415 int error_code; 414 int error_code;
416 - int user_mode_only; /* user mode only simulation */  
417 uint32_t hflags; /* CPU State */ 415 uint32_t hflags; /* CPU State */
418 /* TMASK defines different execution modes */ 416 /* TMASK defines different execution modes */
419 #define MIPS_HFLAG_TMASK 0x01FF 417 #define MIPS_HFLAG_TMASK 0x01FF
target-ppc/cpu.h
@@ -647,7 +647,6 @@ struct CPUPPCState { @@ -647,7 +647,6 @@ struct CPUPPCState {
647 uint32_t flags; 647 uint32_t flags;
648 648
649 int error_code; 649 int error_code;
650 - int interrupt_request;  
651 uint32_t pending_interrupts; 650 uint32_t pending_interrupts;
652 #if !defined(CONFIG_USER_ONLY) 651 #if !defined(CONFIG_USER_ONLY)
653 /* This is the IRQ controller, which is implementation dependant 652 /* This is the IRQ controller, which is implementation dependant
@@ -671,7 +670,6 @@ struct CPUPPCState { @@ -671,7 +670,6 @@ struct CPUPPCState {
671 opc_handler_t *opcodes[0x40]; 670 opc_handler_t *opcodes[0x40];
672 671
673 /* Those resources are used only in Qemu core */ 672 /* Those resources are used only in Qemu core */
674 - int user_mode_only; /* user mode only simulation */  
675 target_ulong hflags; /* hflags is a MSR & HFLAGS_MASK */ 673 target_ulong hflags; /* hflags is a MSR & HFLAGS_MASK */
676 target_ulong hflags_nmsr; /* specific hflags, not comming from MSR */ 674 target_ulong hflags_nmsr; /* specific hflags, not comming from MSR */
677 int mmu_idx; /* precomputed MMU index to speed up mem accesses */ 675 int mmu_idx; /* precomputed MMU index to speed up mem accesses */
target-sh4/cpu.h
@@ -114,8 +114,6 @@ typedef struct CPUSH4State { @@ -114,8 +114,6 @@ typedef struct CPUSH4State {
114 uint32_t expevt; /* exception event register */ 114 uint32_t expevt; /* exception event register */
115 uint32_t intevt; /* interrupt event register */ 115 uint32_t intevt; /* interrupt event register */
116 116
117 - int user_mode_only;  
118 - int interrupt_request;  
119 CPU_COMMON tlb_t utlb[UTLB_SIZE]; /* unified translation table */ 117 CPU_COMMON tlb_t utlb[UTLB_SIZE]; /* unified translation table */
120 tlb_t itlb[ITLB_SIZE]; /* instruction translation table */ 118 tlb_t itlb[ITLB_SIZE]; /* instruction translation table */
121 void *intc_handle; 119 void *intc_handle;
target-sparc/cpu.h
@@ -215,9 +215,7 @@ typedef struct CPUSPARCState { @@ -215,9 +215,7 @@ typedef struct CPUSPARCState {
215 uint32_t pil_in; /* incoming interrupt level bitmap */ 215 uint32_t pil_in; /* incoming interrupt level bitmap */
216 int psref; /* enable fpu */ 216 int psref; /* enable fpu */
217 target_ulong version; 217 target_ulong version;
218 - int user_mode_only;  
219 int interrupt_index; 218 int interrupt_index;
220 - int interrupt_request;  
221 uint32_t mmu_bm; 219 uint32_t mmu_bm;
222 uint32_t mmu_ctpr_mask; 220 uint32_t mmu_ctpr_mask;
223 uint32_t mmu_cxr_mask; 221 uint32_t mmu_cxr_mask;