Skip to contentSkip to conversation

: add alpha es40 system emulation (v4)

PATCH In review Tristan Gingold 3 participants 36 messages Mar 30, 2009 – Apr 21, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

cover : add alpha es40 system emulation (v4)

new version of alpha system emulation.

I have followed Paul Brook's advice and now patch 02 has only one code paths. For 32 bits address spaces the code looks equivalent to the current one. For address spaces lager than 32 bits, only the size of level may have changed.

I have also fixed the comment (thanks to Aurelien) in path 05.

Two new bugs in alpha tcg code have been fixed (see pathes 07 and 08)

Some bugs have also been fixed in system emulation code. I am making progress... With some additionnal patches, I can now run AlphaBIOS.

Comments and reviews are welcome,
Tristan.

#1 lore raw

PATCH 1/19 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, 26 insertions(+), 24 deletions(-)
exec.c +25 -23
index df22c79..4b2ebc2 100644
@@ -147,15 +147,14 @@ 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)
+
+#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 (32 - L2_BITS - TARGET_PAGE_BITS)
+#define L1_BITS L1_BITS_
 #endif
+#define L1_SHIFT (TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS - L1_BITS)
 
 #define L1_SIZE (1 << L1_BITS)
 #define L2_SIZE (1 << L2_BITS)
@@ -165,7 +164,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;
 
