Commit cafe8464 authored by Pete Zaitcev's avatar Pete Zaitcev Committed by David S. Miller

SPARC: Fix prom_printf and prom console behavior.

parent 15c5cc6e
...@@ -130,7 +130,7 @@ void kernel_enter_debugger(void) ...@@ -130,7 +130,7 @@ void kernel_enter_debugger(void)
static void static void
prom_console_write(struct console *con, const char *s, unsigned n) prom_console_write(struct console *con, const char *s, unsigned n)
{ {
prom_printf("%s", s); prom_write(s, n);
} }
static struct console prom_debug_console = { static struct console prom_debug_console = {
......
/* $Id: printf.c,v 1.7 2000/02/08 20:24:23 davem Exp $ /*
* printf.c: Internal prom library printf facility. * printf.c: Internal prom library printf facility.
* *
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
*/ * Copyright (c) 2002 Pete Zaitcev (zaitcev@yahoo.com)
*
/* This routine is internal to the prom library, no one else should know * We used to warn all over the code: DO NOT USE prom_printf(),
* about or use it! It's simple and smelly anyway.... * and yet people do. Anton's banking code was outputing banks
* with prom_printf for most of the 2.4 lifetime. Since an effective
* stick is not available, we deployed a carrot: an early printk
* through PROM by means of -p boot option. This ought to fix it.
* USE printk; if you need, deploy -p.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -15,24 +19,28 @@ ...@@ -15,24 +19,28 @@
static char ppbuf[1024]; static char ppbuf[1024];
void
prom_write(const char *buf, unsigned int n)
{
char ch;
while (n != 0) {
--n;
if ((ch = *buf++) == '\n')
prom_putchar('\r');
prom_putchar(ch);
}
}
void void
prom_printf(char *fmt, ...) prom_printf(char *fmt, ...)
{ {
va_list args; va_list args;
char ch, *bptr;
int i; int i;
va_start(args, fmt); va_start(args, fmt);
i = vsprintf(ppbuf, fmt, args); i = vsnprintf(ppbuf, sizeof(ppbuf), fmt, args);
bptr = ppbuf;
while((ch = *(bptr++)) != 0) {
if(ch == '\n')
prom_putchar('\r');
prom_putchar(ch);
}
va_end(args); va_end(args);
return;
prom_write(ppbuf, i);
} }
...@@ -73,7 +73,7 @@ asmlinkage void sys_sync(void); /* it's really int */ ...@@ -73,7 +73,7 @@ asmlinkage void sys_sync(void); /* it's really int */
static void static void
prom_console_write(struct console *con, const char *s, unsigned n) prom_console_write(struct console *con, const char *s, unsigned n)
{ {
prom_printf("%s", s); prom_write(s, n);
} }
static struct console prom_console = { static struct console prom_console = {
......
/* $Id: printf.c,v 1.3 1997/03/18 18:00:00 jj Exp $ /*
* printf.c: Internal prom library printf facility. * printf.c: Internal prom library printf facility.
* *
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
* Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
*/ * Copyright (c) 2002 Pete Zaitcev (zaitcev@yahoo.com)
*
/* This routine is internal to the prom library, no one else should know * We used to warn all over the code: DO NOT USE prom_printf(),
* about or use it! It's simple and smelly anyway.... * and yet people do. Anton's banking code was outputing banks
* with prom_printf for most of the 2.4 lifetime. Since an effective
* stick is not available, we deployed a carrot: an early printk
* through PROM by means of -p boot option. This ought to fix it.
* USE printk; if you need, deploy -p.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -16,31 +20,28 @@ ...@@ -16,31 +20,28 @@
static char ppbuf[1024]; static char ppbuf[1024];
extern void prom_puts (char *, int); void
prom_write(const char *buf, unsigned int n)
{
char ch;
while (n != 0) {
--n;
if ((ch = *buf++) == '\n')
prom_putchar('\r');
prom_putchar(ch);
}
}
void void
prom_printf(char *fmt, ...) prom_printf(char *fmt, ...)
{ {
va_list args; va_list args;
char ch, *bptr, *last;
int i; int i;
va_start(args, fmt); va_start(args, fmt);
i = vsprintf(ppbuf, fmt, args); i = vsnprintf(ppbuf, sizeof(ppbuf), fmt, args);
bptr = ppbuf;
last = ppbuf;
while((ch = *(bptr++)) != 0) {
if(ch == '\n') {
if (last < bptr - 1)
prom_puts (last, bptr - 1 - last);
prom_putchar('\r');
last = bptr - 1;
}
}
if (last < bptr - 1)
prom_puts (last, bptr - 1 - last);
va_end(args); va_end(args);
return;
prom_write(ppbuf, i);
} }
...@@ -153,8 +153,9 @@ extern char prom_getchar(void); ...@@ -153,8 +153,9 @@ extern char prom_getchar(void);
/* Blocking put character to console. */ /* Blocking put character to console. */
extern void prom_putchar(char character); extern void prom_putchar(char character);
/* Prom's internal printf routine, don't use in kernel/boot code. */ /* Prom's internal routines, don't use in kernel/boot code. */
void prom_printf(char *fmt, ...); extern void prom_printf(char *fmt, ...);
extern void prom_write(const char *buf, unsigned int len);
/* Query for input device type */ /* Query for input device type */
......
...@@ -153,8 +153,9 @@ extern char prom_getchar(void); ...@@ -153,8 +153,9 @@ extern char prom_getchar(void);
/* Blocking put character to console. */ /* Blocking put character to console. */
extern void prom_putchar(char character); extern void prom_putchar(char character);
/* Prom's internal printf routine, don't use in kernel/boot code. */ /* Prom's internal routines, don't use in kernel/boot code. */
void prom_printf(char *fmt, ...); extern void prom_printf(char *fmt, ...);
extern void prom_write(const char *buf, unsigned int len);
/* Query for input device type */ /* Query for input device type */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment