diff options
author | Mike Frysinger <vapier.adi@gmail.com> | 2009-01-07 10:14:39 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@kernel.org> | 2009-01-07 10:14:39 -0500 |
commit | 459249aa2d9ae02f49479a2096e5372ccc29c9be (patch) | |
tree | 9da223c667b0446f97dd2ac872dfddc0c76d0979 /arch/blackfin | |
parent | dbdf20db537a5369c65330f878ad4905020a8bfa (diff) |
Blackfin arch: merge kgdb test code using common CONFIG_KGDB_TESTS
[Grace Pan <grace.pan@analog.com>: Add case for kgdb test in l1 and l2]
Signed-off-by: Grace Pan <grace.pan@analog.com>
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r-- | arch/blackfin/Kconfig.debug | 8 | ||||
-rw-r--r-- | arch/blackfin/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/blackfin/kernel/kgdb_test.c | 123 |
3 files changed, 131 insertions, 1 deletions
diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug index bfd712ab125c..c8ff41eebc98 100644 --- a/arch/blackfin/Kconfig.debug +++ b/arch/blackfin/Kconfig.debug | |||
@@ -19,7 +19,13 @@ config DEBUG_STACK_USAGE | |||
19 | This option will slow down process creation somewhat. | 19 | This option will slow down process creation somewhat. |
20 | 20 | ||
21 | config HAVE_ARCH_KGDB | 21 | config HAVE_ARCH_KGDB |
22 | def_bool y | 22 | def_bool y |
23 | |||
24 | config KGDB_TESTCASE | ||
25 | tristate "KGDB: for test case in expect" | ||
26 | default n | ||
27 | help | ||
28 | This is a kgdb test case for automated testing. | ||
23 | 29 | ||
24 | config DEBUG_VERBOSE | 30 | config DEBUG_VERBOSE |
25 | bool "Verbose fault messages" | 31 | bool "Verbose fault messages" |
diff --git a/arch/blackfin/kernel/Makefile b/arch/blackfin/kernel/Makefile index 01a60ca69216..f0902c120dc2 100644 --- a/arch/blackfin/kernel/Makefile +++ b/arch/blackfin/kernel/Makefile | |||
@@ -19,4 +19,5 @@ obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o | |||
19 | obj-$(CONFIG_CPLB_INFO) += cplbinfo.o | 19 | obj-$(CONFIG_CPLB_INFO) += cplbinfo.o |
20 | obj-$(CONFIG_MODULES) += module.o | 20 | obj-$(CONFIG_MODULES) += module.o |
21 | obj-$(CONFIG_KGDB) += kgdb.o | 21 | obj-$(CONFIG_KGDB) += kgdb.o |
22 | obj-$(CONFIG_KGDB_TESTCASE) += kgdb_test.o | ||
22 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | 23 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
diff --git a/arch/blackfin/kernel/kgdb_test.c b/arch/blackfin/kernel/kgdb_test.c new file mode 100644 index 000000000000..3dba9c17304a --- /dev/null +++ b/arch/blackfin/kernel/kgdb_test.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * arch/blackfin/kernel/kgdb_test.c - Blackfin kgdb tests | ||
3 | * | ||
4 | * Copyright 2005-2008 Analog Devices Inc. | ||
5 | * | ||
6 | * Licensed under the GPL-2 or later. | ||
7 | */ | ||
8 | |||
9 | #include <linux/module.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/proc_fs.h> | ||
13 | |||
14 | #include <asm/current.h> | ||
15 | #include <asm/uaccess.h> | ||
16 | #include <asm/system.h> | ||
17 | |||
18 | #include <asm/blackfin.h> | ||
19 | |||
20 | static char cmdline[256]; | ||
21 | static unsigned long len; | ||
22 | |||
23 | static int num1 __attribute__((l1_data)); | ||
24 | |||
25 | void kgdb_l1_test(void) __attribute__((l1_text)); | ||
26 | |||
27 | void kgdb_l1_test(void) | ||
28 | { | ||
29 | printk(KERN_ALERT "L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); | ||
30 | printk(KERN_ALERT "L1 : code function addr = 0x%p\n", kgdb_l1_test); | ||
31 | num1 = num1 + 10 ; | ||
32 | printk(KERN_ALERT "L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); | ||
33 | return ; | ||
34 | } | ||
35 | #if L2_LENGTH | ||
36 | |||
37 | static int num2 __attribute__((l2)); | ||
38 | void kgdb_l2_test(void) __attribute__((l2)); | ||
39 | |||
40 | void kgdb_l2_test(void) | ||
41 | { | ||
42 | printk(KERN_ALERT "L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); | ||
43 | printk(KERN_ALERT "L2 : code function addr = 0x%p\n", kgdb_l2_test); | ||
44 | num2 = num2 + 20 ; | ||
45 | printk(KERN_ALERT "L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); | ||
46 | return ; | ||
47 | } | ||
48 | |||
49 | #endif | ||
50 | |||
51 | |||
52 | int kgdb_test(char *name, int len, int count, int z) | ||
53 | { | ||
54 | printk(KERN_DEBUG "kgdb name(%d): %s, %d, %d\n", len, name, count, z); | ||
55 | count = z; | ||
56 | return count; | ||
57 | } | ||
58 | |||
59 | static int test_proc_output(char *buf) | ||
60 | { | ||
61 | kgdb_test("hello world!", 12, 0x55, 0x10); | ||
62 | kgdb_l1_test(); | ||
63 | #if L2_LENGTH | ||
64 | kgdb_l2_test(); | ||
65 | #endif | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static int test_read_proc(char *page, char **start, off_t off, | ||
71 | int count, int *eof, void *data) | ||
72 | { | ||
73 | int len; | ||
74 | |||
75 | len = test_proc_output(page); | ||
76 | if (len <= off+count) | ||
77 | *eof = 1; | ||
78 | *start = page + off; | ||
79 | len -= off; | ||
80 | if (len > count) | ||
81 | len = count; | ||
82 | if (len < 0) | ||
83 | len = 0; | ||
84 | return len; | ||
85 | } | ||
86 | |||
87 | static int test_write_proc(struct file *file, const char *buffer, | ||
88 | unsigned long count, void *data) | ||
89 | { | ||
90 | if (count >= 256) | ||
91 | len = 255; | ||
92 | else | ||
93 | len = count; | ||
94 | |||
95 | memcpy(cmdline, buffer, count); | ||
96 | cmdline[len] = 0; | ||
97 | |||
98 | return len; | ||
99 | } | ||
100 | |||
101 | static int __init kgdbtest_init(void) | ||
102 | { | ||
103 | struct proc_dir_entry *entry; | ||
104 | |||
105 | entry = create_proc_entry("kgdbtest", 0, NULL); | ||
106 | if (entry == NULL) | ||
107 | return -ENOMEM; | ||
108 | |||
109 | entry->read_proc = test_read_proc; | ||
110 | entry->write_proc = test_write_proc; | ||
111 | entry->data = NULL; | ||
112 | |||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | static void __exit kgdbtest_exit(void) | ||
117 | { | ||
118 | remove_proc_entry("kgdbtest", NULL); | ||
119 | } | ||
120 | |||
121 | module_init(kgdbtest_init); | ||
122 | module_exit(kgdbtest_exit); | ||
123 | MODULE_LICENSE("GPL"); | ||