blob: ed39e75828bd1eb6057f192d052ab88f5b943ddd [file] [log] [blame]
David S. Millerd979f172007-10-27 00:13:04 -07001/* console.c: Routines that deal with sending and receiving IO
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * to/from the current console device using the PROM.
3 *
David S. Millerd979f172007-10-27 00:13:04 -07004 * Copyright (C) 1995 David S. Miller (davem@davemloft.net)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 */
7
8#include <linux/types.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <asm/openprom.h>
12#include <asm/oplib.h>
13#include <asm/system.h>
14#include <linux/string.h>
15
16extern int prom_stdin, prom_stdout;
17
David S. Miller595a2512010-11-30 20:15:58 -080018static int __prom_console_write_buf(const char *buf, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019{
David S. Miller25edd692010-08-23 23:10:57 -070020 unsigned long args[7];
David S. Miller595a2512010-11-30 20:15:58 -080021 int ret;
David S. Miller25edd692010-08-23 23:10:57 -070022
23 args[0] = (unsigned long) "write";
24 args[1] = 3;
25 args[2] = 1;
26 args[3] = (unsigned int) prom_stdout;
David S. Millere62cac12010-11-30 14:33:29 -080027 args[4] = (unsigned long) buf;
David S. Miller595a2512010-11-30 20:15:58 -080028 args[5] = (unsigned int) len;
David S. Miller25edd692010-08-23 23:10:57 -070029 args[6] = (unsigned long) -1;
30
31 p1275_cmd_direct(args);
32
David S. Miller595a2512010-11-30 20:15:58 -080033 ret = (int) args[6];
34 if (ret < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 return -1;
David S. Miller595a2512010-11-30 20:15:58 -080036 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037}
38
David S. Miller595a2512010-11-30 20:15:58 -080039void prom_console_write_buf(const char *buf, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040{
David S. Miller595a2512010-11-30 20:15:58 -080041 while (len) {
42 int n = __prom_console_write_buf(buf, len);
43 if (n < 0)
44 continue;
45 len -= n;
46 buf += len;
David S. Millere62cac12010-11-30 14:33:29 -080047 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070048}