Skip to content

Commit

Permalink
[MIPS] Fix and cleanup the mess that a dozen prom_printf variants are.
Browse files Browse the repository at this point in the history
early_printk is a so much saner thing.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Ralf Baechle committed Mar 4, 2007
1 parent ca471c8 commit 36a8853
Show file tree
Hide file tree
Showing 42 changed files with 254 additions and 427 deletions.
31 changes: 28 additions & 3 deletions arch/mips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ config MACH_DECSTATION
bool "DECstations"
select BOOT_ELF32
select DMA_NONCOHERENT
select EARLY_PRINTK
select SYS_HAS_EARLY_PRINTK
select IRQ_CPU
select SYS_HAS_CPU_R3000
select SYS_HAS_CPU_R4X00
Expand Down Expand Up @@ -242,6 +242,7 @@ config MACH_JAZZ
config LASAT
bool "LASAT Networks platforms"
select DMA_NONCOHERENT
select SYS_HAS_EARLY_PRINTK
select HW_HAS_PCI
select MIPS_GT64120
select MIPS_NILE4
Expand All @@ -256,6 +257,7 @@ config MIPS_ATLAS
bool "MIPS Atlas board"
select BOOT_ELF32
select DMA_NONCOHERENT
select SYS_HAS_EARLY_PRINTK
select IRQ_CPU
select HW_HAS_PCI
select MIPS_BOARDS_GEN
Expand Down Expand Up @@ -301,6 +303,7 @@ config MIPS_MALTA
select SYS_HAS_CPU_MIPS64_R1
select SYS_HAS_CPU_NEVADA
select SYS_HAS_CPU_RM7000
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_64BIT_KERNEL
select SYS_SUPPORTS_BIG_ENDIAN
Expand All @@ -316,6 +319,7 @@ config MIPS_SEAD
depends on EXPERIMENTAL
select IRQ_CPU
select DMA_NONCOHERENT
select SYS_HAS_EARLY_PRINTK
select MIPS_BOARDS_GEN
select SYS_HAS_CPU_MIPS32_R1
select SYS_HAS_CPU_MIPS32_R2
Expand Down Expand Up @@ -353,9 +357,11 @@ config WR_PPMC
config MIPS_SIM
bool 'MIPS simulator (MIPSsim)'
select DMA_NONCOHERENT
select SYS_HAS_EARLY_PRINTK
select IRQ_CPU
select SYS_HAS_CPU_MIPS32_R1
select SYS_HAS_CPU_MIPS32_R2
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_BIG_ENDIAN
select SYS_SUPPORTS_LITTLE_ENDIAN
Expand All @@ -376,6 +382,7 @@ config MOMENCO_JAGUAR_ATX
select RM7000_CPU_SCACHE
select SWAP_IO_SPACE
select SYS_HAS_CPU_RM9000
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_64BIT_KERNEL
select SYS_SUPPORTS_BIG_ENDIAN
Expand Down Expand Up @@ -513,6 +520,7 @@ config PMC_YOSEMITE
select IRQ_CPU_RM9K
select SWAP_IO_SPACE
select SYS_HAS_CPU_RM9000
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_64BIT_KERNEL
select SYS_SUPPORTS_BIG_ENDIAN
Expand Down Expand Up @@ -573,6 +581,7 @@ config SGI_IP22
select SWAP_IO_SPACE
select SYS_HAS_CPU_R4X00
select SYS_HAS_CPU_R5000
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_64BIT_KERNEL
select SYS_SUPPORTS_BIG_ENDIAN
Expand All @@ -587,7 +596,7 @@ config SGI_IP27
select ARC64
select BOOT_ELF64
select DMA_IP27
select EARLY_PRINTK
select SYS_HAS_EARLY_PRINTK
select HW_HAS_PCI
select NR_CPUS_DEFAULT_64
select PCI_DOMAINS
Expand Down Expand Up @@ -749,6 +758,7 @@ config SNI_RM
select SYS_HAS_CPU_R5000
select SYS_HAS_CPU_R10000
select R5000_CPU_SCACHE
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
select SYS_SUPPORTS_BIG_ENDIAN
Expand Down Expand Up @@ -897,6 +907,20 @@ config DMA_NEED_PCI_MAP_STATE
bool

