1 | /* |
---|
2 | * This program is free software; you can redistribute it and/or modify |
---|
3 | * it under the terms of the GNU General Public License as published by |
---|
4 | * the Free Software Foundation; either version 2 of the License, or |
---|
5 | * (at your option) any later version. |
---|
6 | * |
---|
7 | * This program is distributed in the hope that it will be useful, |
---|
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | * GNU General Public License for more details. |
---|
11 | * |
---|
12 | * You should have received a copy of the GNU General Public License |
---|
13 | * along with this program; if not, write to the Free Software |
---|
14 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
15 | * |
---|
16 | * Copyright (C) IBM Corp. 2005 |
---|
17 | * |
---|
18 | * Authors: Jimi Xenidis <jimix@watson.ibm.com> |
---|
19 | */ |
---|
20 | |
---|
21 | #include "ofh.h" |
---|
22 | |
---|
23 | static struct ofh_ihandle _ih_cons; |
---|
24 | |
---|
25 | void |
---|
26 | ofh_vty_init(ofdn_t chosen, ulong b) |
---|
27 | { |
---|
28 | void *mem = ofd_mem(b); |
---|
29 | u32 ih = DRELA((u32)&_ih_cons, b); |
---|
30 | struct ofh_ihandle *ihp = (struct ofh_ihandle *)((ulong)ih); |
---|
31 | ofdn_t n = 0; |
---|
32 | s32 ret; |
---|
33 | u32 chan = OFH_CONS_XEN; |
---|
34 | |
---|
35 | ihp->ofi_intf = NULL; |
---|
36 | |
---|
37 | /* find the vty */ |
---|
38 | n = ofd_node_find(mem, |
---|
39 | DRELA((const char *)"/vdevice/vty", b)); |
---|
40 | if (n > 0) { |
---|
41 | /* PAPR VTERM */ |
---|
42 | ret = ofd_getprop(mem, n, DRELA((const char *)"reg", b), |
---|
43 | &chan, sizeof (chan)); |
---|
44 | if (ret != (s32)sizeof (chan)) { |
---|
45 | chan = 0; |
---|
46 | } |
---|
47 | } else { |
---|
48 | /* xen console */ |
---|
49 | u32 addr; |
---|
50 | |
---|
51 | n = ofd_node_find(mem, DRELA((const char *)"/xen/console", b)); |
---|
52 | if (n > 0) { |
---|
53 | ret = ofd_getprop(mem, n, DRELA((const char *)"reg", b), |
---|
54 | &addr, sizeof (addr)); |
---|
55 | if (addr == 0) { |
---|
56 | ihp->ofi_intf = NULL; |
---|
57 | } else { |
---|
58 | ihp->ofi_intf = (struct xencons_interface *)(ulong)addr; |
---|
59 | } |
---|
60 | } |
---|
61 | } |
---|
62 | if (n > 0) { |
---|
63 | ihp->ofi_node = n; |
---|
64 | } |
---|
65 | ihp->ofi_chan = chan; |
---|
66 | ofh_cons_init(ihp, b); |
---|
67 | |
---|
68 | ofd_prop_add(mem, chosen, DRELA((const char *)"stdout", b), |
---|
69 | &ih, sizeof (ih)); |
---|
70 | ofd_prop_add(mem, chosen, DRELA((const char *)"stdin", b), |
---|
71 | &ih, sizeof (ih)); |
---|
72 | } |
---|
73 | |
---|
74 | |
---|