2009-01-07 08:14:39 -07:00
|
|
|
/*
|
|
|
|
* arch/blackfin/kernel/kgdb_test.c - Blackfin kgdb tests
|
|
|
|
*
|
|
|
|
* Copyright 2005-2008 Analog Devices Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the GPL-2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
|
|
|
|
#include <asm/current.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/system.h>
|
|
|
|
|
|
|
|
#include <asm/blackfin.h>
|
|
|
|
|
2009-12-07 03:20:20 -07:00
|
|
|
/* Symbols are here for kgdb test to poke directly */
|
2009-01-07 08:14:39 -07:00
|
|
|
static char cmdline[256];
|
2009-12-04 17:27:29 -07:00
|
|
|
static size_t len;
|
2009-01-07 08:14:39 -07:00
|
|
|
|
2009-03-05 01:44:53 -07:00
|
|
|
#ifndef CONFIG_SMP
|
2009-01-07 08:14:39 -07:00
|
|
|
static int num1 __attribute__((l1_data));
|
|
|
|
|
|
|
|
void kgdb_l1_test(void) __attribute__((l1_text));
|
|
|
|
|
|
|
|
void kgdb_l1_test(void)
|
|
|
|
{
|
2009-12-07 03:20:20 -07:00
|
|
|
pr_alert("L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1);
|
|
|
|
pr_alert("L1 : code function addr = 0x%p\n", kgdb_l1_test);
|
|
|
|
num1 = num1 + 10;
|
|
|
|
pr_alert("L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1);
|
2009-01-07 08:14:39 -07:00
|
|
|
}
|
2009-03-05 01:44:53 -07:00
|
|
|
#endif
|
|
|
|
|
2009-01-07 08:14:39 -07:00
|
|
|
#if L2_LENGTH
|
|
|
|
|
|
|
|
static int num2 __attribute__((l2));
|
|
|
|
void kgdb_l2_test(void) __attribute__((l2));
|
|
|
|
|
|
|
|
void kgdb_l2_test(void)
|
|
|
|
{
|
2009-12-07 03:20:20 -07:00
|
|
|
pr_alert("L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2);
|
|
|
|
pr_alert("L2 : code function addr = 0x%p\n", kgdb_l2_test);
|
|
|
|
num2 = num2 + 20;
|
|
|
|
pr_alert("L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2);
|
2009-01-07 08:14:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int kgdb_test(char *name, int len, int count, int z)
|
|
|
|
{
|
2009-12-07 03:20:20 -07:00
|
|
|
pr_alert("kgdb name(%d): %s, %d, %d\n", len, name, count, z);
|
2009-01-07 08:14:39 -07:00
|
|
|
count = z;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2009-12-07 03:20:20 -07:00
|
|
|
static ssize_t
|
|
|
|
kgdb_test_proc_read(struct file *file, char __user *buf,
|
|
|
|
size_t count, loff_t *ppos)
|
2009-01-07 08:14:39 -07:00
|
|
|
{
|
|
|
|
kgdb_test("hello world!", 12, 0x55, 0x10);
|
2009-03-05 01:44:53 -07:00
|
|
|
#ifndef CONFIG_SMP
|
2009-01-07 08:14:39 -07:00
|
|
|
kgdb_l1_test();
|
2009-03-05 01:44:53 -07:00
|
|
|
#endif
|
|
|
|
#if L2_LENGTH
|
2009-01-07 08:14:39 -07:00
|
|
|
kgdb_l2_test();
|
2009-03-05 01:44:53 -07:00
|
|
|
#endif
|
2009-01-07 08:14:39 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-07 03:20:20 -07:00
|
|
|
static ssize_t
|
|
|
|
kgdb_test_proc_write(struct file *file, const char __user *buffer,
|
|
|
|
size_t count, loff_t *pos)
|
2009-01-07 08:14:39 -07:00
|
|
|
{
|
2009-12-07 03:20:20 -07:00
|
|
|
len = min_t(size_t, 255, count);
|
2009-01-07 08:14:39 -07:00
|
|
|
memcpy(cmdline, buffer, count);
|
|
|
|
cmdline[len] = 0;
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2009-12-04 17:27:29 -07:00
|
|
|
static const struct file_operations kgdb_test_proc_fops = {
|
2009-12-07 03:20:20 -07:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.read = kgdb_test_proc_read,
|
|
|
|
.write = kgdb_test_proc_write,
|
2009-12-04 17:27:29 -07:00
|
|
|
};
|
|
|
|
|
2009-01-07 08:14:39 -07:00
|
|
|
static int __init kgdbtest_init(void)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *entry;
|
|
|
|
|
2009-12-04 17:27:29 -07:00
|
|
|
entry = proc_create("kgdbtest", 0, NULL, &kgdb_test_proc_fops);
|
2009-01-07 08:14:39 -07:00
|
|
|
if (entry == NULL)
|
|
|
|
return -ENOMEM;
|
2009-12-07 03:20:20 -07:00
|
|
|
|
2009-01-07 08:14:39 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit kgdbtest_exit(void)
|
|
|
|
{
|
|
|
|
remove_proc_entry("kgdbtest", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(kgdbtest_init);
|
|
|
|
module_exit(kgdbtest_exit);
|
|
|
|
MODULE_LICENSE("GPL");
|