diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2014-07-31 14:30:03 +1000 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-08-08 16:07:26 +1000 |
commit | 451e6a755e58e692d1ec8ffb1b1416a0a0c47604 (patch) | |
tree | cb61365796c0f4ea47c5ccc0d40c045dbdbd2857 /core/console.c | |
parent | 904a3b51a20102fb504c498a55d31ce87c525643 (diff) | |
download | skiboot-451e6a755e58e692d1ec8ffb1b1416a0a0c47604.zip skiboot-451e6a755e58e692d1ec8ffb1b1416a0a0c47604.tar.gz skiboot-451e6a755e58e692d1ec8ffb1b1416a0a0c47604.tar.bz2 |
Write log messages with log_level > PR_NOTICE only to in memory log
We modify write() (adding console_write()) which calls down to
a modified __flush_console() which can now decide if it's flushing
the added console contents to the console drivers or not.
A future patch may add support for changing PR_NOTICE to some other level
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'core/console.c')
-rw-r--r-- | core/console.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/core/console.c b/core/console.c index 5794151..9b41962 100644 --- a/core/console.c +++ b/core/console.c @@ -81,9 +81,11 @@ void clear_console(void) /* * Flush the console buffer into the driver, returns true - * if there is more to go + * if there is more to go. + * Optionally can skip flushing to drivers, leaving messages + * just in memory console. */ -bool __flush_console(void) +bool __flush_console(bool flush_to_drivers) { struct cpu_thread *cpu = this_cpu(); size_t req, len = 0; @@ -124,18 +126,27 @@ bool __flush_console(void) more_flush = false; if (con_out > con_in) { req = INMEM_CON_OUT_LEN - con_out; - unlock(&con_lock); - len = con_driver->write(con_buf + con_out, req); - lock(&con_lock); + if (!flush_to_drivers) { + len = req; + } else { + unlock(&con_lock); + len = con_driver->write(con_buf + con_out, + req); + lock(&con_lock); + } con_out = (con_out + len) % INMEM_CON_OUT_LEN; if (len < req) goto bail; } if (con_out < con_in) { - unlock(&con_lock); - len = con_driver->write(con_buf + con_out, - con_in - con_out); - lock(&con_lock); + if (!flush_to_drivers) { + len = con_in - con_out; + } else { + unlock(&con_lock); + len = con_driver->write(con_buf + con_out, + con_in - con_out); + lock(&con_lock); + } con_out = (con_out + len) % INMEM_CON_OUT_LEN; } } while(more_flush); @@ -149,7 +160,7 @@ bool flush_console(void) bool ret; lock(&con_lock); - ret = __flush_console(); + ret = __flush_console(true); unlock(&con_lock); return ret; @@ -206,7 +217,7 @@ static void write_char(char c) inmem_write(c); } -ssize_t write(int fd __unused, const void *buf, size_t count) +ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count) { /* We use recursive locking here as we can get called * from fairly deep debug path @@ -221,7 +232,7 @@ ssize_t write(int fd __unused, const void *buf, size_t count) write_char(c); } - __flush_console(); + __flush_console(flush_to_drivers); if (need_unlock) unlock(&con_lock); @@ -229,6 +240,11 @@ ssize_t write(int fd __unused, const void *buf, size_t count) return count; } +ssize_t write(int fd __unused, const void *buf, size_t count) +{ + return console_write(true, buf, count); +} + ssize_t read(int fd __unused, void *buf, size_t req_count) { bool need_unlock = lock_recursive(&con_lock); |