1*4aad8f51SJason Wessel /* 2*4aad8f51SJason Wessel * Created by: Jason Wessel <jason.wessel@windriver.com> 3*4aad8f51SJason Wessel * 4*4aad8f51SJason Wessel * Copyright (c) 2010 Wind River Systems, Inc. All Rights Reserved. 5*4aad8f51SJason Wessel * 6*4aad8f51SJason Wessel * This file is licensed under the terms of the GNU General Public 7*4aad8f51SJason Wessel * License version 2. This program is licensed "as is" without any 8*4aad8f51SJason Wessel * warranty of any kind, whether express or implied. 9*4aad8f51SJason Wessel */ 10*4aad8f51SJason Wessel 11*4aad8f51SJason Wessel #include <linux/module.h> 12*4aad8f51SJason Wessel #include <linux/kdb.h> 13*4aad8f51SJason Wessel 14*4aad8f51SJason Wessel /* 15*4aad8f51SJason Wessel * All kdb shell command call backs receive argc and argv, where 16*4aad8f51SJason Wessel * argv[0] is the command the end user typed 17*4aad8f51SJason Wessel */ 18*4aad8f51SJason Wessel static int kdb_hello_cmd(int argc, const char **argv) 19*4aad8f51SJason Wessel { 20*4aad8f51SJason Wessel if (argc > 1) 21*4aad8f51SJason Wessel return KDB_ARGCOUNT; 22*4aad8f51SJason Wessel 23*4aad8f51SJason Wessel if (argc) 24*4aad8f51SJason Wessel kdb_printf("Hello %s.\n", argv[1]); 25*4aad8f51SJason Wessel else 26*4aad8f51SJason Wessel kdb_printf("Hello world!\n"); 27*4aad8f51SJason Wessel 28*4aad8f51SJason Wessel return 0; 29*4aad8f51SJason Wessel } 30*4aad8f51SJason Wessel 31*4aad8f51SJason Wessel 32*4aad8f51SJason Wessel static int __init kdb_hello_cmd_init(void) 33*4aad8f51SJason Wessel { 34*4aad8f51SJason Wessel /* 35*4aad8f51SJason Wessel * Registration of a dynamically added kdb command is done with 36*4aad8f51SJason Wessel * kdb_register() with the arguments being: 37*4aad8f51SJason Wessel * 1: The name of the shell command 38*4aad8f51SJason Wessel * 2: The function that processes the command 39*4aad8f51SJason Wessel * 3: Description of the usage of any arguments 40*4aad8f51SJason Wessel * 4: Descriptive text when you run help 41*4aad8f51SJason Wessel * 5: Number of characters to complete the command 42*4aad8f51SJason Wessel * 0 == type the whole command 43*4aad8f51SJason Wessel * 1 == match both "g" and "go" for example 44*4aad8f51SJason Wessel */ 45*4aad8f51SJason Wessel kdb_register("hello", kdb_hello_cmd, "[string]", 46*4aad8f51SJason Wessel "Say Hello World or Hello [string]", 0); 47*4aad8f51SJason Wessel return 0; 48*4aad8f51SJason Wessel } 49*4aad8f51SJason Wessel 50*4aad8f51SJason Wessel static void __exit kdb_hello_cmd_exit(void) 51*4aad8f51SJason Wessel { 52*4aad8f51SJason Wessel kdb_unregister("hello"); 53*4aad8f51SJason Wessel } 54*4aad8f51SJason Wessel 55*4aad8f51SJason Wessel module_init(kdb_hello_cmd_init); 56*4aad8f51SJason Wessel module_exit(kdb_hello_cmd_exit); 57*4aad8f51SJason Wessel 58*4aad8f51SJason Wessel MODULE_AUTHOR("WindRiver"); 59*4aad8f51SJason Wessel MODULE_DESCRIPTION("KDB example to add a hello command"); 60*4aad8f51SJason Wessel MODULE_LICENSE("GPL"); 61