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