kdb_hello.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Created by: Jason Wessel <[email protected]>
  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 kdbtab_t hello_cmd = {
  27. .name = "hello",
  28. .func = kdb_hello_cmd,
  29. .usage = "[string]",
  30. .help = "Say Hello World or Hello [string]",
  31. };
  32. static int __init kdb_hello_cmd_init(void)
  33. {
  34. /*
  35. * Registration of a dynamically added kdb command is done with
  36. * kdb_register().
  37. */
  38. kdb_register(&hello_cmd);
  39. return 0;
  40. }
  41. static void __exit kdb_hello_cmd_exit(void)
  42. {
  43. kdb_unregister(&hello_cmd);
  44. }
  45. module_init(kdb_hello_cmd_init);
  46. module_exit(kdb_hello_cmd_exit);
  47. MODULE_AUTHOR("WindRiver");
  48. MODULE_DESCRIPTION("KDB example to add a hello command");
  49. MODULE_LICENSE("GPL");