aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel/kgdb_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/kernel/kgdb_test.c')
-rw-r--r--arch/blackfin/kernel/kgdb_test.c123
1 files changed, 123 insertions, 0 deletions
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
20static char cmdline[256];
21static unsigned long len;
22
23static int num1 __attribute__((l1_data));
24
25void kgdb_l1_test(void) __attribute__((l1_text));
26
27void 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
37static int num2 __attribute__((l2));
38void kgdb_l2_test(void) __attribute__((l2));
39
40void 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
52int 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
59static 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
70static 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
87static 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
101static 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
116static void __exit kgdbtest_exit(void)
117{
118 remove_proc_entry("kgdbtest", NULL);
119}
120
121module_init(kgdbtest_init);
122module_exit(kgdbtest_exit);
123MODULE_LICENSE("GPL");