xtest.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2014-2018 K. Lange
  5. */
  6. #include <kernel/system.h>
  7. #include <kernel/module.h>
  8. #include <kernel/printf.h>
  9. #include <kernel/logging.h>
  10. #include <kernel/mod/shell.h>
  11. static void xtest_a(void * data, char * name) {
  12. fs_node_t * tty = data;
  13. fprintf(tty, "[%s] Hello world.\n", name);
  14. while (1) {
  15. fprintf(tty, "[%s] Ping.\n", name);
  16. unsigned long s, ss;
  17. relative_time(1, 0, &s, &ss);
  18. sleep_until((process_t *)current_process, s, ss);
  19. switch_task(0);
  20. }
  21. }
  22. static int hello(void) {
  23. fs_node_t * tty = kopen("/dev/ttyS0", 0);
  24. fprintf(tty, "[xtest] Starting background thread...\n");
  25. create_kernel_tasklet(xtest_a, "xtest-a", (void *)tty);
  26. fprintf(tty, "[xtest] Enabling logging directly to serial...\n");
  27. debug_file = tty;
  28. debug_level = 1;
  29. return 0;
  30. }
  31. static int goodbye(void) {
  32. return 0;
  33. }
  34. MODULE_DEF(xtest, hello, goodbye);
  35. MODULE_DEPENDS(serial);