xref: /openbmc/linux/arch/powerpc/boot/ofconsole.c (revision 2874c5fd)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * OF console routines
4  *
5  * Copyright (C) Paul Mackerras 1997.
6  */
7 #include <stddef.h>
8 #include "types.h"
9 #include "elf.h"
10 #include "string.h"
11 #include "stdio.h"
12 #include "page.h"
13 #include "ops.h"
14 
15 #include "of.h"
16 
17 static unsigned int of_stdout_handle;
18 
of_console_open(void)19 static int of_console_open(void)
20 {
21 	void *devp;
22 
23 	if (((devp = of_finddevice("/chosen")) != NULL)
24 	    && (of_getprop(devp, "stdout", &of_stdout_handle,
25 			   sizeof(of_stdout_handle))
26 		== sizeof(of_stdout_handle))) {
27 		of_stdout_handle = be32_to_cpu(of_stdout_handle);
28 		return 0;
29 	}
30 
31 	return -1;
32 }
33 
of_console_write(const char * buf,int len)34 static void of_console_write(const char *buf, int len)
35 {
36 	of_call_prom("write", 3, 1, of_stdout_handle, buf, len);
37 }
38 
of_console_init(void)39 void of_console_init(void)
40 {
41 	console_ops.open = of_console_open;
42 	console_ops.write = of_console_write;
43 }
44