@@ -338,25 +339,26 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
 {
     void **lp, **p;
     PhysPageDesc *pd;
+    int i;
 
+    /* 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
-    lp = p + ((index >> (L1_BITS + L2_BITS)) & (L1_SIZE - 1));
-    p = *lp;
-    if (!p) {
-        /* allocate if not found */
-        if (!alloc)
-            return NULL;
-        p = qemu_vmalloc(sizeof(void *) * L1_SIZE);
-        memset(p, 0, sizeof(void *) * L1_SIZE);
-        *lp = p;
+    /* 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));
     }
-#endif
-    lp = p + ((index >> L2_BITS) & (L1_SIZE - 1));
+
     pd = *lp;
     if (!pd) {
         int i;
Signature · 1 line
1.6.2
#2 lore raw

PATCH 2/19 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
index 4b2ebc2..5dc6bc7 100644
@@ -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
#3 lore raw

PATCH 3/19 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
index a9f1c0f..582827e 100644
@@ -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
#4 lore raw

PATCH 4/19 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
index 5dc6bc7..7c2def0 100644
@@ -1736,12 +1736,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 *));
@@ -1785,9 +1791,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);
@@ -1871,10 +1880,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
     }
 }
@@ -1920,10 +1933,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
 }
 
@@ -1945,9 +1962,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
index 9cc4535..a43e621 100644
@@ -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 >= 5) */
+
+#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
#5 lore raw

PATCH 5/19 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
index 143aca1..a661cb1 100644
@@ -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
index a1b3808..f6f83da 100644
@@ -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
index 582827e..3798157 100644
@@ -331,16 +331,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
index 7ad1b3d..433a0da 100644
@@ -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
index f98655f..c0cfb8d 100644
@@ -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
index e98a48d..807a55a 100644
@@ -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
index d5fcb9e..20699e9 100644
@@ -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
index 90bceab..f3ccb53 100644
@@ -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
index e2529eb..94af716 100644
@@ -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
index b415dc4..a793166 100644
@@ -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
index 87b3460..4d75ced 100644
@@ -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
index aea7108..eaae3cf 100644
@@ -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
index 8b84789..33cf4c3 100644
@@ -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
index d059408..017c375 100644
@@ -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
#6 lore raw

PATCH 6/19 Bug fix alpha: stop translation if too long

---
 target-alpha/translate.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
target-alpha/translate.c +3 -3
index e9463ae..dad1686 100644
@@ -2401,10 +2401,10 @@ static always_inline void gen_intermediate_code_internal (CPUState *env,
         ret = translate_one(ctxp, insn);
         if (ret != 0)
             break;
-        /* if we reach a page boundary or are single stepping, stop
-         * generation
-         */
+        /* if we reach a page boundary, or translation is too long
+           or are single stepping, stop generation.  */
         if (((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) ||
+            gen_opc_ptr >= gen_opc_end ||
             num_insns >= max_insns) {
             break;
         }
Signature · 1 line
1.6.2
#7 lore raw

PATCH 7/19 Alpha bug: fix palcode mask for user pal calls

(Also 6 bits for unprivileged calls)

---
 target-alpha/translate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/translate.c +1 -1
index dad1686..821f0d4 100644
@@ -685,7 +685,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)
         /* CALL_PAL */
         if (palcode >= 0x80 && palcode < 0xC0) {
             /* Unprivileged PAL call */
-            gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x1F) << 6), 0);
+            gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x3F) << 6), 0);
 #if !defined (CONFIG_USER_ONLY)
         } else if (palcode < 0x40) {
             /* Privileged PAL code */
Signature · 1 line
1.6.2
#8 lore raw

PATCH 8/19 Alpha: document more registers used by 21264

---
 target-alpha/cpu.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
target-alpha/cpu.h +2 -2
index 3798157..db53650 100644
@@ -158,7 +158,7 @@ enum {
     IPR_ITB_PTE      = 0x01,            /* 21264 */
     IPR_ITB_IAP      = 0x02,
     IPR_ITB_IA       = 0x03,            /* 21264 */
-    IPR_ITB_IS       = 0x04,
+    IPR_ITB_IS       = 0x04,            /* 21264 */
     IPR_PMPC         = 0x05,
     IPR_EXC_ADDR     = 0x06,            /* 21264 */
     IPR_IVA_FORM     = 0x07,            /* 21264 */
@@ -221,7 +221,7 @@ enum {
     IPR_M_CTL        = 0x28,            /* 21264 */
 #define IPR_M_CTL_SPE_SHIFT 1
 #define IPR_M_CTL_SPE_MASK 7
-    IPR_DC_CTL       = 0x29,
+    IPR_DC_CTL       = 0x29,            /* 21264 */
     IPR_DC_STAT      = 0x2A,            /* 21264 */
     /* Cbox IPRs */
     IPR_C_DATA       = 0x2B,
Signature · 1 line
1.6.2
#9 lore raw

PATCH 9/19 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
index 5b08d72..f6bb21d 100644
@@ -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   0x04
 
 struct 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 defined TARGET_I386 || defined TARGET_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] & REG_B_PIE) && !hpet_in_legacy_mode()) {
+    enable_pie = hpet_in_legacy_mode();
 #else
-    if (period_code != 0 && (s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
+    enable_pie = 1;
 #endif
+    if (period_code != 0
+        && (((s->cmos_data[RTC_REG_B] & REG_B_PIE) && enable_pie)
+            || ((s->cmos_data[RTC_REG_B] & REG_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] & REG_B_PIE) {
+        s->cmos_data[RTC_REG_C] |= 0xc0;
+        rtc_irq_raise(s->irq);
+    }
+    if (s->cmos_data[RTC_REG_B] & REG_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
index 5b378d4..7345f04 100644
@@ -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
#10 lore raw

PATCH 10/19 Add ali1543 super IO pci device.

This is a very partial implementation just enough for es40 firmware.

---
 hw/ali1543.c |  150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci.h     |    5 ++
 hw/pci_ids.h |    3 +
 3 files changed, 158 insertions(+), 0 deletions(-)
 create mode 100644 hw/ali1543.c
hw/ali1543.c new file +150 -0
new file mode 100644
index 0000000..c4b0572
@@ -0,0 +1,150 @@
+/*
+ * 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;
+    uint32_t res;
+
+    if ((addr & 1) == 0) {
+        if (ali->cfg_state != CFG_EN) {
+            qemu_log("ali1543-cfg: read fromcfg_port\n");
+            res = 0;
+        }
+        else
+            res = ali->cfg_index;
+    }
+    else {
+        switch (ali->cfg_index) {
+        case 0x20:
+            res = 0x43;
+            break;
+        case 0x21:
+            res = 0x15;
+            break;
+        default:
+#ifdef DEBUG_CFG
+            qemu_log("ali1543-cfg: read from reg %02x\n", ali->cfg_index);
+#endif
+            res = 0;
+            break;
+        }
+    }
+    return res;
+}
+
+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
index 831f1b1..e4e0738 100644
@@ -261,4 +261,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
index 427fcd5..4119ead 100644
@@ -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
#11 lore raw

PATCH 11/19 Add 21272 chipset (memory and pci controller for alpha)

---
 hw/21272.c |  869 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci.h   |    8 +
 2 files changed, 877 insertions(+), 0 deletions(-)
 create mode 100644 hw/21272.c
hw/21272.c new file +869 -0
new file mode 100644
index 0000000..a54dd59
@@ -0,0 +1,869 @@
+/*
+ * 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;
+    uint32_t plat;
+    /* 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;
+    case 0x0c:
+        val = s->drir;
+        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 = 0x01 * 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 */
+            | (1 << 24) /* Rev */
+            | (s->mwin << 6)
+            | (s->hole << 5)
+            | (s->chaindis << 3);
+        break;
+    case 0x0d: /* plat */
+        val = s->plat;
+        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 0x0d: /* plat */
+        s->plat = val & 0xff00;
+        break;
+    case 0x0f: /* PERROR */
+        break; /* Not emulated.  */
+    case 0x10: /* PERRMASK */
+        s->perrmask = val & 0xfff;
+        break;
+    case 0x13: /* tlbia */
+        /* FIXME: todo */
+        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;
+
+    if (s->num == 0)
+        val = pci_data_read(s->pci, a, 1 << sz);
+    else {
+        switch (sz) {
+        case 0:
+            val = 0xff;
+            break;
+        case 1:
+            val = 0xffff;
+            break;
+        default:
+        case 2:
+            val = 0xffffffff;
+            break;
+        }
+    }
+
+#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);
+
+    /* Pchip0 PCI cfg  */
+    pci_cfg = cpu_register_io_memory(0, pchip_pci_cfg_read,
+                                    pchip_pci_cfg_write, &s->pchip[1]);
+    cpu_register_physical_memory(0x803fe000000ULL, 0x0010000, pci_cfg);
+
+    s->pchip[0].pci = pci_register_bus(typhoon_set_irq,
+                                       typhoon_map_irq,
+                                       (void *)&s->pchip[0], 0, 64);
+
+    pci_mem_base = 0x80000000000ULL;
+    isa_mem_base = 0x80000000000ULL;
+
+    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
index e4e0738..4f2496f 100644
@@ -261,6 +261,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
#12 lore raw

PATCH 12/19 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
index f862d90..68937fe 100644
@@ -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
index 1e18ba6..48c9821 100644
@@ -127,4 +127,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
new file mode 100644
index 0000000..ed42af9
@@ -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
#13 lore raw

PATCH 13/19 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
index 9ea7030..0ce82c8 100644
@@ -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
index 433a0da..4b6ada7 100644
@@ -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)
 {
     tb_flush(env);
Signature · 1 line
1.6.2
#14 lore raw

PATCH 14/19 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
index 4c4855d..7c7278f 100644
@@ -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
index 821f0d4..41f24a5 100644
@@ -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
#15 lore raw

PATCH 15/19 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
index db53650..c27e89f 100644
@@ -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
index 41f24a5..dab8d78 100644
@@ -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
#16 lore raw

PATCH 16/19 Alpha: lower parent irq when irq is lowered.

---
 hw/i8259.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/i8259.c +1 -1
index f813525..adabd2b 100644
@@ -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
#17 lore raw

PATCH 17/19 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
index 68937fe..de6f7eb 100644
@@ -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
index c27e89f..7cd6395 100644
@@ -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
index fc68a7e..4046463 100644
@@ -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
index dab8d78..061cf5f 100644
@@ -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
#18 lore raw

PATCH 18/19 Correctly decode hw_ld/hw_st opcodes for all alpha implementations.

Allow privilegied pal_code only in kernel mode.

---
 target-alpha/translate.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)
target-alpha/translate.c +23 -7
index 061cf5f..6938b5d 100644
@@ -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);
@@ -2089,7 +2104,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)
         } 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
#19 lore raw

PATCH 19/19 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       |  286 +++++++++++------
 target-alpha/helper.c    |  798 +++++++++++++++++++++++++++++-----------------
 target-alpha/helper.h    |    6 +-
 target-alpha/op_helper.c |  199 ++++++++-----
 target-alpha/translate.c |  153 +++++----
 7 files changed, 944 insertions(+), 536 deletions(-)
cpu-exec.c +1 -0
index cf7c1fb..674d521 100644
@@ -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
index 189033c..c778319 100644
@@ -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 +188 -98

362 lines not on this page · raw message

target-alpha/helper.c +507 -291

887 lines not on this page · raw message

target-alpha/helper.h +2 -4
index 7c7278f..eaab3d0 100644
@@ -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 +127 -72

331 lines not on this page · raw message

target-alpha/translate.c +86 -67

273 lines not on this page · raw message

Signature · 1 line
1.6.2
#20 lore raw

Re: [Qemu-devel] [PATCH 18/19] Correctly decode hw_ld/hw_st opcodes for all alpha implementations.

In reply to Tristan Gingold
Quoted 90 lines · Tristan Gingold

Allow privilegied pal_code only in kernel mode.

---
 target-alpha/translate.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)
target-alpha/translate.c +22 -7
index 061cf5f..6938b5d 100644
@@ -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);
@@ -2089,7 +2104,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)
         } 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:

