console_64.c 1.0 KB
Newer Older
D
David S. Miller 已提交
1
/* console.c: Routines that deal with sending and receiving IO
L
Linus Torvalds 已提交
2 3
 *            to/from the current console device using the PROM.
 *
D
David S. Miller 已提交
4
 * Copyright (C) 1995 David S. Miller (davem@davemloft.net)
L
Linus Torvalds 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17
 * 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 <asm/system.h>
#include <linux/string.h>

extern int prom_stdin, prom_stdout;

18
static int __prom_console_write_buf(const char *buf, int len)
L
Linus Torvalds 已提交
19
{
20
	unsigned long args[7];
21
	int ret;
22 23 24 25 26

	args[0] = (unsigned long) "write";
	args[1] = 3;
	args[2] = 1;
	args[3] = (unsigned int) prom_stdout;
27
	args[4] = (unsigned long) buf;
28
	args[5] = (unsigned int) len;
29 30 31 32
	args[6] = (unsigned long) -1;

	p1275_cmd_direct(args);

33 34
	ret = (int) args[6];
	if (ret < 0)
L
Linus Torvalds 已提交
35
		return -1;
36
	return ret;
L
Linus Torvalds 已提交
37 38
}

39
void prom_console_write_buf(const char *buf, int len)
L
Linus Torvalds 已提交
40
{
41 42 43 44 45 46
	while (len) {
		int n = __prom_console_write_buf(buf, len);
		if (n < 0)
			continue;
		len -= n;
		buf += len;
47
	}
L
Linus Torvalds 已提交
48
}