Skip to content

Commit a1f3800

Browse files
CV-Bowenxiaoxiang781216
authored andcommitted
arm_gicv2_dump: optimize gic dump
1. Add config CONFIG_ARMV7A_GICv2_DUMP to control gic dump, because irqinfo introduce too much other log; 2. Change the log api from irqinfo() to syslog(), syslog not append the function name in the log, so the gic dump format will not be destoried. Signed-off-by: Bowen Wang <[email protected]>
1 parent 9eb7665 commit a1f3800

File tree

3 files changed

+43
-26
lines changed

3 files changed

+43
-26
lines changed

arch/arm/src/armv7-a/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ config ARMV7A_HAVE_GICv2
1717

1818
if ARMV7A_HAVE_GICv2
1919

20+
config ARMV7A_GICv2_DUMP
21+
bool "Dump the gic register"
22+
default DEBUG_IRQ_INFO
23+
2024
config ARMV7A_GIC_EOIMODE
2125
bool "Enable GIC EOImode"
2226
default n

arch/arm/src/armv7-a/arm_gicv2_dump.c

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,23 @@
2525
#include <nuttx/config.h>
2626

2727
#include <stdint.h>
28+
#include <syslog.h>
2829
#include <debug.h>
2930

3031
#include "arm_internal.h"
3132
#include "gic.h"
3233

33-
#if defined(CONFIG_ARMV7A_HAVE_GICv2) && defined(CONFIG_DEBUG_IRQ_INFO)
34+
#if defined(CONFIG_ARMV7A_HAVE_GICv2) && defined(CONFIG_ARMV7A_GICv2_DUMP)
35+
36+
/****************************************************************************
37+
* Pre-processor Definitions
38+
****************************************************************************/
39+
40+
#ifdef CONFIG_CPP_HAVE_VARARGS
41+
# define gicdump(fmt, ...) syslog(LOG_ALERT, fmt, ##__VA_ARGS__)
42+
#else
43+
# define gicdump(fmt, ...)
44+
#endif
3445

