17913ad1aSFinn Thain /* 27913ad1aSFinn Thain * This file is subject to the terms and conditions of the GNU General Public 37913ad1aSFinn Thain * License. See the file "COPYING" in the main directory of this archive 47913ad1aSFinn Thain * for more details. 57913ad1aSFinn Thain * 67913ad1aSFinn Thain * Copyright (c) 2014 Finn Thain 77913ad1aSFinn Thain */ 87913ad1aSFinn Thain 97913ad1aSFinn Thain #include <linux/kernel.h> 107913ad1aSFinn Thain #include <linux/console.h> 117913ad1aSFinn Thain #include <linux/init.h> 127913ad1aSFinn Thain #include <linux/string.h> 137913ad1aSFinn Thain #include <asm/setup.h> 147913ad1aSFinn Thain 15*c46f46d0SFinn Thain extern void mvme16x_cons_write(struct console *co, 16*c46f46d0SFinn Thain const char *str, unsigned count); 17*c46f46d0SFinn Thain 187913ad1aSFinn Thain asmlinkage void __init debug_cons_nputs(const char *s, unsigned n); 197913ad1aSFinn Thain 20*c46f46d0SFinn Thain static void __ref debug_cons_write(struct console *c, 217913ad1aSFinn Thain const char *s, unsigned n) 227913ad1aSFinn Thain { 23*c46f46d0SFinn Thain #if !(defined(CONFIG_SUN3) || defined(CONFIG_M68360) || \ 24*c46f46d0SFinn Thain defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)) 25*c46f46d0SFinn Thain if (MACH_IS_MVME16x) 26*c46f46d0SFinn Thain mvme16x_cons_write(c, s, n); 27*c46f46d0SFinn Thain else 287913ad1aSFinn Thain debug_cons_nputs(s, n); 29*c46f46d0SFinn Thain #endif 307913ad1aSFinn Thain } 317913ad1aSFinn Thain 327913ad1aSFinn Thain static struct console early_console_instance = { 337913ad1aSFinn Thain .name = "debug", 347913ad1aSFinn Thain .write = debug_cons_write, 357913ad1aSFinn Thain .flags = CON_PRINTBUFFER | CON_BOOT, 367913ad1aSFinn Thain .index = -1 377913ad1aSFinn Thain }; 387913ad1aSFinn Thain 397913ad1aSFinn Thain static int __init setup_early_printk(char *buf) 407913ad1aSFinn Thain { 417913ad1aSFinn Thain if (early_console || buf) 427913ad1aSFinn Thain return 0; 437913ad1aSFinn Thain 447913ad1aSFinn Thain early_console = &early_console_instance; 457913ad1aSFinn Thain register_console(early_console); 467913ad1aSFinn Thain 477913ad1aSFinn Thain return 0; 487913ad1aSFinn Thain } 497913ad1aSFinn Thain early_param("earlyprintk", setup_early_printk); 507913ad1aSFinn Thain 517913ad1aSFinn Thain /* 527913ad1aSFinn Thain * debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be called 537913ad1aSFinn Thain * after init sections are discarded (for platforms that use it). 547913ad1aSFinn Thain */ 557913ad1aSFinn Thain #if !(defined(CONFIG_SUN3) || defined(CONFIG_M68360) || \ 567913ad1aSFinn Thain defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)) 577913ad1aSFinn Thain 587913ad1aSFinn Thain static int __init unregister_early_console(void) 597913ad1aSFinn Thain { 60*c46f46d0SFinn Thain if (!early_console || MACH_IS_MVME16x) 617913ad1aSFinn Thain return 0; 627913ad1aSFinn Thain 637913ad1aSFinn Thain return unregister_console(early_console); 647913ad1aSFinn Thain } 657913ad1aSFinn Thain late_initcall(unregister_early_console); 667913ad1aSFinn Thain 677913ad1aSFinn Thain #endif 68