@@ -85,6 +85,7 @@ struct dt_node *add_opal_console_node(int index, const char *type,
extern struct opal_con_ops uart_opal_con;
extern struct opal_con_ops fsp_opal_con;
extern struct opal_con_ops dummy_opal_con;
+extern struct opal_con_ops mambo_opal_con;
void mprintf(const char *fmt, ...);
@@ -3,6 +3,7 @@
#include <skiboot.h>
#include <console.h>
+#include <opal-api.h>
#include "mambo.h"
@@ -42,9 +43,8 @@ size_t mambo_console_write(const char *buf, size_t len)
return len;
}
+/* used to write out the internal console */
static struct con_ops mambo_con_driver = {
- .poll_read = mambo_console_poll,
- .read = mambo_console_read,
.write = mambo_console_write,
};
@@ -54,6 +54,66 @@ void enable_mambo_console(void)
set_console(&mambo_con_driver);
}
+
+/* OPAL call interface into the underlying mambo console */
+static int64_t mambo_opal_write(int64_t term_number, __be64 *__length,
+ const uint8_t *buffer)
+{
+ size_t len = be64_to_cpu(*__length);
+
+ if (term_number != 0)
+ return OPAL_PARAMETER;
+
+ mambo_console_write(buffer, len);
+
+ return OPAL_SUCCESS;
+}
+
+static int64_t mambo_opal_write_buffer_space(int64_t term_number,
+ __be64 *__length)
+{
+ if (term_number != 0)
+ return OPAL_PARAMETER;
+
+ *__length = cpu_to_be64(256);
+
+ return OPAL_SUCCESS;
+}
+
+static int64_t mambo_opal_read(int64_t term_number, __be64 *__length,
+ uint8_t *buffer)
+{
+ size_t req_count = be64_to_cpu(*__length), read_cnt = 0;
+
+ if (term_number != 0)
+ return OPAL_PARAMETER;
+
+ read_cnt = mambo_console_read(buffer, req_count);
+ *__length = cpu_to_be64(read_cnt);
+
+ return OPAL_SUCCESS;
+}
+
+static int64_t mambo_opal_flush(int64_t term_number)
+{
+ if (term_number != 0)
+ return OPAL_PARAMETER;
+ return OPAL_SUCCESS;
+}
+
+static void mambo_init_opal_console(void)
+{
+}
+
+struct opal_con_ops mambo_opal_con = {
+ .name = "OPAL Mambo console",
+ .init = mambo_init_opal_console,
+ .read = mambo_opal_read,
+ .write = mambo_opal_write,
+ .space = mambo_opal_write_buffer_space,
+ .flush = mambo_opal_flush,
+};
+
/*
* mambo console based printf(), this is useful for debugging the console
* since mambo_console_write() can be safely called from anywhere.
Add a "real" opal_con_driver for the mambo platform instead of using the dummy console. This gets mambo using the same console IO path as every other platform and leaves the dummy console only being used for cronus booted systems. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- Yoinked out of Nick's raw console patch set. --- include/console.h | 1 + platforms/mambo/console.c | 64 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-)