@@ -32,7 +32,6 @@ static int vprlog(int log_level, const char *fmt, va_list ap)
{
int count;
char buffer[320];
- bool flush_to_drivers = true;
unsigned long tb = mftb();
/* It's safe to return 0 when we "did" something here
@@ -50,10 +49,7 @@ static int vprlog(int log_level, const char *fmt, va_list ap)
tb_to_secs(tb), tb_remaining_nsecs(tb), log_level);
count+= vsnprintf(buffer+count, sizeof(buffer)-count, fmt, ap);
- if (log_level > (debug_descriptor.console_log_levels & 0x0f))
- flush_to_drivers = false;
-
- console_write(flush_to_drivers, buffer, count);
+ console_write(buffer, count);
return count;
}
@@ -143,7 +143,7 @@ static int parse_loghdr(int start, int *log_level)
* if there is more to go, but that only happens when the
* underlying driver failed so don't call it again.
*/
-static bool __flush_console(bool flush_to_drivers __unused)
+static bool __flush_console(void)
{
int flush_lvl = debug_descriptor.console_log_levels & 0xf;
struct cpu_thread *cpu = this_cpu();
@@ -179,16 +179,6 @@ static bool __flush_console(bool flush_to_drivers __unused)
in_flush = true;
- /*
- * NB: this must appear after the in_flush check since it modifies
- * con_out.
- */
- if (!flush_to_drivers) {
- con_out = con_in;
- in_flush = false;
- return false;
- }
-
do {
int start, req, len, log_lvl;
@@ -234,7 +224,7 @@ bool flush_console(void)
bool ret;
lock(&con_lock);
- ret = __flush_console(true);
+ ret = __flush_console();
unlock(&con_lock);
return ret;
@@ -293,7 +283,7 @@ static void write_char(char c)
inmem_write(c);
}
-ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
+ssize_t console_write(const void *buf, size_t count)
{
/* We use recursive locking here as we can get called
* from fairly deep debug path
@@ -308,7 +298,7 @@ ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
write_char(c);
}
- __flush_console(flush_to_drivers);
+ __flush_console();
if (need_unlock)
unlock(&con_lock);
@@ -318,7 +308,7 @@ ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
ssize_t write(int fd __unused, const void *buf, size_t count)
{
- return console_write(true, buf, count);
+ return console_write(buf, count);
}
ssize_t read(int fd __unused, void *buf, size_t req_count)
@@ -108,7 +108,7 @@ int main(void)
memcons.obuf_size = sizeof(console_buffer);
populate_console(PR_INSANE, PR_NOTICE);
- __flush_console(true);
+ __flush_console();
/*
* Refill the console buffer dropping everything above PR_NOTICE
@@ -53,11 +53,8 @@ static inline unsigned long mftb(void)
char console_buffer[4096];
struct debug_descriptor debug_descriptor;
-bool flushed_to_drivers;
-
-ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
+ssize_t console_write(const void *buf, size_t count)
{
- flushed_to_drivers = flush_to_drivers;
memcpy(console_buffer, buf, count);
return count;
}
@@ -36,13 +36,10 @@ static inline unsigned long mftb(void)
#include "../../libc/stdio/vsnprintf.c"
struct debug_descriptor debug_descriptor;
-
-bool flushed_to_drivers;
char console_buffer[4096];
-ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
+ssize_t console_write(const void *buf, size_t count)
{
- flushed_to_drivers = flush_to_drivers;
memcpy(console_buffer, buf, count);
return count;
}
@@ -51,24 +48,19 @@ int main(void)
{
debug_descriptor.console_log_levels = 0x75;
+ /* check basic functionality */
prlog(PR_EMERG, "Hello World");
assert(strcmp(console_buffer, "[ 0.000000042,0] PREFIX: Hello World") == 0);
- assert(flushed_to_drivers==true);
memset(console_buffer, 0, sizeof(console_buffer));
- // Below log level
+ /* Below log level is filtered */
prlog(PR_TRACE, "Hello World");
assert(console_buffer[0] == 0);
- // Should not be flushed to console
- prlog(PR_DEBUG, "Hello World");
- assert(strcmp(console_buffer, "[ 0.000000042,7] PREFIX: Hello World") == 0);
- assert(flushed_to_drivers==false);
-
+ /* check printf */
printf("Hello World");
assert(strcmp(console_buffer, "[ 0.000000042,5] PREFIX: Hello World") == 0);
- assert(flushed_to_drivers==true);
return 0;
}
@@ -36,13 +36,10 @@ int _printf(const char* fmt, ...);
#include "../console-log.c"
struct debug_descriptor debug_descriptor;
-
-bool flushed_to_drivers;
char console_buffer[4096];
-ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
+ssize_t console_write(const void *buf, size_t count)
{
- flushed_to_drivers = flush_to_drivers;
memcpy(console_buffer, buf, count);
return count;
}
@@ -53,22 +50,14 @@ int main(void)
prlog(PR_EMERG, "Hello World");
assert(strcmp(console_buffer, "[ 0.000000042,0] Hello World") == 0);
- assert(flushed_to_drivers==true);
-
memset(console_buffer, 0, sizeof(console_buffer));
// Below log level
prlog(PR_TRACE, "Hello World");
assert(console_buffer[0] == 0);
- // Should not be flushed to console
- prlog(PR_DEBUG, "Hello World");
- assert(strcmp(console_buffer, "[ 0.000000042,7] Hello World") == 0);
- assert(flushed_to_drivers==false);
-
printf("Hello World");
assert(strcmp(console_buffer, "[ 0.000000042,5] Hello World") == 0);
- assert(flushed_to_drivers==true);
return 0;
}
@@ -86,7 +86,7 @@ extern void console_complete_flush(void);
extern size_t mambo_console_write(const char *buf, size_t count);
extern void enable_mambo_console(void);
-ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count);
+ssize_t console_write(const void *buf, size_t count);
extern void clear_console(void);
extern void memcons_add_properties(void);
This is no longer used and can be removed. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- core/console-log.c | 6 +----- core/console.c | 20 +++++--------------- core/test/run-console-flush.c | 2 +- core/test/run-console-log-buf-overrun.c | 5 +---- core/test/run-console-log-pr_fmt.c | 16 ++++------------ core/test/run-console-log.c | 13 +------------ include/console.h | 2 +- 7 files changed, 14 insertions(+), 50 deletions(-)