aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/console.c14
-rw-r--r--hw/fsp/fsp-console.c15
-rw-r--r--hw/lpc-uart.c17
-rw-r--r--include/console.h27
4 files changed, 73 insertions, 0 deletions
diff --git a/core/console.c b/core/console.c
index e132ba0..d602b7f 100644
--- a/core/console.c
+++ b/core/console.c
@@ -370,6 +370,11 @@ static int64_t dummy_console_read(int64_t term_number, int64_t *length,
}
opal_call(OPAL_CONSOLE_READ, dummy_console_read, 3);
+static int64_t dummy_console_flush(int64_t term_number __unused)
+{
+ return OPAL_UNSUPPORTED;
+}
+
static void dummy_console_poll(void *data __unused)
{
bool has_data = false;
@@ -403,3 +408,12 @@ void dummy_console_add_nodes(void)
opal_add_poller(dummy_console_poll, NULL);
}
+
+struct opal_con_ops dummy_opal_con = {
+ .name = "Dummy Console",
+ .init = dummy_console_add_nodes,
+ .read = dummy_console_read,
+ .write = dummy_console_write,
+ .space = dummy_console_write_buffer_space,
+ .flush = dummy_console_flush,
+};
diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c
index 8fd18d1..8589e8c 100644
--- a/hw/fsp/fsp-console.c
+++ b/hw/fsp/fsp-console.c
@@ -818,6 +818,21 @@ void fsp_console_init(void)
op_display(OP_LOG, OP_MOD_FSPCON, 0x0005);
}
+static int64_t fsp_console_flush(int64_t terminal __unused)
+{
+ /* FIXME: There's probably something we can do here... */
+ return OPAL_PARAMETER;
+}
+
+struct opal_con_ops fsp_opal_con = {
+ .name = "FSP OPAL console",
+ .init = NULL, /* all the required setup is done in fsp_console_init() */
+ .read = fsp_console_read,
+ .write = fsp_console_write,
+ .space = fsp_console_write_buffer_space,
+ .flush = fsp_console_flush,
+};
+
static void flush_all_input(void)
{
unsigned int i;
diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c
index 2383ff5..cc1c165 100644
--- a/hw/lpc-uart.c
+++ b/hw/lpc-uart.c
@@ -375,6 +375,14 @@ static int64_t uart_opal_read(int64_t term_number, int64_t *length,
return OPAL_SUCCESS;
}
+static int64_t uart_opal_flush(int64_t term_number)
+{
+ if (term_number != 0)
+ return OPAL_PARAMETER;
+
+ return uart_con_flush();
+}
+
static void __uart_do_poll(u8 trace_ctx)
{
if (!in_buf)
@@ -453,6 +461,15 @@ void uart_setup_opal_console(void)
opal_add_poller(uart_console_poll, NULL);
}
+struct opal_con_ops uart_opal_con = {
+ .name = "OPAL UART console",
+ .init = uart_setup_opal_console,
+ .read = uart_opal_read,
+ .write = uart_opal_write,
+ .space = uart_opal_write_buffer_space,
+ .flush = uart_opal_flush,
+};
+
static bool uart_init_hw(unsigned int speed, unsigned int clock)
{
unsigned int dll = (clock / 16) / speed;
diff --git a/include/console.h b/include/console.h
index 08d2961..e821ce7 100644
--- a/include/console.h
+++ b/include/console.h
@@ -54,6 +54,28 @@ struct con_ops {
int64_t (*flush)(void);
};
+struct opal_con_ops {
+ const char *name;
+
+ /*
+ * OPAL console driver specific init function.
+ */
+ void (*init)(void);
+
+ int64_t (*write)(int64_t term, int64_t *len, const uint8_t *buf);
+ int64_t (*read)(int64_t term, int64_t *len, uint8_t *buf);
+
+ /*
+ * returns the amount of space available in the console write buffer
+ */
+ int64_t (*space)(int64_t term_number, int64_t *length);
+
+ /*
+ * Forces the write buffer to be flushed by the driver
+ */
+ int64_t (*flush)(int64_t term_number);
+};
+
extern bool dummy_console_enabled(void);
extern void force_dummy_console(void);
extern bool flush_console(void);
@@ -73,4 +95,9 @@ extern void dummy_console_add_nodes(void);
struct dt_node *add_opal_console_node(int index, const char *type,
uint32_t write_buffer_size);
+/* OPAL console drivers */
+extern struct opal_con_ops uart_opal_con;
+extern struct opal_con_ops fsp_opal_con;
+extern struct opal_con_ops dummy_opal_con;
+
#endif /* __CONSOLE_H */