[MIPS] Fix and cleanup the mess that a dozen prom_printf variants are.

early_printk is a so much saner thing.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
Ralf Baechle
2007-03-01 11:56:43 +00:00
parent ca471c8604
commit 36a885306f
42 changed files with 255 additions and 428 deletions

View File

@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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

View File

@@ -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);
}

View File

@@ -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)
;
}
@@ -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
}

View File

@@ -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++;
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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);
s[0] = c;
s[1] = '\0';
prom_printf( 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);
}
}
void __init unregister_prom_console(void)
{
if (promcons_output) {
unregister_console(&promcons);
promcons_output = 0;
}
}
void disable_early_printk(void)
__attribute__((alias("unregister_prom_console")));

View File

@@ -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,

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -110,12 +110,13 @@ int lasat_init_board_info(void)
sizeof(struct lasat_eeprom_struct) - 4);
if (crc != lasat_board_info.li_eeprom_info.crc32) {
prom_printf("WARNING...\nWARNING...\nEEPROM CRC does not match calculated, attempting to soldier on...\n");
printk(KERN_WARNING "WARNING...\nWARNING...\nEEPROM CRC does "
"not match calculated, attempting to soldier on...\n");
}
if (lasat_board_info.li_eeprom_info.version != LASAT_EEPROM_VERSION)
{
prom_printf("WARNING...\nWARNING...\nEEPROM version %d, wanted version %d, attempting to soldier on...\n",
if (lasat_board_info.li_eeprom_info.version != LASAT_EEPROM_VERSION) {
printk(KERN_WARNING "WARNING...\nWARNING...\nEEPROM version "
"%d, wanted version %d, attempting to soldier on...\n",
(unsigned int)lasat_board_info.li_eeprom_info.version,
LASAT_EEPROM_VERSION);
}
@@ -124,7 +125,9 @@ int lasat_init_board_info(void)
cfg1 = lasat_board_info.li_eeprom_info.cfg[1];
if ( LASAT_W0_DSCTYPE(cfg0) != 1) {
prom_printf("WARNING...\nWARNING...\nInvalid configuration read from EEPROM, attempting to soldier on...");
printk(KERN_WARNING "WARNING...\nWARNING...\n"
"Invalid configuration read from EEPROM, attempting to "
"soldier on...");
}
/* We have a valid configuration */

View File

@@ -23,10 +23,6 @@
#define PROM_PUTC_ADDR PROM_JUMP_TABLE_ENTRY(1)
#define PROM_MONITOR_ADDR PROM_JUMP_TABLE_ENTRY(2)
static void null_prom_printf(const char * fmt, ...)
{
}
static void null_prom_display(const char *string, int pos, int clear)
{
}
@@ -40,50 +36,29 @@ static void null_prom_putc(char c)
}
/* these are functions provided by the bootloader */
static void (* prom_putc)(char c) = null_prom_putc;
void (* prom_printf)(const char * fmt, ...) = null_prom_printf;
static void (* __prom_putc)(char c) = null_prom_putc;
void prom_putchar(char c)
{
__prom_putc(c);
}
void (* prom_display)(const char *string, int pos, int clear) =
null_prom_display;
void (* prom_monitor)(void) = null_prom_monitor;
unsigned int lasat_ndelay_divider;
#define PROM_PRINTFBUF_SIZE 256
static char prom_printfbuf[PROM_PRINTFBUF_SIZE];
static void real_prom_printf(const char * fmt, ...)
{
va_list ap;
int len;
char *c = prom_printfbuf;
int i;
va_start(ap, fmt);
len = vsnprintf(prom_printfbuf, PROM_PRINTFBUF_SIZE, fmt, ap);
va_end(ap);
/* output overflowed the buffer */
if (len < 0 || len > PROM_PRINTFBUF_SIZE)
len = PROM_PRINTFBUF_SIZE;
for (i=0; i < len; i++) {
if (*c == '\n')
prom_putc('\r');
prom_putc(*c++);
}
}
static void setup_prom_vectors(void)
{
u32 version = *(u32 *)(RESET_VECTOR + 0x90);
if (version >= 307) {
prom_display = (void *)PROM_DISPLAY_ADDR;
prom_putc = (void *)PROM_PUTC_ADDR;
prom_printf = real_prom_printf;
__prom_putc = (void *)PROM_PUTC_ADDR;
prom_monitor = (void *)PROM_MONITOR_ADDR;
}
prom_printf("prom vectors set up\n");
printk("prom vectors set up\n");
}
static struct at93c_defs at93c_defs[N_MACHTYPES] = {
@@ -101,11 +76,11 @@ void __init prom_init(void)
setup_prom_vectors();
if (current_cpu_data.cputype == CPU_R5000) {
prom_printf("LASAT 200 board\n");
printk("LASAT 200 board\n");
mips_machtype = MACH_LASAT_200;
lasat_ndelay_divider = LASAT_200_DIVIDER;
} else {
prom_printf("LASAT 100 board\n");
printk("LASAT 100 board\n");
mips_machtype = MACH_LASAT_100;
lasat_ndelay_divider = LASAT_100_DIVIDER;
}

View File

@@ -2,5 +2,4 @@
#define PROM_H
extern void (* prom_display)(const char *string, int pos, int clear);
extern void (* prom_monitor)(void);
extern void (* prom_printf)(const char * fmt, ...);
#endif

View File

@@ -178,5 +178,5 @@ void __init plat_mem_setup(void)
/* Switch from prom exception handler to normal mode */
change_c0_status(ST0_BEV,0);
prom_printf("Lasat specific initialization complete\n");
pr_info("Lasat specific initialization complete\n");
}

View File

@@ -2,8 +2,8 @@
# Makefile for MIPS-specific library files..
#
lib-y += csum_partial.o memcpy.o memcpy-inatomic.o memset.o promlib.o \
strlen_user.o strncpy_user.o strnlen_user.o uncached.o
lib-y += csum_partial.o memcpy.o memcpy-inatomic.o memset.o strlen_user.o \
strncpy_user.o strnlen_user.o uncached.o
obj-y += iomap.o
obj-$(CONFIG_PCI) += iomap-pci.o

View File

@@ -1,24 +0,0 @@
#include <stdarg.h>
#include <linux/kernel.h>
extern void prom_putchar(char);
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);
}

View File

@@ -18,7 +18,9 @@
# Makefile for the MIPS boards generic routines under Linux.
#
obj-y := reset.o display.o init.o memory.o printf.o \
obj-y := reset.o display.o init.o memory.o \
cmdline.o time.o
obj-$(CONFIG_EARLY_PRINTK) += console.o
obj-$(CONFIG_PCI) += pci.o
obj-$(CONFIG_KGDB) += gdb_hook.o

View File

@@ -17,10 +17,9 @@
*
* Putting things on the screen/serial line using YAMONs facilities.
*/
#include <linux/console.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/serial_reg.h>
#include <linux/spinlock.h>
#include <asm/io.h>
#ifdef CONFIG_MIPS_ATLAS
@@ -67,12 +66,3 @@ int prom_putchar(char c)
return 1;
}
char prom_getchar(void)
{
while (!(serial_in(UART_LSR) & UART_LSR_DR))
;
return serial_in(UART_RX);
}

Some files were not shown because too many files have changed in this diff Show More