]> git.proxmox.com Git - mirror_qemu.git/blobdiff - target-sparc/helper.c
find -type f | xargs sed -i 's/[\t ]$//g' # on most files
[mirror_qemu.git] / target-sparc / helper.c
index 982b7fcdec7ae8b1949dafead321b84db7c036e1..af4a8b00acb255d5421c8d78027aadda2fa450b7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  sparc helpers
- * 
+ *
  *  Copyright (c) 2003-2005 Fabrice Bellard
  *
  * This library is free software; you can redistribute it and/or
@@ -46,7 +46,7 @@ void cpu_unlock(void)
     spin_unlock(&global_cpu_lock);
 }
 
-#if defined(CONFIG_USER_ONLY) 
+#if defined(CONFIG_USER_ONLY)
 
 int cpu_sparc_handle_mmu_fault(CPUState *env, target_ulong address, int rw,
                                int is_user, int is_softmmu)
@@ -117,7 +117,7 @@ int get_physical_address (CPUState *env, target_phys_addr_t *physical, int *prot
     }
 
     *access_index = ((rw & 1) << 2) | (rw & 2) | (is_user? 0 : 1);
-    *physical = 0xfffff000;
+    *physical = 0xffffffffffff0000ULL;
 
     /* SPARC reference MMU table walk: Context table->L1->L2->PTE */
     /* Context base + context number */
@@ -203,7 +203,7 @@ int get_physical_address (CPUState *env, target_phys_addr_t *physical, int *prot
 
     /* Even if large ptes, we map only one 4KB page in the cache to
        avoid filling it too fast */
-    *physical = ((pde & PTE_ADDR_MASK) << 4) + page_offset;
+    *physical = ((target_phys_addr_t)(pde & PTE_ADDR_MASK) << 4) + page_offset;
     return error_code;
 }
 
