: add alpha es40 system emulation (v3)
cover : add alpha es40 system emulation (v3)
Hi,
these patches add alpha system emulation. Currently it emulates an es40 system just enough to get the firmware prompt.
This is the second version of the patches. They addresses the comments made and I made a very improvments too.
Only the last patch adds full cpu emulation. Most of the previous ones fix bugs or add new devices and can be applied independently.
Tristan.
PATCH 1/25 Add support for multi-level phys map.
As Alpha physical addresses are 44 bits, l1_phys_map can't be anymore 2 levels. Use a more generic multi-level approach and explain why we don't need to extend l1_map.
--- exec.c | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 38 insertions(+), 12 deletions(-)
exec.c +38 -12
@@ -147,14 +147,17 @@ typedef struct PhysPageDesc { } PhysPageDesc;#define L2_BITS 10 -#if defined(CONFIG_USER_ONLY ) && defined(TARGET_VIRT_ADDR_SPACE_BITS ) -/* XXX: this is a temporary hack for alpha target. -* In the future, this is to be replaced by a multi-level table -* to actually be able to handle the complete 64 bits address space. -*/ -#define L1_BITS (TARGET_VIRT_ADDR_SPACE_BITS - L2_BITS - TARGET_PAGE_BITS) + +#if TARGET_PHYS_ADDR_SPACE_BITS > (32 +32 -L2_BITS -TARGET_PAGE_BITS ) +# define MULTILEVEL_PHYS_MAP +# define L1_BITS_ ((TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS) % L2_BITS) +# if L1_BITS_ <4 /* avoid ridiculous small l1 */ +# define L1_BITS (L1_BITS_ + L2_BITS) +# else +# define L1_BITS L1_BITS_ +# endif #else -#define L1_BITS (32 - L2_BITS - TARGET_PAGE_BITS) +# define L1_BITS (32 - L2_BITS - TARGET_PAGE_BITS)#endif #define L1_SIZE (1 << L1_BITS)
@@ -165,7 +168,9 @@ unsigned long qemu_host_page_bits;unsigned long qemu_host_page_size;unsigned long qemu_host_page_mask; -/* XXX: for system emulation, it could just be an array */ +/* XXX: for system emulation, it could just be an array. As this is currently +a two level map this limits the size of RAM memory that can contains +target code. In practice this is large enough (>= 4GB) */ static PageDesc *l1_map[L1_SIZE ];static PhysPageDesc **l1_phys_map;
@@ -339,12 +344,31 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)void **lp, **p;PhysPageDesc *pd; +#ifdef MULTILEVEL_PHYS_MAP + int i; +#define L1_SHIFT (TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS - L1_BITS) + + /* Level 1. */ p = (void **)l1_phys_map; -#if TARGET_PHYS_ADDR_SPACE_BITS >32 + lp = p + ((index >> L1_SHIFT) & (L1_SIZE - 1)); -#if TARGET_PHYS_ADDR_SPACE_BITS > (32 +L1_BITS ) -#error unsupported TARGET_PHYS_ADDR_SPACE_BITS -#endif + /* Level 2..n-1 */ + for (i = (L1_SHIFT / L2_BITS) - 1; i > 0; i--) { + p = *lp; + if (!p) { + /* allocate if not found */ + if (!alloc) + return NULL; + p = qemu_vmalloc(sizeof(void *) * L2_SIZE); + memset(p, 0, sizeof(void *) * L2_SIZE); + *lp = p; + } + lp = p + ((index >> (i * L2_BITS)) & (L2_SIZE - 1)); + } +#else + p = (void **)l1_phys_map; + +#if TARGET_PHYS_ADDR_SPACE_BITS > 32 lp = p + ((index >> (L1_BITS + L2_BITS)) & (L1_SIZE - 1)); p = *lp; if (!p) {
@@ -357,6 +381,8 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) }#endif lp = p + ((index >>L2_BITS ) & (L1_SIZE -1 )); +#endif + pd = *lp;if (!pd) {int i;
Signature · 1 line
1.6.2
PATCH 2/25 Fix bug: palcode is at least 6 bits.
--- target-alpha/translate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/translate.c +1 -1
@@ -692,7 +692,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)if (ctx->mem_idx &1 ) goto invalid_opc;else -gen_excp (ctx,EXCP_CALL_PALP + ((palcode &0x1F ) <<6 ),0 ); +gen_excp (ctx,EXCP_CALL_PALP + ((palcode &0x3F ) <<6 ),0 );#endif }else {/* Invalid PAL call */
Signature · 1 line
1.6.2
PATCH 3/25 Fix bug: do not mask address LSBs for ldwu.
--- target-alpha/translate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/translate.c +1 -1
@@ -753,7 +753,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)/* LDWU */ if (!(ctx->amask &AMASK_BWX )) goto invalid_opc; -gen_load_mem (ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16,0 ,1 ); +gen_load_mem (ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16,0 ,0 );break ;case 0x0D :/* STW */
Signature · 1 line
1.6.2
PATCH 4/25 Fix bug: integer conditionnal branch offset is 21 bits wide.
--- target-alpha/translate.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
target-alpha/translate.c +10 -10
@@ -290,7 +290,7 @@ static always_inline void gen_store_mem (DisasContext *ctx, static always_inline void gen_bcond (DisasContext *ctx,TCGCond cond, -int ra,int32_t disp16,int mask) +int ra,int32_t disp,int mask) {int l1, l2;
@@ -313,7 +313,7 @@ static always_inline void gen_bcond (DisasContext *ctx,tcg_gen_movi_i64 (cpu_pc, ctx->pc);tcg_gen_br (l2);gen_set_label (l1); -tcg_gen_movi_i64 (cpu_pc, ctx->pc + (int64_t )(disp16 <<2 )); +tcg_gen_movi_i64 (cpu_pc, ctx->pc + (int64_t )(disp <<2 ));gen_set_label (l2); }
@@ -2285,42 +2285,42 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)break ;case 0x38 :/* BLBC */ -gen_bcond (ctx,TCG_COND_EQ , ra, disp16,1 ); +gen_bcond (ctx,TCG_COND_EQ , ra, disp21,1 ); ret =1 ;break ;case 0x39 :/* BEQ */ -gen_bcond (ctx,TCG_COND_EQ , ra, disp16,0 ); +gen_bcond (ctx,TCG_COND_EQ , ra, disp21,0 ); ret =1 ;break ;case 0x3A :/* BLT */ -gen_bcond (ctx,TCG_COND_LT , ra, disp16,0 ); +gen_bcond (ctx,TCG_COND_LT , ra, disp21,0 ); ret =1 ;break ;case 0x3B :/* BLE */ -gen_bcond (ctx,TCG_COND_LE , ra, disp16,0 ); +gen_bcond (ctx,TCG_COND_LE , ra, disp21,0 ); ret =1 ;break ;case 0x3C :/* BLBS */ -gen_bcond (ctx,TCG_COND_NE , ra, disp16,1 ); +gen_bcond (ctx,TCG_COND_NE , ra, disp21,1 ); ret =1 ;break ;case 0x3D :/* BNE */ -gen_bcond (ctx,TCG_COND_NE , ra, disp16,0 ); +gen_bcond (ctx,TCG_COND_NE , ra, disp21,0 ); ret =1 ;break ;case 0x3E :/* BGE */ -gen_bcond (ctx,TCG_COND_GE , ra, disp16,0 ); +gen_bcond (ctx,TCG_COND_GE , ra, disp21,0 ); ret =1 ;break ;case 0x3F :/* BGT */ -gen_bcond (ctx,TCG_COND_GT , ra, disp16,0 ); +gen_bcond (ctx,TCG_COND_GT , ra, disp21,0 ); ret =1 ;break ; invalid_opc:
Signature · 1 line
1.6.2
PATCH 5/25 bug fix: avoid nop to override next instruction
While searching PC, always store the pc of a new instruction. Instructions that didn't generate tcg code (such as nop) prevented the next one to be referenced.
--- target-alpha/translate.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
target-alpha/translate.c +3 -3
@@ -2380,10 +2380,10 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, lj++;while (lj < j) gen_opc_instr_start[lj++] =0 ; - gen_opc_pc[lj] = ctx.pc; - gen_opc_instr_start[lj] =1 ; - gen_opc_icount[lj] = num_insns; } + gen_opc_pc[lj] = ctx.pc; + gen_opc_instr_start[lj] =1 ; + gen_opc_icount[lj] = num_insns; }if (num_insns +1 == max_insns && (tb->cflags &CF_LAST_IO ))gen_io_start ();
Signature · 1 line
1.6.2
PATCH 6/25 Fix temp free for hw_st
No need to stop translation after hw_st.
--- target-alpha/translate.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
target-alpha/translate.c +1 -2
@@ -2186,11 +2186,10 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)/* Invalid */ goto invalid_opc; } -if (ra !=31 ) +if (ra ==31 )tcg_temp_free (val);tcg_temp_free (addr); } - ret =2 ;break ;#endif case 0x20 :
Signature · 1 line
1.6.2
PATCH 7/25 Increase Alpha physical address size to 44 bits.
Remove unused target virt addr.
--- exec.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
exec.c +1 -2
@@ -68,8 +68,7 @@#elif defined(TARGET_SPARC )#define TARGET_PHYS_ADDR_SPACE_BITS 36#elif defined(TARGET_ALPHA ) -#define TARGET_PHYS_ADDR_SPACE_BITS 42 -#define TARGET_VIRT_ADDR_SPACE_BITS 42 +#define TARGET_PHYS_ADDR_SPACE_BITS 44#elif defined(TARGET_PPC64 )#define TARGET_PHYS_ADDR_SPACE_BITS 42#elif defined(TARGET_X86_64 ) && !defined(USE_KQEMU )
Signature · 1 line
1.6.2
PATCH 8/25 Alpha: set target page size to 13 bits.
(As defined by the alpha arch ref).
--- target-alpha/cpu.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/cpu.h +1 -1
@@ -40,7 +40,7 @@#define ICACHE_LINE_SIZE 32#define DCACHE_LINE_SIZE 32 -#define TARGET_PAGE_BITS 12 +#define TARGET_PAGE_BITS 13#define VA_BITS 43
Signature · 1 line
1.6.2
PATCH 9/25 Allow 5 mmu indexes.
This is necessary for alpha because it has 4 protection levels and pal mode.
--- exec.c | 30 +++++++++++++++++++++++++----- softmmu_exec.h | 29 ++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 10 deletions(-)
exec.c +25 -5
@@ -1760,12 +1760,18 @@ void tlb_flush(CPUState *env, int flush_global) env->tlb_table[2 ][i].addr_read =-1 ; env->tlb_table[2 ][i].addr_write =-1 ; env->tlb_table[2 ][i].addr_code =-1 ; -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 ) env->tlb_table[3 ][i].addr_read =-1 ; env->tlb_table[3 ][i].addr_write =-1 ; env->tlb_table[3 ][i].addr_code =-1 ;#endif +#if (NB_MMU_MODES >=5 ) + env->tlb_table[4 ][i].addr_read =-1 ; + env->tlb_table[4 ][i].addr_write =-1 ; + env->tlb_table[4 ][i].addr_code =-1 ;#endif + }memset (env->tb_jmp_cache,0 ,TB_JMP_CACHE_SIZE *sizeof (void *));
@@ -1809,9 +1815,12 @@ void tlb_flush_page(CPUState *env, target_ulong addr)tlb_flush_entry (&env->tlb_table[1 ][i], addr);#if (NB_MMU_MODES >=3 )tlb_flush_entry (&env->tlb_table[2 ][i], addr); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )tlb_flush_entry (&env->tlb_table[3 ][i], addr);#endif +#if (NB_MMU_MODES >=5 ) +tlb_flush_entry (&env->tlb_table[4 ][i], addr);#endif tlb_flush_jmp_cache (env, addr);
@@ -1895,10 +1904,14 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,#if (NB_MMU_MODES >=3 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_reset_dirty_range (&env->tlb_table[2 ][i], start1, length); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_reset_dirty_range (&env->tlb_table[3 ][i], start1, length);#endif +#if (NB_MMU_MODES >=5 ) +for (i =0 ; i <CPU_TLB_SIZE ; i++) +tlb_reset_dirty_range (&env->tlb_table[4 ][i], start1, length);#endif } }
@@ -1944,10 +1957,14 @@ void cpu_tlb_update_dirty(CPUState *env)#if (NB_MMU_MODES >=3 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_update_dirty (&env->tlb_table[2 ][i]); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_update_dirty (&env->tlb_table[3 ][i]);#endif +#if (NB_MMU_MODES >=5 ) +for (i =0 ; i <CPU_TLB_SIZE ; i++) +tlb_update_dirty (&env->tlb_table[4 ][i]);#endif }
@@ -1969,9 +1986,12 @@ static inline void tlb_set_dirty(CPUState *env, target_ulong vaddr)tlb_set_dirty1 (&env->tlb_table[1 ][i], vaddr);#if (NB_MMU_MODES >=3 )tlb_set_dirty1 (&env->tlb_table[2 ][i], vaddr); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )tlb_set_dirty1 (&env->tlb_table[3 ][i], vaddr);#endif +#if (NB_MMU_MODES >=5 ) +tlb_set_dirty1 (&env->tlb_table[4 ][i], vaddr);#endif }
softmmu_exec.h +24 -5
@@ -60,6 +60,7 @@#include "softmmu_header.h" #undef ACCESS_TYPE#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 3) */ #if (NB_MMU_MODES >=4 )
@@ -78,12 +79,30 @@#include "softmmu_header.h" #undef ACCESS_TYPE#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 4) */ -#if (NB_MMU_MODES >4 ) -#error "NB_MMU_MODES > 4 is not supported for now" -#endif /* (NB_MMU_MODES > 4) */ -#endif /* (NB_MMU_MODES == 4) */ -#endif /* (NB_MMU_MODES >= 3) */ +#if (NB_MMU_MODES >=5 ) + +#define ACCESS_TYPE 4 +#define MEMSUFFIX MMU_MODE4_SUFFIX +#define DATA_SIZE 1 +#include "softmmu_header.h" + +#define DATA_SIZE 2 +#include "softmmu_header.h" + +#define DATA_SIZE 4 +#include "softmmu_header.h" + +#define DATA_SIZE 8 +#include "softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 4) */ + +#if (NB_MMU_MODES >5 ) +#error "NB_MMU_MODES > 5 is not supported for now" +#endif /* (NB_MMU_MODES > 5) */ /* these access are slower, they must be as rare as possible */ #define ACCESS_TYPE (NB_MMU_MODES)
Signature · 1 line
1.6.2
PATCH 10/25 Split cpu_mmu_index into cpu_mmu_index_data and cpu_mmu_index_code.
This is required by alpha system emulation as PAL mode disable instruction mmu but not data mmu.
This might also be required for other cpus that have a split I/D mmu enable.
--- exec-all.h | 2 +- softmmu_header.h | 4 ++-- target-alpha/cpu.h | 13 +++++++++++-- target-alpha/op_helper.c | 4 ++-- target-arm/cpu.h | 3 ++- target-cris/cpu.h | 3 ++- target-cris/translate.c | 6 +++--- target-i386/cpu.h | 3 ++- target-m68k/cpu.h | 3 ++- target-mips/cpu.h | 3 ++- target-ppc/cpu.h | 3 ++- target-sh4/cpu.h | 3 ++- target-sparc/cpu.h | 3 ++- target-sparc/translate.c | 2 +- 14 files changed, 36 insertions(+), 19 deletions(-)
exec-all.h +1 -1
@@ -318,7 +318,7 @@ static inline target_ulong get_phys_addr_code(CPUState *env1, target_ulong addr)int mmu_idx, page_index, pd; page_index = (addr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 ); - mmu_idx =cpu_mmu_index (env1); + mmu_idx =cpu_mmu_index_code (env1);if (unlikely (env1->tlb_table[mmu_idx][page_index].addr_code != (addr &TARGET_PAGE_MASK ))) {ldub_code (addr);
softmmu_header.h +2 -2
@@ -46,12 +46,12 @@#elif ACCESS_TYPE == (NB_MMU_MODES ) -#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define CPU_MMU_INDEX (cpu_mmu_index_data(env))#define MMUSUFFIX _mmu#elif ACCESS_TYPE == (NB_MMU_MODES +1 ) -#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define CPU_MMU_INDEX (cpu_mmu_index_code(env))#define MMUSUFFIX _cmmu#else
target-alpha/cpu.h +11 -2
@@ -297,16 +297,25 @@ struct CPUAlphaState {#define cpu_exec cpu_alpha_exec#define cpu_gen_code cpu_alpha_gen_code#define cpu_signal_handler cpu_alpha_signal_handler +#define cpu_list alpha_cpu_list/* MMU modes definitions */ #define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _executive#define MMU_MODE2_SUFFIX _supervisor#define MMU_MODE3_SUFFIX _user +#define MMU_MODE4_SUFFIX _pal +#define MMU_KERNEL_IDX 0#define MMU_USER_IDX 3 -static inline int cpu_mmu_index (CPUState *env) +#define MMU_PAL_IDX 4 +static inline int cpu_mmu_index_data (CPUState *env) { -return (env->ps >>3 ) &3 ; +return env->mmu_data_index; +} + +static inline int cpu_mmu_index_code (CPUState *env) +{ +return env->mmu_code_index; }#if defined(CONFIG_USER_ONLY )
target-alpha/op_helper.c +2 -2
@@ -1049,7 +1049,7 @@ uint64_t helper_ld_virt_to_phys (uint64_t virtaddr)int index, mmu_idx;void *retaddr; - mmu_idx =cpu_mmu_index (env); + mmu_idx =cpu_mmu_index_data (env); index = (virtaddr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 ); redo: tlb_addr = env->tlb_table[mmu_idx][index].addr_read;
@@ -1071,7 +1071,7 @@ uint64_t helper_st_virt_to_phys (uint64_t virtaddr)int index, mmu_idx;void *retaddr; - mmu_idx =cpu_mmu_index (env); + mmu_idx =cpu_mmu_index_data (env); index = (virtaddr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 ); redo: tlb_addr = env->tlb_table[mmu_idx][index].addr_write;
target-arm/cpu.h +2 -1
@@ -412,7 +412,8 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return (env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR ?1 :0 ; }
target-cris/cpu.h +2 -1
@@ -212,7 +212,8 @@ enum {#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return !!(env->pregs[PR_CCS ] &U_FLAG ); }
target-cris/translate.c +3 -3
@@ -1104,7 +1104,7 @@ static inline void cris_prepare_jmp (DisasContext *dc, unsigned int type)static void gen_load64 (DisasContext *dc,TCGv_i64 dst,TCGv addr) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index_data (dc->env);/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
@@ -1117,7 +1117,7 @@ static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr)static void gen_load (DisasContext *dc,TCGv dst,TCGv addr,unsigned int size,int sign) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index_data (dc->env);/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
@@ -1147,7 +1147,7 @@ static void gen_load(DisasContext *dc, TCGv dst, TCGv addr,static void gen_store (DisasContext *dc,TCGv addr,TCGv val,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index_data (dc->env);/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
target-i386/cpu.h +2 -1
@@ -842,7 +842,8 @@ static inline int cpu_get_time_fast(void)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return (env->hflags &HF_CPL_MASK ) ==3 ?1 :0 ; }
target-m68k/cpu.h +2 -1
@@ -218,7 +218,8 @@ void register_m68k_insns (CPUM68KState *env);#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return (env->sr &SR_S ) ==0 ?1 :0 ; }
target-mips/cpu.h +2 -1
@@ -489,7 +489,8 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,#define MMU_MODE1_SUFFIX _super#define MMU_MODE2_SUFFIX _user#define MMU_USER_IDX 2 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return env->hflags &MIPS_HFLAG_KSU ; }
target-ppc/cpu.h +2 -1
@@ -809,7 +809,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val);#define MMU_MODE1_SUFFIX _kernel#define MMU_MODE2_SUFFIX _hypv#define MMU_USER_IDX 0 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return env->mmu_idx; }
target-sh4/cpu.h +2 -1
@@ -181,7 +181,8 @@ void cpu_load_tlb(CPUSH4State * env);#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return (env->sr &SR_MD ) ==0 ?1 :0 ; }
target-sparc/cpu.h +2 -1
@@ -456,7 +456,8 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);#define MMU_KERNEL_IDX 1#define MMU_HYPV_IDX 2 -static inline int cpu_mmu_index (CPUState *env1) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env1) {#if defined(CONFIG_USER_ONLY )return MMU_USER_IDX ;
target-sparc/translate.c +1 -1
@@ -4769,7 +4769,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, dc->pc = pc_start; last_pc = dc->pc; dc->npc = (target_ulong ) tb->cs_base; - dc->mem_idx =cpu_mmu_index (env); + dc->mem_idx =cpu_mmu_index_code (env); dc->def = env->def;if ((dc->def->features &CPU_FEATURE_FLOAT )) dc->fpu_enabled =cpu_fpu_enabled (env);
Signature · 1 line
1.6.2
PATCH 11/25 Add square wave output support.
This is necessary for es40 as the sqw output is directly connected to the core chipset.
--- hw/mc146818rtc.c | 39 +++++++++++++++++++++++++++++---------- hw/pc.h | 1 + 2 files changed, 30 insertions(+), 10 deletions(-)
hw/mc146818rtc.c +29 -10
@@ -50,11 +50,12 @@#define REG_A_UIP 0x80 -#define REG_B_SET 0x80 -#define REG_B_PIE 0x40 -#define REG_B_AIE 0x20 -#define REG_B_UIE 0x10 -#define REG_B_DM 0x04 +#define REG_B_SET 0x80 +#define REG_B_PIE 0x40 +#define REG_B_AIE 0x20 +#define REG_B_UIE 0x10 +#define REG_B_SQWE 0x08 +#define REG_B_DM 0x04struct RTCState {uint8_t cmos_data[128 ];
@@ -62,6 +63,7 @@ struct RTCState {struct tm current_tm;int base_year;qemu_irq irq; +qemu_irq sqw_irq;int it_shift;/* periodic timer */ QEMUTimer *periodic_timer;
@@ -95,16 +97,20 @@ static void rtc_timer_update(RTCState *s, int64_t current_time) {int period_code, period;int64_t cur_clock, next_irq_clock; +int enable_pie; period_code = s->cmos_data[RTC_REG_A ] &0x0f ;#if definedTARGET_I386 || definedTARGET_X86_64 /* disable periodic timer if hpet is in legacy mode, since interrupts are * disabled anyway. */ -if (period_code !=0 && (s->cmos_data[RTC_REG_B ] ®_B_PIE ) && !hpet_in_legacy_mode ()) { + enable_pie =hpet_in_legacy_mode ();#else -if (period_code !=0 && (s->cmos_data[RTC_REG_B ] ®_B_PIE )) { + enable_pie =1 ;#endif +if (period_code !=0 + && (((s->cmos_data[RTC_REG_B ] ®_B_PIE ) && enable_pie) + || ((s->cmos_data[RTC_REG_B ] ®_B_SQWE ) && s->sqw_irq))) {if (period_code <=2 ) period_code +=7 ;/* period in 32 Khz cycles */
@@ -138,8 +144,15 @@ static void rtc_periodic_timer(void *opaque) return; }#endif - s->cmos_data[RTC_REG_C ] |=0xc0 ; -rtc_irq_raise (s->irq); +if (s->cmos_data[RTC_REG_B ] ®_B_PIE ) { + s->cmos_data[RTC_REG_C ] |=0xc0 ; +rtc_irq_raise (s->irq); + } +if (s->cmos_data[RTC_REG_B ] ®_B_SQWE ) { +/* Not square wave at all but we don't want 2048Hz interrupts! +Must be seen as a pulse. */ +qemu_irq_raise (s->sqw_irq); + } }static void cmos_ioport_write (void *opaque,uint32_t addr,uint32_t data)
@@ -527,13 +540,14 @@ static int rtc_load_td(QEMUFile *f, void *opaque, int version_id) }#endif -RTCState *rtc_init (int base,qemu_irq irq,int base_year) +RTCState *rtc_init_sqw (int base,qemu_irq irq,qemu_irq sqw_irq,int base_year) {RTCState *s; s =qemu_mallocz (sizeof (RTCState)); s->irq = irq; + s->sqw_irq = sqw_irq; s->cmos_data[RTC_REG_A ] =0x26 ; s->cmos_data[RTC_REG_B ] =0x02 ; s->cmos_data[RTC_REG_C ] =0x00 ;
@@ -563,6 +577,11 @@ RTCState *rtc_init(int base, qemu_irq irq, int base_year)return s; } +RTCState *rtc_init (int base,qemu_irq irq,int base_year) +{ +return rtc_init_sqw (base, irq,NULL , base_year); +} +/* Memory mapped interface */ static uint32_t cmos_mm_readb (void *opaque,target_phys_addr_t addr) {
hw/pc.h +1 -0
@@ -90,6 +90,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,typedef struct RTCState RTCState ;RTCState *rtc_init (int base,qemu_irq irq,int base_year); +RTCState *rtc_init_sqw (int base,qemu_irq irq,qemu_irq sqw_irq,int base_year);RTCState *rtc_mm_init (target_phys_addr_t base,int it_shift,qemu_irq irq,int base_year);void rtc_set_memory (RTCState *s,int addr,int val);
Signature · 1 line
1.6.2
PATCH 12/25 Add ali1543 super IO pci device.
This is a very partial implementation just enough for es40 firmware.
--- hw/ali1543.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pci.h | 5 ++ hw/pci_ids.h | 3 + 3 files changed, 146 insertions(+), 0 deletions(-) create mode 100644 hw/ali1543.c
hw/ali1543.c new file +138 -0
@@ -0,0 +1,138 @@ +/* +* QEMU Ali 1543c emulation +* +* Copyright (c) 2009 AdaCore +* +* Written by Tristan Gingold. +* +* This work is licensed under the GNU GPL license version 2 or later. +* +*/ +#include <time.h> +#include <sys/time.h> +#include "hw.h" +#include "net.h" +#include "sysemu.h" +#include "devices.h" +#include "boards.h" +#include "pc.h" +#include "isa.h" +#include "qemu-char.h" +#include "pci.h" + +/* Ali 1543 is a south-bridge super-IO. It contains a DMA, a PIC, a PIT, +a ps/2 kbd interface, 2 IDE controller, 1 USB controller (OHCI), 1 FDC, +2 serials ports, 1 parallel port and a PMU. */ + +//#define DEBUG_CFG + +struct ALI1543State { +PCIDevice pci; + +qemu_irq *irq;/* Upstream handler. */ +PITState *pit; +qemu_irq *i8259; + +/* Configuration. */ +enum cfg_state {CFG_SNOOP ,CFG_51 ,CFG_EN } cfg_state; +unsigned char cfg_index; +}; + +static void ali_cfg_write (void *opaque,uint32_t addr,uint32_t val) +{ +ALI1543State *ali = opaque; + +if ((addr &1 ) ==0 ) { +switch (ali->cfg_state) { +case CFG_SNOOP : +if (val ==0x51 ) + ali->cfg_state =CFG_51 ; +else +qemu_log ("ali1543-cfg: write %02x to cfg_port\n" , val); +break ; +case CFG_51 : +if (val ==0x23 ) + ali->cfg_state =CFG_EN ; +else { +qemu_log ("ali1543-cfg: write %02x to cfg_port (51)\n" , val); + ali->cfg_state =CFG_SNOOP ; + } +break ; +case CFG_EN : + ali->cfg_index = val; +break ; + } + } +else { +#ifdef DEBUG_CFG +qemu_log ("ali1543-cfg: write %02x to cfg reg %02x (addr=%x)\n" , + val, ali->cfg_index, addr); +#endif + } +} + +static uint32_t ali_cfg_read (void *opaque,uint32_t addr) +{ +ALI1543State *ali = opaque; + +if ((addr &1 ) ==0 ) { +if (ali->cfg_state !=CFG_EN ) { +qemu_log ("ali1543-cfg: read fromcfg_port\n" ); +return 0 ; + } +else +return ali->cfg_index; + } +else { +#ifdef DEBUG_CFG +qemu_log ("ali1543-cfg: read from reg %02x\n" , ali->cfg_index); +#endif +return 0 ; + } +} + +ALI1543State *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq) +{ +ALI1543State *ali; +uint8_t *pci_conf; + + ali = (ALI1543State *)pci_register_device (bus,"Ali1543" , +sizeof (ALI1543State), + devfn,NULL ,NULL ); + + pci_conf = ali->pci.config; + +pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_AL ); +pci_config_set_device_id (pci_conf,PCI_DEVICE_ID_AL_M1533 ); + pci_conf[0x08 ] =0xc3 ;// Revision +pci_config_set_class (pci_conf,PCI_CLASS_BRIDGE_ISA ); + pci_conf[0x2c ] =0 ;// Subsystem + pci_conf[0x2d ] =0 ; + pci_conf[0x2e ] =0 ; + pci_conf[0x2f ] =0 ; + +register_ioport_read (0x370 ,2 ,1 , ali_cfg_read, ali); +register_ioport_write (0x370 ,2 ,1 , ali_cfg_write, ali); + + ali->i8259 =i8259_init (irq); + +/* serial_init already handles NULL CharDriverState but this code adds +a more useful label. */ +if (serial_hds[0 ] ==NULL ) + serial_hds[0 ] =qemu_chr_open ("com1" ,"nul" ,NULL ); +if (serial_hds[1 ] ==NULL ) + serial_hds[1 ] =qemu_chr_open ("com2" ,"nul" ,NULL ); + +serial_init (0x3f8 , ali->i8259[4 ],115200 , serial_hds[0 ]); +serial_init (0x2f8 , ali->i8259[3 ],115200 , serial_hds[1 ]); + ali->pit =pit_init (0x40 , ali->i8259[0 ]); +pcspk_init (ali->pit); +DMA_init (0 ); + +return ali; +} + +qemu_irq ali1543_get_irq (ALI1543State *c,int n) +{ +return c->i8259[n]; +}
hw/pci.h +5 -0
@@ -254,4 +254,9 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base,PCIBus *sh_pci_register_bus (pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,qemu_irq *pic,int devfn_min,int nirq); +/* ali1543.c */ +typedef struct ALI1543State ALI1543State ; +ALI1543State *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq); +qemu_irq ali1543_get_irq (ALI1543State *c,int n); +#endif
hw/pci_ids.h +3 -0
@@ -70,6 +70,9 @@#define PCI_VENDOR_ID_CMD 0x1095#define PCI_DEVICE_ID_CMD_646 0x0646 +#define PCI_VENDOR_ID_AL 0x10b9 +#define PCI_DEVICE_ID_AL_M1533 0x1533 +#define PCI_VENDOR_ID_REALTEK 0x10ec#define PCI_DEVICE_ID_REALTEK_8139 0x8139
Signature · 1 line
1.6.2
PATCH 13/25 Add 21272 chipset (memory and pci controller for alpha)
--- hw/21272.c | 831 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pci.h | 8 + 2 files changed, 839 insertions(+), 0 deletions(-) create mode 100644 hw/21272.c
hw/21272.c new file +831 -0
@@ -0,0 +1,831 @@ +/* +* Qemu 21272 (Tsunami/Typhoon) chipset emulation. +* +* Copyright (c) 2009 AdaCore +* +* Written by Tristan Gingold. +* +* This work is licensed under the GNU GPL license version 2 or later. +*/ +#include "hw.h" +#include "devices.h" +#include "pci.h" + +//#define DEBUG_CCHIP +//#define DEBUG_PCHIP +//#define DEBUG_DCHIP +//#define DEBUG_PCICFG + +typedef struct PchipState PchipState ; +struct PchipState { +/* IntAck handler. */ +int (*iack_handler)(void *); +void *iack_handler_param; + +PCIBus *pci; + +/* Pchip id. */ +int num; + +/* Used to reconstruct 64bits accesses. Low long word first. */ +uint32_t data; + +uint32_t wsba[3 ]; +uint64_t wsba3; +uint32_t wsm[3 ]; +uint32_t wsm3; +uint64_t tba[3 ]; +uint64_t tba3; +uint32_t perrmask; +/* pctl */ +unsigned char ptevrfy; +unsigned char mwin; +unsigned char hole; +unsigned char chaindis; +}; + +struct TyphoonState { +qemu_irq *irqs; +qemu_irq *intim_irq; +CPUState *cpu[4 ]; + +/* Used to reconstruct 64bits accesses. Low long word first. */ +uint32_t data; + +unsigned char misc_rev; +unsigned char misc_abw; +unsigned char misc_abt; + +int b_irq[4 ]; + +uint64_t dim[4 ]; +uint64_t dir[4 ]; +uint64_t drir; +uint64_t aar[4 ]; + +/* dchip */ +uint64_t csc; +uint64_t str; + +PchipState pchip[2 ]; +}; + +static void illegal_write (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +qemu_log ("illegal_write at addr=" TARGET_FMT_lx"\n" , addr); +} + +static uint32_t illegal_read (void *opaque,target_phys_addr_t addr) +{ +qemu_log ("illegal_read at addr=" TARGET_FMT_lx"\n" , addr); +return 0 ; +} + +static uint32_t typhoon_cchip_readl (void *opaque,target_phys_addr_t addr) +{ +TyphoonState *s = opaque; +uint64_t val; +int reg; + +/* Handle 64-bits accesses; */ +if (addr &0x04 ) +return s->data; + + reg = addr >>6 ; +switch (reg) { +case 0x00 :/* CSC */ + val = s->csc; +break ; +case 0x02 :/* MISC */ + val = ((uint64_t )s->misc_rev <<32 ) + | ((uint64_t )s->misc_abt <<20 ) + | ((uint64_t )s->misc_abw <<16 ) + | ((s->b_irq[0 ] &4 ) <<2 ) + | ((s->b_irq[1 ] &4 ) <<3 ) + | ((s->b_irq[2 ] &4 ) <<4 ) + | ((s->b_irq[3 ] &4 ) <<5 ) + | ((s->b_irq[0 ] &8 ) <<5 ) + | ((s->b_irq[1 ] &8 ) <<6 ) + | ((s->b_irq[2 ] &8 ) <<7 ) + | ((s->b_irq[3 ] &8 ) <<8 ); +break ; +case 0x04 : +case 0x05 : +case 0x06 : +case 0x07 : + val = s->aar[reg -4 ]; +break ; +case 0x08 : +case 0x09 : +case 0x18 : +case 0x19 : + val = s->dim[(reg &1 ) | ((reg &0x10 ) >>3 )]; +break ; +case 0x0a : +case 0x0b : +case 0x1a : +case 0x1b : + val = s->dir[(reg &1 ) | ((reg &0x10 ) >>3 )]; +break ; +default : +qemu_log ("21272: unhandled cchip read reg=%x\n" , reg); + val =0 ; +break ; + } + +#ifdef DEBUG_CCHIP +fprintf (stderr,"typhoon cchip read reg=%x, val=%016" PRIx64"\n" , reg, val); +#endif + s->data = val >>32 ; +return (uint32_t )val; +} + +static void typhoon_cchip_writel (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +TyphoonState *s = opaque; +int reg; +uint64_t val; + +#if 0 +fprintf (stderr,"typhoon write addr=" TARGET_FMT_lx", val=%08x\n" , + addr, value); +#endif + +/* Handle 64-bits accesses. LSB first. */ +if (!(addr &0x04 )) { + s->data = value; +return ; + } +else + val = ((uint64_t )value <<32 ) | s->data; + + reg = addr >>6 ; + +#ifdef DEBUG_CCHIP +fprintf (stderr,"typhoon cchip write reg=%x, val=%016" PRIx64"\n" , reg, val); +#endif + +switch (reg) { +case 0x00 :/* CSC */ + s->csc = (s->csc &0xffffU ) | (val &0x0777777fff3f0000ULL ); +break ; +case 0x02 :/* MISC */ +if (val & (1 <<24 )) { +/* ACL: arbitration clear. */ + s->misc_abt =0 ; + s->misc_abw =0 ; + } +if (val & (0xf <<12 )) { +int i; +for (i =0 ; i <4 && s->cpu[i]; i++) +if ((val & (0x1000 << i))) { + s->b_irq[i] &= ~(1 <<3 ); +cpu_alpha_update_irq (s->cpu[i], s->b_irq[i]); + } + } +if ((val & (0xf <<16 )) && s->misc_abw ==0 ) { +/* ABW: arbitration won. */ + s->misc_abw = (val >>16 ) &0x0f ; + } +if ((val & (0x0f <<20 )) && s->misc_abt ==0 ) { +/* ABT: arbitration try. */ + s->misc_abt = (val >>20 ) &0x0f ; + } +if (val & (1ULL <<28 )) { +/* NXM - not handled. */ + } +if (val & (0x0fULL <<40 )) { +/* DEVUP - not handled. */ + } +if (val & (0x0f <<4 )) { +/* ITINTR */ +int i; +for (i =0 ; i <4 && s->cpu[i]; i++) +if ((val & (0x10 << i))) { + s->b_irq[i] &= ~(1 <<2 ); +cpu_alpha_update_irq (s->cpu[i], s->b_irq[i]); + } + } +if (val & ~((0xfULL <<40 ) | (0xffULL <<32 ) | (1 <<28 ) | (1ULL <<24 ) + | (0x0f <<12 ) | (0xf <<16 ) + | (0x0f <<20 ) | (0x0f <<4 ))) { +qemu_log ("21272: unhandled value %016" PRIx64" written in MISC\n" , + val); + } +break ; +case 0x08 : +case 0x09 : +case 0x18 : +case 0x19 : + s->dim[(reg &1 ) | ((reg &0x10 ) >>3 )] = val; +break ; +default : +qemu_log ("21272: unhandled cchip write reg %x (%016" PRIx64")\n" , + reg, val); +break ; + } +} + +static CPUReadMemoryFunc *typhoon_cchip_read[] = { + &illegal_read, + &illegal_read, + &typhoon_cchip_readl, +}; + +static CPUWriteMemoryFunc *typhoon_cchip_write[] = { + &illegal_write, + &illegal_write, + &typhoon_cchip_writel, +}; + +static uint32_t typhoon_dchip_readl (void *opaque,target_phys_addr_t addr) +{ +TyphoonState *s = opaque; +uint64_t val; +int reg; + +/* Handle 64-bits accesses; */ +if (addr &0x04 ) +return s->data; + + reg = addr >>6 ; +switch (reg) { +case 0x20 :/* DSC */ + val = (s->csc &0x3f ) | ((s->csc >> (14 -6 )) &0x40 ); + val = (val <<8 ) | val; + val = (val <<16 ) | val; + val = (val <<32 ) | val; +break ; +case 0x21 :/* STR */ + val = s->str; +break ; +case 0x22 :/* DREV */ + val =0x02 *0x0101010101010101ULL ; +break ; +case 0x23 :/* DSC2 */ + val =0 ; +default : +qemu_log ("21272: unhandled dchip read reg=%x\n" , reg); + val =0 ; +break ; + } + +#ifdef DEBUG_DCHIP +fprintf (stderr,"typhoon dchip read reg=%x, val=%016" PRIx64"\n" , reg, val); +#endif + s->data = val >>32 ; +return (uint32_t )val; +} + +static void typhoon_dchip_writel (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +TyphoonState *s = opaque; +int reg; +uint64_t val; + +#if 0 +fprintf (stderr,"typhoon write addr=" TARGET_FMT_lx", val=%08x\n" , + addr, value); +#endif + +/* Handle 64-bits accesses. LSB first. */ +if (!(addr &0x04 )) { + s->data = value; +return ; + } +else + val = ((uint64_t )value <<32 ) | s->data; + + reg = addr >>6 ; + +#ifdef DEBUG_DCHIP +fprintf (stderr,"typhoon dchip write reg=%x, val=%016" PRIx64"\n" , reg, val); +#endif + +switch (reg) { +default : +qemu_log ("21272: unhandled dchip write reg %x (%016" PRIx64")\n" , + reg, val); +break ; + } +} + +static CPUReadMemoryFunc *typhoon_dchip_read[] = { + &illegal_read, + &illegal_read, + &typhoon_dchip_readl, +}; + +static CPUWriteMemoryFunc *typhoon_dchip_write[] = { + &illegal_write, + &illegal_write, + &typhoon_dchip_writel, +}; + +static uint32_t typhoon_pchip_readl (void *opaque,target_phys_addr_t addr) +{ +PchipState *s = opaque; +uint64_t val; +int reg; + +/* Handle 64-bits accesses; */ +if (addr &0x04 ) +return s->data; + + reg = addr >>6 ; +switch (reg) { +case 0x00 : +case 0x01 : +case 0x02 : + val = s->wsba[reg]; +break ; +case 0x03 : + val = s->wsba3; +break ; +case 0x04 : +case 0x05 : +case 0x06 : + val = s->wsm[reg -4 ]; +break ; +case 0x07 : + val = s->wsm3; +break ; +case 0x08 : +case 0x09 : +case 0x0a : + val = s->tba[reg -0x8 ]; +break ; +case 0x0b : + val = s->tba3; +break ; +case 0x0c :/* pctl */ + val = (((uint64_t )(s->num &3 )) <<46 ) + | (((uint64_t )s->ptevrfy) <<44 ) + | (1ULL <<40 )/* PCLKX */ + | (s->mwin <<6 ) + | (s->hole <<5 ) + | (s->chaindis <<3 ); +break ; +case 0x0f :/* PERROR */ + val =0 ;/* Not emulated. */ +break ; +case 0x10 :/* PERRMASK */ + val = s->perrmask; +break ; +case 0x20 :/* WO. */ + val =0 ; +break ; +default : +qemu_log ("21272: unhandled pchip read reg=%x\n" , reg); + val =0 ; +break ; + } + +#ifdef DEBUG_PCHIP +fprintf (stderr,"typhoon pchip%d read reg=%x, val=%016" PRIx64"\n" , + s->num, reg, val); +#endif + s->data = val >>32 ; +return (uint32_t )val; +} + +static void typhoon_pchip_writel (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +PchipState *s = opaque; +int reg; +uint64_t val; + +/* Handle 64-bits accesses. LSB first. */ +if (!(addr &0x04 )) { + s->data = value; +return ; + } +else + val = ((uint64_t )value <<32 ) | s->data; + + reg = addr >>6 ; + +#ifdef DEBUG_PCHIP +fprintf (stderr,"typhoon pchip%d write reg=%x, val=%016" PRIx64"\n" , + s->num, reg, val); +#endif + +switch (reg) { +case 0 : +case 1 : +case 2 : + s->wsba[reg] = val &0xfff00003 ; +if (val &1 ) +qemu_log ("21272: enabling wsba%d!\n" , reg);/* Not yet emulated */ +break ; +case 3 : + s->wsba3 = val &0xffffff80fff00003ULL ; +if (val &1 ) +qemu_log ("21272: enabling wsba3!\n" );/* Not yet emulated */ +break ; +case 0x4 : +case 0x5 : +case 0x6 : + s->wsm[reg -4 ] = val &0xfff00000 ; +break ; +case 0x7 : + s->wsm3 = val &0xfff00000 ; +break ; +case 0x8 : +case 0x9 : +case 0xa : + s->tba[reg -0x8 ] = val &0x7fffffc00 ; +break ; +case 0xb : + s->tba3 = val &0x7fffffc00 ; +break ; +case 0x0c :/* pctl */ + s->ptevrfy = (val >>44 ) &1 ; + s->mwin = (val >>6 ) &1 ; + s->hole = (val >>5 ) &1 ; + s->chaindis = (val >>3 ) &1 ; +if (val & ((1ULL <<43 ) | (1ULL <<42 ) | (3ULL <<36 ) | (0x0fULL <<32 ) + | (0x0f <<20 ) | (1 <<19 ) | (0x3f <<8 ) + | (1 <<2 ) | (1 <<1 ))) +qemu_log ("21272: pchip pctl: unhandled value %016" PRIx64"\n" , + val); +break ; +case 0x0f :/* PERROR */ +break ;/* Not emulated. */ +case 0x10 :/* PERRMASK */ + s->perrmask = val &0xfff ; +break ; +case 0x20 :/* SPRST */ +/* Software pci-reset. FIXME: disable bus? */ +break ; +default : +qemu_log ("21272: unhandled pchip write reg=%x (%016" PRIx64")\n" , + reg, val); +break ; + } +} + +static CPUReadMemoryFunc *typhoon_pchip_read[] = { + &illegal_read, + &illegal_read, + &typhoon_pchip_readl, +}; + +static CPUWriteMemoryFunc *typhoon_pchip_write[] = { + &illegal_write, + &illegal_write, + &typhoon_pchip_writel, +}; + + +static void pchip_pci_io_writeb (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +cpu_outb (NULL , addr, value); +} + +static uint32_t pchip_pci_io_readb (void *opaque,target_phys_addr_t addr) +{ +return cpu_inb (NULL , addr); +} + +static void pchip_pci_io_writew (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +#ifdef TARGET_WORDS_BIGENDIAN + value =bswap16 (value); +#endif +cpu_outw (NULL , addr, value); +} + +static uint32_t pchip_pci_io_readw (void *opaque,target_phys_addr_t addr) +{ +uint32_t ret; + + ret =cpu_inw (NULL , addr); +#ifdef TARGET_WORDS_BIGENDIAN + ret =bswap16 (ret); +#endif +return ret; +} + +static void pchip_pci_io_writel (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +#ifdef TARGET_WORDS_BIGENDIAN + value =bswap32 (value); +#endif +cpu_outl (NULL , addr, value); +} + +static uint32_t pchip_pci_io_readl (void *opaque,target_phys_addr_t addr) +{ +uint32_t ret; + + ret =cpu_inl (NULL , addr); +#ifdef TARGET_WORDS_BIGENDIAN + ret =bswap32 (ret); +#endif +return ret; +} + +static CPUWriteMemoryFunc *pchip_pci_io_write[] = { + &pchip_pci_io_writeb, + &pchip_pci_io_writew, + &pchip_pci_io_writel, +}; + +static CPUReadMemoryFunc *pchip_pci_io_read[] = { + &pchip_pci_io_readb, + &pchip_pci_io_readw, + &pchip_pci_io_readl, +}; + +static void pchip_pci_cfg_writex (void *opaque,target_phys_addr_t addr, +uint32_t value,int sz) +{ +uint32_t a = addr &0xffffffU ; +PchipState *s = opaque; + +#ifdef DEBUG_PCICFG +fprintf (stderr,"pci_cfg write: addr=%06x, sz=%d %u:%u:%02x, val=%08x\n" , + a, sz, + (a >>11 ) &0x1f , (a >>8 ) &0x7 , a &0xff , value); +#endif + +pci_data_write (s->pci, a, value,1 << sz); +} + +static void pchip_pci_cfg_writel (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +#ifdef TARGET_WORDS_BIGENDIAN + value =bswap32 (value); +#endif +pchip_pci_cfg_writex (opaque, addr, value,2 ); +} + +static void pchip_pci_cfg_writew (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +#ifdef TARGET_WORDS_BIGENDIAN + value =bswap16 (value); +#endif +pchip_pci_cfg_writex (opaque, addr, value,1 ); +} + +static void pchip_pci_cfg_writeb (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +pchip_pci_cfg_writex (opaque, addr, value,0 ); +} + +static uint32_t pchip_pci_cfg_readx (void *opaque,target_phys_addr_t addr, +int sz) +{ +uint32_t a = addr &0xffffffU ; +PchipState *s = opaque; +uint32_t val; + + val =pci_data_read (s->pci, a,1 << sz); + +#ifdef DEBUG_PCICFG +fprintf (stderr,"pci_cfg read: addr=%06x, sz=%d %u:%u:%02x, val=%08x\n" , + a, sz, + (a >>11 ) &0x1f , (a >>8 ) &0x7 , a &0xff , + val); +#endif + +return val; +} + +static uint32_t pchip_pci_cfg_readb (void *opaque,target_phys_addr_t addr) +{ +return pchip_pci_cfg_readx (opaque, addr,0 ); +} + +static uint32_t pchip_pci_cfg_readw (void *opaque,target_phys_addr_t addr) +{ +return pchip_pci_cfg_readx (opaque, addr,1 ); +} + +static uint32_t pchip_pci_cfg_readl (void *opaque,target_phys_addr_t addr) +{ +return pchip_pci_cfg_readx (opaque, addr,2 ); +} + +static CPUWriteMemoryFunc *pchip_pci_cfg_write[] = { + &pchip_pci_cfg_writeb, + &pchip_pci_cfg_writew, + &pchip_pci_cfg_writel, +}; + +static CPUReadMemoryFunc *pchip_pci_cfg_read[] = { + &pchip_pci_cfg_readb, + &pchip_pci_cfg_readw, + &pchip_pci_cfg_readl, +}; + +static void pchip_pci_iack_writex (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +qemu_log ("21272: pci iack addr=%08x, val=%08x\n" , (uint32_t )addr, value); +} + +static uint32_t pchip_pci_iack_readx (void *opaque,target_phys_addr_t addr) +{ +PchipState *s = opaque; +uint32_t res; + +/* Ideally we should have a PCIBus interface. */ + res = (*s->iack_handler)(s->iack_handler_param); +//fprintf(stderr, "21272 iack: addr=%016"PRIx64", res=%d\n", addr, res); +return res; +} + +static CPUWriteMemoryFunc *pchip_pci_iack_write[] = { + &pchip_pci_iack_writex, + &pchip_pci_iack_writex, + &pchip_pci_iack_writex, +}; + +static CPUReadMemoryFunc *pchip_pci_iack_read[] = { + &pchip_pci_iack_readx, + &pchip_pci_iack_readx, + &pchip_pci_iack_readx, +}; + +static void typhoon_reset (void *opaque) +{ +TyphoonState *s = opaque; + + s->misc_rev =8 ; + s->misc_abw =0 ; +} + +static void cchip_set_irq (void *opaque,int irq,int level) +{ +TyphoonState *s = opaque; +uint64_t mask; +int i; + +#if 0 +qemu_log ("cchip_set_irq: irq=%d level=%d\n" , irq, level); +#endif + mask =1ULL << irq; +if (level) + s->drir |= mask; +else + s->drir &= ~mask; + +for (i =0 ; i <4 && s->cpu[i]; i++) { +int old = s->b_irq[i]; + s->dir[i] = s->drir & s->dim[i]; +if (s->dir[i] >>58 ) + s->b_irq[i] |= (1 <<0 ); +else + s->b_irq[i] &= ~(1 <<0 ); + +if (s->dir[i] <<8 ) + s->b_irq[i] |= (1 <<1 ); +else + s->b_irq[i] &= ~(1 <<1 ); + +#if 0 +qemu_log ("cchip_set_irq: cpu[%d]: drir=%016" PRIx64" dim=%016" PRIx64" " +" dir=%016" PRIx64" birq=%02x\n" , + i, s->drir, s->dim[i], s->dir[i], s->b_irq[i]); +#endif +if (s->b_irq[i] != old) +cpu_alpha_update_irq (s->cpu[i], s->b_irq[i]); + } +} + +static void intim_set_irq (void *opaque,int irq,int level) +{ +int i; +TyphoonState *s = opaque; +unsigned char old; + +#if 0 + { +static int cnt; + cnt++; +if ((cnt %1024 ) ==1023 ) +fprintf (stderr,"Clock!\n" ); + } +#endif + +if (0 && (s->b_irq[0 ] &0x04 )) +fprintf (stderr,"!!Interrupt missed\n" ); + +for (i =0 ; i <4 && s->cpu[i]; i++) { + old = s->b_irq[i]; +if (!(old & (1 <<2 ))) { + s->b_irq[i] |= (1 <<2 ); +cpu_alpha_update_irq (s->cpu[i], s->b_irq[i]); + } + } +} + + +static int typhoon_map_irq (PCIDevice *pci_dev,int irq_num) +{ +return irq_num; +} + +static void typhoon_set_irq (qemu_irq *pic,int irq_num,int level) +{ +/* Never called (yet). */ +fprintf (stderr,"typhoon_set_irq: irq_num=%d, level=%d\n" , irq_num, level); +exit (4 ); +} + +TyphoonState *typhoon_21272_init (uint64_t *arr,qemu_irq **irqs, +qemu_irq *intim_irq,void *cpu0) +{ +TyphoonState *s; +int cchip; +int dchip; +int pchip; +int pci_io; +int pci_cfg; +int pci_iack; +int i; + + s =qemu_mallocz (sizeof (TyphoonState)); + +/* Cchip registers. */ + cchip =cpu_register_io_memory (0 , typhoon_cchip_read, + typhoon_cchip_write, s); +cpu_register_physical_memory (0x801a0000000ULL ,0x0002000 , cchip); + +/* Dchip registers. */ + dchip =cpu_register_io_memory (0 , typhoon_dchip_read, + typhoon_dchip_write, s); +cpu_register_physical_memory (0x801b0000000ULL ,0x0002000 , dchip); + +/* Pchip0 registers. */ + pchip =cpu_register_io_memory (0 , typhoon_pchip_read, + typhoon_pchip_write, &s->pchip[0 ]); +cpu_register_physical_memory (0x80180000000ULL ,0x0002000 , pchip); + +/* Pchip1 registers. */ + pchip =cpu_register_io_memory (0 , typhoon_pchip_read, + typhoon_pchip_write, &s->pchip[1 ]); +cpu_register_physical_memory (0x80380000000ULL ,0x0002000 , pchip); + +/* Pchip0 PCI I/O */ + pci_io =cpu_register_io_memory (0 , pchip_pci_io_read, + pchip_pci_io_write, &s->pchip[0 ]); +cpu_register_physical_memory (0x801fc000000ULL ,0x0010000 , pci_io); + +/* Pchip0 PCI cfg */ + pci_cfg =cpu_register_io_memory (0 , pchip_pci_cfg_read, + pchip_pci_cfg_write, &s->pchip[0 ]); +cpu_register_physical_memory (0x801fe000000ULL ,0x0010000 , pci_cfg); + +/* Pchip0 PCI IntAck */ + pci_iack =cpu_register_io_memory (0 , pchip_pci_iack_read, + pchip_pci_iack_write, &s->pchip[0 ]); +cpu_register_physical_memory (0x801f8000000ULL ,0x002000 , pci_iack); + + s->pchip[0 ].pci =pci_register_bus (typhoon_set_irq, + typhoon_map_irq, +NULL ,0 ,64 ); + +typhoon_reset (s); +/* P1 chip present, 8 dchips, 2 memory buses. */ + s->csc = (1 <<14 ) | (3 <<0 ); + +/* Configure cchip array address. */ +for (i =0 ; i <4 ; i++) + s->aar[i] = arr[i]; + + s->cpu[0 ] = cpu0; + s->irqs =qemu_allocate_irqs (cchip_set_irq, s,64 ); + *irqs = s->irqs; + + s->intim_irq =qemu_allocate_irqs (intim_set_irq, s,1 ); + *intim_irq = s->intim_irq[0 ]; + +qemu_register_reset (&typhoon_reset, s); + +return s; +} + +void typhoon_set_iack_handler (TyphoonState *c,int num, +int (*handler)(void *),void *param) +{ + c->pchip[num].iack_handler = handler; + c->pchip[num].iack_handler_param = param; +} + +PCIBus *typhoon_get_pci_bus (TyphoonState *c,int num) +{ +return c->pchip[num].pci; +}
hw/pci.h +8 -0
@@ -254,6 +254,14 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base,PCIBus *sh_pci_register_bus (pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,qemu_irq *pic,int devfn_min,int nirq); +/* 21272.c */ +typedef struct TyphoonState TyphoonState ; +TyphoonState *typhoon_21272_init (uint64_t *arr,qemu_irq **irqs, +qemu_irq *intim_irq,void *cpu0); +void typhoon_set_iack_handler (TyphoonState *c,int num, +int (*handler)(void *),void *param); +PCIBus *typhoon_get_pci_bus (TyphoonState *c,int num); +/* ali1543.c */ typedef struct ALI1543State ALI1543State ;ALI1543State *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq);
Signature · 1 line
1.6.2
PATCH 14/25 Add target-alpha/machine.c and hw/es40.c for es40 machine emulation.
The machine emulation is not yet complete, in particular vm save and load is not yet implemented.
--- Makefile.target | 4 + hw/boards.h | 4 + hw/es40.c | 922 ++++++++++++++++++++++++++++++++++++++++++++++++ target-alpha/machine.c | 22 ++ 4 files changed, 952 insertions(+), 0 deletions(-) create mode 100644 hw/es40.c create mode 100644 target-alpha/machine.c
Makefile.target +4 -0
@@ -683,6 +683,10 @@ ifeq ($(TARGET_BASE_ARCH), m68k) OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o OBJS+= m68k-semi.o dummy_m68k.o endif +ifeq ($(TARGET_BASE_ARCH), alpha) +OBJS+= es40.o 21272.o serial.o i8259.o mc146818rtc.o i8254.o pcspk.o dma.o +OBJS+= ali1543.o +endif ifdef CONFIG_GDBSTUB OBJS+=gdbstub.o gdbstub-xml.o endif
hw/boards.h +4 -0
@@ -128,4 +128,8 @@ extern QEMUMachine musicpal_machine;/* tosa.c */ extern QEMUMachine tosapda_machine; +/* es40.c */ +extern QEMUMachine es40_machine; +extern QEMUMachine es40_rombuild_machine; +#endif
hw/es40.c new file +922 -0
922 lines not on this page · raw message
target-alpha/machine.c new file +22 -0
@@ -0,0 +1,22 @@ +#include "hw/hw.h" +#include "hw/boards.h" +#include "qemu-timer.h" + +#include "exec-all.h" + +void register_machines (void ) +{ +qemu_register_machine (&es40_machine); +qemu_register_machine (&es40_rombuild_machine); +} + +void cpu_save (QEMUFile *f,void *opaque) +{ +/* FIXME: todo */ +abort (); +} + +int cpu_load (QEMUFile *f,void *opaque,int version_id) +{ +return -EINVAL ; +}
Signature · 1 line
1.6.2
PATCH 15/25 Move softmmu_helper.h from exec.h to op_helper.c on alpha.
There is no real needs to inline these functions everywhere and this simplify debugging.
--- target-alpha/exec.h | 4 ---- target-alpha/op_helper.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-)
target-alpha/exec.h +0 -4
@@ -36,10 +36,6 @@ register struct CPUAlphaState *env asm(AREG0);#include "cpu.h" #include "exec-all.h" -#if !defined(CONFIG_USER_ONLY ) -#include "softmmu_exec.h" -#endif /* !defined(CONFIG_USER_ONLY) */ - static always_inline void env_to_regs(void) { }
target-alpha/op_helper.c +4 -0
@@ -23,6 +23,10 @@#include "softfloat.h" #include "helper.h" +#if !defined(CONFIG_USER_ONLY ) +#include "softmmu_exec.h" +#endif /* !defined(CONFIG_USER_ONLY) */ +void helper_tb_flush (void ) {tlb_flush (env,1 );
Signature · 1 line
1.6.2
PATCH 16/25 Document which IPR are used by 21264
--- target-alpha/cpu.h | 96 +++++++++++++++++++++++++++++++++++----------------- 1 files changed, 65 insertions(+), 31 deletions(-)
target-alpha/cpu.h +65 -31
@@ -144,51 +144,85 @@ enum {/* XXX: TOFIX: most of those registers are implementation dependant */ enum {/* Ebox IPRs */ -IPR_CC =0xC0 , -IPR_CC_CTL =0xC1 , -IPR_VA =0xC2 , -IPR_VA_CTL =0xC4 , -IPR_VA_FORM =0xC3 , +IPR_CC =0xC0 ,/* 21264 */ +IPR_CC_CTL =0xC1 ,/* 21264 */ +#define IPR_CC_CTL_ENA_SHIFT 32 +#define IPR_CC_CTL_COUNTER_MASK 0xfffffff0UL +IPR_VA =0xC2 ,/* 21264 */ +IPR_VA_CTL =0xC4 ,/* 21264 */ +#define IPR_VA_CTL_VA_48_SHIFT 1 +#define IPR_VA_CTL_VPTB_SHIFT 30 +IPR_VA_FORM =0xC3 ,/* 21264 */ /* Ibox IPRs */ -IPR_ITB_TAG =0x00 , -IPR_ITB_PTE =0x01 , -IPT_ITB_IAP =0x02 , -IPT_ITB_IA =0x03 , -IPT_ITB_IS =0x04 , +IPR_ITB_TAG =0x00 ,/* 21264 */ +IPR_ITB_PTE =0x01 ,/* 21264 */ +IPR_ITB_IAP =0x02 , +IPR_ITB_IA =0x03 ,/* 21264 */ +IPR_ITB_IS =0x04 ,IPR_PMPC =0x05 , -IPR_EXC_ADDR =0x06 , -IPR_IVA_FORM =0x07 , -IPR_CM =0x09 , -IPR_IER =0x0A , -IPR_SIRR =0x0C , -IPR_ISUM =0x0D , -IPR_HW_INT_CLR =0x0E , +IPR_EXC_ADDR =0x06 ,/* 21264 */ +IPR_IVA_FORM =0x07 ,/* 21264 */ +IPR_CM =0x09 ,/* 21264 */ +#define IPR_CM_SHIFT 3 +#define IPR_CM_MASK (3ULL << IPR_CM_SHIFT) /* 21264 */ +IPR_IER =0x0A ,/* 21264 */ +#define IPR_IER_MASK 0x0000007fffffe000ULL + IPR_IER_CM = 0x0B, /* 21264: = CM | IER */ +IPR_SIRR =0x0C ,/* 21264 */ +#define IPR_SIRR_SHIFT 14 +#define IPR_SIRR_MASK 0x7fff +IPR_ISUM =0x0D ,/* 21264 */ +IPR_HW_INT_CLR =0x0E ,/* 21264 */ IPR_EXC_SUM =0x0F ,IPR_PAL_BASE =0x10 ,IPR_I_CTL =0x11 , -IPR_I_STAT =0x16 , -IPR_IC_FLUSH =0x13 , -IPR_IC_FLUSH_ASM =0x12 , +#define IPR_I_CTL_CHIP_ID_SHIFT 24 /* 21264 */ +#define IPR_I_CTL_BIST_FAIL (1 << 23) /* 21264 */ +#define IPR_I_CTL_IC_EN_SHIFT 2 /* 21264 */ +#define IPR_I_CTL_SDE1_SHIFT 7 /* 21264 */ +#define IPR_I_CTL_HWE_SHIFT 12 /* 21264 */ +#define IPR_I_CTL_VA_48_SHIFT 15 /* 21264 */ +#define IPR_I_CTL_SPE_SHIFT 3 /* 21264 */ +#define IPR_I_CTL_CALL_PAL_R23_SHIFT 20 /* 21264 */ +IPR_I_STAT =0x16 ,/* 21264 */ +IPR_IC_FLUSH =0x13 ,/* 21264 */ +IPR_IC_FLUSH_ASM =0x12 ,/* 21264 */ IPR_CLR_MAP =0x15 ,IPR_SLEEP =0x17 ,IPR_PCTX =0x40 , -IPR_PCTR_CTL =0x14 , +IPR_PCTX_ASN =0x01 ,/* field */ +#define IPR_PCTX_ASN_SHIFT 39 + IPR_PCTX_ASTER = 0x02, /* field */ +#define IPR_PCTX_ASTER_SHIFT 5 + IPR_PCTX_ASTRR = 0x04, /* field */ +#define IPR_PCTX_ASTRR_SHIFT 9 + IPR_PCTX_PPCE = 0x08, /* field */ +#define IPR_PCTX_PPCE_SHIFT 1 + IPR_PCTX_FPE = 0x10, /* field */ +#define IPR_PCTX_FPE_SHIFT 2 + IPR_PCTX_ALL = 0x5f, /* all fields */ +IPR_PCTR_CTL =0x14 ,/* 21264 */ /* Mbox IPRs */ -IPR_DTB_TAG0 =0x20 , -IPR_DTB_TAG1 =0xA0 , -IPR_DTB_PTE0 =0x21 , -IPR_DTB_PTE1 =0xA1 , +IPR_DTB_TAG0 =0x20 ,/* 21264 */ +IPR_DTB_TAG1 =0xA0 ,/* 21264 */ +IPR_DTB_PTE0 =0x21 ,/* 21264 */ +IPR_DTB_PTE1 =0xA1 ,/* 21264 */ IPR_DTB_ALTMODE =0xA6 , +IPR_DTB_ALTMODE0 =0x26 ,/* 21264 */ +#define IPR_DTB_ALTMODE_MASK 3 IPR_DTB_IAP = 0xA2, -IPR_DTB_IA =0xA3 , +IPR_DTB_IA =0xA3 ,/* 21264 */ IPR_DTB_IS0 =0x24 ,IPR_DTB_IS1 =0xA4 , -IPR_DTB_ASN0 =0x25 , -IPR_DTB_ASN1 =0xA5 , -IPR_MM_STAT =0x27 , -IPR_M_CTL =0x28 , +IPR_DTB_ASN0 =0x25 ,/* 21264 */ +IPR_DTB_ASN1 =0xA5 ,/* 21264 */ +#define IPR_DTB_ASN_SHIFT 56 + IPR_MM_STAT = 0x27, /* 21264 */ +IPR_M_CTL =0x28 ,/* 21264 */ +#define IPR_M_CTL_SPE_SHIFT 1 +#define IPR_M_CTL_SPE_MASK 7IPR_DC_CTL =0x29 , -IPR_DC_STAT =0x2A , +IPR_DC_STAT =0x2A ,/* 21264 */ /* Cbox IPRs */ IPR_C_DATA =0x2B ,IPR_C_SHIFT =0x2C ,
Signature · 1 line
1.6.2
PATCH 17/25 tb_flush helper should flush the tb (and not the tlb).
Looks to be a typo fix.
--- target-alpha/op_helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/op_helper.c +1 -1
@@ -29,7 +29,7 @@void helper_tb_flush (void ) { -tlb_flush (env,1 ); +tb_flush (env); }/*****************************************************************************/
Signature · 1 line
1.6.2
PATCH 18/25 Add instruction name in comments for hw_ld opcode.
Make code slightly easier to read.
Also unused hw_ld opcodes now generate an invalid opc fault.
--- target-alpha/translate.c | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-)
target-alpha/translate.c +20 -20
@@ -1793,62 +1793,62 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)tcg_gen_movi_i64 (addr, disp12);switch ((insn >>12 ) &0xF ) {case 0x0 : -/* Longword physical access */ +/* Longword physical access (hw_ldl/p) */ gen_helper_ldl_raw (cpu_ir[ra], addr);break ;case 0x1 : -/* Quadword physical access */ +/* Quadword physical access (hw_ldq/p) */ gen_helper_ldq_raw (cpu_ir[ra], addr);break ;case 0x2 : -/* Longword physical access with lock */ +/* Longword physical access with lock (hw_ldl_l/p) */ gen_helper_ldl_l_raw (cpu_ir[ra], addr);break ;case 0x3 : -/* Quadword physical access with lock */ +/* Quadword physical access with lock (hw_ldq_l/p) */ gen_helper_ldq_l_raw (cpu_ir[ra], addr);break ;case 0x4 : -/* Longword virtual PTE fetch */ -gen_helper_ldl_kernel (cpu_ir[ra], addr); +/* Longword virtual PTE fetch (hw_ldl/v) */ +tcg_gen_qemu_ld32s (cpu_ir[ra], addr,0 );break ;case 0x5 : -/* Quadword virtual PTE fetch */ -gen_helper_ldq_kernel (cpu_ir[ra], addr); +/* Quadword virtual PTE fetch (hw_ldq/v) */ +tcg_gen_qemu_ld64 (cpu_ir[ra], addr,0 );break ;case 0x6 :/* Incpu_ir[ra]id */ - goto incpu_ir[ra]id_opc; + goto invalid_opc;case 0x7 :/* Incpu_ir[ra]id */ - goto incpu_ir[ra]id_opc; + goto invalid_opc;case 0x8 : -/* Longword virtual access */ +/* Longword virtual access (hw_ldl) */ gen_helper_st_virt_to_phys (addr, addr);gen_helper_ldl_raw (cpu_ir[ra], addr);break ;case 0x9 : -/* Quadword virtual access */ +/* Quadword virtual access (hw_ldq) */ gen_helper_st_virt_to_phys (addr, addr);gen_helper_ldq_raw (cpu_ir[ra], addr);break ;case 0xA : -/* Longword virtual access with protection check */ -tcg_gen_qemu_ld32s (cpu_ir[ra], addr, ctx->flags); +/* Longword virtual access with protection check (hw_ldl/w) */ +tcg_gen_qemu_ld32s (cpu_ir[ra], addr,0 );break ;case 0xB : -/* Quadword virtual access with protection check */ -tcg_gen_qemu_ld64 (cpu_ir[ra], addr, ctx->flags); +/* Quadword virtual access with protection check (hw_ldq/w) */ +tcg_gen_qemu_ld64 (cpu_ir[ra], addr,0 );break ;case 0xC : -/* Longword virtual access with altenate access mode */ +/* Longword virtual access with alt access mode (hw_ldl/a)*/ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr);gen_helper_ldl_raw (cpu_ir[ra], addr);gen_helper_restore_mode ();break ;case 0xD : -/* Quadword virtual access with altenate access mode */ +/* Quadword virtual access with alt access mode (hw_ldq/a) */ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr);gen_helper_ldq_raw (cpu_ir[ra], addr);
@@ -1856,7 +1856,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)break ;case 0xE :/* Longword virtual access with alternate access mode and -* protection checks +* protection checks (hw_ldl/wa) */ gen_helper_set_alt_mode ();gen_helper_ldl_data (cpu_ir[ra], addr);
@@ -1864,7 +1864,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)break ;case 0xF :/* Quadword virtual access with alternate access mode and -* protection checks +* protection checks (hw_ldq/wa) */ gen_helper_set_alt_mode ();gen_helper_ldq_data (cpu_ir[ra], addr);
Signature · 1 line
1.6.2
PATCH 19/25 Remove PALCODE_ declarations (unused).
--- target-alpha/cpu.h | 10 ---------- 1 files changed, 0 insertions(+), 10 deletions(-)
target-alpha/cpu.h +0 -10
@@ -398,16 +398,6 @@ enum { };enum { -PALCODE_CALL =0x00000000 , -PALCODE_LD =0x01000000 , -PALCODE_ST =0x02000000 , -PALCODE_MFPR =0x03000000 , -PALCODE_MTPR =0x04000000 , -PALCODE_REI =0x05000000 , -PALCODE_INIT =0xF0000000 , -}; - -enum {IR_V0 =0 ,IR_T0 =1 ,IR_T1 =2 ,
Signature · 1 line
1.6.2
PATCH 20/25 alpha ld helpers now directly return the value.
Remove _kernel helpers as they can be directly generated. Replace ld/st_raw with _phys (bug fix).
Change argument name for st helpers (t0/t1 -> val/addr).
--- target-alpha/helper.h | 22 +++++++--------- target-alpha/op_helper.c | 62 ++++++++++++++++++++------------------------- target-alpha/translate.c | 32 ++++++++++++------------ 3 files changed, 54 insertions(+), 62 deletions(-)
target-alpha/helper.h +10 -12
@@ -116,18 +116,16 @@ DEF_HELPER_0(restore_mode, void) DEF_HELPER_1(ld_virt_to_phys, i64, i64) DEF_HELPER_1(st_virt_to_phys, i64, i64) -DEF_HELPER_2(ldl_raw, void, i64, i64) -DEF_HELPER_2(ldq_raw, void, i64, i64) -DEF_HELPER_2(ldl_l_raw, void, i64, i64) -DEF_HELPER_2(ldq_l_raw, void, i64, i64) -DEF_HELPER_2(ldl_kernel, void, i64, i64) -DEF_HELPER_2(ldq_kernel, void, i64, i64) -DEF_HELPER_2(ldl_data, void, i64, i64) -DEF_HELPER_2(ldq_data, void, i64, i64) -DEF_HELPER_2(stl_raw, void, i64, i64) -DEF_HELPER_2(stq_raw, void, i64, i64) -DEF_HELPER_2(stl_c_raw, i64, i64, i64) -DEF_HELPER_2(stq_c_raw, i64, i64, i64) +DEF_HELPER_1(ldl_phys, i64, i64) +DEF_HELPER_1(ldq_phys, i64, i64) +DEF_HELPER_1(ldl_l_phys, i64, i64) +DEF_HELPER_1(ldq_l_phys, i64, i64) +DEF_HELPER_1(ldl_data, i64, i64) +DEF_HELPER_1(ldq_data, i64, i64) +DEF_HELPER_2(stl_phys, void, i64, i64) +DEF_HELPER_2(stq_phys, void, i64, i64) +DEF_HELPER_2(stl_c_phys, i64, i64, i64) +DEF_HELPER_2(stq_c_phys, i64, i64, i64)#endif #include "def-helper.h"
target-alpha/op_helper.c +28 -34
104 lines not on this page · raw message
target-alpha/translate.c +16 -16
@@ -1794,19 +1794,19 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)switch ((insn >>12 ) &0xF ) {case 0x0 :/* Longword physical access (hw_ldl/p) */ -gen_helper_ldl_raw (cpu_ir[ra], addr); +gen_helper_ldl_phys (cpu_ir[ra], addr);break ;case 0x1 :/* Quadword physical access (hw_ldq/p) */ -gen_helper_ldq_raw (cpu_ir[ra], addr); +gen_helper_ldq_phys (cpu_ir[ra], addr);break ;case 0x2 :/* Longword physical access with lock (hw_ldl_l/p) */ -gen_helper_ldl_l_raw (cpu_ir[ra], addr); +gen_helper_ldl_l_phys (cpu_ir[ra], addr);break ;case 0x3 :/* Quadword physical access with lock (hw_ldq_l/p) */ -gen_helper_ldq_l_raw (cpu_ir[ra], addr); +gen_helper_ldq_l_phys (cpu_ir[ra], addr);break ;case 0x4 :/* Longword virtual PTE fetch (hw_ldl/v) */
@@ -1825,12 +1825,12 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)case 0x8 :/* Longword virtual access (hw_ldl) */ gen_helper_st_virt_to_phys (addr, addr); -gen_helper_ldl_raw (cpu_ir[ra], addr); +gen_helper_ldl_phys (cpu_ir[ra], addr);break ;case 0x9 :/* Quadword virtual access (hw_ldq) */ gen_helper_st_virt_to_phys (addr, addr); -gen_helper_ldq_raw (cpu_ir[ra], addr); +gen_helper_ldq_phys (cpu_ir[ra], addr);break ;case 0xA :/* Longword virtual access with protection check (hw_ldl/w) */
@@ -1844,14 +1844,14 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)/* Longword virtual access with alt access mode (hw_ldl/a)*/ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr); -gen_helper_ldl_raw (cpu_ir[ra], addr); +gen_helper_ldl_phys (cpu_ir[ra], addr);gen_helper_restore_mode ();break ;case 0xD :/* Quadword virtual access with alt access mode (hw_ldq/a) */ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr); -gen_helper_ldq_raw (cpu_ir[ra], addr); +gen_helper_ldq_phys (cpu_ir[ra], addr);gen_helper_restore_mode ();break ;case 0xE :
@@ -2123,29 +2123,29 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)switch ((insn >>12 ) &0xF ) {case 0x0 :/* Longword physical access */ -gen_helper_stl_raw (val, addr); +gen_helper_stl_phys (val, addr);break ;case 0x1 :/* Quadword physical access */ -gen_helper_stq_raw (val, addr); +gen_helper_stq_phys (val, addr);break ;case 0x2 :/* Longword physical access with lock */ -gen_helper_stl_c_raw (val, val, addr); +gen_helper_stl_c_phys (val, val, addr);break ;case 0x3 :/* Quadword physical access with lock */ -gen_helper_stq_c_raw (val, val, addr); +gen_helper_stq_c_phys (val, val, addr);break ;case 0x4 :/* Longword virtual access */ gen_helper_st_virt_to_phys (addr, addr); -gen_helper_stl_raw (val, addr); +gen_helper_stl_phys (val, addr);break ;case 0x5 :/* Quadword virtual access */ gen_helper_st_virt_to_phys (addr, addr); -gen_helper_stq_raw (val, addr); +gen_helper_stq_phys (val, addr);break ;case 0x6 :/* Invalid */
@@ -2169,14 +2169,14 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)/* Longword virtual access with alternate access mode */ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr); -gen_helper_stl_raw (val, addr); +gen_helper_stl_phys (val, addr);gen_helper_restore_mode ();break ;case 0xD :/* Quadword virtual access with alternate access mode */ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr); -gen_helper_stl_raw (val, addr); +gen_helper_stl_phys (val, addr);gen_helper_restore_mode ();break ;case 0xE :
Signature · 1 line
1.6.2
PATCH 21/25 Add alpha_cpu_list.
Add alpha_cpu_list and use cpu_model to select the model in cpu_alpha_init. Set implver and amask from the model.
--- target-alpha/cpu.h | 1 + target-alpha/translate.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-)
target-alpha/cpu.h +1 -0
@@ -436,6 +436,7 @@ enum {CPUAlphaState *cpu_alpha_init (const char *cpu_model);int cpu_alpha_exec (CPUAlphaState *s); +void alpha_cpu_list (FILE *f,int (*cpu_fprintf)(FILE *f,const char *fmt, ...));/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */
target-alpha/translate.c +38 -2
@@ -2459,17 +2459,53 @@ void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)gen_intermediate_code_internal (env, tb,1 ); } +struct alpha_def { +const char *name; +uint32_t implver; +uint32_t amask; +}; + +static const struct alpha_def alpha_defs[] = { +#ifdef CONFIG_USER_ONLY + {"21064" , IMPLVER_2106x,0 }, + {"21164" ,IMPLVER_21164 ,0 }, +#endif + {"21264" ,IMPLVER_21264 , (AMASK_PREFETCH |AMASK_TRAP |AMASK_BWX + |AMASK_FIX ) }, +}; + +void alpha_cpu_list (FILE *f,int (*cpu_fprintf)(FILE *f,const char *fmt, ...)) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (alpha_defs); i++) + (*cpu_fprintf)(f,"%s\n" , alpha_defs[i].name); +} +CPUAlphaState *cpu_alpha_init (const char *cpu_model) {CPUAlphaState *env;uint64_t hwpcb; +const struct alpha_def *cpu = alpha_defs; + +if (cpu_model !=NULL ) { +int i; +for (i =0 ; i <ARRAY_SIZE (alpha_defs); i++) +if (strcmp (alpha_defs[i].name, cpu_model) ==0 ) { + cpu = &alpha_defs[i]; +break ; + } +if (cpu ==NULL ) +return NULL ; + } env =qemu_mallocz (sizeof (CPUAlphaState));cpu_exec_init (env);alpha_translate_init ();tlb_flush (env,1 ); -/* XXX: should not be hardcoded */ - env->implver = IMPLVER_2106x; + + env->implver = cpu->implver; + env->amask = cpu->amask; env->ps =0x1F00 ;#if defined (CONFIG_USER_ONLY ) env->ps |=1 <<3 ;
Signature · 1 line
1.6.2
PATCH 22/25 Alpha: lower parent irq when irq is lowered.
--- hw/i8259.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/i8259.c +1 -1
@@ -169,7 +169,7 @@ void pic_update_irq(PicState2 *s) }/* all targets should do this rather than acking the IRQ in the cpu */ -#if defined(TARGET_MIPS ) || defined(TARGET_PPC ) +#if defined(TARGET_MIPS ) || defined(TARGET_PPC ) || defined(TARGET_ALPHA ) else {qemu_irq_lower (s->parent_irq); }
Signature · 1 line
1.6.2
PATCH 23/25 Move linux-user pal emulation to linux-user/
Move pal emulation for user emulation from alpha_palcode.c to linux-user/mai Add generic exception names.
Fix offset for PAL calls.
--- Makefile.target | 5 +-- hw/alpha_palcode.c | 44 --------------------- linux-user/main.c | 96 +++++++++++++++++++++++++--------------------- target-alpha/cpu.h | 39 +++++++++++++++--- target-alpha/helper.c | 4 +- target-alpha/translate.c | 1 - 6 files changed, 87 insertions(+), 102 deletions(-)
Makefile.target +1 -4
@@ -157,10 +157,6 @@ ifeq ($(TARGET_BASE_ARCH), arm) LIBOBJS+= neon_helper.o iwmmxt_helper.o endif -ifeq ($(TARGET_BASE_ARCH), alpha) -LIBOBJS+= alpha_palcode.o -endif - ifeq ($(TARGET_BASE_ARCH), cris) LIBOBJS+= cris-dis.o
@@ -686,6 +682,7 @@ endif ifeq ($(TARGET_BASE_ARCH), alpha) OBJS+= es40.o 21272.o serial.o i8259.o mc146818rtc.o i8254.o pcspk.o dma.o OBJS+= ali1543.o +#OBJS+= alpha_palcode.o # Not currently used until pal is virtualized endif ifdef CONFIG_GDBSTUB OBJS+=gdbstub.o gdbstub-xml.o
hw/alpha_palcode.c +0 -44
53 lines not on this page · raw message
linux-user/main.c +52 -44
135 lines not on this page · raw message
target-alpha/cpu.h +32 -7
@@ -291,7 +291,11 @@ struct pal_handler_t {void (*call_pal)(CPUAlphaState *env,uint32_t palcode); }; +#if !defined(CONFIG_USER_ONLY )#define NB_MMU_MODES 4 +#else +#define NB_MMU_MODES 2 +#endif struct CPUAlphaState {uint64_t ir[31 ];
@@ -318,6 +322,12 @@ struct CPUAlphaState {CPU_COMMON uint32_t hflags; +#if defined(CONFIG_USER_ONLY ) +struct { +uint64_t usp; +uint64_t unique; + } user; +#endif int error_code;
@@ -342,6 +352,8 @@ struct CPUAlphaState {#define MMU_KERNEL_IDX 0#define MMU_USER_IDX 3#define MMU_PAL_IDX 4 + +#if !defined(CONFIG_USER_ONLY )static inline int cpu_mmu_index_data (CPUState *env) {return env->mmu_data_index;
@@ -351,8 +363,13 @@ static inline int cpu_mmu_index_code (CPUState *env) {return env->mmu_code_index; } +#else +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) +{ +return 0 ; +} -#if defined(CONFIG_USER_ONLY )static inline void cpu_clone_regs (CPUState *env,target_ulong newsp) {if (newsp)
@@ -384,9 +401,20 @@ enum {EXCP_UNALIGN =0x11E0 ,EXCP_OPCDEC =0x13E0 ,EXCP_FEN =0x17E0 , -EXCP_CALL_PAL =0x2000 , -EXCP_CALL_PALP =0x3000 , -EXCP_CALL_PALE =0x4000 , + +/* Generic exception - to be mapped to processor. */ +EXCP_GEN_OPCDEC =1 , +EXCP_GEN_ARITH =2 , +EXCP_GEN_INTERRUPT =3 , +EXCP_GEN_LAST =3 , + +/* User linux exception. */ +EXCP_USER_DFAULT =0x0100 , +EXCP_USER_ITB_MISS =0x0101 , + +EXCP_CALL_PALP =0x2000 , +EXCP_CALL_PAL =0x3000 , +EXCP_CALL_PALE =0x4000 ,/* End of Pal */ /* Pseudo exception for console */ EXCP_CONSOLE_DISPATCH =0x4001 , EXCP_CONSOLE_FIXUP = 0x4002,
@@ -448,11 +476,8 @@ void do_interrupt (CPUState *env);int cpu_alpha_mfpr (CPUState *env,int iprn,uint64_t *valp);int cpu_alpha_mtpr (CPUState *env,int iprn,uint64_t val,uint64_t *oldvalp); -void pal_init (CPUState *env);#if !defined (CONFIG_USER_ONLY )void call_pal (CPUState *env); -#else -void call_pal (CPUState *env,int palcode);#endif static inline void cpu_pc_from_tb (CPUState *env,TranslationBlock *tb)
target-alpha/helper.c +2 -2
@@ -31,9 +31,9 @@ int cpu_alpha_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int mmu_idx, int is_softmmu) {if (rw ==2 ) - env->exception_index =EXCP_ITB_MISS ; + env->exception_index =EXCP_USER_ITB_MISS ;else - env->exception_index =EXCP_DFAULT ; + env->exception_index =EXCP_USER_DFAULT ; env->ipr[IPR_EXC_ADDR ] = address;return 1 ;
target-alpha/translate.c +0 -1
@@ -2510,7 +2510,6 @@ CPUAlphaState * cpu_alpha_init (const char *cpu_model)#if defined (CONFIG_USER_ONLY ) env->ps |=1 <<3 ;#endif -pal_init (env);/* Initialize IPR */ hwpcb = env->ipr[IPR_PCBB ]; env->ipr[IPR_ASN ] =0 ;
Signature · 1 line
1.6.2
PATCH 24/25 Correctly decode hw_ld/hw_st opcodes for all alpha implementations.
Allow privilegied pal_code only in kernel mode.
--- target-alpha/translate.c | 32 ++++++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 8 deletions(-)
target-alpha/translate.c +24 -8
@@ -52,6 +52,7 @@ struct DisasContext {int pal_mode;#endif uint32_t amask; +uint32_t implver; };/* global register indexes */
@@ -103,6 +104,20 @@ static void alpha_translate_init(void) done_init =1 ; } +static inline int get_mxcr_iprn (DisasContext *ctx,uint32_t insn) +{ +switch (ctx->implver) { +case IMPLVER_2106x: +return insn &0xff ; +case IMPLVER_21164 : +return insn &0xffff ; +case IMPLVER_21264 : +return (insn >>8 ) &0xff ; +default : +abort (); + } +} + static always_inline void gen_excp (DisasContext *ctx,int exception,int error_code) {
@@ -689,7 +704,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)#if !defined (CONFIG_USER_ONLY ) } else if (palcode < 0x40) {/* Privileged PAL code */ -if (ctx->mem_idx &1 ) +if (ctx->mem_idx !=MMU_KERNEL_IDX ) goto invalid_opc;else gen_excp (ctx,EXCP_CALL_PALP + ((palcode &0x3F ) <<6 ),0 );
@@ -1748,7 +1763,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)if (!ctx->pal_mode) goto invalid_opc;if (ra !=31 ) { -TCGv tmp =tcg_const_i32 (insn &0xFF ); +TCGv tmp =tcg_const_i32 (get_mxcr_iprn (ctx, insn));gen_helper_mfpr (cpu_ir[ra], tmp, cpu_ir[ra]);tcg_temp_free (tmp); }
@@ -2063,9 +2078,9 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)if (!ctx->pal_mode) goto invalid_opc;else { -TCGv tmp1 =tcg_const_i32 (insn &0xFF ); -if (ra !=31 ) -gen_helper_mtpr (tmp1, cpu_ir[ra]); +TCGv tmp1 =tcg_const_i32 (get_mxcr_iprn (ctx, insn)); +if (rb !=31 ) +gen_helper_mtpr (tmp1, cpu_ir[rb]);else {TCGv tmp2 =tcg_const_i64 (0 );gen_helper_mtpr (tmp1, tmp2);
@@ -2088,8 +2103,8 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)gen_helper_hw_rei (); }else {TCGv tmp; - -if (ra !=31 ) { + +if (rb !=31 ) { tmp =tcg_temp_new ();tcg_gen_addi_i64 (tmp, cpu_ir[rb], (((int64_t )insn <<51 ) >>51 )); }else
@@ -2097,7 +2112,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)gen_helper_hw_ret (tmp); tcg_temp_free(tmp); } - ret =2 ; + ret =3 ;break ;#endif case 0x1F :
@@ -2352,6 +2367,7 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, gen_opc_end = gen_opc_buf +OPC_MAX_SIZE ; ctx.pc = pc_start; ctx.amask = env->amask; + ctx.implver = env->implver;#if defined (CONFIG_USER_ONLY ) ctx.mem_idx =0 ;#else
Signature · 1 line
1.6.2
PATCH 25/25 Add full emulation for 21264.
This is still work in progress but complete enough to run the firmware.
Remove old and incomplete code for pal virtualization.
--- cpu-exec.c | 1 + hw/alpha_palcode.c | 37 ++- target-alpha/cpu.h | 284 +++++++++++------ target-alpha/helper.c | 780 +++++++++++++++++++++++++++++----------------- target-alpha/helper.h | 6 +- target-alpha/op_helper.c | 195 ++++++++----- target-alpha/translate.c | 147 +++++---- 7 files changed, 913 insertions(+), 537 deletions(-)
cpu-exec.c +1 -0
@@ -486,6 +486,7 @@ int cpu_exec(CPUState *env1) }#elif defined(TARGET_ALPHA)if (interrupt_request &CPU_INTERRUPT_HARD ) { + env->exception_index =EXCP_GEN_INTERRUPT ;do_interrupt (env); next_tb =0 ; }
hw/alpha_palcode.c +33 -4
@@ -22,10 +22,39 @@#include <stdlib.h> #include <stdio.h> -#include "qemu.h" #include "cpu.h" #include "exec-all.h" +typedef struct pal_handler_t pal_handler_t ; +struct pal_handler_t { +/* Reset */ +void (*reset)(CPUAlphaState *env); +/* Uncorrectable hardware error */ +void (*machine_check)(CPUAlphaState *env); +/* Arithmetic exception */ +void (*arithmetic)(CPUAlphaState *env); +/* Interrupt / correctable hardware error */ +void (*interrupt)(CPUAlphaState *env); +/* Data fault */ +void (*dfault)(CPUAlphaState *env); +/* DTB miss pal */ +void (*dtb_miss_pal)(CPUAlphaState *env); +/* DTB miss native */ +void (*dtb_miss_native)(CPUAlphaState *env); +/* Unaligned access */ +void (*unalign)(CPUAlphaState *env); +/* ITB miss */ +void (*itb_miss)(CPUAlphaState *env); +/* Instruction stream access violation */ +void (*itb_acv)(CPUAlphaState *env); +/* Reserved or privileged opcode */ +void (*opcdec)(CPUAlphaState *env); +/* Floating point exception */ +void (*fen)(CPUAlphaState *env); +/* Call pal instruction */ +void (*call_pal)(CPUAlphaState *env,uint32_t palcode); +}; +/* Shared handlers */ static void pal_reset (CPUState *env);/* Console handlers */
@@ -88,7 +117,7 @@ static void do_swappal (CPUState *env, uint64_t palid) case 0 ... 2: pal_handler = &pal_handlers[palid]; env->pal_handler = pal_handler; - env->ipr[IPR_PAL_BASE ] =-1ULL ; + env->pal_base =-1ULL ; (*pal_handler->reset)(env);break ; case 3 ... 255:
@@ -98,8 +127,8 @@ static void do_swappal (CPUState *env, uint64_t palid)default :/* We were given the entry point address */ env->pal_handler =NULL ; - env->ipr[IPR_PAL_BASE ] = palid; - env->pc = env->ipr[IPR_PAL_BASE ]; + env->pal_base = palid; + env->pc = env->pal_base;cpu_loop_exit (); } }
target-alpha/cpu.h +187 -97
354 lines not on this page · raw message
target-alpha/helper.c +488 -292
868 lines not on this page · raw message
target-alpha/helper.h +2 -4
@@ -111,11 +111,9 @@ DEF_HELPER_0(hw_rei, void) DEF_HELPER_1(hw_ret, void, i64) DEF_HELPER_2(mfpr, i64, int, i64) DEF_HELPER_2(mtpr, void, int, i64) -DEF_HELPER_0(set_alt_mode, void) -DEF_HELPER_0(restore_mode, void) -DEF_HELPER_1(ld_virt_to_phys, i64, i64) -DEF_HELPER_1(st_virt_to_phys, i64, i64) +DEF_HELPER_2(21264_hw_ldq, i64, i64, i32) +DEF_HELPER_2(21264_hw_ldl, i64, i64, i32) DEF_HELPER_1(ldl_phys, i64, i64) DEF_HELPER_1(ldq_phys, i64, i64)DEF_HELPER_1 (ldl_l_phys, i64, i64)
target-alpha/op_helper.c +123 -72
327 lines not on this page · raw message
target-alpha/translate.c +79 -68
273 lines not on this page · raw message
Signature · 1 line
1.6.2
Re: [Qemu-devel] [PATCH 13/25] Add 21272 chipset (memory and pci controller for alpha)
In reply to Tristan GingoldQuoted 76 lines · Tristan Gingold
Signed-off-by Tristan Gingold <[email protected]>--- hw/21272.c | 831 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pci.h | 8 + 2 files changed, 839 insertions(+), 0 deletions(-) create mode 100644 hw/21272.chw/21272.c new file +63
-0@@ -0,0 +1,831 @@ +/* +* Qemu 21272 (Tsunami/Typhoon) chipset emulation. +* +* Copyright (c) 2009 AdaCore +* +* Written by Tristan Gingold. +* +* This work is licensed under the GNU GPL license version 2 or later. +*/ +#include "hw.h" +#include "devices.h" +#include "pci.h" + +//#define DEBUG_CCHIP +//#define DEBUG_PCHIP +//#define DEBUG_DCHIP +//#define DEBUG_PCICFG + +typedef struct PchipState PchipState ; +struct PchipState { +/* IntAck handler. */ +int (*iack_handler)(void *); +void *iack_handler_param; + +PCIBus *pci; + +/* Pchip id. */ +int num; + +/* Used to reconstruct 64bits accesses. Low long word first. */ +uint32_t data; + +uint32_t wsba[3 ]; +uint64_t wsba3; +uint32_t wsm[3 ]; +uint32_t wsm3; +uint64_t tba[3 ]; +uint64_t tba3; +uint32_t perrmask; +/* pctl */ +unsigned char ptevrfy; +unsigned char mwin; +unsigned char hole; +unsigned char chaindis; +}; + +struct TyphoonState { +qemu_irq *irqs; +qemu_irq *intim_irq; +CPUState *cpu[4 ]; + +/* Used to reconstruct 64bits accesses. Low long word first. */ +uint32_t data; + +unsigned char misc_rev; +unsigned char misc_abw; +unsigned char misc_abt; + +int b_irq[4 ]; + +uint64_t dim[4 ]; +uint64_t dir[4 ]; +uint64_t drir;
hw/21272.c line 73
Quoted 10 lines
hw/21272.c new file +10
-0+uint64_t aar[4 ]; + +/* dchip */ +uint64_t csc; +uint64_t str; + +PchipState pchip[2 ]; +}; + +
This looks like a perfect candidate for 64 bit I/O. http://lists.gnu.org/archive/html/qemu-devel/2009-03/msg00918.html
Re: [Qemu-devel] [PATCH 13/25] Add 21272 chipset (memory and pci controller for alpha)
Quoted 1 line · Robert Reif
This looks like a perfect candidate for 64 bit I/O. http://lists.gnu.org/archive/html/qemu-devel/2009-03/msg00918.html
Sure. As alpha is a genuine 64 bits processor, having 64 bit I/O would be useful and would increase performances.
Tristan.
Re: [Qemu-devel] [PATCH 13/25] Add 21272 chipset (memory and pci controller for alpha)
In reply to Robert ReifQuoted 1 line · Robert Reif
This looks like a perfect candidate for 64 bit I/O. http://lists.gnu.org/archive/html/qemu-devel/2009-03/msg00918.html
Sure. As alpha is a genuine 64 bits processor, having 64 bit I/O would be useful and would increase performances.
Tristan.
Re: [Qemu-devel] [PATCH 09/25] Allow 5 mmu indexes.
In reply to Tristan GingoldQuoted 123 lines · Tristan Gingold
This is necessary for alpha because it has 4 protection levels and pal mode.
Signed-off-by Tristan Gingold <[email protected]>--- exec.c | 30 +++++++++++++++++++++++++----- softmmu_exec.h | 29 ++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 10 deletions(-)exec.c +25
-5@@ -1760,12 +1760,18 @@ void tlb_flush(CPUState *env, int flush_global) env->tlb_table[2 ][i].addr_read =-1 ; env->tlb_table[2 ][i].addr_write =-1 ; env->tlb_table[2 ][i].addr_code =-1 ; -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 ) env->tlb_table[3 ][i].addr_read =-1 ; env->tlb_table[3 ][i].addr_write =-1 ; env->tlb_table[3 ][i].addr_code =-1 ;#endif +#if (NB_MMU_MODES >=5 ) + env->tlb_table[4 ][i].addr_read =-1 ; + env->tlb_table[4 ][i].addr_write =-1 ; + env->tlb_table[4 ][i].addr_code =-1 ;#endif + }memset (env->tb_jmp_cache,0 ,TB_JMP_CACHE_SIZE *sizeof (void *));@@ -1809,9 +1815,12 @@ void tlb_flush_page(CPUState *env, target_ulong addr)tlb_flush_entry (&env->tlb_table[1 ][i], addr);#if (NB_MMU_MODES >=3 )tlb_flush_entry (&env->tlb_table[2 ][i], addr); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )tlb_flush_entry (&env->tlb_table[3 ][i], addr);#endif +#if (NB_MMU_MODES >=5 ) +tlb_flush_entry (&env->tlb_table[4 ][i], addr);#endif tlb_flush_jmp_cache (env, addr);@@ -1895,10 +1904,14 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,#if (NB_MMU_MODES >=3 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_reset_dirty_range (&env->tlb_table[2 ][i], start1, length); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_reset_dirty_range (&env->tlb_table[3 ][i], start1, length);#endif +#if (NB_MMU_MODES >=5 ) +for (i =0 ; i <CPU_TLB_SIZE ; i++) +tlb_reset_dirty_range (&env->tlb_table[4 ][i], start1, length);#endif } }@@ -1944,10 +1957,14 @@ void cpu_tlb_update_dirty(CPUState *env)#if (NB_MMU_MODES >=3 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_update_dirty (&env->tlb_table[2 ][i]); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_update_dirty (&env->tlb_table[3 ][i]);#endif +#if (NB_MMU_MODES >=5 ) +for (i =0 ; i <CPU_TLB_SIZE ; i++) +tlb_update_dirty (&env->tlb_table[4 ][i]);#endif }@@ -1969,9 +1986,12 @@ static inline void tlb_set_dirty(CPUState *env, target_ulong vaddr)tlb_set_dirty1 (&env->tlb_table[1 ][i], vaddr);#if (NB_MMU_MODES >=3 )tlb_set_dirty1 (&env->tlb_table[2 ][i], vaddr); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )tlb_set_dirty1 (&env->tlb_table[3 ][i], vaddr);#endif +#if (NB_MMU_MODES >=5 ) +tlb_set_dirty1 (&env->tlb_table[4 ][i], vaddr);#endif }softmmu_exec.h +10
-5@@ -60,6 +60,7 @@#include "softmmu_header.h" #undef ACCESS_TYPE#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 3) */ #if (NB_MMU_MODES >=4 )@@ -78,12 +79,30 @@#include "softmmu_header.h" #undef ACCESS_TYPE#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 4) */ -#if (NB_MMU_MODES >4 ) -#error "NB_MMU_MODES > 4 is not supported for now" -#endif /* (NB_MMU_MODES > 4) */ -#endif /* (NB_MMU_MODES == 4) */ -#endif /* (NB_MMU_MODES >= 3) */ +#if (NB_MMU_MODES >=5 ) + +#define ACCESS_TYPE 4 +#define MEMSUFFIX MMU_MODE4_SUFFIX +#define DATA_SIZE 1 +#include "softmmu_header.h" + +#define DATA_SIZE 2
softmmu_exec.h line 101
Quoted 10 lines
softmmu_exec.h +10
-0+#include "softmmu_header.h" + +#define DATA_SIZE 4 +#include "softmmu_header.h" + +#define DATA_SIZE 8 +#include "softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 4) */
That should be 5 here.
Quoted 4 lines
softmmu_exec.h +3
-0+#if (NB_MMU_MODES >5 ) +#error "NB_MMU_MODES > 5 is not supported for now" +#endif /* (NB_MMU_MODES > 5) */
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 01/25] Add support for multi-level phys map.
In reply to Tristan GingoldQuoted 3 lines · Tristan Gingold
As Alpha physical addresses are 44 bits,
l1_phys_mapcan't be anymore 2 levels. Use a more generic multi-level approach and explain why we don't need to extendl1_map.
Having two different code paths, one of which is going to be largely untested, seems like a bad idea. If done properly the multi-level code should be usable for everything, with little or no performance hit.
Paul
I applied the patches and I don't see an alpha-softmmu like the other full-machine emulators. And I don't see anything in the makefiles for qemu-system-alpha.
Am I missing something obvious?
Brian
Quoted 15 lines · Tristan Gingold
Hi,
these patches add alpha system emulation. Currently it emulates an es40 system just enough to get the firmware prompt.
This is the second version of the patches. They addresses the comments made and I made a very improvments too.
Only the last patch adds full cpu emulation. Most of the previous ones fix bugs or add new devices and can be applied independently.
Tristan.
Quoted 5 lines · Brian Wheeler
I applied the patches and I don't see an alpha-softmmu like the other full-machine emulators. And I don't see anything in the makefiles for qemu-system-alpha.
Am I missing something obvious?
You have to configure with --target-list=alpha-softmmu. It is not build by default yet because you can't go really father that the firmware.
Tristan.
Quoted 6 lines · Tristan Gingold
Quoted 4 lines · Brian Wheeler
I applied the patches and I don't see an alpha-softmmu like the other full-machine emulators. And I don't see anything in the makefiles for qemu-system-alpha.
Quoted 9 lines
Quoted 1 line
Am I missing something obvious?
You have to configure with --target-list=alpha-softmmu. It is not build by default yet because you can't
go really father that the firmware.Tristan.
Neato. I built it and tried to generate the firmware per hw/es40.c and I get a cpu abort since hwe isn't handled...I tried commenting out the abort but I still didn't get the rom file.
That said, I'm really excited to see progress in this area, since the es40 emulator kind of died out...
Thanks!
Brian
Quoted 4 lines · Brian Wheeler
Neato. I built it and tried to generate the firmware per
hw/es40.cand I get a cpu abort since hwe isn't handled...I tried commenting out the abort but I still didn't get the rom file.
Argh, try with:
target-alpha/helper.c +1 -2
@@ -387,8 +387,7 @@ void cpu_alpha_mtpr_21264 (CPUState *env, int iprn, uint64_tunsigned char old_sde1 = env->a21264.sde1; env->a21264.i_vptb = ((((int64_t )val) <<16 ) >>16 ) &0xffffffffc0000000ULL ; -if ((val >>IPR_I_CTL_HWE_SHIFT ) &1 ) -cpu_abort (env,"mtpr i_ctl: hwe not yet handled\n" ); + env->a21264.hwe = (val >>IPR_I_CTL_HWE_SHIFT ) &1 ; env->a21264.sde1 = (val >>IPR_I_CTL_SDE1_SHIFT ) &1 ; env->a21264.iva_48 = (val >>IPR_I_CTL_VA_48_SHIFT ) &3 ; env->a21264.itlb.spe = (val >>IPR_I_CTL_SPE_SHIFT ) &7 ;
target-alpha/translate.c +8 -0
@@ -2429,6 +2429,14 @@ static always_inline void gen_intermediate_code_internal#else ctx.mem_idx = env->mmu_data_index; ctx.pal_mode = env->pal_mode; +switch (env->pal_emul) { +case PAL_21264 : +if (env->a21264.hwe && env->a21264.cm ==0 ) + ctx.pal_mode =1 ; +break ; +default : +break ; + }#endif ctx.fen = env->fen; num_insns =0 ;
Quoted 2 lines
That said, I'm really excited to see progress in this area, since the es40 emulator kind of died out...
Yes! Thanks.
Tristan.
Quoted 10 lines · Tristan Gingold
Hi,
these patches add alpha system emulation. Currently it emulates an es40 system just enough to get the firmware prompt.
This is the second version of the patches. They addresses the comments made and I made a very improvments too.
Only the last patch adds full cpu emulation. Most of the previous ones fix bugs or add new devices and can be applied independently.
I have already applied TCG related patches (2, 3, 4, 6 and 17), I'll look at other patches later.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 6 lines · Aurelien Jarno
Quoted 5 lines · Tristan Gingold
Hi,
these patches add alpha system emulation. Currently it emulates an es40 system just enough to get the firmware prompt.
Quoted 9 lines
Quoted 5 lines
This is the second version of the patches. They addresses the comments made and I made a very improvments too.
Only the last patch adds full cpu emulation. Most of the previous ones fix bugs or add new devices and can be applied independently.
I have already applied TCG related patches (2, 3, 4, 6 and 17), I'll look at other patches later.
I have also applied 16, 19, 19.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net