[Skiboot] [PATCH 4/6] mambo: Convert console read/write from asm to C

Michael Neuling mikey at neuling.org
Wed Nov 2 18:07:37 AEDT 2016


Also changes the function name:
  mambo_read/write() -> mambo_console_read/write()

Signed-off-by: Michael Neuling <mikey at neuling.org>
---
 asm/misc.S              | 18 ------------------
 core/console.c          |  6 +++---
 include/console.h       |  4 ++--
 platforms/mambo/mambo.c | 12 ++++++++++++
 4 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/asm/misc.S b/asm/misc.S
index 6dcbad27af..be87fbe8ed 100644
--- a/asm/misc.S
+++ b/asm/misc.S
@@ -51,24 +51,6 @@ _mcount:
 	b	__mcount_stack_check
 #endif
 
-.global mambo_read
-mambo_read:
-#define SIM_READ_CONSOLE_CODE 60
-	li	%r3,SIM_READ_CONSOLE_CODE
-	.long	0x000eaeb0
-	extsw	%r3,%r3
-	blr
-
-.global mambo_write
-mambo_write:
-#define SIM_WRITE_CONSOLE_CODE 0
-	li	%r6,0
-	mr	%r5,%r4
-	mr	%r4,%r3
-	li	%r3,SIM_WRITE_CONSOLE_CODE
-	.long	0x000eaeb0
-	blr
-
 .global mambo_get_time
 mambo_get_time:
 #define SIM_GET_TIME_CODE 70
diff --git a/core/console.c b/core/console.c
index 1bdb0a72fd..f76ed402c4 100644
--- a/core/console.c
+++ b/core/console.c
@@ -67,7 +67,7 @@ static int mambo_char = -1;
 static bool mambo_con_poll_read(void)
 {
 	if (mambo_char < 0)
-		mambo_char = mambo_read();
+		mambo_char = mambo_console_read();
 	return mambo_char >= 0;
 }
 
@@ -87,7 +87,7 @@ static size_t mambo_con_read(char *buf, size_t len)
 
 static size_t mambo_con_write(const char *buf, size_t len)
 {
-	mambo_write(buf, len);
+	mambo_console_write(buf, len);
 	return len;
 }
 
@@ -243,7 +243,7 @@ static size_t inmem_read(char *buf, size_t req)
 static void write_char(char c)
 {
 #ifdef MAMBO_DEBUG_CONSOLE
-	mambo_write(&c, 1);
+	mambo_console_write(&c, 1);
 #endif
 	inmem_write(c);
 }
diff --git a/include/console.h b/include/console.h
index b6fc8bfa9a..5cb1227e21 100644
--- a/include/console.h
+++ b/include/console.h
@@ -64,8 +64,8 @@ extern void set_console(struct con_ops *driver);
 
 extern void console_complete_flush(void);
 
-extern int mambo_read(void);
-extern void mambo_write(const char *buf, size_t count);
+extern int mambo_console_read(void);
+extern void 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);
diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c
index 76ac0a6744..45ce34d9ca 100644
--- a/platforms/mambo/mambo.c
+++ b/platforms/mambo/mambo.c
@@ -96,7 +96,9 @@ static inline unsigned long callthru3(int command, unsigned long arg1,
 
 #define BD_SECT_SZ		512
 
+#define SIM_WRITE_CONSOLE_CODE	0
 #define SIM_EXIT_CODE		31
+#define SIM_READ_CONSOLE_CODE	60
 #define BOGUS_DISK_READ		116
 #define BOGUS_DISK_WRITE	117
 #define BOGUS_DISK_INFO		118
@@ -240,6 +242,16 @@ static void bogus_disk_flash_init(void)
 	}
 }
 
+int mambo_console_read(void)
+{
+	return callthru0(SIM_READ_CONSOLE_CODE);
+}
+
+void mambo_console_write(const char *buf, size_t count)
+{
+	callthru2(SIM_WRITE_CONSOLE_CODE, (unsigned long)buf, count);
+}
+
 static void mambo_platform_init(void)
 {
 	force_dummy_console();
-- 
2.9.3



More information about the Skiboot mailing list