Commit a316d3353cefb6634f8007c8bb18f4744a66766b
1 parent
6e256c93
added CPU_COMMON and CPUState.tb_jmp_cache[]
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1630 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
6 changed files
with
38 additions
and
91 deletions
cpu-defs.h
| @@ -77,6 +77,9 @@ typedef unsigned long ram_addr_t; | @@ -77,6 +77,9 @@ typedef unsigned long ram_addr_t; | ||
| 77 | 77 | ||
| 78 | #define MAX_BREAKPOINTS 32 | 78 | #define MAX_BREAKPOINTS 32 |
| 79 | 79 | ||
| 80 | +#define TB_JMP_CACHE_BITS 12 | ||
| 81 | +#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) | ||
| 82 | + | ||
| 80 | #define CPU_TLB_SIZE 256 | 83 | #define CPU_TLB_SIZE 256 |
| 81 | 84 | ||
| 82 | typedef struct CPUTLBEntry { | 85 | typedef struct CPUTLBEntry { |
| @@ -91,4 +94,30 @@ typedef struct CPUTLBEntry { | @@ -91,4 +94,30 @@ typedef struct CPUTLBEntry { | ||
| 91 | target_phys_addr_t addend; | 94 | target_phys_addr_t addend; |
| 92 | } CPUTLBEntry; | 95 | } CPUTLBEntry; |
| 93 | 96 | ||
| 97 | +#define CPU_COMMON \ | ||
| 98 | + struct TranslationBlock *current_tb; /* currently executing TB */ \ | ||
| 99 | + /* soft mmu support */ \ | ||
| 100 | + /* in order to avoid passing too many arguments to the memory \ | ||
| 101 | + write helpers, we store some rarely used information in the CPU \ | ||
| 102 | + context) */ \ | ||
| 103 | + unsigned long mem_write_pc; /* host pc at which the memory was \ | ||
| 104 | + written */ \ | ||
| 105 | + target_ulong mem_write_vaddr; /* target virtual addr at which the \ | ||
| 106 | + memory was written */ \ | ||
| 107 | + /* 0 = kernel, 1 = user */ \ | ||
| 108 | + CPUTLBEntry tlb_read[2][CPU_TLB_SIZE]; \ | ||
| 109 | + CPUTLBEntry tlb_write[2][CPU_TLB_SIZE]; \ | ||
| 110 | + struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ | ||
| 111 | + \ | ||
| 112 | + /* from this point: preserved by CPU reset */ \ | ||
| 113 | + /* ice debug support */ \ | ||
| 114 | + target_ulong breakpoints[MAX_BREAKPOINTS]; \ | ||
| 115 | + int nb_breakpoints; \ | ||
| 116 | + int singlestep_enabled; \ | ||
| 117 | + \ | ||
| 118 | + /* user data */ \ | ||
| 119 | + void *opaque; | ||
| 120 | + | ||
| 121 | + | ||
| 122 | + | ||
| 94 | #endif | 123 | #endif |
target-arm/cpu.h
| @@ -60,22 +60,9 @@ typedef struct CPUARMState { | @@ -60,22 +60,9 @@ typedef struct CPUARMState { | ||
| 60 | jmp_buf jmp_env; | 60 | jmp_buf jmp_env; |
| 61 | int exception_index; | 61 | int exception_index; |
| 62 | int interrupt_request; | 62 | int interrupt_request; |
| 63 | - struct TranslationBlock *current_tb; | ||
| 64 | int user_mode_only; | 63 | int user_mode_only; |
| 65 | uint32_t address; | 64 | uint32_t address; |
| 66 | 65 | ||
| 67 | - /* ICE debug support. */ | ||
| 68 | - target_ulong breakpoints[MAX_BREAKPOINTS]; | ||
| 69 | - int nb_breakpoints; | ||
| 70 | - int singlestep_enabled; | ||
| 71 | - | ||
| 72 | - /* in order to avoid passing too many arguments to the memory | ||
| 73 | - write helpers, we store some rarely used information in the CPU | ||
| 74 | - context) */ | ||
| 75 | - unsigned long mem_write_pc; /* host pc at which the memory was | ||
| 76 | - written */ | ||
| 77 | - unsigned long mem_write_vaddr; /* target virtual addr at which the | ||
| 78 | - memory was written */ | ||
| 79 | /* VFP coprocessor state. */ | 66 | /* VFP coprocessor state. */ |
| 80 | struct { | 67 | struct { |
| 81 | float64 regs[16]; | 68 | float64 regs[16]; |
| @@ -93,8 +80,8 @@ typedef struct CPUARMState { | @@ -93,8 +80,8 @@ typedef struct CPUARMState { | ||
| 93 | float_status fp_status; | 80 | float_status fp_status; |
| 94 | } vfp; | 81 | } vfp; |
| 95 | 82 | ||
| 96 | - /* user data */ | ||
| 97 | - void *opaque; | 83 | + CPU_COMMON |
| 84 | + | ||
| 98 | } CPUARMState; | 85 | } CPUARMState; |
| 99 | 86 | ||
| 100 | CPUARMState *cpu_arm_init(void); | 87 | CPUARMState *cpu_arm_init(void); |
target-i386/cpu.h
| @@ -497,28 +497,11 @@ typedef struct CPUX86State { | @@ -497,28 +497,11 @@ typedef struct CPUX86State { | ||
| 497 | int error_code; | 497 | int error_code; |
| 498 | int exception_is_int; | 498 | int exception_is_int; |
| 499 | target_ulong exception_next_eip; | 499 | target_ulong exception_next_eip; |
| 500 | - struct TranslationBlock *current_tb; /* currently executing TB */ | ||
| 501 | target_ulong dr[8]; /* debug registers */ | 500 | target_ulong dr[8]; /* debug registers */ |
| 502 | int interrupt_request; | 501 | int interrupt_request; |
| 503 | int user_mode_only; /* user mode only simulation */ | 502 | int user_mode_only; /* user mode only simulation */ |
| 504 | 503 | ||
| 505 | - /* soft mmu support */ | ||
| 506 | - /* in order to avoid passing too many arguments to the memory | ||
| 507 | - write helpers, we store some rarely used information in the CPU | ||
| 508 | - context) */ | ||
| 509 | - unsigned long mem_write_pc; /* host pc at which the memory was | ||
| 510 | - written */ | ||
| 511 | - target_ulong mem_write_vaddr; /* target virtual addr at which the | ||
| 512 | - memory was written */ | ||
| 513 | - /* 0 = kernel, 1 = user */ | ||
| 514 | - CPUTLBEntry tlb_read[2][CPU_TLB_SIZE]; | ||
| 515 | - CPUTLBEntry tlb_write[2][CPU_TLB_SIZE]; | ||
| 516 | - | ||
| 517 | - /* from this point: preserved by CPU reset */ | ||
| 518 | - /* ice debug support */ | ||
| 519 | - target_ulong breakpoints[MAX_BREAKPOINTS]; | ||
| 520 | - int nb_breakpoints; | ||
| 521 | - int singlestep_enabled; | 504 | + CPU_COMMON |
| 522 | 505 | ||
| 523 | /* processor features (e.g. for CPUID insn) */ | 506 | /* processor features (e.g. for CPUID insn) */ |
| 524 | uint32_t cpuid_level; | 507 | uint32_t cpuid_level; |
| @@ -538,8 +521,6 @@ typedef struct CPUX86State { | @@ -538,8 +521,6 @@ typedef struct CPUX86State { | ||
| 538 | /* in order to simplify APIC support, we leave this pointer to the | 521 | /* in order to simplify APIC support, we leave this pointer to the |
| 539 | user */ | 522 | user */ |
| 540 | struct APICState *apic_state; | 523 | struct APICState *apic_state; |
| 541 | - /* user data */ | ||
| 542 | - void *opaque; | ||
| 543 | } CPUX86State; | 524 | } CPUX86State; |
| 544 | 525 | ||
| 545 | CPUX86State *cpu_x86_init(void); | 526 | CPUX86State *cpu_x86_init(void); |
target-mips/cpu.h
| @@ -162,24 +162,8 @@ struct CPUMIPSState { | @@ -162,24 +162,8 @@ struct CPUMIPSState { | ||
| 162 | #define MIPS_HFLAG_BR 0x0800 /* branch to register (can't link TB) */ | 162 | #define MIPS_HFLAG_BR 0x0800 /* branch to register (can't link TB) */ |
| 163 | target_ulong btarget; /* Jump / branch target */ | 163 | target_ulong btarget; /* Jump / branch target */ |
| 164 | int bcond; /* Branch condition (if needed) */ | 164 | int bcond; /* Branch condition (if needed) */ |
| 165 | - struct TranslationBlock *current_tb; /* currently executing TB */ | ||
| 166 | - /* soft mmu support */ | ||
| 167 | - /* in order to avoid passing too many arguments to the memory | ||
| 168 | - write helpers, we store some rarely used information in the CPU | ||
| 169 | - context) */ | ||
| 170 | - target_ulong mem_write_pc; /* host pc at which the memory was | ||
| 171 | - written */ | ||
| 172 | - unsigned long mem_write_vaddr; /* target virtual addr at which the | ||
| 173 | - memory was written */ | ||
| 174 | - /* 0 = kernel, 1 = user (may have 2 = kernel code, 3 = user code ?) */ | ||
| 175 | - CPUTLBEntry tlb_read[2][CPU_TLB_SIZE]; | ||
| 176 | - CPUTLBEntry tlb_write[2][CPU_TLB_SIZE]; | ||
| 177 | - /* ice debug support */ | ||
| 178 | - target_ulong breakpoints[MAX_BREAKPOINTS]; | ||
| 179 | - int nb_breakpoints; | ||
| 180 | - int singlestep_enabled; /* XXX: should use CPU single step mode instead */ | ||
| 181 | - /* user data */ | ||
| 182 | - void *opaque; | 165 | + |
| 166 | + CPU_COMMON | ||
| 183 | }; | 167 | }; |
| 184 | 168 | ||
| 185 | #include "cpu-all.h" | 169 | #include "cpu-all.h" |
target-ppc/cpu.h
| @@ -493,19 +493,10 @@ struct CPUPPCState { | @@ -493,19 +493,10 @@ struct CPUPPCState { | ||
| 493 | /* floating point status and control register */ | 493 | /* floating point status and control register */ |
| 494 | uint8_t fpscr[8]; | 494 | uint8_t fpscr[8]; |
| 495 | 495 | ||
| 496 | - /* soft mmu support */ | ||
| 497 | - /* 0 = kernel, 1 = user (may have 2 = kernel code, 3 = user code ?) */ | ||
| 498 | - CPUTLBEntry tlb_read[2][CPU_TLB_SIZE]; | ||
| 499 | - CPUTLBEntry tlb_write[2][CPU_TLB_SIZE]; | 496 | + CPU_COMMON |
| 497 | + | ||
| 500 | int access_type; /* when a memory exception occurs, the access | 498 | int access_type; /* when a memory exception occurs, the access |
| 501 | type is stored here */ | 499 | type is stored here */ |
| 502 | - /* in order to avoid passing too many arguments to the memory | ||
| 503 | - write helpers, we store some rarely used information in the CPU | ||
| 504 | - context) */ | ||
| 505 | - unsigned long mem_write_pc; /* host pc at which the memory was | ||
| 506 | - written */ | ||
| 507 | - unsigned long mem_write_vaddr; /* target virtual addr at which the | ||
| 508 | - memory was written */ | ||
| 509 | 500 | ||
| 510 | /* MMU context */ | 501 | /* MMU context */ |
| 511 | /* Address space register */ | 502 | /* Address space register */ |
| @@ -564,22 +555,13 @@ struct CPUPPCState { | @@ -564,22 +555,13 @@ struct CPUPPCState { | ||
| 564 | /* Those resources are used only in Qemu core */ | 555 | /* Those resources are used only in Qemu core */ |
| 565 | jmp_buf jmp_env; | 556 | jmp_buf jmp_env; |
| 566 | int user_mode_only; /* user mode only simulation */ | 557 | int user_mode_only; /* user mode only simulation */ |
| 567 | - struct TranslationBlock *current_tb; /* currently executing TB */ | ||
| 568 | uint32_t hflags; | 558 | uint32_t hflags; |
| 569 | 559 | ||
| 570 | - /* ice debug support */ | ||
| 571 | - target_ulong breakpoints[MAX_BREAKPOINTS]; | ||
| 572 | - int nb_breakpoints; | ||
| 573 | - int singlestep_enabled; /* XXX: should use CPU single step mode instead */ | ||
| 574 | - | ||
| 575 | /* Power management */ | 560 | /* Power management */ |
| 576 | int power_mode; | 561 | int power_mode; |
| 577 | 562 | ||
| 578 | /* temporary hack to handle OSI calls (only used if non NULL) */ | 563 | /* temporary hack to handle OSI calls (only used if non NULL) */ |
| 579 | int (*osi_call)(struct CPUPPCState *env); | 564 | int (*osi_call)(struct CPUPPCState *env); |
| 580 | - | ||
| 581 | - /* user data */ | ||
| 582 | - void *opaque; | ||
| 583 | }; | 565 | }; |
| 584 | 566 | ||
| 585 | /*****************************************************************************/ | 567 | /*****************************************************************************/ |
target-sparc/cpu.h
| @@ -166,21 +166,11 @@ typedef struct CPUSPARCState { | @@ -166,21 +166,11 @@ typedef struct CPUSPARCState { | ||
| 166 | int exception_index; | 166 | int exception_index; |
| 167 | int interrupt_index; | 167 | int interrupt_index; |
| 168 | int interrupt_request; | 168 | int interrupt_request; |
| 169 | - struct TranslationBlock *current_tb; | ||
| 170 | - void *opaque; | ||
| 171 | /* NOTE: we allow 8 more registers to handle wrapping */ | 169 | /* NOTE: we allow 8 more registers to handle wrapping */ |
| 172 | target_ulong regbase[NWINDOWS * 16 + 8]; | 170 | target_ulong regbase[NWINDOWS * 16 + 8]; |
| 173 | 171 | ||
| 174 | - /* in order to avoid passing too many arguments to the memory | ||
| 175 | - write helpers, we store some rarely used information in the CPU | ||
| 176 | - context) */ | ||
| 177 | - unsigned long mem_write_pc; /* host pc at which the memory was | ||
| 178 | - written */ | ||
| 179 | - target_ulong mem_write_vaddr; /* target virtual addr at which the | ||
| 180 | - memory was written */ | ||
| 181 | - /* 0 = kernel, 1 = user (may have 2 = kernel code, 3 = user code ?) */ | ||
| 182 | - CPUTLBEntry tlb_read[2][CPU_TLB_SIZE]; | ||
| 183 | - CPUTLBEntry tlb_write[2][CPU_TLB_SIZE]; | 172 | + CPU_COMMON |
| 173 | + | ||
| 184 | /* MMU regs */ | 174 | /* MMU regs */ |
| 185 | #if defined(TARGET_SPARC64) | 175 | #if defined(TARGET_SPARC64) |
| 186 | uint64_t lsu; | 176 | uint64_t lsu; |
| @@ -222,12 +212,6 @@ typedef struct CPUSPARCState { | @@ -222,12 +212,6 @@ typedef struct CPUSPARCState { | ||
| 222 | #if !defined(TARGET_SPARC64) && !defined(reg_T2) | 212 | #if !defined(TARGET_SPARC64) && !defined(reg_T2) |
| 223 | target_ulong t2; | 213 | target_ulong t2; |
| 224 | #endif | 214 | #endif |
| 225 | - | ||
| 226 | - /* ice debug support */ | ||
| 227 | - target_ulong breakpoints[MAX_BREAKPOINTS]; | ||
| 228 | - int nb_breakpoints; | ||
| 229 | - int singlestep_enabled; /* XXX: should use CPU single step mode instead */ | ||
| 230 | - | ||
| 231 | } CPUSPARCState; | 215 | } CPUSPARCState; |
| 232 | #if defined(TARGET_SPARC64) | 216 | #if defined(TARGET_SPARC64) |
| 233 | #define GET_FSR32(env) (env->fsr & 0xcfc1ffff) | 217 | #define GET_FSR32(env) (env->fsr & 0xcfc1ffff) |