xref: /linux/arch/powerpc/boot/ofconsole.c (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*2874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
22e601613SDavid Gibson /*
32e601613SDavid Gibson  * OF console routines
42e601613SDavid Gibson  *
52e601613SDavid Gibson  * Copyright (C) Paul Mackerras 1997.
62e601613SDavid Gibson  */
72e601613SDavid Gibson #include <stddef.h>
82e601613SDavid Gibson #include "types.h"
92e601613SDavid Gibson #include "elf.h"
102e601613SDavid Gibson #include "string.h"
112e601613SDavid Gibson #include "stdio.h"
122e601613SDavid Gibson #include "page.h"
132e601613SDavid Gibson #include "ops.h"
142e601613SDavid Gibson 
152e601613SDavid Gibson #include "of.h"
162e601613SDavid Gibson 
17926e6940SCédric Le Goater static unsigned int of_stdout_handle;
182e601613SDavid Gibson 
of_console_open(void)192e601613SDavid Gibson static int of_console_open(void)
202e601613SDavid Gibson {
212e601613SDavid Gibson 	void *devp;
222e601613SDavid Gibson 
2308464712SDavid Gibson 	if (((devp = of_finddevice("/chosen")) != NULL)
2408464712SDavid Gibson 	    && (of_getprop(devp, "stdout", &of_stdout_handle,
252e601613SDavid Gibson 			   sizeof(of_stdout_handle))
26926e6940SCédric Le Goater 		== sizeof(of_stdout_handle))) {
27926e6940SCédric Le Goater 		of_stdout_handle = be32_to_cpu(of_stdout_handle);
282e601613SDavid Gibson 		return 0;
29926e6940SCédric Le Goater 	}
302e601613SDavid Gibson 
312e601613SDavid Gibson 	return -1;
322e601613SDavid Gibson }
332e601613SDavid Gibson 
of_console_write(const char * buf,int len)34b96fbb6eSGeoff Levand static void of_console_write(const char *buf, int len)
352e601613SDavid Gibson {
362e601613SDavid Gibson 	of_call_prom("write", 3, 1, of_stdout_handle, buf, len);
372e601613SDavid Gibson }
382e601613SDavid Gibson 
of_console_init(void)392e601613SDavid Gibson void of_console_init(void)
402e601613SDavid Gibson {
412e601613SDavid Gibson 	console_ops.open = of_console_open;
422e601613SDavid Gibson 	console_ops.write = of_console_write;
432e601613SDavid Gibson }
44