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