diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-11-30 12:21:34 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2014-12-01 14:57:44 +1100 |
commit | 9594a715b50c338f1261e88c12c120cf8e5b8bba (patch) | |
tree | 5e5a07267866843ae9b0077122300bc3396ee2e5 /core | |
parent | 566f139cffdcef5d1ce679cc1a7cfd0c7cde3f78 (diff) | |
download | skiboot-9594a715b50c338f1261e88c12c120cf8e5b8bba.zip skiboot-9594a715b50c338f1261e88c12c120cf8e5b8bba.tar.gz skiboot-9594a715b50c338f1261e88c12c120cf8e5b8bba.tar.bz2 |
Add tweaks to work in Mambo simulator
Mambo doesn't implement various things such as PBA SCOMs, LPC,
ChipTOD, etc... It also provides a special console hook.
This adds detection of Mambo via the /mambo node, and enables
us to boot all the way to Linux.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/chip.c | 5 | ||||
-rw-r--r-- | core/console.c | 66 | ||||
-rw-r--r-- | core/init.c | 4 | ||||
-rw-r--r-- | core/platform.c | 1 |
4 files changed, 63 insertions, 13 deletions
diff --git a/core/chip.c b/core/chip.c index 272f024..b805fe1 100644 --- a/core/chip.c +++ b/core/chip.c @@ -20,6 +20,7 @@ #include <device.h> static struct proc_chip *chips[MAX_CHIPS]; +bool is_mambo_chip; uint32_t pir_to_chip_id(uint32_t pir) { @@ -66,6 +67,10 @@ void init_chips(void) struct proc_chip *chip; struct dt_node *xn; + /* Detect mambo chip */ + if (dt_find_by_path(dt_root, "/mambo")) + is_mambo_chip = true; + /* We walk the chips based on xscom nodes in the tree */ dt_for_each_compatible(dt_root, xn, "ibm,xscom") { uint32_t id = dt_get_chip_id(xn); diff --git a/core/console.c b/core/console.c index 111d64f..d24a4b4 100644 --- a/core/console.c +++ b/core/console.c @@ -59,20 +59,47 @@ void force_dummy_console(void) dt_add_property(dt_chosen, "sapphire,enable-dummy-console", NULL, 0); } -#ifdef MAMBO_CONSOLE -static void mambo_write(const char *buf, size_t count) + +static int mambo_char = -1; + +static bool mambo_con_poll_read(void) { -#define SIM_WRITE_CONSOLE_CODE 0 - register int c asm("r3") = 0; /* SIM_WRITE_CONSOLE_CODE */ - register unsigned long a1 asm("r4") = (unsigned long)buf; - register unsigned long a2 asm("r5") = count; - register unsigned long a3 asm("r6") = 0; - asm volatile (".long 0x000eaeb0":"=r" (c):"r"(c), "r"(a1), "r"(a2), - "r"(a3)); + if (mambo_char < 0) + mambo_char = mambo_read(); + return mambo_char >= 0; +} + +static size_t mambo_con_read(char *buf, size_t len) +{ + size_t count = 0; + + while(count < len) { + if (!mambo_con_poll_read()) + break; + *(buf++) = mambo_char; + mambo_char = -1; + count++; + } + return count; +} + +static size_t mambo_con_write(const char *buf, size_t len) +{ + mambo_write(buf, len); + return len; +} + +static struct con_ops mambo_con_driver = { + .poll_read = mambo_con_poll_read, + .read = mambo_con_read, + .write = mambo_con_write, +}; + +void enable_mambo_console(void) +{ + prlog(PR_NOTICE, "Enabling Mambo console\n"); + set_console(&mambo_con_driver); } -#else -static void mambo_write(const char *buf __unused, size_t count __unused) { } -#endif /* MAMBO_CONSOLE */ void clear_console(void) { @@ -213,7 +240,9 @@ static size_t inmem_read(char *buf, size_t req) static void write_char(char c) { +#ifdef MAMBO_DEBUG_CONSOLE mambo_write(&c, 1); +#endif inmem_write(c); } @@ -306,6 +335,7 @@ static int64_t dummy_console_read(int64_t term_number, int64_t *length, if (term_number != 0) return OPAL_PARAMETER; *length = read(0, buffer, *length); + opal_update_pending_evt(OPAL_EVENT_CONSOLE_INPUT, 0); return OPAL_SUCCESS; } @@ -313,8 +343,14 @@ opal_call(OPAL_CONSOLE_READ, dummy_console_read, 3); static void dummy_console_poll(void *data __unused) { + bool has_data = false; + lock(&con_lock); + if (con_driver && con_driver->poll_read) + has_data = con_driver->poll_read; if (memcons.in_prod != memcons.in_cons) + has_data = true; + if (has_data) opal_update_pending_evt(OPAL_EVENT_CONSOLE_INPUT, OPAL_EVENT_CONSOLE_INPUT); else @@ -325,6 +361,7 @@ static void dummy_console_poll(void *data __unused) void dummy_console_add_nodes(void) { struct dt_node *con, *consoles; + struct dt_property *p; consoles = dt_new(opal_node, "consoles"); assert(consoles); @@ -338,6 +375,11 @@ void dummy_console_add_nodes(void) dt_add_property_cells(con, "reg", 0); dt_add_property_string(con, "device_type", "serial"); + /* Mambo might have left a crap one, clear it */ + p = __dt_find_property(dt_chosen, "linux,stdout-path"); + if (p) + dt_del_property(dt_chosen, p); + dt_add_property_string(dt_chosen, "linux,stdout-path", "/ibm,opal/consoles/serial@0"); diff --git a/core/init.c b/core/init.c index d8e9d20..6eeaa0d 100644 --- a/core/init.c +++ b/core/init.c @@ -293,7 +293,7 @@ static bool load_kernel(void) } if (!ksize) - printf("Assuming kernel at 0x%p\n", KERNEL_LOAD_BASE); + printf("Assuming kernel at %p\n", KERNEL_LOAD_BASE); printf("INIT: Kernel loaded, size: %zu bytes (0 = unknown preload)\n", ksize); @@ -537,6 +537,8 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu) * to access chips via that path early on. */ init_chips(); + if (is_mambo_chip) + enable_mambo_console(); xscom_init(); mfsi_init(); diff --git a/core/platform.c b/core/platform.c index 1b0093d..53971e9 100644 --- a/core/platform.c +++ b/core/platform.c @@ -50,6 +50,7 @@ opal_call(OPAL_CEC_REBOOT, opal_cec_reboot, 0); static void generic_platform_init(void) { + force_dummy_console(); fake_rtc_init(); } |