target-alpha/translate.c static always_inline void gen_intermediate_code_internal (CPUState *env, · line 2373

Quoted 7 lines
target-alpha/translate.c +1 -0
@@ -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

implver is defined once at init time, and I don't expect it to change once qemu has been started. Therefore I think there is no need to copy env->implver into ctx.implver, env->implver can be accessed directly, even from translate.c

Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#21 lore raw

Re: [Qemu-devel] [PATCH 18/19] Correctly decode hw_ld/hw_st opcodes for all alpha implementations.

Quoted 4 lines · Aurelien Jarno

implver is defined once at init time, and I don't expect it to change once qemu has been started. Therefore I think there is no need to copy env->implver into ctx.implver, env->implver can be accessed directly, even from translate.c

Yes, I definitely agree with you. I have already slightly changes this patch also to avoid to use an helper for implver instruction.

To be submitted very soon.

Thank you,
Tristan.

#22 lore raw

Re: [Qemu-devel] [PATCH 16/19] Alpha: lower parent irq when irq is lowered.

In reply to Tristan Gingold
Quoted 4 lines · Tristan Gingold
---
 hw/i8259.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Thanks, applied.

Quoted 19 lines
hw/i8259.c +1 -1
index f813525..adabd2b 100644
@@ -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
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#23 lore raw

Re: [Qemu-devel] [PATCH 09/19] Add square wave output support.

In reply to Tristan Gingold
Quoted 4 lines · Tristan Gingold

This is necessary for es40 as the sqw output is directly connected to the core chipset.

Thanks, applied.

Quoted 122 lines
---
 hw/mc146818rtc.c |   39 +++++++++++++++++++++++++++++----------
 hw/pc.h          |    1 +
 2 files changed, 30 insertions(+), 10 deletions(-)
hw/mc146818rtc.c +29 -10
index 5b08d72..f6bb21d 100644
@@ -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   0x04
 
 struct 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 defined TARGET_I386 || defined TARGET_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] & REG_B_PIE) && !hpet_in_legacy_mode()) {
+    enable_pie = hpet_in_legacy_mode();
 #else
-    if (period_code != 0 && (s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
+    enable_pie = 1;
 #endif
+    if (period_code != 0
+        && (((s->cmos_data[RTC_REG_B] & REG_B_PIE) && enable_pie)
+            || ((s->cmos_data[RTC_REG_B] & REG_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] & REG_B_PIE) {
+        s->cmos_data[RTC_REG_C] |= 0xc0;
+        rtc_irq_raise(s->irq);
+    }
+    if (s->cmos_data[RTC_REG_B] & REG_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
index 5b378d4..7345f04 100644
@@ -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
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#24 lore raw

Re: [Qemu-devel] [PATCH 08/19] Alpha: document more registers used by 21264

In reply to Tristan Gingold
Quoted 4 lines · Tristan Gingold
---
 target-alpha/cpu.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Thanks, applied.

Quoted 28 lines
target-alpha/cpu.h +2 -2
index 3798157..db53650 100644
@@ -158,7 +158,7 @@ enum {
     IPR_ITB_PTE      = 0x01,            /* 21264 */
     IPR_ITB_IAP      = 0x02,
     IPR_ITB_IA       = 0x03,            /* 21264 */
-    IPR_ITB_IS       = 0x04,
+    IPR_ITB_IS       = 0x04,            /* 21264 */
     IPR_PMPC         = 0x05,
     IPR_EXC_ADDR     = 0x06,            /* 21264 */
     IPR_IVA_FORM     = 0x07,            /* 21264 */
@@ -221,7 +221,7 @@ enum {
     IPR_M_CTL        = 0x28,            /* 21264 */
 #define IPR_M_CTL_SPE_SHIFT 1
 #define IPR_M_CTL_SPE_MASK 7
-    IPR_DC_CTL       = 0x29,
+    IPR_DC_CTL       = 0x29,            /* 21264 */
     IPR_DC_STAT      = 0x2A,            /* 21264 */
     /* Cbox IPRs */
     IPR_C_DATA       = 0x2B,
Signature · 1 line
1.6.2
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#25 lore raw

Re: [Qemu-devel] [PATCH 07/19] Alpha bug: fix palcode mask for user pal calls

In reply to Tristan Gingold
Quoted 3 lines · Tristan Gingold

(Also 6 bits for unprivileged calls)

Thanks, applied.

Quoted 23 lines
---
 target-alpha/translate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/translate.c +1 -1
index dad1686..821f0d4 100644
@@ -685,7 +685,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)
         /* CALL_PAL */
         if (palcode >= 0x80 && palcode < 0xC0) {
             /* Unprivileged PAL call */
-            gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x1F) << 6), 0);
+            gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x3F) << 6), 0);
 #if !defined (CONFIG_USER_ONLY)
         } else if (palcode < 0x40) {
             /* Privileged PAL code */
Signature · 1 line
1.6.2
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#26 lore raw

Re: [Qemu-devel] [PATCH 06/19] Bug fix alpha: stop translation if too long

In reply to Tristan Gingold
Quoted 4 lines · Tristan Gingold
---
 target-alpha/translate.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

I have applied a slightly different patch to split the tests into different if for better readability. Thanks.

Quoted 24 lines
target-alpha/translate.c +3 -3
index e9463ae..dad1686 100644
@@ -2401,10 +2401,10 @@ static always_inline void gen_intermediate_code_internal (CPUState *env,
         ret = translate_one(ctxp, insn);
         if (ret != 0)
             break;
-        /* if we reach a page boundary or are single stepping, stop
-         * generation
-         */
+        /* if we reach a page boundary, or translation is too long
+           or are single stepping, stop generation.  */
         if (((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) ||
+            gen_opc_ptr >= gen_opc_end ||
             num_insns >= max_insns) {
             break;
         }
Signature · 1 line
1.6.2
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#27 lore raw

Re: [Qemu-devel] [PATCH 05/19] Split cpu_mmu_index into cpu_mmu_index_data and cpu_mmu_index_code.

In reply to Tristan Gingold
Quoted 85 lines · Tristan Gingold

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
index 143aca1..a661cb1 100644
@@ -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
index a1b3808..f6f83da 100644
@@ -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
index 582827e..3798157 100644
@@ -331,16 +331,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;
 }
 
Quoted 1 line

From where env->mmu_data_index and env->mmu_code_index come from? After

applying this patch, I get:

CC main.o
In file included from /home/aurel32/git/qemu/linux-user/qemu.h:8,

                 from /home/aurel32/git/qemu/linux-user/main.c:30:

/home/aurel32/git/qemu/target-alpha/cpu.h: In function 'cpu_mmu_index_data':
/home/aurel32/git/qemu/target-alpha/cpu.h:347: error: 'struct CPUAlphaState' has no member named 'mmu_data_index' /home/aurel32/git/qemu/target-alpha/cpu.h: In function 'cpu_mmu_index_code':
/home/aurel32/git/qemu/target-alpha/cpu.h:352: error: 'struct CPUAlphaState' has no member named 'mmu_code_index' /home/aurel32/git/qemu/linux-user/main.c: In function 'main':
/home/aurel32/git/qemu/linux-user/main.c:2359: warning: implicit declaration of function 'alpha_cpu_list'
make: *** [main.o] Error 1

Quoted 185 lines

#if defined(CONFIG_USER_ONLY)

target-alpha/op_helper.c +2 -2
index 7ad1b3d..433a0da 100644
@@ -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
index f98655f..c0cfb8d 100644
@@ -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
index e98a48d..807a55a 100644
@@ -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
index d5fcb9e..20699e9 100644
@@ -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
index 90bceab..f3ccb53 100644
@@ -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
index e2529eb..94af716 100644
@@ -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
index b415dc4..a793166 100644
@@ -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
index 87b3460..4d75ced 100644
@@ -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
index aea7108..eaae3cf 100644
@@ -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
index 8b84789..33cf4c3 100644
@@ -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
index d059408..017c375 100644
@@ -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
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#28 lore raw

Re: [Qemu-devel] [PATCH 05/19] Split cpu_mmu_index into cpu_mmu_index_data and cpu_mmu_index_code.

Quoted 4 lines · Aurelien Jarno
Quoted 3 lines · Tristan Gingold

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.

[...]

Quoted 6 lines
Quoted 6 lines
target-alpha/cpu.h +2 -0
+#define MMU_PAL_IDX 4
+static inline int cpu_mmu_index_data (CPUState *env)

{

target-alpha/cpu.h +2 -1
-    return (env->ps >> 3) & 3;
+    return env->mmu_data_index;
+}
Quoted 8 lines
Quoted 5 lines
target-alpha/cpu.h +4 -0
+
+static inline int cpu_mmu_index_code (CPUState *env)
+{
+    return env->mmu_code_index;

}

From where env->mmu_data_index and env->mmu_code_index come from? After applying this patch, I get:

Yes, the dependancy is wrong. I will fix it.

Tristan.

#29 lore raw

Re: [Qemu-devel] [PATCH 04/19] Allow 5 mmu indexes.

In reply to Tristan Gingold
Quoted 3 lines · Tristan Gingold

This is necessary for alpha because it has 4 protection levels and pal mode.

Thanks, applied.

Quoted 143 lines
---
 exec.c         |   30 +++++++++++++++++++++++++-----
 softmmu_exec.h |   29 ++++++++++++++++++++++++-----
 2 files changed, 49 insertions(+), 10 deletions(-)
exec.c +25 -5
index 5dc6bc7..7c2def0 100644
@@ -1736,12 +1736,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 *));
@@ -1785,9 +1791,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);
@@ -1871,10 +1880,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
     }
 }
