| 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 | */ | 
|  | 10 | #include <linux/console.h> | 
|  | 11 | #include <linux/init.h> | 
|  | 12 |  | 
| Dmitri Vorobiev | 07cdb78 | 2008-05-29 17:57:08 +0300 | [diff] [blame] | 13 | #include <asm/setup.h> | 
|  | 14 |  | 
| Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 15 | extern void prom_putchar(char); | 
|  | 16 |  | 
| Franck Bui-Huu | ca4437d | 2007-05-03 12:58:54 +0200 | [diff] [blame] | 17 | static void __init | 
|  | 18 | early_console_write(struct console *con, const char *s, unsigned n) | 
| Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 19 | { | 
|  | 20 | while (n-- && *s) { | 
|  | 21 | if (*s == '\n') | 
|  | 22 | prom_putchar('\r'); | 
|  | 23 | prom_putchar(*s); | 
|  | 24 | s++; | 
|  | 25 | } | 
|  | 26 | } | 
|  | 27 |  | 
| Franck Bui-Huu | ca4437d | 2007-05-03 12:58:54 +0200 | [diff] [blame] | 28 | static struct console early_console __initdata = { | 
| Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 29 | .name	= "early", | 
|  | 30 | .write	= early_console_write, | 
|  | 31 | .flags	= CON_PRINTBUFFER | CON_BOOT, | 
|  | 32 | .index	= -1 | 
|  | 33 | }; | 
|  | 34 |  | 
| Franck Bui-Huu | 36ea1d5 | 2007-05-03 13:01:32 +0200 | [diff] [blame] | 35 | static int early_console_initialized __initdata; | 
|  | 36 |  | 
| Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 37 | void __init setup_early_printk(void) | 
|  | 38 | { | 
| Franck Bui-Huu | 36ea1d5 | 2007-05-03 13:01:32 +0200 | [diff] [blame] | 39 | if (early_console_initialized) | 
|  | 40 | return; | 
|  | 41 | early_console_initialized = 1; | 
|  | 42 |  | 
| Ralf Baechle | 36a8853 | 2007-03-01 11:56:43 +0000 | [diff] [blame] | 43 | register_console(&early_console); | 
|  | 44 | } |