From: anonymix007 <48598263+anonymix007@users.noreply.github.com> Date: Wed, 11 Sep 2024 21:26:34 +0000 (+0300) Subject: boot: Add log_info and log_debug X-Git-Tag: v257-rc1~254^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=beb41e3948a4a48535dba728ad1dfdc1e1677bd1;p=thirdparty%2Fsystemd.git boot: Add log_info and log_debug --- diff --git a/src/boot/efi/log.c b/src/boot/efi/log.c index 364471e6a28..8ada8e9d8cf 100644 --- a/src/boot/efi/log.c +++ b/src/boot/efi/log.c @@ -2,7 +2,6 @@ #include "log.h" #include "proto/rng.h" -#include "proto/simple-text-io.h" #include "util.h" static unsigned log_count = 0; @@ -32,14 +31,14 @@ void efi_assert(const char *expr, const char *file, unsigned line, const char *f freeze(); } -EFI_STATUS log_internal(EFI_STATUS status, const char *format, ...) { +EFI_STATUS log_internal(EFI_STATUS status, uint8_t text_color, const char *format, ...) { assert(format); int32_t attr = ST->ConOut->Mode->Attribute; if (ST->ConOut->Mode->CursorColumn > 0) ST->ConOut->OutputString(ST->ConOut, (char16_t *) u"\r\n"); - ST->ConOut->SetAttribute(ST->ConOut, EFI_TEXT_ATTR(EFI_LIGHTRED, EFI_BLACK)); + ST->ConOut->SetAttribute(ST->ConOut, EFI_TEXT_ATTR(text_color, EFI_BLACK)); va_list ap; va_start(ap, format); @@ -58,7 +57,7 @@ void log_hexdump(const char16_t *prefix, const void *data, size_t size) { /* Debugging helper — please keep this around, even if not used */ _cleanup_free_ char16_t *hex = hexdump(data, size); - log_internal(EFI_SUCCESS, "%ls[%zu]: %ls", prefix, size, hex); + log_internal(EFI_SUCCESS, EFI_LIGHTRED, "%ls[%zu]: %ls", prefix, size, hex); } #endif diff --git a/src/boot/efi/log.h b/src/boot/efi/log.h index 13f3887b8a8..9ea8e1891f3 100644 --- a/src/boot/efi/log.h +++ b/src/boot/efi/log.h @@ -2,6 +2,7 @@ #pragma once #include "efi-string.h" +#include "proto/simple-text-io.h" #if defined __has_attribute # if __has_attribute(no_stack_protector) @@ -21,11 +22,13 @@ __attribute__((no_stack_protector, noinline)) void __stack_chk_guard_init(void); _noreturn_ void freeze(void); void log_wait(void); -_gnu_printf_(2, 3) EFI_STATUS log_internal(EFI_STATUS status, const char *format, ...); -#define log_error_status(status, ...) log_internal(status, __VA_ARGS__) -#define log_error(...) log_internal(EFI_INVALID_PARAMETER, __VA_ARGS__) -#define log_oom() log_internal(EFI_OUT_OF_RESOURCES, "Out of memory.") -#define log_trace() log_internal(EFI_SUCCESS, "%s:%i@%s", __FILE__, __LINE__, __func__) +_gnu_printf_(3, 4) EFI_STATUS log_internal(EFI_STATUS status, uint8_t text_color, const char *format, ...); +#define log_debug(...) log_internal(EFI_SUCCESS, EFI_LIGHTGRAY, __VA_ARGS__) +#define log_info(...) log_internal(EFI_SUCCESS, EFI_WHITE, __VA_ARGS__) +#define log_error_status(status, ...) log_internal(status, EFI_LIGHTRED, __VA_ARGS__) +#define log_error(...) log_internal(EFI_INVALID_PARAMETER, EFI_LIGHTRED, __VA_ARGS__) +#define log_oom() log_internal(EFI_OUT_OF_RESOURCES, EFI_LIGHTRED, "Out of memory.") +#define log_trace() log_internal(EFI_SUCCESS, EFI_LIGHTRED, "%s:%i@%s", __FILE__, __LINE__, __func__) #ifdef EFI_DEBUG void log_hexdump(const char16_t *prefix, const void *data, size_t size);