config EARLY_PRINTK
bool "Early printk" if EMBEDDED && DEBUG_KERNEL
depends on SYS_HAS_EARLY_PRINTK
default y
help
This option enables special console drivers which allow the kernel
to print messages very early in the bootup process.

This is useful for kernel debugging when your machine crashes very
early before the console code is initialized. For normal operation
it is not recommended because it looks on some machines ugly and
oesn't cooperate with an X server. You should normally N here,
unless you want to debug such a crash.

config SYS_HAS_EARLY_PRINTK
bool

config GENERIC_ISA_DMA
Expand Down Expand Up @@ -1033,6 +1057,7 @@ config SOC_PNX8550
select DMA_NONCOHERENT
select HW_HAS_PCI
select SYS_HAS_CPU_MIPS32_R1
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_32BIT_KERNEL
select GENERIC_HARDIRQS_NO__DO_IRQ
select SYS_SUPPORTS_KGDB
Expand Down Expand Up @@ -1093,7 +1118,7 @@ config HAVE_STD_PC_SERIAL_PORT

config ARC_CONSOLE
bool "ARC console support"
depends on SGI_IP22 || SNI_RM
depends on SGI_IP22 || (SNI_RM && CPU_LITTLE_ENDIAN)

config ARC_MEMORY
bool
Expand Down
32 changes: 0 additions & 32 deletions arch/mips/arc/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,3 @@ void prom_putchar(char c)
ArcWrite(1, &it, 1, &cnt);
bc_enable();
}

char prom_getchar(void)
{
ULONG cnt;
CHAR c;

bc_disable();
ArcRead(0, &c, 1, &cnt);
bc_enable();

return c;
}

void prom_printf(char *fmt, ...)
{
va_list args;
char ppbuf[1024];
char *bptr;

va_start(args, fmt);
vsprintf(ppbuf, fmt, args);

bptr = ppbuf;

while (*bptr != 0) {
if (*bptr == '\n')
prom_putchar('\r');

prom_putchar(*bptr++);
}
va_end(args);
}
9 changes: 6 additions & 3 deletions arch/mips/arc/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ void __init prom_init(void)
{
PSYSTEM_PARAMETER_BLOCK pb = PROMBLOCK;
romvec = ROMVECTOR;
ULONG cnt;
CHAR c;

prom_argc = fw_arg0;
_prom_argv = (LONG *) fw_arg1;
_prom_envp = (LONG *) fw_arg2;

if (pb->magic != 0x53435241) {
prom_printf("Aieee, bad prom vector magic %08lx\n", pb->magic);
printk(KERN_CRIT "Aieee, bad prom vector magic %08lx\n", pb->magic);
while(1)
;
}
Expand All @@ -41,8 +44,8 @@ void __init prom_init(void)
prom_meminit();

#ifdef DEBUG_PROM_INIT
prom_printf("Press a key to reboot\n");
prom_getchar();
pr_info("Press a key to reboot\n");
ArcRead(0, &c, 1, &cnt);
ArcEnterInteractiveMode();
#endif
}
6 changes: 3 additions & 3 deletions arch/mips/arc/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ void __init prom_meminit(void)
#ifdef DEBUG
int i = 0;

prom_printf("ARCS MEMORY DESCRIPTOR dump:\n");
printk("ARCS MEMORY DESCRIPTOR dump:\n");
p = ArcGetMemoryDescriptor(PROM_NULL_MDESC);
while(p) {
prom_printf("[%d,%p]: base<%08lx> pages<%08lx> type<%s>\n",
i, p, p->base, p->pages, mtypes(p->type));
printk("[%d,%p]: base<%08lx> pages<%08lx> type<%s>\n",
i, p, p->base, p->pages, mtypes(p->type));
p = ArcGetMemoryDescriptor(p);
i++;
}
Expand Down
10 changes: 5 additions & 5 deletions arch/mips/arc/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ static char *iflags[] = {
static void __init
dump_component(pcomponent *p)
{
prom_printf("[%p]:class<%s>type<%s>flags<%s>ver<%d>rev<%d>",
p, classes[p->class], types[p->type],
iflags[p->iflags], p->vers, p->rev);
prom_printf("key<%08lx>\n\tamask<%08lx>cdsize<%d>ilen<%d>iname<%s>\n",
p->key, p->amask, (int)p->cdsize, (int)p->ilen, p->iname);
printk("[%p]:class<%s>type<%s>flags<%s>ver<%d>rev<%d>",
p, classes[p->class], types[p->type],
iflags[p->iflags], p->vers, p->rev);
printk("key<%08lx>\n\tamask<%08lx>cdsize<%d>ilen<%d>iname<%s>\n",
p->key, p->amask, (int)p->cdsize, (int)p->ilen, p->iname);
}

static void __init
Expand Down
26 changes: 0 additions & 26 deletions arch/mips/cobalt/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,3 @@ static void putchar(int c)

COBALT_UART[UART_TX] = c;
}

