changeset: 9752:62eaa86f6658869d62f8882c731409941e9b2b2b
user: jimix@xxxxxxxxxxxxxxxxxxxxx
date: Tue Apr 4 08:22:02 2006 -0400
files: xen/arch/ppc/of_handler/console.c
xen/arch/ppc/of_handler/devtree.c xen/arch/ppc/of_handler/ofh.h
xen/arch/ppc/of_handler/vdevice.c
description:
[ppc] more code for DomU console support for OFH
diff -r d8726d7827b42c4c3254751aaafb306cc0f12590 -r
62eaa86f6658869d62f8882c731409941e9b2b2b xen/arch/ppc/of_handler/console.c
--- a/xen/arch/ppc/of_handler/console.c Tue Apr 4 08:20:42 2006 -0400
+++ b/xen/arch/ppc/of_handler/console.c Tue Apr 4 08:22:02 2006 -0400
@@ -19,6 +19,7 @@
#include "ofh.h"
#include "papr.h"
#include <xen/string.h>
+#include <asm/system.h>
union chpack {
u64 oct[2];
@@ -29,7 +30,7 @@ union chpack {
/* used for internal printing */
static struct ofh_ihandle *ofh_ihp;
-static s32 ofh_papr_read(s32 chan, void *buf, u32 count, s32 *actual)
+static s32 ofh_papr_read(s32 chan, void *buf, u32 count, s32 *actual, ulong b)
{
s32 rc;
ulong ret[5];
@@ -44,7 +45,8 @@ static s32 ofh_papr_read(s32 chan, void
return OF_SUCCESS;
}
-static s32 ofh_papr_write(s32 chan, const void *buf, u32 count, s32 *actual)
+static s32 ofh_papr_write(s32 chan, const void *buf, u32 count, s32 *actual,
+ ulong b)
{
const char *str = (const char *)buf;
u32 i;
@@ -95,7 +97,8 @@ extern long xen_hvcall(ulong code, ...);
extern long xen_hvcall(ulong code, ...);
#define XENCOMM_MINI_AREA (sizeof(struct xencomm_mini) * 2)
-static s32 ofh_xen_dom0_read(s32 chan, void *buf, u32 count, s32 *actual)
+static s32 ofh_xen_dom0_read(s32 chan, void *buf, u32 count, s32 *actual,
+ ulong b)
{
char __storage[XENCOMM_MINI_AREA];
struct xencomm_desc *desc;
@@ -120,7 +123,8 @@ static s32 ofh_xen_dom0_read(s32 chan, v
return OF_SUCCESS;
}
-static s32 ofh_xen_dom0_write(s32 chan, const void *buf, u32 count, s32
*actual)
+static s32 ofh_xen_dom0_write(s32 chan, const void *buf, u32 count,
+ s32 *actual, ulong b)
{
char __storage[XENCOMM_MINI_AREA];
struct xencomm_desc *desc;
@@ -148,13 +152,59 @@ static s32 ofh_xen_dom0_write(s32 chan,
return OF_SUCCESS;
}
+static s32 ofh_xen_domu_read(s32 chan, void *buf, u32 count, s32 *actual,
+ ulong b)
+{
+ struct xencons_interface *intf;
+ XENCONS_RING_IDX cons, prod;
+ s32 ret;
+
+ intf = DRELA(ofh_ihp, b)->ofi_intf;
+ cons = intf->in_cons;
+ prod = intf->in_prod;
+ mb();
+
+ ret = prod - cons;
+
+ if (ret > 0) {
+ ret = (ret < count) ? ret : count;
+ memcpy(buf, intf->in+MASK_XENCONS_IDX(cons,intf->in), ret);
+ }
+
+ *actual = (ret < 0) ? 0 : ret;
+ return OF_SUCCESS;
+}
+
+static s32 ofh_xen_domu_write(s32 chan, const void *buf, u32 count,
+ s32 *actual, ulong b)
+{
+ struct xencons_interface *intf;
+ XENCONS_RING_IDX cons, prod;
+ s32 ret;
+
+ intf = DRELA(ofh_ihp, b)->ofi_intf;
+ cons = intf->in_cons;
+ prod = intf->in_prod;
+ mb();
+
+ ret = prod - cons;
+ /* FIXME: Do we have to write the whole thing or are partial writes ok? */
+ if (ret > 0) {
+ ret = (ret < count) ? ret : count;
+ memcpy(intf->in+MASK_XENCONS_IDX(cons,intf->in), buf, ret);
+ }
+
+ *actual = (ret < 0) ? 0 : ret;
+ return OF_SUCCESS;
+}
+
/* for emergency printing in the OFH */
s32 ofh_cons_write(const void *buf, u32 count, s32 *actual)
{
ulong b = get_base();
struct ofh_ihandle *ihp = DRELA(ofh_ihp, b);
- return ihp->ofi_write(ihp->ofi_chan, buf, count, actual);
+ return ihp->ofi_write(ihp->ofi_chan, buf, count, actual, b);
}
s32 ofh_cons_close(void)
@@ -163,22 +213,19 @@ s32 ofh_cons_close(void)
}
void
-ofh_cons_init(s32 chan, struct ofh_ihandle *ihp, ulong b)
-{
- switch (chan) {
- case OFH_CONS_XEN_DOM0:
- ihp->ofi_write = ofh_xen_dom0_write;
- ihp->ofi_read = ofh_xen_dom0_read;
- break;
- case OFH_CONS_XEN_DOMU:
- ihp->ofi_write = ofh_xen_dom0_write;
- ihp->ofi_read = ofh_xen_dom0_read;
- break;
- default:
+ofh_cons_init(struct ofh_ihandle *ihp, ulong b)
+{
+ if (ihp->ofi_chan == OFH_CONS_XEN) {
+ if (ihp->ofi_intf == NULL) {
+ ihp->ofi_write = ofh_xen_dom0_write;
+ ihp->ofi_read = ofh_xen_dom0_read;
+ } else {
+ ihp->ofi_write = ofh_xen_domu_write;
+ ihp->ofi_read = ofh_xen_domu_read;
+ }
+ } else {
ihp->ofi_write = ofh_papr_write;
ihp->ofi_read = ofh_papr_read;
- break;
- }
- ihp->ofi_chan = chan;
+ }
*DRELA(&ofh_ihp, b) = ihp;
}
diff -r d8726d7827b42c4c3254751aaafb306cc0f12590 -r
62eaa86f6658869d62f8882c731409941e9b2b2b xen/arch/ppc/of_handler/devtree.c
--- a/xen/arch/ppc/of_handler/devtree.c Tue Apr 4 08:20:42 2006 -0400
+++ b/xen/arch/ppc/of_handler/devtree.c Tue Apr 4 08:22:02 2006 -0400
@@ -232,9 +232,10 @@ ofh_instance_to_path(u32 nargs, u32 nret
void *mem = ofd_mem(b);
ph = ih->ofi_node;
- *len = ofd_node_to_path(mem, ph, buf, sz);
-
- return OF_SUCCESS;
+ if (ph > 0) {
+ *len = ofd_node_to_path(mem, ph, buf, sz);
+ return OF_SUCCESS;
+ }
}
}
return OF_FAILURE;
@@ -251,13 +252,14 @@ ofh_package_to_path(u32 nargs, u32 nrets
s32 *len = &retp[0];
void *mem = ofd_mem(b);
- *len = ofd_node_to_path(mem, ph, buf, sz);
-
- return OF_SUCCESS;
- }
- }
- return OF_FAILURE;
-}
-
-
-
+ if (ph > 0) {
+ *len = ofd_node_to_path(mem, ph, buf, sz);
+ return OF_SUCCESS;
+ }
+ }
+ }
+ return OF_FAILURE;
+}
+
+
+
diff -r d8726d7827b42c4c3254751aaafb306cc0f12590 -r
62eaa86f6658869d62f8882c731409941e9b2b2b xen/arch/ppc/of_handler/ofh.h
--- a/xen/arch/ppc/of_handler/ofh.h Tue Apr 4 08:20:42 2006 -0400
+++ b/xen/arch/ppc/of_handler/ofh.h Tue Apr 4 08:22:02 2006 -0400
@@ -23,6 +23,7 @@
#include <xen/types.h>
#include <public/of-devtree.h>
#include <public/xencomm.h>
+#include <public/io/console.h>
#define MIN(x,y) (((x)<(y))?(x):(y))
@@ -91,10 +92,12 @@ struct ofh_methods {
struct ofh_ihandle {
s32 (*ofi_close)(void);
- s32 (*ofi_read)(s32 chan, void *buf, u32 count, s32 *actual);
- s32 (*ofi_write)(s32 chan, const void *buf, u32 count, s32 *actual);
+ s32 (*ofi_read)(s32 chan, void *buf, u32 count, s32 *actual, ulong b);
+ s32 (*ofi_write)(s32 chan, const void *buf, u32 count, s32 *actual,
+ ulong b);
s32 (*ofi_seek)(u32 pos_hi, u32 pos_lo, u32 *status);
struct ofh_methods *ofi_methods;
+ struct xencons_interface *ofi_intf;
s32 ofi_node;
s32 ofi_chan;
};
@@ -116,9 +119,8 @@ extern s32 ofh_start(struct ofh_args *);
extern s32 ofh_start(struct ofh_args *);
extern void _start(void);
-#define OFH_CONS_XEN_DOM0 -1
-#define OFH_CONS_XEN_DOMU -2
-extern void ofh_cons_init(s32 chan, struct ofh_ihandle *ihp, ulong b);
+#define OFH_CONS_XEN -1
+extern void ofh_cons_init(struct ofh_ihandle *ihp, ulong b);
extern s32 ofh_cons_read(s32 chan, void *buf, u32 count, s32 *actual);
extern s32 ofh_cons_write(const void *buf, u32 count, s32 *actual);
extern s32 ofh_cons_close(void);
diff -r d8726d7827b42c4c3254751aaafb306cc0f12590 -r
62eaa86f6658869d62f8882c731409941e9b2b2b xen/arch/ppc/of_handler/vdevice.c
--- a/xen/arch/ppc/of_handler/vdevice.c Tue Apr 4 08:20:42 2006 -0400
+++ b/xen/arch/ppc/of_handler/vdevice.c Tue Apr 4 08:22:02 2006 -0400
@@ -26,18 +26,17 @@ ofh_vty_init(ofdn_t chosen, ulong b)
void *mem = ofd_mem(b);
u32 ih = DRELA((u32)&_ih_cons, b);
struct ofh_ihandle *ihp = (struct ofh_ihandle *)((ulong)ih);
- ofdn_t n;
+ ofdn_t n = 0;
s32 ret;
- u32 chan = 0;
+ u32 chan = OFH_CONS_XEN;
+
+ ihp->ofi_intf = NULL;
/* find the vty */
n = ofd_node_find(mem,
DRELA((const char *)"/vdevice/vty", b));
if (n > 0) {
/* PAPR VTERM */
-
- ihp->ofi_node = n;
-
ret = ofd_getprop(mem, n, DRELA((const char *)"reg", b),
&chan, sizeof (chan));
if (ret != (s32)sizeof (chan)) {
@@ -45,20 +44,25 @@ ofh_vty_init(ofdn_t chosen, ulong b)
}
} else {
/* xen console */
- s32 domain;
+ u32 addr;
- n = ofd_node_find(mem, DRELA((const char *)"/xen", b));
+ n = ofd_node_find(mem, DRELA((const char *)"/xen/console", b));
if (n > 0) {
ret = ofd_getprop(mem, n, DRELA((const char *)"reg", b),
- &domain, sizeof (domain));
- if (domain == 0) {
- chan = OFH_CONS_XEN_DOM0;
+ &addr, sizeof (addr));
+ if (addr == 0) {
+ ihp->ofi_intf = NULL;
} else {
- chan = OFH_CONS_XEN_DOMU;
+ ihp->ofi_intf = (struct xencons_interface *)(ulong)addr;
}
}
}
- ofh_cons_init(chan, ihp, b);
+ if (n > 0) {
+ ihp->ofi_node = n;
+ }
+ ihp->ofi_chan = chan;
+ ofh_cons_init(ihp, b);
+
ofd_prop_add(mem, chosen, DRELA((const char *)"stdout", b),
&ih, sizeof (ih));
ofd_prop_add(mem, chosen, DRELA((const char *)"stdin", b),
_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel
|