Path: blob/master/arch/blackfin/kernel/kgdb_test.c
10817 views
/*1* arch/blackfin/kernel/kgdb_test.c - Blackfin kgdb tests2*3* Copyright 2005-2008 Analog Devices Inc.4*5* Licensed under the GPL-2 or later.6*/78#include <linux/module.h>9#include <linux/kernel.h>10#include <linux/init.h>11#include <linux/proc_fs.h>1213#include <asm/current.h>14#include <asm/uaccess.h>15#include <asm/system.h>1617#include <asm/blackfin.h>1819/* Symbols are here for kgdb test to poke directly */20static char cmdline[256];21static size_t len;2223#ifndef CONFIG_SMP24static int num1 __attribute__((l1_data));2526void kgdb_l1_test(void) __attribute__((l1_text));2728void kgdb_l1_test(void)29{30pr_alert("L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1);31pr_alert("L1 : code function addr = 0x%p\n", kgdb_l1_test);32num1 = num1 + 10;33pr_alert("L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1);34}35#endif3637#if L2_LENGTH3839static int num2 __attribute__((l2));40void kgdb_l2_test(void) __attribute__((l2));4142void kgdb_l2_test(void)43{44pr_alert("L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2);45pr_alert("L2 : code function addr = 0x%p\n", kgdb_l2_test);46num2 = num2 + 20;47pr_alert("L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2);48}4950#endif515253int kgdb_test(char *name, int len, int count, int z)54{55pr_alert("kgdb name(%d): %s, %d, %d\n", len, name, count, z);56count = z;57return count;58}5960static ssize_t61kgdb_test_proc_read(struct file *file, char __user *buf,62size_t count, loff_t *ppos)63{64kgdb_test("hello world!", 12, 0x55, 0x10);65#ifndef CONFIG_SMP66kgdb_l1_test();67#endif68#if L2_LENGTH69kgdb_l2_test();70#endif7172return 0;73}7475static ssize_t76kgdb_test_proc_write(struct file *file, const char __user *buffer,77size_t count, loff_t *pos)78{79len = min_t(size_t, 255, count);80memcpy(cmdline, buffer, count);81cmdline[len] = 0;8283return len;84}8586static const struct file_operations kgdb_test_proc_fops = {87.owner = THIS_MODULE,88.read = kgdb_test_proc_read,89.write = kgdb_test_proc_write,90.llseek = noop_llseek,91};9293static int __init kgdbtest_init(void)94{95struct proc_dir_entry *entry;9697#if L2_LENGTH98num2 = 0;99#endif100101entry = proc_create("kgdbtest", 0, NULL, &kgdb_test_proc_fops);102if (entry == NULL)103return -ENOMEM;104105return 0;106}107108static void __exit kgdbtest_exit(void)109{110remove_proc_entry("kgdbtest", NULL);111}112113module_init(kgdbtest_init);114module_exit(kgdbtest_exit);115MODULE_LICENSE("GPL");116117118