@@ -1920,10 +1933,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
 }
 
@@ -1945,9 +1962,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
index 9cc4535..a43e621 100644
@@ -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 >= 5) */
+
+#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
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#30 lore raw

Re: [Qemu-devel] [PATCH 03/19] Alpha: set target page size to 13 bits.

In reply to Tristan Gingold
Quoted 3 lines · Tristan Gingold

(As defined by the alpha arch ref).

Thanks, applied.

Quoted 23 lines
---
 target-alpha/cpu.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/cpu.h +1 -1
index a9f1c0f..582827e 100644
@@ -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
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#31 lore raw

Re: [Qemu-devel] [PATCH 01/19] Add support for multi-level phys map.

In reply to Tristan Gingold
Quoted 78 lines · Tristan Gingold

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, 26 insertions(+), 24 deletions(-)
exec.c +21 -21
index df22c79..4b2ebc2 100644
@@ -147,15 +147,14 @@ 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)
+
+#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 (32 - L2_BITS - TARGET_PAGE_BITS)
+#define L1_BITS L1_BITS_
 #endif
+#define L1_SHIFT (TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS - L1_BITS)
 
 #define L1_SIZE (1 << L1_BITS)
 #define L2_SIZE (1 << L2_BITS)
@@ -165,7 +164,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;
 
