Commit | Line | Data |
---|---|---|
459249aa MF |
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 | ||
0bf3d933 | 23 | #ifndef CONFIG_SMP |
459249aa MF |
24 | static int num1 __attribute__((l1_data)); |
25 | ||
26 | void kgdb_l1_test(void) __attribute__((l1_text)); | |
27 | ||
28 | void kgdb_l1_test(void) | |
29 | { | |
30 | printk(KERN_ALERT "L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); | |
31 | printk(KERN_ALERT "L1 : code function addr = 0x%p\n", kgdb_l1_test); | |
32 | num1 = num1 + 10 ; | |
33 | printk(KERN_ALERT "L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); | |
34 | return ; | |
35 | } | |
0bf3d933 SZ |
36 | #endif |
37 | ||
459249aa MF |
38 | #if L2_LENGTH |
39 | ||
40 | static int num2 __attribute__((l2)); | |
41 | void kgdb_l2_test(void) __attribute__((l2)); | |
42 | ||
43 | void kgdb_l2_test(void) | |
44 | { | |
45 | printk(KERN_ALERT "L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); | |
46 | printk(KERN_ALERT "L2 : code function addr = 0x%p\n", kgdb_l2_test); | |
47 | num2 = num2 + 20 ; | |
48 | printk(KERN_ALERT "L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); | |
49 | return ; | |
50 | } | |
51 | ||
52 | #endif | |
53 | ||
54 | ||
55 | int kgdb_test(char *name, int len, int count, int z) | |
56 | { | |
4a3e53c1 | 57 | printk(KERN_ALERT "kgdb name(%d): %s, %d, %d\n", len, name, count, z); |
459249aa MF |
58 | count = z; |
59 | return count; | |
60 | } | |
61 | ||
62 | static int test_proc_output(char *buf) | |
63 | { | |
64 | kgdb_test("hello world!", 12, 0x55, 0x10); | |
0bf3d933 | 65 | #ifndef CONFIG_SMP |
459249aa | 66 | kgdb_l1_test(); |
0bf3d933 SZ |
67 | #endif |
68 | #if L2_LENGTH | |
459249aa | 69 | kgdb_l2_test(); |
0bf3d933 | 70 | #endif |
459249aa MF |
71 | |
72 | return 0; | |
73 | } | |
74 | ||
75 | static int test_read_proc(char *page, char **start, off_t off, | |
76 | int count, int *eof, void *data) | |
77 | { | |
78 | int len; | |
79 | ||
80 | len = test_proc_output(page); | |
81 | if (len <= off+count) | |
82 | *eof = 1; | |
83 | *start = page + off; | |
84 | len -= off; | |
85 | if (len > count) | |
86 | len = count; | |
87 | if (len < 0) | |
88 | len = 0; | |
89 | return len; | |
90 | } | |
91 | ||
92 | static int test_write_proc(struct file *file, const char *buffer, | |
93 | unsigned long count, void *data) | |
94 | { | |
95 | if (count >= 256) | |
96 | len = 255; | |
97 | else | |
98 | len = count; | |
99 | ||
100 | memcpy(cmdline, buffer, count); | |
101 | cmdline[len] = 0; | |
102 | ||
103 | return len; | |
104 | } | |
105 | ||
106 | static int __init kgdbtest_init(void) | |
107 | { | |
108 | struct proc_dir_entry *entry; | |
109 | ||
110 | entry = create_proc_entry("kgdbtest", 0, NULL); | |
111 | if (entry == NULL) | |
112 | return -ENOMEM; | |
113 | ||
114 | entry->read_proc = test_read_proc; | |
115 | entry->write_proc = test_write_proc; | |
116 | entry->data = NULL; | |
117 | ||
118 | return 0; | |
119 | } | |
120 | ||
121 | static void __exit kgdbtest_exit(void) | |
122 | { | |
123 | remove_proc_entry("kgdbtest", NULL); | |
124 | } | |
125 | ||
126 | module_init(kgdbtest_init); | |
127 | module_exit(kgdbtest_exit); | |
128 | MODULE_LICENSE("GPL"); |