Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 2002, 2003, 06, 07 Ralf Baechle (ralf@linux-mips.org) |
| 7 | * Copyright (C) 2007 MIPS Technologies, Inc. |
| 8 | * written by Ralf Baechle (ralf@linux-mips.org) |
| 9 | */ |
Thomas Gleixner | d0380e6 | 2013-04-29 16:17:18 -0700 | [diff] [blame] | 10 | #include <linux/kernel.h> |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 11 | #include <linux/console.h> |
Thomas Gleixner | d0380e6 | 2013-04-29 16:17:18 -0700 | [diff] [blame] | 12 | #include <linux/printk.h> |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 13 | #include <linux/init.h> |
| 14 | |
Dmitri Vorobiev | 07cdb78 | 2008-05-29 17:57:08 +0300 | [diff] [blame] | 15 | #include <asm/setup.h> |
| 16 | |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 17 | extern void prom_putchar(char); |
| 18 | |
Aaro Koskinen | f7be4e7 | 2013-02-11 20:51:49 +0000 | [diff] [blame] | 19 | static void early_console_write(struct console *con, const char *s, unsigned n) |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 20 | { |
| 21 | while (n-- && *s) { |
| 22 | if (*s == '\n') |
| 23 | prom_putchar('\r'); |
| 24 | prom_putchar(*s); |
| 25 | s++; |
| 26 | } |
| 27 | } |
| 28 | |
Thomas Gleixner | d0380e6 | 2013-04-29 16:17:18 -0700 | [diff] [blame] | 29 | static struct console early_console_prom = { |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 30 | .name = "early", |
| 31 | .write = early_console_write, |
| 32 | .flags = CON_PRINTBUFFER | CON_BOOT, |
| 33 | .index = -1 |
| 34 | }; |
| 35 | |
| 36 | void __init setup_early_printk(void) |
| 37 | { |
Thomas Gleixner | d0380e6 | 2013-04-29 16:17:18 -0700 | [diff] [blame] | 38 | if (early_console) |
Franck Bui-Huu | 36ea1d5 | 2007-05-03 13:01:32 +0200 | [diff] [blame] | 39 | return; |
Thomas Gleixner | d0380e6 | 2013-04-29 16:17:18 -0700 | [diff] [blame] | 40 | early_console = &early_console_prom; |
Franck Bui-Huu | 36ea1d5 | 2007-05-03 13:01:32 +0200 | [diff] [blame] | 41 | |
Thomas Gleixner | d0380e6 | 2013-04-29 16:17:18 -0700 | [diff] [blame] | 42 | register_console(&early_console_prom); |
Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 43 | } |