89 lines
2.6 KiB
Diff
89 lines
2.6 KiB
Diff
|
From 81218e2fd9442ce2cbc901b7f6d2b3df3f705bba Mon Sep 17 00:00:00 2001
|
||
|
From: Gerd Hoffmann <kraxel@redhat.com>
|
||
|
Date: Wed, 3 May 2023 10:31:23 +0200
|
||
|
Subject: [PATCH] add hwerr_printf function for threads
|
||
|
|
||
|
RH-Author: Gerd Hoffmann <None>
|
||
|
RH-MergeRequest: 6: log error message to screen when booting with (unsupported) 4k sectors
|
||
|
RH-Jira: RHEL-7110
|
||
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
||
|
RH-Commit: [1/2] 37f3d1b45b289e4efb18817c265be2bff2606ebb (kraxel.rh/centos-src-seabios)
|
||
|
|
||
|
Printing to the screen from threads doesn't work, because that involves
|
||
|
a switch to real mode for using int10h services.
|
||
|
|
||
|
Add a string buffer and hwerr_printf() helper functions to store error
|
||
|
messages. Print the buffer later, after device initialization, from main
|
||
|
thread in case it is not empty.
|
||
|
|
||
|
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
||
|
|
||
|
Patch-name: seabios-add-hwerr_printf-function-for-threads.patch
|
||
|
Patch-id: 1
|
||
|
Patch-present-in-specfile: True
|
||
|
---
|
||
|
src/output.c | 17 +++++++++++++++++
|
||
|
src/output.h | 5 +++++
|
||
|
src/post.c | 4 ++++
|
||
|
3 files changed, 26 insertions(+)
|
||
|
|
||
|
diff --git a/src/output.c b/src/output.c
|
||
|
index 0184444c..8c9d6b8f 100644
|
||
|
--- a/src/output.c
|
||
|
+++ b/src/output.c
|
||
|
@@ -419,6 +419,23 @@ snprintf(char *str, size_t size, const char *fmt, ...)
|
||
|
return end - str;
|
||
|
}
|
||
|
|
||
|
+char hwerror_str[512];
|
||
|
+struct snprintfinfo hwerror_info = {
|
||
|
+ .info = { putc_str },
|
||
|
+ .str = hwerror_str,
|
||
|
+ .end = hwerror_str + sizeof(hwerror_str) - 1,
|
||
|
+};
|
||
|
+
|
||
|
+void
|
||
|
+hwerr_printf(const char *fmt, ...)
|
||
|
+{
|
||
|
+ ASSERT32FLAT();
|
||
|
+ va_list args;
|
||
|
+ va_start(args, fmt);
|
||
|
+ bvprintf(&hwerror_info.info, fmt, args);
|
||
|
+ va_end(args);
|
||
|
+}
|
||
|
+
|
||
|
// Build a formatted string - malloc'ing the memory.
|
||
|
char *
|
||
|
znprintf(size_t size, const char *fmt, ...)
|
||
|
diff --git a/src/output.h b/src/output.h
|
||
|
index 14288cf5..4548d2d4 100644
|
||
|
--- a/src/output.h
|
||
|
+++ b/src/output.h
|
||
|
@@ -16,6 +16,11 @@ char * znprintf(size_t size, const char *fmt, ...)
|
||
|
__attribute__ ((format (printf, 2, 3)));
|
||
|
void __dprintf(const char *fmt, ...)
|
||
|
__attribute__ ((format (printf, 1, 2)));
|
||
|
+
|
||
|
+extern char hwerror_str[512];
|
||
|
+void hwerr_printf(const char *fmt, ...)
|
||
|
+ __attribute__ ((format (printf, 1, 2)));
|
||
|
+
|
||
|
struct bregs;
|
||
|
void __debug_enter(struct bregs *regs, const char *fname);
|
||
|
void __debug_isr(const char *fname);
|
||
|
diff --git a/src/post.c b/src/post.c
|
||
|
index f93106a1..3e85da43 100644
|
||
|
--- a/src/post.c
|
||
|
+++ b/src/post.c
|
||
|
@@ -216,6 +216,10 @@ maininit(void)
|
||
|
device_hardware_setup();
|
||
|
wait_threads();
|
||
|
}
|
||
|
+ if (hwerror_str[0])
|
||
|
+ printf("\n"
|
||
|
+ "hardware setup errors:\n"
|
||
|
+ "%s", hwerror_str);
|
||
|
|
||
|
// Run option roms
|
||
|
optionrom_setup();
|