Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * OF console routines
0004  *
0005  * Copyright (C) Paul Mackerras 1997.
0006  */
0007 #include <stddef.h>
0008 #include "types.h"
0009 #include "elf.h"
0010 #include "string.h"
0011 #include "stdio.h"
0012 #include "page.h"
0013 #include "ops.h"
0014 
0015 #include "of.h"
0016 
0017 static unsigned int of_stdout_handle;
0018 
0019 static int of_console_open(void)
0020 {
0021     void *devp;
0022 
0023     if (((devp = of_finddevice("/chosen")) != NULL)
0024         && (of_getprop(devp, "stdout", &of_stdout_handle,
0025                sizeof(of_stdout_handle))
0026         == sizeof(of_stdout_handle))) {
0027         of_stdout_handle = be32_to_cpu(of_stdout_handle);
0028         return 0;
0029     }
0030 
0031     return -1;
0032 }
0033 
0034 static void of_console_write(const char *buf, int len)
0035 {
0036     of_call_prom("write", 3, 1, of_stdout_handle, buf, len);
0037 }
0038 
0039 void of_console_init(void)
0040 {
0041     console_ops.open = of_console_open;
0042     console_ops.write = of_console_write;
0043 }