qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>
Subject: [Qemu-devel] [PATCH 04/13] hw/ppc.c: use LOG_TB instead of #ifdefs
Date: Wed, 10 Dec 2008 16:24:15 -0200	[thread overview]
Message-ID: <1228933464-7670-5-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1228933464-7670-1-git-send-email-ehabkost@redhat.com>

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/ppc.c |  114 ++++++++++---------------------------------------------------
 1 files changed, 19 insertions(+), 95 deletions(-)

diff --git a/hw/ppc.c b/hw/ppc.c
index 53257a4..7a404bf 100644
--- a/hw/ppc.c
+++ b/hw/ppc.c
@@ -352,11 +352,7 @@ uint32_t cpu_ppc_load_tbl (CPUState *env)
     uint64_t tb;
 
     tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset);
-#if defined(PPC_DEBUG_TB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: tb %016" PRIx64 "\n", __func__, tb);
-    }
-#endif
+    LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb);
 
     return tb & 0xFFFFFFFF;
 }
@@ -367,11 +363,7 @@ static always_inline uint32_t _cpu_ppc_load_tbu (CPUState *env)
     uint64_t tb;
 
     tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset);
-#if defined(PPC_DEBUG_TB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: tb %016" PRIx64 "\n", __func__, tb);
-    }
-#endif
+    LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb);
 
     return tb >> 32;
 }
@@ -386,12 +378,8 @@ static always_inline void cpu_ppc_store_tb (ppc_tb_t *tb_env, uint64_t vmclk,
                                             uint64_t value)
 {
     *tb_offsetp = value - muldiv64(vmclk, tb_env->tb_freq, ticks_per_sec);
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: tb %016" PRIx64 " offset %08" PRIx64 "\n",
+    LOG_TB("%s: tb %016" PRIx64 " offset %08" PRIx64 "\n",
                 __func__, value, *tb_offsetp);
-    }
-#endif
 }
 
 void cpu_ppc_store_tbl (CPUState *env, uint32_t value)
@@ -427,11 +415,7 @@ uint32_t cpu_ppc_load_atbl (CPUState *env)
     uint64_t tb;
 
     tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset);
-#if defined(PPC_DEBUG_TB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: tb %016" PRIx64 "\n", __func__, tb);
-    }
-#endif
+    LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb);
 
     return tb & 0xFFFFFFFF;
 }
@@ -442,11 +426,7 @@ uint32_t cpu_ppc_load_atbu (CPUState *env)
     uint64_t tb;
 
     tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset);
-#if defined(PPC_DEBUG_TB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: tb %016" PRIx64 "\n", __func__, tb);
-    }
-#endif
+    LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb);
 
     return tb >> 32;
 }
@@ -528,11 +508,7 @@ static always_inline uint32_t _cpu_ppc_load_decr (CPUState *env,
         decr = muldiv64(diff, tb_env->decr_freq, ticks_per_sec);
     else
         decr = -muldiv64(-diff, tb_env->decr_freq, ticks_per_sec);
-#if defined(PPC_DEBUG_TB)
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: %08" PRIx32 "\n", __func__, decr);
-    }
-#endif
+    LOG_TB("%s: %08" PRIx32 "\n", __func__, decr);
 
     return decr;
 }
@@ -567,22 +543,14 @@ uint64_t cpu_ppc_load_purr (CPUState *env)
 static always_inline void cpu_ppc_decr_excp (CPUState *env)
 {
     /* Raise it */
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "raise decrementer exception\n");
-    }
-#endif
+    LOG_TB("raise decrementer exception\n");
     ppc_set_irq(env, PPC_INTERRUPT_DECR, 1);
 }
 
 static always_inline void cpu_ppc_hdecr_excp (CPUState *env)
 {
     /* Raise it */
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "raise decrementer exception\n");
-    }
-#endif
+    LOG_TB("raise decrementer exception\n");
     ppc_set_irq(env, PPC_INTERRUPT_HDECR, 1);
 }
 
