Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Created by: Jason Wessel <jason.wessel@windriver.com>
0003  *
0004  * Copyright (c) 2010 Wind River Systems, Inc.  All Rights Reserved.
0005  *
0006  * This file is licensed under the terms of the GNU General Public
0007  * License version 2. This program is licensed "as is" without any
0008  * warranty of any kind, whether express or implied.
0009  */
0010 
0011 #include <linux/module.h>
0012 #include <linux/kdb.h>
0013 
0014 /*
0015  * All kdb shell command call backs receive argc and argv, where
0016  * argv[0] is the command the end user typed
0017  */
0018 static int kdb_hello_cmd(int argc, const char **argv)
0019 {
0020     if (argc > 1)
0021         return KDB_ARGCOUNT;
0022 
0023     if (argc)
0024         kdb_printf("Hello %s.\n", argv[1]);
0025     else
0026         kdb_printf("Hello world!\n");
0027 
0028     return 0;
0029 }
0030 
0031 static kdbtab_t hello_cmd = {
0032     .name = "hello",
0033     .func = kdb_hello_cmd,
0034     .usage = "[string]",
0035     .help = "Say Hello World or Hello [string]",
0036 };
0037 
0038 static int __init kdb_hello_cmd_init(void)
0039 {
0040     /*
0041      * Registration of a dynamically added kdb command is done with
0042      * kdb_register().
0043      */
0044     kdb_register(&hello_cmd);
0045     return 0;
0046 }
0047 
0048 static void __exit kdb_hello_cmd_exit(void)
0049 {
0050     kdb_unregister(&hello_cmd);
0051 }
0052 
0053 module_init(kdb_hello_cmd_init);
0054 module_exit(kdb_hello_cmd_exit);
0055 
0056 MODULE_AUTHOR("WindRiver");
0057 MODULE_DESCRIPTION("KDB example to add a hello command");
0058 MODULE_LICENSE("GPL");