xref: /linux/arch/powerpc/boot/ofconsole.c (revision 926e6940f54313813d177b5cfb9ec31a441cd259)
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 
21*926e6940SCédric Le Goater static unsigned int of_stdout_handle;
222e601613SDavid Gibson 
232e601613SDavid Gibson static int of_console_open(void)
242e601613SDavid Gibson {
252e601613SDavid Gibson 	void *devp;
262e601613SDavid Gibson 
2708464712SDavid Gibson 	if (((devp = of_finddevice("/chosen")) != NULL)
2808464712SDavid Gibson 	    && (of_getprop(devp, "stdout", &of_stdout_handle,
292e601613SDavid Gibson 			   sizeof(of_stdout_handle))
30*926e6940SCédric Le Goater 		== sizeof(of_stdout_handle))) {
31*926e6940SCédric Le Goater 		of_stdout_handle = be32_to_cpu(of_stdout_handle);
322e601613SDavid Gibson 		return 0;
33*926e6940SCédric Le Goater 	}
342e601613SDavid Gibson 
352e601613SDavid Gibson 	return -1;
362e601613SDavid Gibson }
372e601613SDavid Gibson 
38b96fbb6eSGeoff Levand static void of_console_write(const char *buf, int len)
392e601613SDavid Gibson {
402e601613SDavid Gibson 	of_call_prom("write", 3, 1, of_stdout_handle, buf, len);
412e601613SDavid Gibson }
422e601613SDavid Gibson 
432e601613SDavid Gibson void of_console_init(void)
442e601613SDavid Gibson {
452e601613SDavid Gibson 	console_ops.open = of_console_open;
462e601613SDavid Gibson 	console_ops.write = of_console_write;
472e601613SDavid Gibson }
48