diff options
Diffstat (limited to 'arch/powerpc/xmon')
-rw-r--r-- | arch/powerpc/xmon/Makefile | 2 | ||||
-rw-r--r-- | arch/powerpc/xmon/nonstdio.c | 53 | ||||
-rw-r--r-- | arch/powerpc/xmon/nonstdio.h | 6 | ||||
-rw-r--r-- | arch/powerpc/xmon/start.c | 34 | ||||
-rw-r--r-- | arch/powerpc/xmon/xmon.c | 26 |
5 files changed, 29 insertions, 92 deletions
diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile index c168c54e3c40..b49fdbd15808 100644 --- a/arch/powerpc/xmon/Makefile +++ b/arch/powerpc/xmon/Makefile | |||
@@ -6,7 +6,7 @@ GCOV_PROFILE := n | |||
6 | 6 | ||
7 | ccflags-$(CONFIG_PPC64) := -mno-minimal-toc | 7 | ccflags-$(CONFIG_PPC64) := -mno-minimal-toc |
8 | 8 | ||
9 | obj-y += xmon.o start.o nonstdio.o | 9 | obj-y += xmon.o nonstdio.o |
10 | 10 | ||
11 | ifdef CONFIG_XMON_DISASSEMBLY | 11 | ifdef CONFIG_XMON_DISASSEMBLY |
12 | obj-y += ppc-dis.o ppc-opc.o | 12 | obj-y += ppc-dis.o ppc-opc.o |
diff --git a/arch/powerpc/xmon/nonstdio.c b/arch/powerpc/xmon/nonstdio.c index bfac84fbe780..bce3dcfe5058 100644 --- a/arch/powerpc/xmon/nonstdio.c +++ b/arch/powerpc/xmon/nonstdio.c | |||
@@ -7,9 +7,23 @@ | |||
7 | * 2 of the License, or (at your option) any later version. | 7 | * 2 of the License, or (at your option) any later version. |
8 | */ | 8 | */ |
9 | #include <linux/string.h> | 9 | #include <linux/string.h> |
10 | #include <asm/udbg.h> | ||
10 | #include <asm/time.h> | 11 | #include <asm/time.h> |
11 | #include "nonstdio.h" | 12 | #include "nonstdio.h" |
12 | 13 | ||
14 | |||
15 | static int xmon_write(const void *ptr, int nb) | ||
16 | { | ||
17 | return udbg_write(ptr, nb); | ||
18 | } | ||
19 | |||
20 | static int xmon_readchar(void) | ||
21 | { | ||
22 | if (udbg_getc) | ||
23 | return udbg_getc(); | ||
24 | return -1; | ||
25 | } | ||
26 | |||
13 | int xmon_putchar(int c) | 27 | int xmon_putchar(int c) |
14 | { | 28 | { |
15 | char ch = c; | 29 | char ch = c; |
@@ -23,34 +37,7 @@ static char line[256]; | |||
23 | static char *lineptr; | 37 | static char *lineptr; |
24 | static int lineleft; | 38 | static int lineleft; |
25 | 39 | ||
26 | int xmon_expect(const char *str, unsigned long timeout) | 40 | static int xmon_getchar(void) |
27 | { | ||
28 | int c; | ||
29 | unsigned long t0; | ||
30 | |||
31 | /* assume 25MHz default timebase if tb_ticks_per_sec not set yet */ | ||
32 | timeout *= tb_ticks_per_sec? tb_ticks_per_sec: 25000000; | ||
33 | t0 = get_tbl(); | ||
34 | do { | ||
35 | lineptr = line; | ||
36 | for (;;) { | ||
37 | c = xmon_read_poll(); | ||
38 | if (c == -1) { | ||
39 | if (get_tbl() - t0 > timeout) | ||
40 | return 0; | ||
41 | continue; | ||
42 | } | ||
43 | if (c == '\n') | ||
44 | break; | ||
45 | if (c != '\r' && lineptr < &line[sizeof(line) - 1]) | ||
46 | *lineptr++ = c; | ||
47 | } | ||
48 | *lineptr = 0; | ||
49 | } while (strstr(line, str) == NULL); | ||
50 | return 1; | ||
51 | } | ||
52 | |||
53 | int xmon_getchar(void) | ||
54 | { | 41 | { |
55 | int c; | 42 | int c; |
56 | 43 | ||
@@ -124,13 +111,19 @@ char *xmon_gets(char *str, int nb) | |||
124 | void xmon_printf(const char *format, ...) | 111 | void xmon_printf(const char *format, ...) |
125 | { | 112 | { |
126 | va_list args; | 113 | va_list args; |
127 | int n; | ||
128 | static char xmon_outbuf[1024]; | 114 | static char xmon_outbuf[1024]; |
115 | int rc, n; | ||
129 | 116 | ||
130 | va_start(args, format); | 117 | va_start(args, format); |
131 | n = vsnprintf(xmon_outbuf, sizeof(xmon_outbuf), format, args); | 118 | n = vsnprintf(xmon_outbuf, sizeof(xmon_outbuf), format, args); |
132 | va_end(args); | 119 | va_end(args); |
133 | xmon_write(xmon_outbuf, n); | 120 | |
121 | rc = xmon_write(xmon_outbuf, n); | ||
122 | |||
123 | if (n && rc == 0) { | ||
124 | /* No udbg hooks, fallback to printk() - dangerous */ | ||
125 | printk(xmon_outbuf); | ||
126 | } | ||
134 | } | 127 | } |
135 | 128 | ||
136 | void xmon_puts(const char *str) | 129 | void xmon_puts(const char *str) |
diff --git a/arch/powerpc/xmon/nonstdio.h b/arch/powerpc/xmon/nonstdio.h index 23dd95f4599c..18a51ded4ffd 100644 --- a/arch/powerpc/xmon/nonstdio.h +++ b/arch/powerpc/xmon/nonstdio.h | |||
@@ -4,12 +4,6 @@ | |||
4 | #define putchar xmon_putchar | 4 | #define putchar xmon_putchar |
5 | 5 | ||
6 | extern int xmon_putchar(int c); | 6 | extern int xmon_putchar(int c); |
7 | extern int xmon_getchar(void); | ||
8 | extern void xmon_puts(const char *); | 7 | extern void xmon_puts(const char *); |
9 | extern char *xmon_gets(char *, int); | 8 | extern char *xmon_gets(char *, int); |
10 | extern void xmon_printf(const char *, ...); | 9 | extern void xmon_printf(const char *, ...); |
11 | extern void xmon_map_scc(void); | ||
12 | extern int xmon_expect(const char *str, unsigned long timeout); | ||
13 | extern int xmon_write(const void *ptr, int nb); | ||
14 | extern int xmon_readchar(void); | ||
15 | extern int xmon_read_poll(void); | ||
diff --git a/arch/powerpc/xmon/start.c b/arch/powerpc/xmon/start.c deleted file mode 100644 index 8864de2af382..000000000000 --- a/arch/powerpc/xmon/start.c +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1996 Paul Mackerras. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | #include <asm/machdep.h> | ||
10 | #include <asm/udbg.h> | ||
11 | #include "nonstdio.h" | ||
12 | |||
13 | void xmon_map_scc(void) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | int xmon_write(const void *ptr, int nb) | ||
18 | { | ||
19 | return udbg_write(ptr, nb); | ||
20 | } | ||
21 | |||
22 | int xmon_readchar(void) | ||
23 | { | ||
24 | if (udbg_getc) | ||
25 | return udbg_getc(); | ||
26 | return -1; | ||
27 | } | ||
28 | |||
29 | int xmon_read_poll(void) | ||
30 | { | ||
31 | if (udbg_getc_poll) | ||
32 | return udbg_getc_poll(); | ||
33 | return -1; | ||
34 | } | ||
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index 3a56a639a92e..1f8d2f10a432 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c | |||
@@ -52,9 +52,6 @@ | |||
52 | #include "nonstdio.h" | 52 | #include "nonstdio.h" |
53 | #include "dis-asm.h" | 53 | #include "dis-asm.h" |
54 | 54 | ||
55 | #define scanhex xmon_scanhex | ||
56 | #define skipbl xmon_skipbl | ||
57 | |||
58 | #ifdef CONFIG_SMP | 55 | #ifdef CONFIG_SMP |
59 | static cpumask_t cpus_in_xmon = CPU_MASK_NONE; | 56 | static cpumask_t cpus_in_xmon = CPU_MASK_NONE; |
60 | static unsigned long xmon_taken = 1; | 57 | static unsigned long xmon_taken = 1; |
@@ -169,12 +166,8 @@ extern void xmon_leave(void); | |||
169 | 166 | ||
170 | #ifdef CONFIG_PPC64 | 167 | #ifdef CONFIG_PPC64 |
171 | #define REG "%.16lx" | 168 | #define REG "%.16lx" |
172 | #define REGS_PER_LINE 4 | ||
173 | #define LAST_VOLATILE 13 | ||
174 | #else | 169 | #else |
175 | #define REG "%.8lx" | 170 | #define REG "%.8lx" |
176 | #define REGS_PER_LINE 8 | ||
177 | #define LAST_VOLATILE 12 | ||
178 | #endif | 171 | #endif |
179 | 172 | ||
180 | #define GETWORD(v) (((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3]) | 173 | #define GETWORD(v) (((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3]) |
@@ -1288,27 +1281,19 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp, | |||
1288 | catch_memory_errors = 0; | 1281 | catch_memory_errors = 0; |
1289 | } | 1282 | } |
1290 | 1283 | ||
1291 | static int xmon_depth_to_print = 64; | ||
1292 | |||
1293 | #define LRSAVE_OFFSET (STACK_FRAME_LR_SAVE * sizeof(unsigned long)) | 1284 | #define LRSAVE_OFFSET (STACK_FRAME_LR_SAVE * sizeof(unsigned long)) |
1294 | #define MARKER_OFFSET (STACK_FRAME_MARKER * sizeof(unsigned long)) | 1285 | #define MARKER_OFFSET (STACK_FRAME_MARKER * sizeof(unsigned long)) |
1295 | 1286 | ||
1296 | #ifdef __powerpc64__ | ||
1297 | #define REGS_OFFSET 0x70 | ||
1298 | #else | ||
1299 | #define REGS_OFFSET 16 | ||
1300 | #endif | ||
1301 | |||
1302 | static void xmon_show_stack(unsigned long sp, unsigned long lr, | 1287 | static void xmon_show_stack(unsigned long sp, unsigned long lr, |
1303 | unsigned long pc) | 1288 | unsigned long pc) |
1304 | { | 1289 | { |
1290 | int max_to_print = 64; | ||
1305 | unsigned long ip; | 1291 | unsigned long ip; |
1306 | unsigned long newsp; | 1292 | unsigned long newsp; |
1307 | unsigned long marker; | 1293 | unsigned long marker; |
1308 | int count = 0; | ||
1309 | struct pt_regs regs; | 1294 | struct pt_regs regs; |
1310 | 1295 | ||
1311 | do { | 1296 | while (max_to_print--) { |
1312 | if (sp < PAGE_OFFSET) { | 1297 | if (sp < PAGE_OFFSET) { |
1313 | if (sp != 0) | 1298 | if (sp != 0) |
1314 | printf("SP (%lx) is in userspace\n", sp); | 1299 | printf("SP (%lx) is in userspace\n", sp); |
@@ -1362,10 +1347,10 @@ static void xmon_show_stack(unsigned long sp, unsigned long lr, | |||
1362 | an exception frame. */ | 1347 | an exception frame. */ |
1363 | if (mread(sp + MARKER_OFFSET, &marker, sizeof(unsigned long)) | 1348 | if (mread(sp + MARKER_OFFSET, &marker, sizeof(unsigned long)) |
1364 | && marker == STACK_FRAME_REGS_MARKER) { | 1349 | && marker == STACK_FRAME_REGS_MARKER) { |
1365 | if (mread(sp + REGS_OFFSET, ®s, sizeof(regs)) | 1350 | if (mread(sp + STACK_FRAME_OVERHEAD, ®s, sizeof(regs)) |
1366 | != sizeof(regs)) { | 1351 | != sizeof(regs)) { |
1367 | printf("Couldn't read registers at %lx\n", | 1352 | printf("Couldn't read registers at %lx\n", |
1368 | sp + REGS_OFFSET); | 1353 | sp + STACK_FRAME_OVERHEAD); |
1369 | break; | 1354 | break; |
1370 | } | 1355 | } |
1371 | printf("--- Exception: %lx %s at ", regs.trap, | 1356 | printf("--- Exception: %lx %s at ", regs.trap, |
@@ -1379,7 +1364,7 @@ static void xmon_show_stack(unsigned long sp, unsigned long lr, | |||
1379 | break; | 1364 | break; |
1380 | 1365 | ||
1381 | sp = newsp; | 1366 | sp = newsp; |
1382 | } while (count++ < xmon_depth_to_print); | 1367 | } |
1383 | } | 1368 | } |
1384 | 1369 | ||
1385 | static void backtrace(struct pt_regs *excp) | 1370 | static void backtrace(struct pt_regs *excp) |
@@ -2943,7 +2928,6 @@ static void xmon_init(int enable) | |||
2943 | __debugger_dabr_match = NULL; | 2928 | __debugger_dabr_match = NULL; |
2944 | __debugger_fault_handler = NULL; | 2929 | __debugger_fault_handler = NULL; |
2945 | } | 2930 | } |
2946 | xmon_map_scc(); | ||
2947 | } | 2931 | } |
2948 | 2932 | ||
2949 | #ifdef CONFIG_MAGIC_SYSRQ | 2933 | #ifdef CONFIG_MAGIC_SYSRQ |