printf.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2010-2019 Richard Braun.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <stdio.h>
  18. #include <kern/console.h>
  19. #include <kern/fmt.h>
  20. #include <kern/init.h>
  21. #include <kern/spinlock.h>
  22. #include <machine/boot.h>
  23. #include <machine/cpu.h>
  24. int
  25. printf (const char *format, ...)
  26. {
  27. va_list ap;
  28. va_start (ap, format);
  29. int length = vprintf (format, ap);
  30. va_end (ap);
  31. return (length);
  32. }
  33. int
  34. vprintf (const char *format, va_list ap)
  35. {
  36. return (fmt_vxprintf (console_stream, format, ap));
  37. }
  38. static int __init
  39. printf_setup (void)
  40. {
  41. return (0);
  42. }
  43. INIT_OP_DEFINE (printf_setup,
  44. INIT_OP_DEP (boot_bootstrap_console, true),
  45. INIT_OP_DEP (console_bootstrap, true),
  46. INIT_OP_DEP (spinlock_setup, true));