early_printk.c 1.6 KB
Newer Older
F
Finn Thain 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (c) 2014 Finn Thain
 */

#include <linux/kernel.h>
#include <linux/console.h>
#include <linux/init.h>
#include <linux/string.h>
#include <asm/setup.h>

15 16 17
extern void mvme16x_cons_write(struct console *co,
			       const char *str, unsigned count);

F
Finn Thain 已提交
18 19
asmlinkage void __init debug_cons_nputs(const char *s, unsigned n);

20 21
static void __ref debug_cons_write(struct console *c,
				   const char *s, unsigned n)
F
Finn Thain 已提交
22
{
23 24
#if !(defined(CONFIG_SUN3) || defined(CONFIG_M68000) || \
      defined(CONFIG_COLDFIRE))
25 26 27 28 29
	if (MACH_IS_MVME16x)
		mvme16x_cons_write(c, s, n);
	else
		debug_cons_nputs(s, n);
#endif
F
Finn Thain 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
}

static struct console early_console_instance = {
	.name  = "debug",
	.write = debug_cons_write,
	.flags = CON_PRINTBUFFER | CON_BOOT,
	.index = -1
};

static int __init setup_early_printk(char *buf)
{
	if (early_console || buf)
		return 0;

	early_console = &early_console_instance;
	register_console(early_console);

	return 0;
}
early_param("earlyprintk", setup_early_printk);

/*
 * debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be called
 * after init sections are discarded (for platforms that use it).
 */
55 56
#if !(defined(CONFIG_SUN3) || defined(CONFIG_M68000) || \
      defined(CONFIG_COLDFIRE))
F
Finn Thain 已提交
57 58 59

static int __init unregister_early_console(void)
{
60
	if (!early_console || MACH_IS_MVME16x)
F
Finn Thain 已提交
61 62 63 64 65 66 67
		return 0;

	return unregister_console(early_console);
}
late_initcall(unregister_early_console);

#endif