@@ -595,12 +563,8 @@ static void __cpu_ppc_store_decr (CPUState *env, uint64_t *nextp,
     ppc_tb_t *tb_env = env->tb_env;
     uint64_t now, next;
 
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: %08" PRIx32 " => %08" PRIx32 "\n", __func__,
+    LOG_TB("%s: %08" PRIx32 " => %08" PRIx32 "\n", __func__,
                 decr, value);
-    }
-#endif
     now = qemu_get_clock(vm_clock);
     next = now + muldiv64(value, ticks_per_sec, tb_env->decr_freq);
     if (is_excp)
@@ -781,13 +745,9 @@ static void cpu_4xx_fit_cb (void *opaque)
     env->spr[SPR_40x_TSR] |= 1 << 26;
     if ((env->spr[SPR_40x_TCR] >> 23) & 0x1)
         ppc_set_irq(env, PPC_INTERRUPT_FIT, 1);
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: ir %d TCR " ADDRX " TSR " ADDRX "\n", __func__,
+    LOG_TB("%s: ir %d TCR " ADDRX " TSR " ADDRX "\n", __func__,
                 (int)((env->spr[SPR_40x_TCR] >> 23) & 0x1),
                 env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]);
-    }
-#endif
 }
 
 /* Programmable interval timer */
@@ -801,19 +761,11 @@ static void start_stop_pit (CPUState *env, ppc_tb_t *tb_env, int is_excp)
         !((env->spr[SPR_40x_TCR] >> 26) & 0x1) ||
         (is_excp && !((env->spr[SPR_40x_TCR] >> 22) & 0x1))) {
         /* Stop PIT */
-#ifdef PPC_DEBUG_TB
-        if (loglevel != 0) {
-            fprintf(logfile, "%s: stop PIT\n", __func__);
-        }
-#endif
+        LOG_TB("%s: stop PIT\n", __func__);
         qemu_del_timer(tb_env->decr_timer);
     } else {
-#ifdef PPC_DEBUG_TB
-        if (loglevel != 0) {
-            fprintf(logfile, "%s: start PIT %016" PRIx64 "\n",
+        LOG_TB("%s: start PIT %016" PRIx64 "\n",
                     __func__, ppcemb_timer->pit_reload);
-        }
-#endif
         now = qemu_get_clock(vm_clock);
         next = now + muldiv64(ppcemb_timer->pit_reload,
                               ticks_per_sec, tb_env->decr_freq);
@@ -839,16 +791,12 @@ static void cpu_4xx_pit_cb (void *opaque)
     if ((env->spr[SPR_40x_TCR] >> 26) & 0x1)
         ppc_set_irq(env, PPC_INTERRUPT_PIT, 1);
     start_stop_pit(env, tb_env, 1);
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: ar %d ir %d TCR " ADDRX " TSR " ADDRX " "
+    LOG_TB("%s: ar %d ir %d TCR " ADDRX " TSR " ADDRX " "
                 "%016" PRIx64 "\n", __func__,
                 (int)((env->spr[SPR_40x_TCR] >> 22) & 0x1),
                 (int)((env->spr[SPR_40x_TCR] >> 26) & 0x1),
                 env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR],
                 ppcemb_timer->pit_reload);
-    }
-#endif
 }
 
 /* Watchdog timer */
@@ -883,12 +831,8 @@ static void cpu_4xx_wdt_cb (void *opaque)
     next = now + muldiv64(next, ticks_per_sec, tb_env->decr_freq);
     if (next == now)
         next++;
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: TCR " ADDRX " TSR " ADDRX "\n", __func__,
+    LOG_TB("%s: TCR " ADDRX " TSR " ADDRX "\n", __func__,
                 env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]);
-    }
-#endif
     switch ((env->spr[SPR_40x_TSR] >> 30) & 0x3) {
     case 0x0:
     case 0x1:
@@ -930,11 +874,7 @@ void store_40x_pit (CPUState *env, target_ulong val)
 
     tb_env = env->tb_env;
     ppcemb_timer = tb_env->opaque;
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s val" ADDRX "\n", __func__, val);
-    }
-#endif
+    LOG_TB("%s val" ADDRX "\n", __func__, val);
     ppcemb_timer->pit_reload = val;
     start_stop_pit(env, tb_env, 0);
 }
