printk.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #include <efi.h>
  3. #include "linux/stdarg.h"
  4. #define efi_printk(__fmt, ...) \
  5. ({ \
  6. static CHAR16 __mem[2048]; \
  7. int i; \
  8. for (i = 0; __fmt[i]; ++i) \
  9. __mem[i] = (CHAR16)__fmt[i]; \
  10. __mem[i] = 0; \
  11. Print(__mem, ##__VA_ARGS__); \
  12. })
  13. #define efi_todo(__fmt) \
  14. ({ \
  15. efi_printk("Not yet implemented: " __fmt); \
  16. while (1) \
  17. ; \
  18. })
  19. #define efi_info(fmt, ...) efi_printk("[INFO]: " fmt, ##__VA_ARGS__)
  20. #define efi_warn(fmt, ...) efi_printk("[WARNING]: " fmt, ##__VA_ARGS__)
  21. #define efi_err(fmt, ...) efi_printk("[ERROR]: " fmt, ##__VA_ARGS__)
  22. #define efi_debug(fmt, ...) efi_printk("[DEBUG]: " fmt, ##__VA_ARGS__)
  23. /**
  24. * snprintf - Format a string and place it in a buffer
  25. * @buf: The buffer to place the result into
  26. * @size: The size of the buffer, including the trailing null space
  27. * @fmt: The format string to use
  28. * @...: Arguments for the format string
  29. *
  30. * The return value is the number of characters which would be
  31. * generated for the given input, excluding the trailing null,
  32. * as per ISO C99. If the return is greater than or equal to
  33. * @size, the resulting string is truncated.
  34. *
  35. * See the vsnprintf() documentation for format string extensions over C99.
  36. */
  37. int snprintf(char *buf, size_t size, const char *fmt, ...);
  38. /**
  39. * vsnprintf - Format a string and place it in a buffer
  40. * @buf: The buffer to place the result into
  41. * @size: The size of the buffer, including the trailing null space
  42. * @fmt: The format string to use
  43. * @args: Arguments for the format string
  44. *
  45. * This function generally follows C99 vsnprintf, but has some
  46. * extensions and a few limitations:
  47. *
  48. * - ``%n`` is unsupported
  49. * - ``%p*`` is handled by pointer()
  50. *
  51. * See pointer() or Documentation/core-api/printk-formats.rst for more
  52. * extensive description.
  53. *
  54. * **Please update the documentation in both places when making changes**
  55. *
  56. * The return value is the number of characters which would
  57. * be generated for the given input, excluding the trailing
  58. * '\0', as per ISO C99. If you want to have the exact
  59. * number of characters written into @buf as return value
  60. * (not including the trailing '\0'), use vscnprintf(). If the
  61. * return is greater than or equal to @size, the resulting
  62. * string is truncated.
  63. *
  64. * If you're not already dealing with a va_list consider using snprintf().
  65. */
  66. int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);