summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--payloads/libpayload/include/libpayload.h1
-rw-r--r--payloads/libpayload/libc/console.c17
2 files changed, 18 insertions, 0 deletions
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 9781c9eab5..40a85cfd62 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -282,6 +282,7 @@ struct console_output_driver {
void console_add_output_driver(struct console_output_driver *out);
void console_add_input_driver(struct console_input_driver *in);
+int console_remove_output_driver(void *function);
#define havechar havekey
/** @} */
diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c
index 8c0664d125..827da792b9 100644
--- a/payloads/libpayload/libc/console.c
+++ b/payloads/libpayload/libc/console.c
@@ -48,6 +48,23 @@ void console_add_input_driver(struct console_input_driver *in)
console_in = in;
}
+/*
+ * For when you really need to silence an output driver (e.g. to avoid ugly
+ * recursions). Takes the pointer of either of the two output functions, since
+ * the struct console_output_driver itself is often static and inaccessible.
+ */
+int console_remove_output_driver(void *function)
+{
+ struct console_output_driver **out;
+ for (out = &console_out; *out; out = &(*out)->next)
+ if ((*out)->putchar == function || (*out)->write == function) {
+ *out = (*out)->next;
+ return 1;
+ }
+
+ return 0;
+}
+
void console_init(void)
{
#ifdef CONFIG_LP_VIDEO_CONSOLE