@@ -212,7 +212,7 @@ int cpu_sparc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
                               int is_user, int is_softmmu)
 {
     target_phys_addr_t paddr;
-    unsigned long vaddr;
+    target_ulong vaddr;
     int error_code = 0, prot, ret = 0, access_index;
 
     error_code = get_physical_address(env, &paddr, &prot, &access_index, address, rw, is_user);
@@ -220,7 +220,8 @@ int cpu_sparc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
        vaddr = address & TARGET_PAGE_MASK;
        paddr &= TARGET_PAGE_MASK;
 #ifdef DEBUG_MMU
-       printf("Translate at 0x%lx -> 0x%lx, vaddr 0x%lx\n", (long)address, (long)paddr, (long)vaddr);
+       printf("Translate at " TARGET_FMT_lx " -> " TARGET_FMT_plx ", vaddr "
+               TARGET_FMT_lx "\n", address, paddr, vaddr);
 #endif
        ret = tlb_set_page_exec(env, vaddr, paddr, prot, is_user, is_softmmu);
        return ret;
@@ -255,7 +256,8 @@ target_ulong mmu_probe(CPUState *env, target_ulong address, int mmulev)
     uint32_t pde;
 
     /* Context base + context number */
-    pde_ptr = (env->mmuregs[1] << 4) + (env->mmuregs[2] << 2);
+    pde_ptr = (target_phys_addr_t)(env->mmuregs[1] << 4) +
+        (env->mmuregs[2] << 2);
     pde = ldl_phys(pde_ptr);
 
     switch (pde & PTE_ENTRYTYPE_MASK) {
@@ -314,30 +316,35 @@ target_ulong mmu_probe(CPUState *env, target_ulong address, int mmulev)
 #ifdef DEBUG_MMU
 void dump_mmu(CPUState *env)
 {
-     target_ulong va, va1, va2;
-     unsigned int n, m, o;
-     target_phys_addr_t pde_ptr, pa;
+    target_ulong va, va1, va2;
+    unsigned int n, m, o;
+    target_phys_addr_t pde_ptr, pa;
     uint32_t pde;
 
     printf("MMU dump:\n");
     pde_ptr = (env->mmuregs[1] << 4) + (env->mmuregs[2] << 2);
     pde = ldl_phys(pde_ptr);
-    printf("Root ptr: " TARGET_FMT_lx ", ctx: %d\n", env->mmuregs[1] << 4, env->mmuregs[2]);
+    printf("Root ptr: " TARGET_FMT_plx ", ctx: %d\n",
+           (target_phys_addr_t)env->mmuregs[1] << 4, env->mmuregs[2]);
     for (n = 0, va = 0; n < 256; n++, va += 16 * 1024 * 1024) {
-       pde_ptr = mmu_probe(env, va, 2);
-       if (pde_ptr) {
+       pde = mmu_probe(env, va, 2);
+       if (pde) {
            pa = cpu_get_phys_page_debug(env, va);
-           printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx " PDE: " TARGET_FMT_lx "\n", va, pa, pde_ptr);
+           printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_plx
+                   " PDE: " TARGET_FMT_lx "\n", va, pa, pde);
            for (m = 0, va1 = va; m < 64; m++, va1 += 256 * 1024) {
-               pde_ptr = mmu_probe(env, va1, 1);
-               if (pde_ptr) {
+               pde = mmu_probe(env, va1, 1);
+               if (pde) {
                    pa = cpu_get_phys_page_debug(env, va1);
-                   printf(" VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx " PDE: " TARGET_FMT_lx "\n", va1, pa, pde_ptr);
+                   printf(" VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_plx
+                           " PDE: " TARGET_FMT_lx "\n", va1, pa, pde);
                    for (o = 0, va2 = va1; o < 64; o++, va2 += 4 * 1024) {
-                       pde_ptr = mmu_probe(env, va2, 0);
-                       if (pde_ptr) {
+                       pde = mmu_probe(env, va2, 0);
+                       if (pde) {
                            pa = cpu_get_phys_page_debug(env, va2);
-                           printf("  VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx " PTE: " TARGET_FMT_lx "\n", va2, pa, pde_ptr);
+                           printf("  VA: " TARGET_FMT_lx ", PA: "
+                                   TARGET_FMT_plx " PTE: " TARGET_FMT_lx "\n",
+                                   va2, pa, pde);
                        }
                    }
                }
@@ -394,7 +401,7 @@ static int get_physical_address_data(CPUState *env, target_phys_addr_t *physical
                env->dmmuregs[4] = address; /* Fault address register */
                env->exception_index = TT_DFAULT;
 #ifdef DEBUG_MMU
-               printf("DFAULT at 0x%llx\n", address);
+               printf("DFAULT at 0x%" PRIx64 "\n", address);
 #endif
                return 1;
            }
@@ -406,7 +413,7 @@ static int get_physical_address_data(CPUState *env, target_phys_addr_t *physical
        }
     }
 #ifdef DEBUG_MMU
-    printf("DMISS at 0x%llx\n", address);
+    printf("DMISS at 0x%" PRIx64 "\n", address);
 #endif
     env->exception_index = TT_DMISS;
     return 1;
@@ -452,7 +459,7 @@ static int get_physical_address_code(CPUState *env, target_phys_addr_t *physical
                env->immuregs[3] |= (is_user << 3) | 1;
                env->exception_index = TT_TFAULT;
 #ifdef DEBUG_MMU
-               printf("TFAULT at 0x%llx\n", address);
+               printf("TFAULT at 0x%" PRIx64 "\n", address);
 #endif
                return 1;
            }
@@ -462,7 +469,7 @@ static int get_physical_address_code(CPUState *env, target_phys_addr_t *physical
        }
     }
 #ifdef DEBUG_MMU
-    printf("TMISS at 0x%llx\n", address);
+    printf("TMISS at 0x%" PRIx64 "\n", address);
 #endif
     env->exception_index = TT_TMISS;
     return 1;
@@ -491,7 +498,7 @@ int cpu_sparc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
        virt_addr = address & TARGET_PAGE_MASK;
        vaddr = virt_addr + ((address & TARGET_PAGE_MASK) & (TARGET_PAGE_SIZE - 1));
 #ifdef DEBUG_MMU
-       printf("Translate at 0x%llx -> 0x%llx, vaddr 0x%llx\n", address, paddr, vaddr);
+       printf("Translate at 0x%" PRIx64 " -> 0x%" PRIx64 ", vaddr 0x%" PRIx64 "\n", address, paddr, vaddr);
 #endif
        ret = tlb_set_page_exec(env, vaddr, paddr, prot, is_user, is_softmmu);
        return ret;
@@ -506,7 +513,7 @@ void dump_mmu(CPUState *env)
     unsigned int i;
     const char *mask;
 
-    printf("MMU contexts: Primary: %lld, Secondary: %lld\n", env->dmmuregs[1], env->dmmuregs[2]);
+    printf("MMU contexts: Primary: %" PRId64 ", Secondary: %" PRId64 "\n", env->dmmuregs[1], env->dmmuregs[2]);
     if ((env->lsu & DMMU_E) == 0) {
        printf("DMMU disabled\n");
     } else {
@@ -528,7 +535,7 @@ void dump_mmu(CPUState *env)
                break;
            }
            if ((env->dtlb_tte[i] & 0x8000000000000000ULL) != 0) {
-               printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx ", %s, %s, %s, %s, ctx %lld\n",
+               printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx ", %s, %s, %s, %s, ctx %" PRId64 "\n",
                       env->dtlb_tag[i] & ~0x1fffULL,
                       env->dtlb_tte[i] & 0x1ffffffe000ULL,
                       mask,
@@ -560,7 +567,7 @@ void dump_mmu(CPUState *env)
                break;
            }
            if ((env->itlb_tte[i] & 0x8000000000000000ULL) != 0) {
-               printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx ", %s, %s, %s, ctx %lld\n",
+               printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx ", %s, %s, %s, ctx %" PRId64 "\n",
                       env->itlb_tag[i] & ~0x1fffULL,
                       env->itlb_tte[i] & 0x1ffffffe000ULL,
                       mask,