]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Blackfin arch: Clean up trace buffer handling, No major functional changes.
authorRobin Getz <robin.getz@analog.com>
Thu, 21 Jun 2007 08:34:08 +0000 (16:34 +0800)
committerBryan Wu <bryan.wu@analog.com>
Thu, 21 Jun 2007 08:34:08 +0000 (16:34 +0800)
Turns on trace earlier, so crashes at kernel start should print out a
trace, making things easier to debug.

Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Mike Frysinger <michael.frysinger@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
arch/blackfin/kernel/setup.c
arch/blackfin/kernel/traps.c
arch/blackfin/mach-bf533/head.S
arch/blackfin/mach-bf537/head.S
arch/blackfin/mach-bf548/head.S
arch/blackfin/mach-bf561/head.S
arch/blackfin/mach-common/entry.S
arch/blackfin/mach-common/interrupt.S
include/asm-blackfin/trace.h [new file with mode: 0644]

index 07c1cfdc958e883998830694d13a906b14d29fe2..a86bf6545781cc3ebd69b98987624e63ac3cdb4b 100644 (file)
@@ -194,6 +194,17 @@ void __init setup_arch(char **cmdline_p)
        /* this give a chance to get printk() working before crash. */
 #endif
 
+       printk(KERN_INFO "Hardware Trace ");
+       if (bfin_read_TBUFCTL() & 0x1 )
+               printk("Active ");
+       else
+               printk("Off ");
+       if (bfin_read_TBUFCTL() & 0x2)
+               printk("and Enabled\n");
+       else
+       printk("and Disabled\n");
+
+
 #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH)
        /* we need to initialize the Flashrom device here since we might
         * do things with flash early on in the boot
@@ -397,9 +408,6 @@ void __init setup_arch(char **cmdline_p)
        _bfin_swrst = bfin_read_SWRST();
 #endif
 
-       printk(KERN_INFO "Hardware Trace Enabled\n");
-       bfin_write_TBUFCTL(0x03);
-
        /* Copy atomic sequences to their fixed location, and sanity check that
           these locations are the ones that we advertise to userspace.  */
        memcpy((void *)FIXED_CODE_START, &fixed_code_start,
index 56058b0b6d4a604954938c5f1964e4e58d2f66cc..a58d0f50be20f18abcbf78c03d9c1db757fdaa5b 100644 (file)
@@ -33,6 +33,7 @@
 #include <asm/blackfin.h>
 #include <asm/uaccess.h>
 #include <asm/irq_handler.h>
+#include <asm/trace.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/kallsyms.h>
@@ -131,16 +132,6 @@ static int printk_address(unsigned long address)
        return printk("[<0x%p>]", (void*)address);
 }
 
