]>
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> | |
7c0f6ba6 | 15 | #include <linux/uaccess.h> |
459249aa MF |
16 | |
17 | #include <asm/blackfin.h> | |
18 | ||
88f7c2fb | 19 | /* Symbols are here for kgdb test to poke directly */ |
459249aa | 20 | static char cmdline[256]; |
397b761c | 21 | static size_t len; |
459249aa | 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 | { | |
88f7c2fb MF |
30 | pr_alert("L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); |
31 | pr_alert("L1 : code function addr = 0x%p\n", kgdb_l1_test); | |
32 | num1 = num1 + 10; | |
33 | pr_alert("L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); | |
459249aa | 34 | } |
0bf3d933 SZ |
35 | #endif |
36 | ||
459249aa MF |
37 | #if L2_LENGTH |
38 | ||
39 | static int num2 __attribute__((l2)); | |
40 | void kgdb_l2_test(void) __attribute__((l2)); | |
41 | ||
42 | void kgdb_l2_test(void) | |
43 | { | |
88f7c2fb MF |
44 | pr_alert("L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); |
45 | pr_alert("L2 : code function addr = 0x%p\n", kgdb_l2_test); | |
46 | num2 = num2 + 20; | |
47 | pr_alert("L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); | |
459249aa MF |
48 | } |
49 | ||
50 | #endif | |
51 | ||
a9930fd2 | 52 | noinline int kgdb_test(char *name, int len, int count, int z) |
459249aa | 53 | { |
88f7c2fb | 54 | pr_alert("kgdb name(%d): %s, %d, %d\n", len, name, count, z); |
459249aa MF |
55 | count = z; |
56 | return count; | |
57 | } | |
58 | ||
88f7c2fb MF |
59 | static ssize_t |
60 | kgdb_test_proc_read(struct file *file, char __user *buf, | |
61 | size_t count, loff_t *ppos) | |
459249aa MF |
62 | { |
63 | kgdb_test("hello world!", 12, 0x55, 0x10); | |
0bf3d933 | 64 | #ifndef CONFIG_SMP |
459249aa | 65 | kgdb_l1_test(); |
0bf3d933 SZ |
66 | #endif |
67 | #if L2_LENGTH | |
459249aa | 68 | kgdb_l2_test(); |
0bf3d933 | 69 | #endif |
459249aa MF |
70 | |
71 | return 0; | |
72 | } | |
73 | ||
88f7c2fb MF |
74 | static ssize_t |
75 | kgdb_test_proc_write(struct file *file, const char __user *buffer, | |
76 | size_t count, loff_t *pos) | |
459249aa | 77 | { |
88f7c2fb | 78 | len = min_t(size_t, 255, count); |
459249aa MF |
79 | memcpy(cmdline, buffer, count); |
80 | cmdline[len] = 0; | |
81 | ||
82 | return len; | |
83 | } | |
84 | ||
397b761c | 85 | static const struct file_operations kgdb_test_proc_fops = { |
88f7c2fb MF |
86 | .owner = THIS_MODULE, |
87 | .read = kgdb_test_proc_read, | |
88 | .write = kgdb_test_proc_write, | |
6038f373 | 89 | .llseek = noop_llseek, |
397b761c AD |
90 | }; |
91 | ||
459249aa MF |
92 | static int __init kgdbtest_init(void) |
93 | { | |
94 | struct proc_dir_entry *entry; | |
95 | ||
9fc20528 VL |
96 | #if L2_LENGTH |
97 | num2 = 0; | |
98 | #endif | |
99 | ||
397b761c | 100 | entry = proc_create("kgdbtest", 0, NULL, &kgdb_test_proc_fops); |
459249aa MF |
101 | if (entry == NULL) |
102 | return -ENOMEM; | |
88f7c2fb | 103 | |
459249aa MF |
104 | return 0; |
105 | } | |
106 | ||
107 | static void __exit kgdbtest_exit(void) | |
108 | { | |
109 | remove_proc_entry("kgdbtest", NULL); | |
110 | } | |
111 | ||
112 | module_init(kgdbtest_init); | |
113 | module_exit(kgdbtest_exit); | |
114 | MODULE_LICENSE("GPL"); |