xref: /openbmc/linux/arch/sparc/prom/console_64.c (revision 595a251c)
15de18cdeSSam Ravnborg /* console.c: Routines that deal with sending and receiving IO
25de18cdeSSam Ravnborg  *            to/from the current console device using the PROM.
35de18cdeSSam Ravnborg  *
45de18cdeSSam Ravnborg  * Copyright (C) 1995 David S. Miller (davem@davemloft.net)
55de18cdeSSam Ravnborg  * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
65de18cdeSSam Ravnborg  */
75de18cdeSSam Ravnborg 
85de18cdeSSam Ravnborg #include <linux/types.h>
95de18cdeSSam Ravnborg #include <linux/kernel.h>
105de18cdeSSam Ravnborg #include <linux/sched.h>
115de18cdeSSam Ravnborg #include <asm/openprom.h>
125de18cdeSSam Ravnborg #include <asm/oplib.h>
135de18cdeSSam Ravnborg #include <asm/system.h>
145de18cdeSSam Ravnborg #include <linux/string.h>
155de18cdeSSam Ravnborg 
165de18cdeSSam Ravnborg extern int prom_stdin, prom_stdout;
175de18cdeSSam Ravnborg 
18595a251cSDavid S. Miller static int __prom_console_write_buf(const char *buf, int len)
195de18cdeSSam Ravnborg {
2025edd694SDavid S. Miller 	unsigned long args[7];
21595a251cSDavid S. Miller 	int ret;
2225edd694SDavid S. Miller 
2325edd694SDavid S. Miller 	args[0] = (unsigned long) "write";
2425edd694SDavid S. Miller 	args[1] = 3;
2525edd694SDavid S. Miller 	args[2] = 1;
2625edd694SDavid S. Miller 	args[3] = (unsigned int) prom_stdout;
27e62cac1fSDavid S. Miller 	args[4] = (unsigned long) buf;
28595a251cSDavid S. Miller 	args[5] = (unsigned int) len;
2925edd694SDavid S. Miller 	args[6] = (unsigned long) -1;
3025edd694SDavid S. Miller 
3125edd694SDavid S. Miller 	p1275_cmd_direct(args);
3225edd694SDavid S. Miller 
33595a251cSDavid S. Miller 	ret = (int) args[6];
34595a251cSDavid S. Miller 	if (ret < 0)
355de18cdeSSam Ravnborg 		return -1;
36595a251cSDavid S. Miller 	return ret;
375de18cdeSSam Ravnborg }
385de18cdeSSam Ravnborg 
39595a251cSDavid S. Miller void prom_console_write_buf(const char *buf, int len)
405de18cdeSSam Ravnborg {
41595a251cSDavid S. Miller 	while (len) {
42595a251cSDavid S. Miller 		int n = __prom_console_write_buf(buf, len);
43595a251cSDavid S. Miller 		if (n < 0)
44595a251cSDavid S. Miller 			continue;
45595a251cSDavid S. Miller 		len -= n;
46595a251cSDavid S. Miller 		buf += len;
47e62cac1fSDavid S. Miller 	}
485de18cdeSSam Ravnborg }
49