Marc Jones (marc.jones@se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8116
-gerrit
commit 203361da903fde75d7cdfc3180824c3ae4881230 Author: Julius Werner jwerner@chromium.org Date: Mon Jun 2 20:13:51 2014 -0700
libpayload: Add ability to unregister output driver
This patch adds a console_kill_output_driver() function, which can remove a previously registered output driver. This is mostly useful when you overlay some output channel over another, such as when the GDB stub takes direct control of the UART (and thus has to get rid of the existing serial output driver).
BUG=chrome-os-partner:18390 TEST=None
Original-Change-Id: I6fce95c22fd15cd321ca6b2d6fbc4e3902b1eac3 Original-Signed-off-by: Julius Werner jwerner@chromium.org Original-Reviewed-on: https://chromium-review.googlesource.com/202561 Original-Reviewed-by: Stefan Reinauer reinauer@chromium.org (cherry picked from commit 87680a246429d24e99b7b477b743c357f73b752c) Signed-off-by: Marc Jones marc.jones@se-eng.com
Change-Id: I50001cee4582c962ceedc215d59238867a6ae95a --- payloads/libpayload/include/libpayload.h | 1 + payloads/libpayload/libc/console.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index 9781c9e..40a85cf 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 8c0664d..827da79 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