3546
/****************************************************************************
3647
* Private Functions
@@ -54,20 +65,20 @@
5465

5566
static inline void arm_gic_dump_cpu(bool all, int irq, int nlines)
5667
{
57-
irqinfo(" CPU Interface Registers:\n");
58-
irqinfo(" ICR: %08x PMR: %08x BPR: %08x IAR: %08x\n",
68+
gicdump(" CPU Interface Registers:\n");
69+
gicdump(" ICR: %08lx PMR: %08lx BPR: %08lx IAR: %08lx\n",
5970
getreg32(GIC_ICCICR), getreg32(GIC_ICCPMR),
6071
getreg32(GIC_ICCBPR), getreg32(GIC_ICCIAR));
61-
irqinfo(" RPR: %08x HPIR: %08x ABPR: %08x\n",
72+
gicdump(" RPR: %08lx HPIR: %08lx ABPR: %08lx\n",
6273
getreg32(GIC_ICCRPR), getreg32(GIC_ICCHPIR),
6374
getreg32(GIC_ICCABPR));
64-
irqinfo(" AIAR: %08x AHPIR: %08x IDR: %08x\n",
75+
gicdump(" AIAR: %08lx AHPIR: %08lx IDR: %08lx\n",
6576
getreg32(GIC_ICCAIAR), getreg32(GIC_ICCAHPIR),
6677
getreg32(GIC_ICCIDR));
67-
irqinfo(" APR1: %08x APR2: %08x APR3: %08x APR4: %08x\n",
78+
gicdump(" APR1: %08lx APR2: %08lx APR3: %08lx APR4: %08lx\n",
6879
getreg32(GIC_ICCAPR1), getreg32(GIC_ICCAPR2),
6980
getreg32(GIC_ICCAPR3), getreg32(GIC_ICCAPR4));
70-
irqinfo(" NSAPR1: %08x NSAPR2: %08x NSAPR3: %08x NSAPR4: %08x\n",
81+
gicdump(" NSAPR1: %08lx NSAPR2: %08lx NSAPR3: %08lx NSAPR4: %08lx\n",
7182
getreg32(GIC_ICCNSAPR1), getreg32(GIC_ICCNSAPR2),
7283
getreg32(GIC_ICCNSAPR3), getreg32(GIC_ICCNSAPR4));
7384
}
@@ -95,7 +106,7 @@ static void arm_gic_dumpregs(uintptr_t regaddr, int nlines, int incr)
95106
incr <<= 2;
96107
for (i = 0; i < nlines; i += incr, regaddr += 16)
97108
{
98-
irqinfo(" %08x %08x %08x %08x\n",
109+
gicdump(" %08lx %08lx %08lx %08lx\n",
99110
getreg32(regaddr), getreg32(regaddr + 4),
100111
getreg32(regaddr + 8), getreg32(regaddr + 12));
101112
}
@@ -120,7 +131,7 @@ static void arm_gic_dumpregs(uintptr_t regaddr, int nlines, int incr)
120131
static inline void arm_gic_dump4(const char *name, uintptr_t regaddr,
121132
int nlines)
122133
{
123-
irqinfo(" %s[%08lx]\n", name, (unsigned long)regaddr);
134+
gicdump(" %s[%08lx]\n", name, (unsigned long)regaddr);
124135
arm_gic_dumpregs(regaddr, nlines, 4);
125136
}
126137

@@ -143,7 +154,7 @@ static inline void arm_gic_dump4(const char *name, uintptr_t regaddr,
143154
static inline void arm_gic_dump8(const char *name, uintptr_t regaddr,
144155
int nlines)
145156
{
146-
irqinfo(" %s[%08lx]\n", name, (unsigned long)regaddr);
157+
gicdump(" %s[%08lx]\n", name, (unsigned long)regaddr);
147158
arm_gic_dumpregs(regaddr, nlines, 8);
148159
}
149160

@@ -166,7 +177,7 @@ static inline void arm_gic_dump8(const char *name, uintptr_t regaddr,
166177
static inline void arm_gic_dump16(const char *name, uintptr_t regaddr,
167178
int nlines)
168179
{
169-
irqinfo(" %s[%08lx]\n", name, (unsigned long)regaddr);
180+
gicdump(" %s[%08lx]\n", name, (unsigned long)regaddr);
170181
arm_gic_dumpregs(regaddr, nlines, 16);
171182
}
172183

@@ -189,7 +200,7 @@ static inline void arm_gic_dump16(const char *name, uintptr_t regaddr,
189200
static inline void arm_gic_dump32(const char *name, uintptr_t regaddr,
190201
int nlines)
191202
{
192-
irqinfo(" %s[%08lx]\n", name, (unsigned long)regaddr);
203+
gicdump(" %s[%08lx]\n", name, (unsigned long)regaddr);
193204
arm_gic_dumpregs(regaddr, nlines, 32);
194205
}
195206

@@ -211,8 +222,8 @@ static inline void arm_gic_dump32(const char *name, uintptr_t regaddr,
211222

212223
static inline void arm_gic_dump_distributor(bool all, int irq, int nlines)
213224
{
214-
irqinfo(" Distributor Registers:\n");
215-
irqinfo(" DCR: %08x ICTR: %08x IIDR: %08x\n",
225+
gicdump(" Distributor Registers:\n");
226+
gicdump(" DCR: %08lx ICTR: %08lx IIDR: %08lx\n",
216227
getreg32(GIC_ICDDCR), getreg32(GIC_ICDICTR),
217228
getreg32(GIC_ICDIIDR));
218229

@@ -231,25 +242,27 @@ static inline void arm_gic_dump_distributor(bool all, int irq, int nlines)
231242
}
232243
else
233244
{
234-
irqinfo(" ISR: %08x ISER: %08x ISPR: %08x SAR: %08x\n",
245+
gicdump(" ISR: %08lx ISER: %08lx ISPR: %08lx"
246+
" SAR: %08lx\n",
235247
getreg32(GIC_ICDISR(irq)), getreg32(GIC_ICDISER(irq)),
236248
getreg32(GIC_ICDISPR(irq)), getreg32(GIC_ICDSAR(irq)));
237-
irqinfo(" IPR: %08x IPTR: %08x ICFR: %08x SPISR: %08x\n",
249+
gicdump(" IPR: %08lx IPTR: %08lx ICFR: %08lx"
250+
" SPISR: %08lx\n",
238251
getreg32(GIC_ICDIPR(irq)), getreg32(GIC_ICDIPTR(irq)),
239252
getreg32(GIC_ICDICFR(irq)), getreg32(GIC_ICDSPISR(irq)));
240-
irqinfo(" NSACR: %08x SCPR: %08x\n",
253+
gicdump(" NSACR: %08lx SCPR: %08lx\n",
241254
getreg32(GIC_ICDNSACR(irq)), getreg32(GIC_ICDSCPR(irq)));
242255
}
243256

244-
irqinfo(" PIDR[%08lx]:\n", (unsigned long)GIC_ICDPIDR(0));
245-
irqinfo(" %08x %08x %08x %08x\n",
257+
gicdump(" PIDR[%08lx]:\n", (unsigned long)GIC_ICDPIDR(0));
258+
gicdump(" %08lx %08lx %08lx %08lx\n",
246259
getreg32(GIC_ICDPIDR(0)), getreg32(GIC_ICDPIDR(1)),
247260
getreg32(GIC_ICDPIDR(2)), getreg32(GIC_ICDPIDR(3)));
248-
irqinfo(" %08x %08x %08x %08x\n",
261+
gicdump(" %08lx %08lx %08lx\n",
249262
getreg32(GIC_ICDPIDR(4)), getreg32(GIC_ICDPIDR(5)),
250263
getreg32(GIC_ICDPIDR(6)));
251-
irqinfo(" CIDR[%08lx]:\n", (unsigned long)GIC_ICDCIDR(0));
252-
irqinfo(" %08x %08x %08x %08x\n",
264+
gicdump(" CIDR[%08lx]:\n", (unsigned long)GIC_ICDCIDR(0));
265+
gicdump(" %08lx %08lx %08lx %08lx\n",
253266
getreg32(GIC_ICDCIDR(0)), getreg32(GIC_ICDCIDR(1)),
254267
getreg32(GIC_ICDCIDR(2)), getreg32(GIC_ICDCIDR(3)));
255268
}
@@ -280,15 +293,15 @@ void arm_gic_dump(const char *msg, bool all, int irq)
280293

281294
if (all)
282295
{
283-
irqinfo("GIC: %s NLINES=%u\n", msg, nlines);
296+
gicdump("GIC: %s NLINES=%u\n", msg, nlines);
284297
}
285298
else
286299
{
287-
irqinfo("GIC: %s IRQ=%d\n", msg, irq);
300+
gicdump("GIC: %s IRQ=%d\n", msg, irq);
288301
}
289302

290303
arm_gic_dump_cpu(all, irq, nlines);
291304
arm_gic_dump_distributor(all, irq, nlines);
292305
}
293306

294-
#endif /* CONFIG_ARMV7A_HAVE_GICv2 && CONFIG_DEBUG_IRQ_INFO */
307+
#endif /* CONFIG_ARMV7A_HAVE_GICv2 && CONFIG_ARMV7A_GICv2_DUMP */

arch/arm/src/armv7-a/gic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ int arm_smp_sched_handler(int irq, void *context, void *arg);
872872
*
873873
****************************************************************************/
874874

875-
#ifdef CONFIG_DEBUG_IRQ_INFO
875+
#ifdef CONFIG_ARMV7A_GICv2_DUMP
876876
void arm_gic_dump(const char *msg, bool all, int irq);
877877
#else
878878
# define arm_gic_dump(msg, all, irq)

0 commit comments

Comments
 (0)