Skip to content

Commit 459249a

Browse files
Mike FrysingerBryan Wu
authored andcommitted
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>
1 parent dbdf20d commit 459249a

3 files changed

Lines changed: 131 additions & 1 deletion

File tree

‎arch/blackfin/Kconfig.debug‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ config DEBUG_STACK_USAGE
1919
This option will slow down process creation somewhat.
2020

2121
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.
2329

2430
config DEBUG_VERBOSE
2531
bool "Verbose fault messages"

‎arch/blackfin/kernel/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o
1919
obj-$(CONFIG_CPLB_INFO) += cplbinfo.o
2020
obj-$(CONFIG_MODULES) += module.o
2121
obj-$(CONFIG_KGDB) += kgdb.o
22+
obj-$(CONFIG_KGDB_TESTCASE) += kgdb_test.o
2223
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o

‎arch/blackfin/kernel/kgdb_test.c‎

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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");

0 commit comments

Comments
 (0)