@@ -338,25 +339,26 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
 {
     void **lp, **p;
     PhysPageDesc *pd;
+    int i;
 
+    /* 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
-    lp = p + ((index >> (L1_BITS + L2_BITS)) & (L1_SIZE - 1));
-    p = *lp;
-    if (!p) {
-        /* allocate if not found */
-        if (!alloc)
-            return NULL;
-        p = qemu_vmalloc(sizeof(void *) * L1_SIZE);
-        memset(p, 0, sizeof(void *) * L1_SIZE);
-        *lp = p;
+    /* 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);

exec.c static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) · line 364

Quoted 10 lines
exec.c +4 -2
+            *lp = p;
+        }
+        lp = p + ((index >> (i * L2_BITS)) & (L2_SIZE - 1));
     }
-#endif
-    lp = p + ((index >> L2_BITS) & (L1_SIZE - 1));
+
     pd = *lp;
     if (!pd) {
         int i;

While this part of the patch looks ok, it seems that some other parts of exec.c needs to be modified to accommodate the new multi-level map. Is some parts of the patch missing?

Also I think that we should remove L2_* into LN_* to show it is actually a multilevel map.

Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#32 lore raw

Re: [Qemu-devel] [PATCH 01/19] Add support for multi-level phys map.

Quoted 4 lines · Aurelien Jarno
Quoted 3 lines · Tristan Gingold

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.

[...]

Quoted 3 lines

While this part of the patch looks ok, it seems that some other parts of exec.c needs to be modified to accommodate the new multi-level map. Is some parts of the patch missing?

No, I think it is complete. Can you point out which part seems to be modified ?

Quoted 2 lines

Also I think that we should remove L2_* into LN_* to show it is actually a multilevel map.

Yes, good idea.

Tristan.

#33 lore raw
In reply to Tristan Gingold

I get a fatal message on boot:

es40: arr[0]=0000000000004005: 128MB at 128MB
qemu: fatal: cpu_alpha_mtpr_21264: ipr 0x80 not handled

Putting an empty case in helper.c gets past that, but then fails on 0xf0 and 0x22. Then it fails on pctx.astrr

Brian

Quoted 18 lines · Tristan Gingold

new version of alpha system emulation.

I have followed Paul Brook's advice and now patch 02 has only one code paths. For 32 bits address spaces the code looks equivalent to the current one. For address spaces lager than 32 bits, only the size of level may have changed.

I have also fixed the comment (thanks to Aurelien) in path 05.

Two new bugs in alpha tcg code have been fixed (see pathes 07 and 08)

Some bugs have also been fixed in system emulation code. I am making progress... With some additionnal patches, I can now run AlphaBIOS.

Comments and reviews are welcome,
Tristan.

#34 lore raw
Quoted 8 lines · Brian Wheeler

I get a fatal message on boot:

es40: arr[0]=0000000000004005: 128MB at 128MB
qemu: fatal: cpu_alpha_mtpr_21264: ipr 0x80 not handled

Putting an empty case in helper.c gets past that, but then fails on 0xf0 and 0x22. Then it fails on pctx.astrr

Looks like garbage is executed. Can you send to me /tmp/qemu.log when run with -d in_asm,cpu,exec ?

Thanks,
Tristan.

#35 lore raw
Quoted 12 lines · Tristan Gingold
Quoted 9 lines · Brian Wheeler

I get a fatal message on boot:

es40: arr[0]=0000000000004005: 128MB at 128MB
qemu: fatal: cpu_alpha_mtpr_21264: ipr 0x80 not handled

Putting an empty case in helper.c gets past that, but then fails on 0xf0
and 0x22. Then it fails on pctx.astrr

Quoted 8 lines

Looks like garbage is executed. Can you send to me /tmp/qemu.log when run with -d in_asm,cpu,exec ?

Thanks,
Tristan.

Its attached.

Brian

pc 0000000000008000 mem_idx 0
opcode 47ff0410 2
opc 11 ra 31 rb 31 rc 16 disp16 0410
pc 0000000000008004 mem_idx 0
opcode c3402e1e 4
opc 30 ra 26 rb 0 rc 30 disp16 2e1e

     PC  0000000000008000      pal=1
IR00 v0  0000000000000000 IR01 t0  0000000000000000 IR02 t1  0000000000000000 
IR03 t2  0000000000000000 IR04 t3  0000000000000000 IR05 t4  0000000000000000 
IR06 t5  0000000000000000 IR07 t6  0000000000000000 IR08 t7  0000000000000000 
IR09 s0  0000000000000000 IR10 s1  0000000000000000 IR11 s2  0000000000000000 
IR12 s3  0000000000000000 IR13 s4  0000000000000000 IR14 s5  0000000000000000 
IR15 fp  0000000000000000 IR16 a0  0000000000000000 IR17 a1  0000000000000000 
IR18 a2  0000000000000000 IR19 a3  0000000000000000 IR20 a4  0000000000000000 
IR21 a5  0000000000000000 IR22 t8  0000000000000000 IR23 t9  0000000000000000 
IR24 t10 0000000000000000 IR25 t11 0000000000000000 IR26 ra  0000000000000000 
IR27 t12 0000000000000000 IR28 at  0000000000000000 IR29 gp  0000000000000000 
IR30 sp  0000000000000000 
FIR00    0000000000000000 FIR01    0000000000000000 FIR02    0000000000000000 
FIR03    0000000000000000 FIR04    0000000000000000 FIR05    0000000000000000 
FIR06    0000000000000000 FIR07    0000000000000000 FIR08    0000000000000000 
FIR09    0000000000000000 FIR10    0000000000000000 FIR11    0000000000000000 
FIR12    0000000000000000 FIR13    0000000000000000 FIR14    0000000000000000 
FIR15    0000000000000000 FIR16    0000000000000000 FIR17    0000000000000000 
FIR18    0000000000000000 FIR19    0000000000000000 FIR20    0000000000000000 
FIR21    0000000000000000 FIR22    0000000000000000 FIR23    0000000000000000 
FIR24    0000000000000000 FIR25    0000000000000000 FIR26    0000000000000000 
FIR27    0000000000000000 FIR28    0000000000000000 FIR29    0000000000000000 
FIR30    0000000000000000 

IN:
0x0000000000008000: clr a0
0x0000000000008004: br ra,0x13880

pc 0000000000013880 mem_idx 0
opcode 44000400 6
opc 11 ra 0 rb 0 rc 0 disp16 0400
pc 0000000000013884 mem_idx 0
opcode 47ff041f 8
opc 11 ra 31 rb 31 rc 31 disp16 041f
pc 0000000000013888 mem_idx 0
opcode 47ff041f 10
opc 11 ra 31 rb 31 rc 31 disp16 041f
pc 000000000001388c mem_idx 0
opcode 47ff041f 12
opc 11 ra 31 rb 31 rc 31 disp16 041f
pc 0000000000013890 mem_idx 0
opcode 77ff0310 14
opc 1d ra 31 rb 31 rc 16 disp16 0310

     PC  0000000000013880      pal=1
IR00 v0  0000000000000000 IR01 t0  0000000000000000 IR02 t1  0000000000000000 
IR03 t2  0000000000000000 IR04 t3  0000000000000000 IR05 t4  0000000000000000 
IR06 t5  0000000000000000 IR07 t6  0000000000000000 IR08 t7  0000000000000000 
IR09 s0  0000000000000000 IR10 s1  0000000000000000 IR11 s2  0000000000000000 
IR12 s3  0000000000000000 IR13 s4  0000000000000000 IR14 s5  0000000000000000 
IR15 fp  0000000000000000 IR16 a0  0000000000000000 IR17 a1  0000000000000000 
IR18 a2  0000000000000000 IR19 a3  0000000000000000 IR20 a4  0000000000000000 
IR21 a5  0000000000000000 IR22 t8  0000000000000000 IR23 t9  0000000000000000 
IR24 t10 0000000000000000 IR25 t11 0000000000000000 IR26 ra  0000000000008008 
IR27 t12 0000000000000000 IR28 at  0000000000000000 IR29 gp  0000000000000000 
IR30 sp  0000000000000000 
FIR00    0000000000000000 FIR01    0000000000000000 FIR02    0000000000000000 
FIR03    0000000000000000 FIR04    0000000000000000 FIR05    0000000000000000 
FIR06    0000000000000000 FIR07    0000000000000000 FIR08    0000000000000000 
FIR09    0000000000000000 FIR10    0000000000000000 FIR11    0000000000000000 
FIR12    0000000000000000 FIR13    0000000000000000 FIR14    0000000000000000 
FIR15    0000000000000000 FIR16    0000000000000000 FIR17    0000000000000000 
FIR18    0000000000000000 FIR19    0000000000000000 FIR20    0000000000000000 
FIR21    0000000000000000 FIR22    0000000000000000 FIR23    0000000000000000 
FIR24    0000000000000000 FIR25    0000000000000000 FIR26    0000000000000000 
FIR27    0000000000000000 FIR28    0000000000000000 FIR29    0000000000000000 
FIR30    0000000000000000 
IN: 
0x0000000000013880:  mov	v0,v0
0x0000000000013884:  nop	
0x0000000000013888:  nop	
0x000000000001388c:  nop	
0x0000000000013890:  pal1d	0x3ff0310

pc 0000000000013894 mem_idx 0
opcode 77ffa380 16
opc 1d ra 31 rb 31 rc 0 disp16 ffffa380

     PC  0000000000013894      pal=1
IR00 v0  0000000000000000 IR01 t0  0000000000000000 IR02 t1  0000000000000000 
IR03 t2  0000000000000000 IR04 t3  0000000000000000 IR05 t4  0000000000000000 
IR06 t5  0000000000000000 IR07 t6  0000000000000000 IR08 t7  0000000000000000 
IR09 s0  0000000000000000 IR10 s1  0000000000000000 IR11 s2  0000000000000000 
IR12 s3  0000000000000000 IR13 s4  0000000000000000 IR14 s5  0000000000000000 
IR15 fp  0000000000000000 IR16 a0  0000000000000000 IR17 a1  0000000000000000 
IR18 a2  0000000000000000 IR19 a3  0000000000000000 IR20 a4  0000000000000000 
IR21 a5  0000000000000000 IR22 t8  0000000000000000 IR23 t9  0000000000000000 
IR24 t10 0000000000000000 IR25 t11 0000000000000000 IR26 ra  0000000000008008 
IR27 t12 0000000000000000 IR28 at  0000000000000000 IR29 gp  0000000000000000 
IR30 sp  0000000000000000 
FIR00    0000000000000000 FIR01    0000000000000000 FIR02    0000000000000000 
FIR03    0000000000000000 FIR04    0000000000000000 FIR05    0000000000000000 
FIR06    0000000000000000 FIR07    0000000000000000 FIR08    0000000000000000 
FIR09    0000000000000000 FIR10    0000000000000000 FIR11    0000000000000000 
FIR12    0000000000000000 FIR13    0000000000000000 FIR14    0000000000000000 
FIR15    0000000000000000 FIR16    0000000000000000 FIR17    0000000000000000 
FIR18    0000000000000000 FIR19    0000000000000000 FIR20    0000000000000000 
FIR21    0000000000000000 FIR22    0000000000000000 FIR23    0000000000000000 
FIR24    0000000000000000 FIR25    0000000000000000 FIR26    0000000000000000 
FIR27    0000000000000000 FIR28    0000000000000000 FIR29    0000000000000000 
FIR30    0000000000000000 

IN:
0x0000000000013894: pal1d 0x3ffa380

qemu: fatal: cpu_alpha_mtpr_21264: ipr 0x80 not handled

     PC  0000000000013894      pal=1
IR00 v0  0000000000000000 IR01 t0  0000000000000000 IR02 t1  0000000000000000 
IR03 t2  0000000000000000 IR04 t3  0000000000000000 IR05 t4  0000000000000000 
IR06 t5  0000000000000000 IR07 t6  0000000000000000 IR08 t7  0000000000000000 
IR09 s0  0000000000000000 IR10 s1  0000000000000000 IR11 s2  0000000000000000 
IR12 s3  0000000000000000 IR13 s4  0000000000000000 IR14 s5  0000000000000000 
IR15 fp  0000000000000000 IR16 a0  0000000000000000 IR17 a1  0000000000000000 
IR18 a2  0000000000000000 IR19 a3  0000000000000000 IR20 a4  0000000000000000 
IR21 a5  0000000000000000 IR22 t8  0000000000000000 IR23 t9  0000000000000000 
IR24 t10 0000000000000000 IR25 t11 0000000000000000 IR26 ra  0000000000008008 
IR27 t12 0000000000000000 IR28 at  0000000000000000 IR29 gp  0000000000000000 
IR30 sp  0000000000000000 
FIR00    0000000000000000 FIR01    0000000000000000 FIR02    0000000000000000 
FIR03    0000000000000000 FIR04    0000000000000000 FIR05    0000000000000000 
FIR06    0000000000000000 FIR07    0000000000000000 FIR08    0000000000000000 
FIR09    0000000000000000 FIR10    0000000000000000 FIR11    0000000000000000 
FIR12    0000000000000000 FIR13    0000000000000000 FIR14    0000000000000000 
FIR15    0000000000000000 FIR16    0000000000000000 FIR17    0000000000000000 
FIR18    0000000000000000 FIR19    0000000000000000 FIR20    0000000000000000 
FIR21    0000000000000000 FIR22    0000000000000000 FIR23    0000000000000000 
FIR24    0000000000000000 FIR25    0000000000000000 FIR26    0000000000000000 
FIR27    0000000000000000 FIR28    0000000000000000 FIR29    0000000000000000 
FIR30    0000000000000000