static void cons_write(struct console *c, const char *s, unsigned n)
{
while(n-- && *s)
putchar(*s++);
}

static struct console cons_info =
{
.name = "uart",
.write = cons_write,
.flags = CON_PRINTBUFFER | CON_BOOT,
.index = -1,
};

void __init cobalt_early_console(void)
{
register_console(&cons_info);

printk("Cobalt: early console registered\n");
}

void __init disable_early_printk(void)
{
unregister_console(&cons_info);
}
4 changes: 0 additions & 4 deletions arch/mips/cobalt/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ void __init plat_mem_setup(void)
#endif

if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
#ifdef CONFIG_EARLY_PRINTK
cobalt_early_console();
#endif

#ifdef CONFIG_SERIAL_8250
uart.line = 0;
uart.type = PORT_UNKNOWN;
Expand Down
38 changes: 5 additions & 33 deletions arch/mips/dec/prom/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,12 @@

#include <asm/dec/prom.h>

static void __init prom_console_write(struct console *con, const char *s,
unsigned int c)
void prom_putchar(char c)
{
static char sfmt[] __initdata = "%%%us";
char fmt[13];
char s[2];

snprintf(fmt, sizeof(fmt), sfmt, c);
prom_printf(fmt, s);
}

static struct console promcons __initdata = {
.name = "prom",
.write = prom_console_write,
.flags = CON_PRINTBUFFER,
.index = -1,
};

static int promcons_output __initdata = 0;

void __init register_prom_console(void)
{
if (!promcons_output) {
promcons_output = 1;
register_console(&promcons);
}
}
s[0] = c;
s[1] = '\0';

void __init unregister_prom_console(void)
{
if (promcons_output) {
unregister_console(&promcons);
promcons_output = 0;
}
prom_printf( s);
}

void disable_early_printk(void)
__attribute__((alias("unregister_prom_console")));
5 changes: 0 additions & 5 deletions arch/mips/gt64120/ev64120/promcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ static void prom_console_write(struct console *co, const char *s,
}
}

int prom_getchar(void)
{
return 0;
}

static struct console sercons = {
.name = "ttyS",
.write = prom_console_write,
Expand Down
1 change: 1 addition & 0 deletions arch/mips/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ obj-$(CONFIG_64BIT) += cpu-bugs64.o
obj-$(CONFIG_I8253) += i8253.o

obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o

CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
40 changes: 40 additions & 0 deletions arch/mips/kernel/early_printk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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) 2002, 2003, 06, 07 Ralf Baechle (ralf@linux-mips.org)
* Copyright (C) 2007 MIPS Technologies, Inc.
* written by Ralf Baechle (ralf@linux-mips.org)
*/
#include <linux/console.h>
#include <linux/init.h>

extern void prom_putchar(char);

static void early_console_write(struct console *con, const char *s, unsigned n)
{
while (n-- && *s) {
if (*s == '\n')
prom_putchar('\r');
prom_putchar(*s);
s++;
}
}

static struct console early_console = {
.name = "early",
.write = early_console_write,
.flags = CON_PRINTBUFFER | CON_BOOT,
.index = -1
};

void __init setup_early_printk(void)
{
register_console(&early_console);
}

void __init disable_early_printk(void)
{
unregister_console(&early_console);
}
8 changes: 8 additions & 0 deletions arch/mips/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,14 @@ void __init setup_arch(char **cmdline_p)
{
cpu_probe();
prom_init();

#ifdef CONFIG_EARLY_PRINTK
{
extern void setup_early_printk(void);

setup_early_printk();
}
#endif
cpu_report();

#if defined(CONFIG_VT)
Expand Down
Loading

0 comments on commit 36a8853

Please sign in to comment.