kdb_hello.c 1.5 KB

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