qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 02/13] hw/ppc.c: use LOG_IRQ instead of #ifdefs


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH 02/13] hw/ppc.c: use LOG_IRQ instead of #ifdefs
Date: Wed, 10 Dec 2008 16:24:13 -0200

Use the new LOG_IRQ macro.

Signed-off-by: Eduardo Habkost <address@hidden>
---
 hw/ppc.c |  180 ++++++++++---------------------------------------------------
 1 files changed, 30 insertions(+), 150 deletions(-)

diff --git a/hw/ppc.c b/hw/ppc.c
index cbd69e0..44d2f48 100644
--- a/hw/ppc.c
+++ b/hw/ppc.c
@@ -54,13 +54,9 @@ static void ppc_set_irq (CPUState *env, int n_IRQ, int level)
         if (env->pending_interrupts == 0)
             cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
     }
-#if defined(PPC_DEBUG_IRQ)
-    if (loglevel & CPU_LOG_INT) {
-        fprintf(logfile, "%s: %p n_IRQ %d level %d => pending %08" PRIx32
+    LOG_IRQ("%s: %p n_IRQ %d level %d => pending %08" PRIx32
                 "req %08x\n", __func__, env, n_IRQ, level,
                 env->pending_interrupts, env->interrupt_request);
-    }
-#endif
 }
 
 /* PowerPC 6xx / 7xx internal IRQ controller */
@@ -69,24 +65,16 @@ static void ppc6xx_set_irq (void *opaque, int pin, int 
level)
     CPUState *env = opaque;
     int cur_level;
 
-#if defined(PPC_DEBUG_IRQ)
-    if (loglevel & CPU_LOG_INT) {
-        fprintf(logfile, "%s: env %p pin %d level %d\n", __func__,
+    LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
                 env, pin, level);
-    }
-#endif
     cur_level = (env->irq_input_state >> pin) & 1;
     /* Don't generate spurious events */
     if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) {
         switch (pin) {
         case PPC6xx_INPUT_TBEN:
             /* Level sensitive - active high */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: %s the time base\n",
+            LOG_IRQ("%s: %s the time base\n",
                         __func__, level ? "start" : "stop");
-            }
-#endif
             if (level) {
                 cpu_ppc_tb_start(env);
             } else {
@@ -94,22 +82,14 @@ static void ppc6xx_set_irq (void *opaque, int pin, int 
level)
             }
         case PPC6xx_INPUT_INT:
             /* Level sensitive - active high */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the external IRQ state to %d\n",
+            LOG_IRQ("%s: set the external IRQ state to %d\n",
                         __func__, level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_EXT, level);
             break;
         case PPC6xx_INPUT_SMI:
             /* Level sensitive - active high */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the SMI IRQ state to %d\n",
+            LOG_IRQ("%s: set the SMI IRQ state to %d\n",
                         __func__, level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_SMI, level);
             break;
         case PPC6xx_INPUT_MCP:
@@ -118,12 +98,8 @@ static void ppc6xx_set_irq (void *opaque, int pin, int 
level)
              *            603/604/740/750: check HID0[EMCP]
              */
             if (cur_level == 1 && level == 0) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: raise machine check state\n",
+                LOG_IRQ("%s: raise machine check state\n",
                             __func__);
-                }
-#endif
                 ppc_set_irq(env, PPC_INTERRUPT_MCK, 1);
             }
             break;
@@ -132,22 +108,14 @@ static void ppc6xx_set_irq (void *opaque, int pin, int 
level)
             /* XXX: TODO: relay the signal to CKSTP_OUT pin */
             /* XXX: Note that the only way to restart the CPU is to reset it */
             if (level) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: stop the CPU\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: stop the CPU\n", __func__);
                 env->halted = 1;
             }
             break;
         case PPC6xx_INPUT_HRESET:
             /* Level sensitive - active low */
             if (level) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: reset the CPU\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: reset the CPU\n", __func__);
                 env->interrupt_request |= CPU_INTERRUPT_EXITTB;
                 /* XXX: TOFIX */
 #if 0
@@ -158,21 +126,13 @@ static void ppc6xx_set_irq (void *opaque, int pin, int 
level)
             }
             break;
         case PPC6xx_INPUT_SRESET:
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the RESET IRQ state to %d\n",
+            LOG_IRQ("%s: set the RESET IRQ state to %d\n",
                         __func__, level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_RESET, level);
             break;
         default:
             /* Unknown pin - do nothing */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin);
-            }
-#endif
+            LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin);
             return;
         }
         if (level)
@@ -195,34 +155,22 @@ static void ppc970_set_irq (void *opaque, int pin, int 
level)
     CPUState *env = opaque;
     int cur_level;
 
