Commit 4fff5ac2f89140361e373818aa3c8c6c7dbd20e9

Authored by Mike Frysinger
1 parent 5079d8bbad

Blackfin: jtag-console: add debug markers

While we're in here, add some useful debug points.  We need custom debug
statements because we need the output to only go to the serial port.  If
we used the standard debug helpers, the output would also go to the stdout
(which would be the jtag console) and make it hard to figure out what is
going where exactly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Showing 1 changed file with 27 additions and 1 deletions Side-by-side Diff

arch/blackfin/cpu/jtag-console.c
... ... @@ -10,6 +10,22 @@
10 10 #include <stdio_dev.h>
11 11 #include <asm/blackfin.h>
12 12  
  13 +#ifdef DEBUG
  14 +# define dprintf(...) serial_printf(__VA_ARGS__)
  15 +#else
  16 +# define dprintf(...) do { if (0) printf(__VA_ARGS__); } while (0)
  17 +#endif
  18 +
  19 +static inline void dprintf_decode(const char *s, uint32_t len)
  20 +{
  21 + uint32_t i;
  22 + for (i = 0; i < len; ++i)
  23 + if (s[i] < 0x20 || s[i] >= 0x7f)
  24 + dprintf("\\%o", s[i]);
  25 + else
  26 + dprintf("%c", s[i]);
  27 +}
  28 +
13 29 static inline uint32_t bfin_write_emudat(uint32_t emudat)
14 30 {
15 31 __asm__ __volatile__("emudat = %0;" : : "d"(emudat));
... ... @@ -52,6 +68,10 @@
52 68 if (len == 0)
53 69 return;
54 70  
  71 + dprintf("%s(\"", __func__);
  72 + dprintf_decode(c, len);
  73 + dprintf("\", %i)\n", len);
  74 +
55 75 /* First send the length */
56 76 if (jtag_write_emudat(len))
57 77 return;
... ... @@ -83,7 +103,10 @@
83 103 /* Lower layers want to know when jtag has data */
84 104 static int jtag_tstc_dbg(void)
85 105 {
86   - return (bfin_read_DBGSTAT() & 0x2);
  106 + int ret = (bfin_read_DBGSTAT() & 0x2);
  107 + if (ret)
  108 + dprintf("%s: ret:%i\n", __func__, ret);
  109 + return ret;
87 110 }
88 111  
89 112 /* Higher layers want to know when any data is available */
... ... @@ -100,6 +123,9 @@
100 123 {
101 124 int ret;
102 125 uint32_t emudat;
  126 +
  127 + dprintf("%s: inlen:%zu leftlen:%zu left:%x\n", __func__,
  128 + inbound_len, leftovers_len, leftovers);
103 129  
104 130 /* see if any data is left over */
105 131 if (leftovers_len) {