xref: /linux/arch/powerpc/boot/ofconsole.c (revision b96fbb6e1eb81bb21a8c3462773a0056e12de427)
12e601613SDavid Gibson /*
22e601613SDavid Gibson  * OF console routines
32e601613SDavid Gibson  *
42e601613SDavid Gibson  * Copyright (C) Paul Mackerras 1997.
52e601613SDavid Gibson  *
62e601613SDavid Gibson  * This program is free software; you can redistribute it and/or
72e601613SDavid Gibson  * modify it under the terms of the GNU General Public License
82e601613SDavid Gibson  * as published by the Free Software Foundation; either version
92e601613SDavid Gibson  * 2 of the License, or (at your option) any later version.
102e601613SDavid Gibson  */
112e601613SDavid Gibson #include <stddef.h>
122e601613SDavid Gibson #include "types.h"
132e601613SDavid Gibson #include "elf.h"
142e601613SDavid Gibson #include "string.h"
152e601613SDavid Gibson #include "stdio.h"
162e601613SDavid Gibson #include "page.h"
172e601613SDavid Gibson #include "ops.h"
182e601613SDavid Gibson 
192e601613SDavid Gibson #include "of.h"
202e601613SDavid Gibson 
212e601613SDavid Gibson static void *of_stdout_handle;
222e601613SDavid Gibson 
232e601613SDavid Gibson static int of_console_open(void)
242e601613SDavid Gibson {
252e601613SDavid Gibson 	void *devp;
262e601613SDavid Gibson 
272e601613SDavid Gibson 	if (((devp = finddevice("/chosen")) != NULL)
282e601613SDavid Gibson 			&& (getprop(devp, "stdout", &of_stdout_handle,
292e601613SDavid Gibson 				sizeof(of_stdout_handle))
302e601613SDavid Gibson 				== sizeof(of_stdout_handle)))
312e601613SDavid Gibson 		return 0;
322e601613SDavid Gibson 
332e601613SDavid Gibson 	return -1;
342e601613SDavid Gibson }
352e601613SDavid Gibson 
36*b96fbb6eSGeoff Levand static void of_console_write(const char *buf, int len)
372e601613SDavid Gibson {
382e601613SDavid Gibson 	of_call_prom("write", 3, 1, of_stdout_handle, buf, len);
392e601613SDavid Gibson }
402e601613SDavid Gibson 
412e601613SDavid Gibson void of_console_init(void)
422e601613SDavid Gibson {
432e601613SDavid Gibson 	console_ops.open = of_console_open;
442e601613SDavid Gibson 	console_ops.write = of_console_write;
452e601613SDavid Gibson }
46