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