@@ -946,11 +886,7 @@ target_ulong load_40x_pit (CPUState *env)
 
 void store_booke_tsr (CPUState *env, target_ulong val)
 {
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: val " ADDRX "\n", __func__, val);
-    }
-#endif
+    LOG_TB("%s: val " ADDRX "\n", __func__, val);
     env->spr[SPR_40x_TSR] &= ~(val & 0xFC000000);
     if (val & 0x80000000)
         ppc_set_irq(env, PPC_INTERRUPT_PIT, 0);
@@ -961,11 +897,7 @@ void store_booke_tcr (CPUState *env, target_ulong val)
     ppc_tb_t *tb_env;
 
     tb_env = env->tb_env;
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s: val " ADDRX "\n", __func__, val);
-    }
-#endif
+    LOG_TB("%s: val " ADDRX "\n", __func__, val);
     env->spr[SPR_40x_TCR] = val & 0xFFC00000;
     start_stop_pit(env, tb_env, 1);
     cpu_4xx_wdt_cb(env);
@@ -976,12 +908,8 @@ static void ppc_emb_set_tb_clk (void *opaque, uint32_t freq)
     CPUState *env = opaque;
     ppc_tb_t *tb_env = env->tb_env;
 
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s set new frequency to %" PRIu32 "\n", __func__,
+    LOG_TB("%s set new frequency to %" PRIu32 "\n", __func__,
                 freq);
-    }
-#endif
     tb_env->tb_freq = freq;
     tb_env->decr_freq = freq;
     /* XXX: we should also update all timers */
@@ -1001,11 +929,7 @@ clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq)
     tb_env->tb_freq = freq;
     tb_env->decr_freq = freq;
     tb_env->opaque = ppcemb_timer;
-#ifdef PPC_DEBUG_TB
-    if (loglevel != 0) {
-        fprintf(logfile, "%s freq %" PRIu32 "\n", __func__, freq);
-    }
-#endif
+    LOG_TB("%s freq %" PRIu32 "\n", __func__, freq);
     if (ppcemb_timer != NULL) {
         /* We use decr timer for PIT */
         tb_env->decr_timer = qemu_new_timer(vm_clock, &cpu_4xx_pit_cb, env);
-- 
1.5.5.GIT

  parent reply	other threads:[~2008-12-10 18:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro Eduardo Habkost
2008-12-11 21:45   ` Anthony Liguori
2008-12-11 22:54     ` Andreas Färber
2008-12-11 23:31       ` Eduardo Habkost
2008-12-14 18:09         ` Jamie Lokier
2008-12-12 14:31       ` Anthony Liguori
2008-12-10 18:24 ` [Qemu-devel] [PATCH 02/13] hw/ppc.c: use LOG_IRQ instead of #ifdefs Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 03/13] hw/ppc.c: LOG_TB macro Eduardo Habkost
2008-12-10 18:24 ` Eduardo Habkost [this message]
2008-12-10 18:24 ` [Qemu-devel] [PATCH 05/13] vl.c: LOG_IOPORT macro Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 06/13] vl.c: use LOG_IOPORT instead of #ifdefs Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 07/13] kqemu.c: LOG_INT macro Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 08/13] kqemu.c: use LOG_INT instead of #ifdefs Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 09/13] kqemu.c: LOG_INT_STATE macro Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 10/13] kqemu.c: use LOG_INT_STATE instead of #ifdefs Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 11/13] target-i386/op_helper.c: LOG_PCALL macro Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 12/13] target-i386/op_helper.c: use LOG_PCALL instead of #ifdefs Eduardo Habkost
2008-12-10 18:24 ` [Qemu-devel] [PATCH 13/13] target-cris/translate.c: create LOG_DIS macro Eduardo Habkost
2008-12-11  8:43   ` Edgar E. Iglesias
2008-12-10 21:37 ` [Qemu-devel] [PATCH 00/13] Cleanup some logging code Hollis Blanchard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1228933464-7670-5-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).