2007-10-27 01:13:04 -06:00
|
|
|
/* console.c: Routines that deal with sending and receiving IO
|
2005-04-16 16:20:36 -06:00
|
|
|
* to/from the current console device using the PROM.
|
|
|
|
*
|
2007-10-27 01:13:04 -06:00
|
|
|
* Copyright (C) 1995 David S. Miller (davem@davemloft.net)
|
2005-04-16 16:20:36 -06:00
|
|
|
* Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <asm/openprom.h>
|
|
|
|
#include <asm/oplib.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
2010-11-30 21:15:58 -07:00
|
|
|
static int __prom_console_write_buf(const char *buf, int len)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2010-08-24 00:10:57 -06:00
|
|
|
unsigned long args[7];
|
2010-11-30 21:15:58 -07:00
|
|
|
int ret;
|
2010-08-24 00:10:57 -06:00
|
|
|
|
|
|
|
args[0] = (unsigned long) "write";
|
|
|
|
args[1] = 3;
|
|
|
|
args[2] = 1;
|
|
|
|
args[3] = (unsigned int) prom_stdout;
|
2010-11-30 15:33:29 -07:00
|
|
|
args[4] = (unsigned long) buf;
|
2010-11-30 21:15:58 -07:00
|
|
|
args[5] = (unsigned int) len;
|
2010-08-24 00:10:57 -06:00
|
|
|
args[6] = (unsigned long) -1;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
|
|
|
|
2010-11-30 21:15:58 -07:00
|
|
|
ret = (int) args[6];
|
|
|
|
if (ret < 0)
|
2005-04-16 16:20:36 -06:00
|
|
|
return -1;
|
2010-11-30 21:15:58 -07:00
|
|
|
return ret;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2010-11-30 21:15:58 -07:00
|
|
|
void prom_console_write_buf(const char *buf, int len)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2010-11-30 21:15:58 -07:00
|
|
|
while (len) {
|
|
|
|
int n = __prom_console_write_buf(buf, len);
|
|
|
|
if (n < 0)
|
|
|
|
continue;
|
|
|
|
len -= n;
|
|
|
|
buf += len;
|
2010-11-30 15:33:29 -07:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|