1/*
2 * Copyright (C) Paul Mackerras 1997.
3 * Copyright (C) Leigh Brown 2002.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#include "of1275.h"
12
13int
14ofstdio(ihandle *stdin, ihandle *stdout, ihandle *stderr)
15{
16    ihandle in, out;
17    phandle chosen;
18
19    if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE)
20	goto err;
21    if (getprop(chosen, "stdout", &out, sizeof(out)) != 4)
22	goto err;
23    if (getprop(chosen, "stdin", &in, sizeof(in)) != 4)
24	goto err;
25
26    *stdin  = in;
27    *stdout = out;
28    *stderr = out;
29    return 0;
30err:
31    return -1;
32}
33