qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 27/31] target-ppc/op_helper.c: LOG_SWTLB macro


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH 27/31] target-ppc/op_helper.c: LOG_SWTLB macro
Date: Fri, 12 Dec 2008 13:09:06 -0200

Create a LOG_SWTLB macro and use it instead of #ifdef DEBUG_SOFTWARE_TLB.

Signed-off-by: Eduardo Habkost <address@hidden>
---
 target-ppc/op_helper.c |   64 ++++++++++++++---------------------------------
 1 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 0a084bf..a6049cb 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -27,6 +27,16 @@
 //#define DEBUG_EXCEPTIONS
 //#define DEBUG_SOFTWARE_TLB
 
+#ifdef DEBUG_SOFTWARE_TLB
+#  define LOG_SWTLB(...) do {            \
+     if (loglevel)                       \
+       fprintf(logfile, ## __VA_ARGS__); \
+   } while (0)
+#else
+#  define LOG_SWTLB(...) do { } while (0)
+#endif
+
+
 /*****************************************************************************/
 /* Exceptions processing helpers */
 
@@ -2741,13 +2751,9 @@ static void do_6xx_tlb (target_ulong new_EPN, int 
is_code)
         EPN = env->spr[SPR_DMISS];
     }
     way = (env->spr[SPR_SRR1] >> 17) & 1;
-#if defined (DEBUG_SOFTWARE_TLB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: EPN " ADDRX " " ADDRX " PTE0 " ADDRX
+    LOG_SWTLB("%s: EPN " ADDRX " " ADDRX " PTE0 " ADDRX
                 " PTE1 " ADDRX " way %d\n",
                 __func__, new_EPN, EPN, CMP, RPN, way);
-    }
-#endif
     /* Store this TLB */
     ppc6xx_tlb_store(env, (uint32_t)(new_EPN & TARGET_PAGE_MASK),
                      way, is_code, CMP, RPN);
@@ -2773,13 +2779,9 @@ static void do_74xx_tlb (target_ulong new_EPN, int 
is_code)
     CMP = env->spr[SPR_PTEHI];
     EPN = env->spr[SPR_TLBMISS] & ~0x3;
     way = env->spr[SPR_TLBMISS] & 0x3;
-#if defined (DEBUG_SOFTWARE_TLB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: EPN " ADDRX " " ADDRX " PTE0 " ADDRX
+    LOG_SWTLB("%s: EPN " ADDRX " " ADDRX " PTE0 " ADDRX
                 " PTE1 " ADDRX " way %d\n",
                 __func__, new_EPN, EPN, CMP, RPN, way);
-    }
-#endif
     /* Store this TLB */
     ppc6xx_tlb_store(env, (uint32_t)(new_EPN & TARGET_PAGE_MASK),
                      way, is_code, CMP, RPN);
@@ -2903,22 +2905,14 @@ void helper_4xx_tlbwe_hi (target_ulong entry, 
target_ulong val)
     ppcemb_tlb_t *tlb;
     target_ulong page, end;
 
-#if defined (DEBUG_SOFTWARE_TLB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s entry %d val " ADDRX "\n", __func__, (int)entry, 
val);
-    }
-#endif
+    LOG_SWTLB("%s entry %d val " ADDRX "\n", __func__, (int)entry, val);
     entry &= 0x3F;
     tlb = &env->tlb[entry].tlbe;
     /* Invalidate previous TLB (if it's valid) */
     if (tlb->prot & PAGE_VALID) {
         end = tlb->EPN + tlb->size;
-#if defined (DEBUG_SOFTWARE_TLB)
-        if (loglevel != 0) {
-            fprintf(logfile, "%s: invalidate old TLB %d start " ADDRX
+        LOG_SWTLB("%s: invalidate old TLB %d start " ADDRX
                     " end " ADDRX "\n", __func__, (int)entry, tlb->EPN, end);
-        }
-#endif
         for (page = tlb->EPN; page < end; page += TARGET_PAGE_SIZE)
             tlb_flush_page(env, page);
     }
@@ -2943,26 +2937,18 @@ void helper_4xx_tlbwe_hi (target_ulong entry, 
target_ulong val)
     }
     tlb->PID = env->spr[SPR_40x_PID]; /* PID */
     tlb->attr = val & 0xFF;
