diff options
Diffstat (limited to 'arch/blackfin/kernel/shadow_console.c')
-rw-r--r-- | arch/blackfin/kernel/shadow_console.c | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/arch/blackfin/kernel/shadow_console.c b/arch/blackfin/kernel/shadow_console.c index 15819ff1057..8b8c7107a16 100644 --- a/arch/blackfin/kernel/shadow_console.c +++ b/arch/blackfin/kernel/shadow_console.c @@ -24,15 +24,18 @@ static __initdata char *shadow_console_buffer = (char *)SHADOW_CONSOLE_START; -static __init void early_shadow_write(struct console *con, const char *s, +__init void early_shadow_write(struct console *con, const char *s, unsigned int n) { + unsigned int i; /* * save 2 bytes for the double null at the end * once we fail on a long line, make sure we don't write a short line afterwards */ if ((shadow_console_buffer + n) <= (char *)(SHADOW_CONSOLE_END - 2)) { - memcpy(shadow_console_buffer, s, n); + /* can't use memcpy - it may not be relocated yet */ + for (i = 0; i <= n; i++) + shadow_console_buffer[i] = s[i]; shadow_console_buffer += n; shadow_console_buffer[0] = 0; shadow_console_buffer[1] = 0; @@ -48,16 +51,24 @@ static __initdata struct console early_shadow_console = { .device = 0, }; -__init void enable_shadow_console(void) +__init int shadow_console_enabled(void) +{ + return early_shadow_console.flags & CON_ENABLED; +} + +__init void mark_shadow_error(void) { int *loc = (int *)SHADOW_CONSOLE_MAGIC_LOC; + loc[0] = SHADOW_CONSOLE_MAGIC; + loc[1] = SHADOW_CONSOLE_START; +} - if (!(early_shadow_console.flags & CON_ENABLED)) { +__init void enable_shadow_console(void) +{ + if (!shadow_console_enabled()) { register_console(&early_shadow_console); /* for now, assume things are going to fail */ - *loc = SHADOW_CONSOLE_MAGIC; - loc++; - *loc = SHADOW_CONSOLE_START; + mark_shadow_error(); } } @@ -71,8 +82,32 @@ static __init int disable_shadow_console(void) */ int *loc = (int *)SHADOW_CONSOLE_MAGIC_LOC; - *loc = 0; + loc[0] = 0; return 0; } pure_initcall(disable_shadow_console); + +/* + * since we can't use printk, dump numbers (as hex), n = # bits + */ +__init void early_shadow_reg(unsigned long reg, unsigned int n) +{ + /* + * can't use any "normal" kernel features, since thay + * may not be relocated to their execute address yet + */ + int i; + char ascii[11] = " 0x"; + + n = n / 4; + reg = reg << ((8 - n) * 4); + n += 3; + + for (i = 3; i <= n ; i++) { + ascii[i] = hex_asc_lo(reg >> 28); + reg <<= 4; + } + early_shadow_write(NULL, ascii, n); + +} |