diff options
-rw-r--r-- | core/console.c | 53 | ||||
-rw-r--r-- | core/init.c | 5 | ||||
-rw-r--r-- | core/platform.c | 4 | ||||
-rw-r--r-- | hw/fsp/fsp-console.c | 9 | ||||
-rw-r--r-- | hw/lpc-uart.c | 7 | ||||
-rw-r--r-- | include/console.h | 3 | ||||
-rw-r--r-- | platforms/astbmc/common.c | 3 | ||||
-rw-r--r-- | platforms/qemu/qemu.c | 3 |
8 files changed, 61 insertions, 26 deletions
diff --git a/core/console.c b/core/console.c index d602b7f..e3bb8ce 100644 --- a/core/console.c +++ b/core/console.c @@ -31,8 +31,13 @@ static char *con_buf = (char *)INMEM_CON_START; static size_t con_in; static size_t con_out; static bool con_wrapped; + +/* Internal console driver ops */ static struct con_ops *con_driver; +/* External (OPAL) console driver ops */ +static struct opal_con_ops *opal_con_driver = &dummy_opal_con; + static struct lock con_lock = LOCK_UNLOCKED; /* This is mapped via TCEs so we keep it alone in a page */ @@ -303,6 +308,12 @@ void console_complete_flush(void) } } +/* + * set_console() + * + * This sets the driver used internally by Skiboot. This is different to the + * OPAL console driver. + */ void set_console(struct con_ops *driver) { con_driver = driver; @@ -310,6 +321,45 @@ void set_console(struct con_ops *driver) flush_console(); } +/* + * set_opal_console() + * + * Configure the console driver to handle the console provided by the OPAL API. + * They are different to the above in that they are typically buffered, and used + * by the host OS rather than skiboot. + */ +static bool opal_cons_init = false; + +void set_opal_console(struct opal_con_ops *driver) +{ + assert(!opal_cons_init); + opal_con_driver = driver; +} + +void init_opal_console(void) +{ + assert(!opal_cons_init); + opal_cons_init = true; + + if (dummy_console_enabled() && opal_con_driver != &dummy_opal_con) { + prlog(PR_WARNING, "OPAL: Dummy console forced, %s ignored\n", + opal_con_driver->name); + + opal_con_driver = &dummy_opal_con; + } + + prlog(PR_NOTICE, "OPAL: Using %s\n", opal_con_driver->name); + + if (opal_con_driver->init) + opal_con_driver->init(); + + opal_register(OPAL_CONSOLE_READ, opal_con_driver->read, 3); + opal_register(OPAL_CONSOLE_WRITE, opal_con_driver->write, 3); + opal_register(OPAL_CONSOLE_FLUSH, opal_con_driver->flush, 1); + opal_register(OPAL_CONSOLE_WRITE_BUFFER_SPACE, + opal_con_driver->space, 2); +} + void memcons_add_properties(void) { dt_add_property_u64(opal_node, "ibm,opal-memcons", (u64) &memcons); @@ -336,7 +386,6 @@ static int64_t dummy_console_write(int64_t term_number, int64_t *length, return OPAL_SUCCESS; } -opal_call(OPAL_CONSOLE_WRITE, dummy_console_write, 3); static int64_t dummy_console_write_buffer_space(int64_t term_number, int64_t *length) @@ -352,7 +401,6 @@ static int64_t dummy_console_write_buffer_space(int64_t term_number, return OPAL_SUCCESS; } -opal_call(OPAL_CONSOLE_WRITE_BUFFER_SPACE, dummy_console_write_buffer_space, 2); static int64_t dummy_console_read(int64_t term_number, int64_t *length, uint8_t *buffer) @@ -368,7 +416,6 @@ static int64_t dummy_console_read(int64_t term_number, int64_t *length, return OPAL_SUCCESS; } -opal_call(OPAL_CONSOLE_READ, dummy_console_read, 3); static int64_t dummy_console_flush(int64_t term_number __unused) { diff --git a/core/init.c b/core/init.c index 9d4ab60..81939dd 100644 --- a/core/init.c +++ b/core/init.c @@ -896,9 +896,8 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* Secure/Trusted Boot init. We look for /ibm,secureboot in DT */ stb_init(); - /* Setup dummy console nodes if it's enabled */ - if (dummy_console_enabled()) - dummy_console_add_nodes(); + /* Install the OPAL Console handlers */ + init_opal_console(); /* Init SLW related stuff, including fastsleep */ slw_init(); diff --git a/core/platform.c b/core/platform.c index 838dfd6..bde3932 100644 --- a/core/platform.c +++ b/core/platform.c @@ -114,9 +114,7 @@ static bool generic_platform_probe(void) static void generic_platform_init(void) { if (uart_enabled()) - uart_setup_opal_console(); - else - force_dummy_console(); + set_opal_console(&uart_opal_con); /* Enable a BT interface if we find one too */ bt_init(); diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c index 8589e8c..6683679 100644 --- a/hw/fsp/fsp-console.c +++ b/hw/fsp/fsp-console.c @@ -384,7 +384,7 @@ static void fsp_close_vserial(struct fsp_msg *msg) set_console(NULL); } #endif - + lock(&fsp_con_lock); if (fs->open) { fs->open = false; @@ -783,11 +783,6 @@ void fsp_console_init(void) if (!fsp_present()) return; - opal_register(OPAL_CONSOLE_READ, fsp_console_read, 3); - opal_register(OPAL_CONSOLE_WRITE_BUFFER_SPACE, - fsp_console_write_buffer_space, 2); - opal_register(OPAL_CONSOLE_WRITE, fsp_console_write, 3); - /* Wait until we got the intf query before moving on */ while (!got_intf_query) opal_run_pollers(); @@ -816,6 +811,8 @@ void fsp_console_init(void) } op_display(OP_LOG, OP_MOD_FSPCON, 0x0005); + + set_opal_console(&fsp_opal_con); } static int64_t fsp_console_flush(int64_t terminal __unused) diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index cc1c165..0b78a76 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -450,13 +450,6 @@ void uart_setup_opal_console(void) /* Allocate an input buffer */ in_buf = zalloc(IN_BUF_SIZE); out_buf = zalloc(OUT_BUF_SIZE); - prlog(PR_DEBUG, "UART: Enabled as OS console\n"); - - /* Register OPAL APIs */ - opal_register(OPAL_CONSOLE_READ, uart_opal_read, 3); - opal_register(OPAL_CONSOLE_WRITE_BUFFER_SPACE, - uart_opal_write_buffer_space, 2); - opal_register(OPAL_CONSOLE_WRITE, uart_opal_write, 3); opal_add_poller(uart_console_poll, NULL); } diff --git a/include/console.h b/include/console.h index e821ce7..425f35e 100644 --- a/include/console.h +++ b/include/console.h @@ -79,7 +79,10 @@ struct opal_con_ops { extern bool dummy_console_enabled(void); extern void force_dummy_console(void); extern bool flush_console(void); + extern void set_console(struct con_ops *driver); +extern void set_opal_console(struct opal_con_ops *driver); +extern void init_opal_console(void); extern void console_complete_flush(void); diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c index 6e678a1..ce8edea 100644 --- a/platforms/astbmc/common.c +++ b/platforms/astbmc/common.c @@ -138,8 +138,7 @@ void astbmc_init(void) ipmi_set_fw_progress_sensor(IPMI_FW_MOTHERBOARD_INIT); /* Setup UART console for use by Linux via OPAL API */ - if (!dummy_console_enabled()) - uart_setup_opal_console(); + set_opal_console(&uart_opal_con); } int64_t astbmc_ipmi_power_down(uint64_t request) diff --git a/platforms/qemu/qemu.c b/platforms/qemu/qemu.c index 0c583f1..85ca213 100644 --- a/platforms/qemu/qemu.c +++ b/platforms/qemu/qemu.c @@ -79,8 +79,7 @@ static void qemu_ipmi_setenables(void) static void qemu_init(void) { /* Setup UART console for use by Linux via OPAL API */ - if (!dummy_console_enabled()) - uart_setup_opal_console(); + set_opal_console(&uart_opal_con); /* Setup LPC RTC and use it as time source. Call after * chiptod_init() |