-#if defined (DEBUG_SOFTWARE_TLB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: set up TLB %d RPN " PADDRX " EPN " ADDRX
+    LOG_SWTLB("%s: set up TLB %d RPN " PADDRX " EPN " ADDRX
                 " size " ADDRX " prot %c%c%c%c PID %d\n", __func__,
                 (int)entry, tlb->RPN, tlb->EPN, tlb->size,
                 tlb->prot & PAGE_READ ? 'r' : '-',
                 tlb->prot & PAGE_WRITE ? 'w' : '-',
                 tlb->prot & PAGE_EXEC ? 'x' : '-',
                 tlb->prot & PAGE_VALID ? 'v' : '-', (int)tlb->PID);
-    }
-#endif
     /* Invalidate new TLB (if valid) */
     if (tlb->prot & PAGE_VALID) {
         end = tlb->EPN + tlb->size;
-#if defined (DEBUG_SOFTWARE_TLB)
-        if (loglevel != 0) {
-            fprintf(logfile, "%s: invalidate TLB %d start " ADDRX
+        LOG_SWTLB("%s: invalidate TLB %d start " ADDRX
                     " end " ADDRX "\n", __func__, (int)entry, tlb->EPN, end);
-        }
-#endif
         for (page = tlb->EPN; page < end; page += TARGET_PAGE_SIZE)
             tlb_flush_page(env, page);
     }
@@ -2972,11 +2958,7 @@ void helper_4xx_tlbwe_lo (target_ulong entry, 
target_ulong val)
 {
     ppcemb_tlb_t *tlb;
 
-#if defined (DEBUG_SOFTWARE_TLB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s entry %i val " ADDRX "\n", __func__, (int)entry, 
val);
-    }
-#endif
+    LOG_SWTLB("%s entry %i val " ADDRX "\n", __func__, (int)entry, val);
     entry &= 0x3F;
     tlb = &env->tlb[entry].tlbe;
     tlb->RPN = val & 0xFFFFFC00;
@@ -2985,17 +2967,13 @@ void helper_4xx_tlbwe_lo (target_ulong entry, 
target_ulong val)
         tlb->prot |= PAGE_EXEC;
     if (val & 0x100)
         tlb->prot |= PAGE_WRITE;
-#if defined (DEBUG_SOFTWARE_TLB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: set up TLB %d RPN " PADDRX " EPN " ADDRX
+    LOG_SWTLB("%s: set up TLB %d RPN " PADDRX " EPN " ADDRX
                 " size " ADDRX " prot %c%c%c%c PID %d\n", __func__,
                 (int)entry, tlb->RPN, tlb->EPN, tlb->size,
                 tlb->prot & PAGE_READ ? 'r' : '-',
                 tlb->prot & PAGE_WRITE ? 'w' : '-',
                 tlb->prot & PAGE_EXEC ? 'x' : '-',
                 tlb->prot & PAGE_VALID ? 'v' : '-', (int)tlb->PID);
-    }
-#endif
 }
 
 target_ulong helper_4xx_tlbsx (target_ulong address)
@@ -3010,12 +2988,8 @@ void helper_440_tlbwe (uint32_t word, target_ulong 
entry, target_ulong value)
     target_ulong EPN, RPN, size;
     int do_flush_tlbs;
 
-#if defined (DEBUG_SOFTWARE_TLB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s word %d entry %d value " ADDRX "\n",
+    LOG_SWTLB("%s word %d entry %d value " ADDRX "\n",
                 __func__, word, (int)entry, value);
-    }
-#endif
     do_flush_tlbs = 0;
     entry &= 0x3F;
     tlb = &env->tlb[entry].tlbe;
-- 
1.5.5.GIT





reply via email to

[Prev in Thread] Current Thread [Next in Thread]