xref: /openbmc/linux/arch/sparc/prom/console_64.c (revision b2441318)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
25de18cdeSSam Ravnborg /* console.c: Routines that deal with sending and receiving IO
35de18cdeSSam Ravnborg  *            to/from the current console device using the PROM.
45de18cdeSSam Ravnborg  *
55de18cdeSSam Ravnborg  * Copyright (C) 1995 David S. Miller (davem@davemloft.net)
65de18cdeSSam Ravnborg  * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
75de18cdeSSam Ravnborg  */
85de18cdeSSam Ravnborg 
95de18cdeSSam Ravnborg #include <linux/types.h>
105de18cdeSSam Ravnborg #include <linux/kernel.h>
115de18cdeSSam Ravnborg #include <linux/sched.h>
125de18cdeSSam Ravnborg #include <asm/openprom.h>
135de18cdeSSam Ravnborg #include <asm/oplib.h>
145de18cdeSSam Ravnborg #include <linux/string.h>
155de18cdeSSam Ravnborg 
__prom_console_write_buf(const char * buf,int len)16595a251cSDavid S. Miller static int __prom_console_write_buf(const char *buf, int len)
175de18cdeSSam Ravnborg {
1825edd694SDavid S. Miller 	unsigned long args[7];
19595a251cSDavid S. Miller 	int ret;
2025edd694SDavid S. Miller 
2125edd694SDavid S. Miller 	args[0] = (unsigned long) "write";
2225edd694SDavid S. Miller 	args[1] = 3;
2325edd694SDavid S. Miller 	args[2] = 1;
2425edd694SDavid S. Miller 	args[3] = (unsigned int) prom_stdout;
25e62cac1fSDavid S. Miller 	args[4] = (unsigned long) buf;
26595a251cSDavid S. Miller 	args[5] = (unsigned int) len;
2725edd694SDavid S. Miller 	args[6] = (unsigned long) -1;
2825edd694SDavid S. Miller 
2925edd694SDavid S. Miller 	p1275_cmd_direct(args);
3025edd694SDavid S. Miller 
31595a251cSDavid S. Miller 	ret = (int) args[6];
32595a251cSDavid S. Miller 	if (ret < 0)
335de18cdeSSam Ravnborg 		return -1;
34595a251cSDavid S. Miller 	return ret;
355de18cdeSSam Ravnborg }
365de18cdeSSam Ravnborg 
prom_console_write_buf(const char * buf,int len)37595a251cSDavid S. Miller void prom_console_write_buf(const char *buf, int len)
385de18cdeSSam Ravnborg {
39595a251cSDavid S. Miller 	while (len) {
40595a251cSDavid S. Miller 		int n = __prom_console_write_buf(buf, len);
41595a251cSDavid S. Miller 		if (n < 0)
42595a251cSDavid S. Miller 			continue;
43595a251cSDavid S. Miller 		len -= n;
44595a251cSDavid S. Miller 		buf += len;
45e62cac1fSDavid S. Miller 	}
465de18cdeSSam Ravnborg }
47