xref: /linux/arch/powerpc/boot/ofconsole.c (revision 2e6016133755eb3cc44e8efab92573d23ed75888)
1*2e601613SDavid Gibson /*
2*2e601613SDavid Gibson  * OF console routines
3*2e601613SDavid Gibson  *
4*2e601613SDavid Gibson  * Copyright (C) Paul Mackerras 1997.
5*2e601613SDavid Gibson  *
6*2e601613SDavid Gibson  * This program is free software; you can redistribute it and/or
7*2e601613SDavid Gibson  * modify it under the terms of the GNU General Public License
8*2e601613SDavid Gibson  * as published by the Free Software Foundation; either version
9*2e601613SDavid Gibson  * 2 of the License, or (at your option) any later version.
10*2e601613SDavid Gibson  */
11*2e601613SDavid Gibson #include <stddef.h>
12*2e601613SDavid Gibson #include "types.h"
13*2e601613SDavid Gibson #include "elf.h"
14*2e601613SDavid Gibson #include "string.h"
15*2e601613SDavid Gibson #include "stdio.h"
16*2e601613SDavid Gibson #include "page.h"
17*2e601613SDavid Gibson #include "ops.h"
18*2e601613SDavid Gibson 
19*2e601613SDavid Gibson #include "of.h"
20*2e601613SDavid Gibson 
21*2e601613SDavid Gibson static void *of_stdout_handle;
22*2e601613SDavid Gibson 
23*2e601613SDavid Gibson static int of_console_open(void)
24*2e601613SDavid Gibson {
25*2e601613SDavid Gibson 	void *devp;
26*2e601613SDavid Gibson 
27*2e601613SDavid Gibson 	if (((devp = finddevice("/chosen")) != NULL)
28*2e601613SDavid Gibson 			&& (getprop(devp, "stdout", &of_stdout_handle,
29*2e601613SDavid Gibson 				sizeof(of_stdout_handle))
30*2e601613SDavid Gibson 				== sizeof(of_stdout_handle)))
31*2e601613SDavid Gibson 		return 0;
32*2e601613SDavid Gibson 
33*2e601613SDavid Gibson 	return -1;
34*2e601613SDavid Gibson }
35*2e601613SDavid Gibson 
36*2e601613SDavid Gibson static void of_console_write(char *buf, int len)
37*2e601613SDavid Gibson {
38*2e601613SDavid Gibson 	of_call_prom("write", 3, 1, of_stdout_handle, buf, len);
39*2e601613SDavid Gibson }
40*2e601613SDavid Gibson 
41*2e601613SDavid Gibson void of_console_init(void)
42*2e601613SDavid Gibson {
43*2e601613SDavid Gibson 	console_ops.open = of_console_open;
44*2e601613SDavid Gibson 	console_ops.write = of_console_write;
45*2e601613SDavid Gibson }
46