blob: 9ae813eb782e9cebe160df532b113e456d7fe799 [file] [log] [blame]
Ralf Baechle36a88532007-03-01 11:56:43 +00001/*
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 Vorobiev07cdb782008-05-29 17:57:08 +030013#include <asm/setup.h>
14
Ralf Baechle36a88532007-03-01 11:56:43 +000015extern void prom_putchar(char);
16
Franck Bui-Huuca4437d2007-05-03 12:58:54 +020017static void __init
18early_console_write(struct console *con, const char *s, unsigned n)
Ralf Baechle36a88532007-03-01 11:56:43 +000019{
20 while (n-- && *s) {
21 if (*s == '\n')
22 prom_putchar('\r');
23 prom_putchar(*s);
24 s++;
25 }
26}
27
Franck Bui-Huuca4437d2007-05-03 12:58:54 +020028static struct console early_console __initdata = {
Ralf Baechle36a88532007-03-01 11:56:43 +000029 .name = "early",
30 .write = early_console_write,
31 .flags = CON_PRINTBUFFER | CON_BOOT,
32 .index = -1
33};
34
Franck Bui-Huu36ea1d52007-05-03 13:01:32 +020035static int early_console_initialized __initdata;
36
Ralf Baechle36a88532007-03-01 11:56:43 +000037void __init setup_early_printk(void)
38{
Franck Bui-Huu36ea1d52007-05-03 13:01:32 +020039 if (early_console_initialized)
40 return;
41 early_console_initialized = 1;
42
Ralf Baechle36a88532007-03-01 11:56:43 +000043 register_console(&early_console);
44}