[Skiboot] [RFC PATCH 03/12] core/console: Move con_out wrap marking

Oliver O'Halloran oohall at gmail.com
Tue May 19 15:46:24 AEST 2020


The con_out global tracks how much of the skiboot log buffer has been
written out to the driver. We'd like to re-use inmem_write() so that we
can have multiple memcons instances so move the con_out tracking into
write_char() which is used to write a single character into the skiboot
log buffer.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 core/console.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/core/console.c b/core/console.c
index 42328dbe2d2e..8724c71113a6 100644
--- a/core/console.c
+++ b/core/console.c
@@ -198,10 +198,6 @@ static void inmem_write(char c)
 		opos |= MEMCONS_OUT_POS_WRAP;
 	lwsync();
 	memcons.out_pos = cpu_to_be32(opos);
-
-	/* If head reaches tail, push tail around & drop chars */
-	if (con_in == con_out)
-		con_out = (con_in + 1) % INMEM_CON_OUT_LEN;
 }
 
 static size_t inmem_read(char *buf, size_t req)
@@ -221,10 +217,11 @@ static size_t inmem_read(char *buf, size_t req)
 
 static void write_char(char c)
 {
-#ifdef MAMBO_DEBUG_CONSOLE
-	mambo_console_write(&c, 1);
-#endif
 	inmem_write(c);
+
+	/* If head reaches tail, push tail around & drop chars */
+	if (con_out == memcons.out_pos)
+		con_out = (memcons.out_pos + 1) % memcons.obuf_size;
 }
 
 ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
-- 
2.26.2



More information about the Skiboot mailing list