-#define trace_buffer_save(x) \
-       do { \
-               (x) = bfin_read_TBUFCTL(); \
-               bfin_write_TBUFCTL((x) & ~TBUFEN); \
-       } while (0)
-#define trace_buffer_restore(x) \
-       do { \
-               bfin_write_TBUFCTL((x));        \
-       } while (0)
-
 asmlinkage void trap_c(struct pt_regs *fp)
 {
        int j, sig = 0;
index 7e2aa8d0f44f624c35df56197fb2943812bdb113..7dd0e9c3a936402e4e9470677114b8155eababbe 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/blackfin.h>
+#include <asm/trace.h>
 #if CONFIG_BFIN_KERNEL_CLOCK
 #include <asm/mach/mem_init.h>
 #endif
@@ -96,6 +97,10 @@ ENTRY(__start)
        M2 = r0;
        M3 = r0;
 
+       trace_buffer_start(p0,r0);
+       P0 = R1;
+       R0 = R1;
+
 #if CONFIG_DEBUG_KERNEL_START
 
 /*
index 7d902bbd860fa652ce26722a899d5d277b86ac0c..429c8a1019dab0de10bc9e7dfdc2f1392994cc42 100644 (file)
@@ -30,6 +30,8 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/blackfin.h>
+#include <asm/trace.h>
+
 #if CONFIG_BFIN_KERNEL_CLOCK
 #include <asm/mach/mem_init.h>
 #endif
@@ -93,6 +95,10 @@ ENTRY(__start)
        M2 = r0;
        M3 = r0;
 
+       trace_buffer_start(p0,r0);
+       P0 = R1;
+       R0 = R1;
+
        /* Turn off the icache */
        p0.l = (IMEM_CONTROL & 0xFFFF);
        p0.h = (IMEM_CONTROL >> 16);
index 0e1a25447391df82b8baa4a87ad945dda7d43796..06751ae8b85704335d279127bd184bf42f5945b4 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/linkage.h>
 #include <asm/blackfin.h>
+#include <asm/trace.h>
 #if CONFIG_BFIN_KERNEL_CLOCK
 #include <asm/mach/mem_init.h>
 #endif
@@ -91,6 +92,10 @@ ENTRY(__stext)
        M2 = r0;
        M3 = r0;
 
+       trace_buffer_start(p0,r0);
+       P0 = R1;
+       R0 = R1;
+
        /* Turn off the icache */
        p0.l = (IMEM_CONTROL & 0xFFFF);
        p0.h = (IMEM_CONTROL >> 16);
index 31cbc75c85cfdac9507445bc873f0e158e6008a8..2f08bcb2dded5158cd0270011ebab21415390496 100644 (file)
@@ -30,6 +30,8 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/blackfin.h>
+#include <asm/trace.h>
+
 #if CONFIG_BFIN_KERNEL_CLOCK
 #include <asm/mach/mem_init.h>
 #endif
@@ -93,6 +95,10 @@ ENTRY(__start)
        M2 = r0;
        M3 = r0;
 
+       trace_buffer_start(p0,r0);
+       P0 = R1;
+       R0 = R1;
+
        /* Turn off the icache */
        p0.l = (IMEM_CONTROL & 0xFFFF);
        p0.h = (IMEM_CONTROL >> 16);
index c4a32ea06c4b39c8cbe7b48794f57411b83bb853..15603275f749bdc05669102ccf1d90f35da3270a 100644 (file)
 #include <asm/errno.h>
 #include <asm/thread_info.h>  /* TIF_NEED_RESCHED */
 #include <asm/asm-offsets.h>
+#include <asm/trace.h>
 
 #include <asm/mach-common/context.S>
 
-#ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
-       /*
-        * TODO: this should be proper save/restore, but for now
-        * we'll just cheat and use 0x1/0x13
-        */
-# define DEBUG_START_HWTRACE \
-       P5.l = LO(TBUFCTL); \
-       P5.h = HI(TBUFCTL); \
-       R7 = 0x13; \
-       [P5] = R7;
-# define DEBUG_STOP_HWTRACE \
-       P5.l = LO(TBUFCTL); \
-       P5.h = HI(TBUFCTL); \
-       R7 = 0x01; \
-       [P5] = R7;
-#else
-# define DEBUG_START_HWTRACE
-# define DEBUG_STOP_HWTRACE
-#endif
-
 #ifdef CONFIG_EXCPT_IRQ_SYSC_L1
 .section .l1.text
 #else
@@ -110,7 +91,7 @@ ENTRY(_ex_icplb)
        ASTAT = [sp++];
        SAVE_ALL_SYS
        call __cplb_hdr;
-       DEBUG_START_HWTRACE
+       DEBUG_START_HWTRACE(p5, r7)
        RESTORE_ALL_SYS
        SP = RETN;
        rtx;
@@ -128,7 +109,7 @@ ENTRY(_ex_spinlock)
 ENDPROC(_ex_spinlock)
 
 ENTRY(_ex_syscall)
-       DEBUG_START_HWTRACE
+       DEBUG_START_HWTRACE(p5, r7)
        (R7:6,P5:4) = [sp++];
        ASTAT = [sp++];
        raise 15;               /* invoked by TRAP #0, for sys call */
@@ -186,7 +167,7 @@ ENTRY(_ex_single_step)
        if !cc jump _ex_trap_c;
 
 _return_from_exception:
-       DEBUG_START_HWTRACE
+       DEBUG_START_HWTRACE(p5, r7)
 #ifdef ANOMALY_05000257
        R7=LC0;
        LC0=R7;
@@ -208,7 +189,7 @@ ENTRY(_handle_bad_cplb)
         * need to make a CPLB exception look like a normal exception
         */
 
-       DEBUG_START_HWTRACE
+       DEBUG_START_HWTRACE(p5, r7)
        RESTORE_ALL_SYS
        [--sp] = ASTAT;
        [--sp] = (R7:6, P5:4);
@@ -251,7 +232,7 @@ ENTRY(_ex_trap_c)
        R6 = SEQSTAT;
        [P5] = R6;
 
-       DEBUG_START_HWTRACE
+       DEBUG_START_HWTRACE(p5, r7)
        (R7:6,P5:4) = [sp++];
        ASTAT = [sp++];
        SP = RETN;
@@ -335,7 +316,7 @@ ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
        /* Try to deal with syscalls quickly.  */
        [--sp] = ASTAT;
        [--sp] = (R7:6, P5:4);
-       DEBUG_STOP_HWTRACE
+       DEBUG_STOP_HWTRACE(p5, r7)
        r7 = SEQSTAT;           /* reason code is in bit 5:0 */
        r6.l = lo(SEQSTAT_EXCAUSE);
        r6.h = hi(SEQSTAT_EXCAUSE);
index 8be548e061bff73a82b98659e500ddadd29abbc2..203e20709163811021e98131d2747b32e189c3a1 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/linkage.h>
 #include <asm/entry.h>
 #include <asm/asm-offsets.h>
+#include <asm/trace.h>
 
 #include <asm/mach-common/context.S>
 
@@ -170,10 +171,9 @@ ENTRY(_evt_ivhw)
        r7.l = W[p5];
 1:
 #endif
-       p0.l = lo(TBUFCTL);
-       p0.h = hi(TBUFCTL);
-       r0 = 1;
-       [p0] = r0;
+
+       trace_buffer_stop(p0, r0);
+
        r0 = IRQ_HWERR;
        r1 = sp;
 
diff --git a/include/asm-blackfin/trace.h b/include/asm-blackfin/trace.h
new file mode 100644 (file)
index 0000000..9c2474c
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Common header file for blackfin family of processors.
+ *
+ */
+
+#ifndef _BLACKFIN_TRACE_
+#define _BLACKFIN_TRACE_
+
+#ifndef __ASSEMBLY__
+/* Trace Macros for C files */
+
+#define trace_buffer_save(x) \
+        do { \
+                (x) = bfin_read_TBUFCTL(); \
+                bfin_write_TBUFCTL((x) & ~TBUFEN); \
+        } while (0)
+
+#define trace_buffer_restore(x) \
+        do { \
+                bfin_write_TBUFCTL((x));        \
+        } while (0)
+
+#else
+/* Trace Macros for Assembly files */
+
+#define TRACE_BUFFER_START(preg, dreg) trace_buffer_start(preg, dreg)
+#define TRACE_BUFFER_STOP(preg, dreg)  trace_buffer_stop(preg, dreg)
+
+#define trace_buffer_stop(preg, dreg)  \
+       preg.L = LO(TBUFCTL);           \
+       preg.H = HI(TBUFCTL);           \
+       dreg = 0x1;                     \
+       [preg] = dreg;
+
+#define trace_buffer_start(preg, dreg) \
+       preg.L = LO(TBUFCTL);           \
+       preg.H = HI(TBUFCTL);           \
+       dreg = 0x13;                    \
+       [preg] = dreg;
+
+#ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
+# define DEBUG_START_HWTRACE(preg, dreg) trace_buffer_start(preg, dreg)
+# define DEBUG_STOP_HWTRACE(preg, dreg) trace_buffer_stop(preg, dreg)
+
+#else
+# define DEBUG_START_HWTRACE(preg, dreg)
+# define DEBUG_STOP_HWTRACE(preg, dreg)
+#endif
+
+#endif /* __ASSEMBLY__ */
+
+#endif                         /* _BLACKFIN_TRACE_ */