-#if defined(PPC_DEBUG_IRQ)
-    if (loglevel & CPU_LOG_INT) {
-        fprintf(logfile, "%s: env %p pin %d level %d\n", __func__,
+    LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
                 env, pin, level);
-    }
-#endif
     cur_level = (env->irq_input_state >> pin) & 1;
     /* Don't generate spurious events */
     if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) {
         switch (pin) {
         case PPC970_INPUT_INT:
             /* Level sensitive - active high */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the external IRQ state to %d\n",
+            LOG_IRQ("%s: set the external IRQ state to %d\n",
                         __func__, level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_EXT, level);
             break;
         case PPC970_INPUT_THINT:
             /* Level sensitive - active high */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the SMI IRQ state to %d\n", __func__,
+            LOG_IRQ("%s: set the SMI IRQ state to %d\n", __func__,
                         level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_THERM, level);
             break;
         case PPC970_INPUT_MCP:
@@ -231,12 +179,8 @@ static void ppc970_set_irq (void *opaque, int pin, int 
level)
              *            603/604/740/750: check HID0[EMCP]
              */
             if (cur_level == 1 && level == 0) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: raise machine check state\n",
+                LOG_IRQ("%s: raise machine check state\n",
                             __func__);
-                }
-#endif
                 ppc_set_irq(env, PPC_INTERRUPT_MCK, 1);
             }
             break;
@@ -244,18 +188,10 @@ static void ppc970_set_irq (void *opaque, int pin, int 
level)
             /* Level sensitive - active low */
             /* XXX: TODO: relay the signal to CKSTP_OUT pin */
             if (level) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: stop the CPU\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: stop the CPU\n", __func__);
                 env->halted = 1;
             } else {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: restart the CPU\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: restart the CPU\n", __func__);
                 env->halted = 0;
             }
             break;
@@ -263,40 +199,24 @@ static void ppc970_set_irq (void *opaque, int pin, int 
level)
             /* Level sensitive - active low */
             if (level) {
 #if 0 // XXX: TOFIX
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: reset the CPU\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: reset the CPU\n", __func__);
                 cpu_reset(env);
 #endif
             }
             break;
         case PPC970_INPUT_SRESET:
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the RESET IRQ state to %d\n",
+            LOG_IRQ("%s: set the RESET IRQ state to %d\n",
                         __func__, level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_RESET, level);
             break;
         case PPC970_INPUT_TBEN:
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the TBEN state to %d\n", __func__,
+            LOG_IRQ("%s: set the TBEN state to %d\n", __func__,
                         level);
-            }
-#endif
             /* XXX: TODO */
             break;
         default:
             /* Unknown pin - do nothing */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin);
-            }
-#endif
+            LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin);
             return;
         }
         if (level)
@@ -319,103 +239,63 @@ static void ppc40x_set_irq (void *opaque, int pin, int 
level)
     CPUState *env = opaque;
     int cur_level;
 
-#if defined(PPC_DEBUG_IRQ)
-    if (loglevel & CPU_LOG_INT) {
-        fprintf(logfile, "%s: env %p pin %d level %d\n", __func__,
+    LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
                 env, pin, level);
-    }
-#endif
     cur_level = (env->irq_input_state >> pin) & 1;
     /* Don't generate spurious events */
     if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) {
         switch (pin) {
         case PPC40x_INPUT_RESET_SYS:
             if (level) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: reset the PowerPC system\n",
+                LOG_IRQ("%s: reset the PowerPC system\n",
                             __func__);
-                }
-#endif
                 ppc40x_system_reset(env);
             }
             break;
         case PPC40x_INPUT_RESET_CHIP:
             if (level) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: reset the PowerPC chip\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: reset the PowerPC chip\n", __func__);
                 ppc40x_chip_reset(env);
             }
             break;
         case PPC40x_INPUT_RESET_CORE:
             /* XXX: TODO: update DBSR[MRR] */
             if (level) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: reset the PowerPC core\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: reset the PowerPC core\n", __func__);
                 ppc40x_core_reset(env);
             }
             break;
         case PPC40x_INPUT_CINT:
             /* Level sensitive - active high */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the critical IRQ state to %d\n",
+            LOG_IRQ("%s: set the critical IRQ state to %d\n",
                         __func__, level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_CEXT, level);
             break;
         case PPC40x_INPUT_INT:
             /* Level sensitive - active high */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the external IRQ state to %d\n",
+            LOG_IRQ("%s: set the external IRQ state to %d\n",
                         __func__, level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_EXT, level);
             break;
         case PPC40x_INPUT_HALT:
             /* Level sensitive - active low */
             if (level) {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: stop the CPU\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: stop the CPU\n", __func__);
                 env->halted = 1;
             } else {
-#if defined(PPC_DEBUG_IRQ)
-                if (loglevel & CPU_LOG_INT) {
-                    fprintf(logfile, "%s: restart the CPU\n", __func__);
-                }
-#endif
+                LOG_IRQ("%s: restart the CPU\n", __func__);
                 env->halted = 0;
             }
             break;
         case PPC40x_INPUT_DEBUG:
             /* Level sensitive - active high */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: set the debug pin state to %d\n",
+            LOG_IRQ("%s: set the debug pin state to %d\n",
                         __func__, level);
-            }
-#endif
             ppc_set_irq(env, PPC_INTERRUPT_DEBUG, level);
             break;
         default:
             /* Unknown pin - do nothing */
-#if defined(PPC_DEBUG_IRQ)
-            if (loglevel & CPU_LOG_INT) {
-                fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin);
-            }
-#endif
+            LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin);
             return;
         }
         if (level)
-- 
1.5.5.GIT





reply via email to

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