[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 08/10] plat/xen/drivers/cons: Write to Consfront



Signed-off-by: Birlea Costin <costin.birlea@xxxxxxxxx>
---
 plat/xen/drivers/cons/consfront.c | 62 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/plat/xen/drivers/cons/consfront.c 
b/plat/xen/drivers/cons/consfront.c
index 4dd57151..5e1aa063 100644
--- a/plat/xen/drivers/cons/consfront.c
+++ b/plat/xen/drivers/cons/consfront.c
@@ -252,6 +252,67 @@ static int consfront_stop(struct uk_consdev *dev)
        return 0;
 }
 
+static unsigned int pvconsole_output(struct consfront_dev *dev,
+                               char *buf, unsigned int len)
+{
+       struct xencons_interface *intf;
+       XENCONS_RING_IDX cons, prod;
+       unsigned int sent = 0;
+       unsigned int index;
+
+       intf = dev->ring;
+       UK_ASSERT(intf);
+
+       cons = intf->out_cons;
+       prod = intf->out_prod;
+
+       /* Make sure we have cons & prod before touching the ring */
+       mb();
+       UK_BUGON((prod - cons) > sizeof(intf->out));
+
+       while ((sent < len) && ((prod - cons) < sizeof(intf->out))) {
+               index = MASK_XENCONS_IDX(prod++, intf->out);
+               intf->out[index] = buf[sent];
+               sent++;
+       }
+       /* Ensure characters are written before increasing out_prod */
+       wmb();
+       intf->out_prod = prod;
+
+       notify_remote_via_evtchn(dev->evtchn);
+
+       return sent;
+}
+
+static unsigned int consfront_write(struct uk_consdev *dev,
+                               char *buf, unsigned int len)
+{
+       struct consfront_dev *cfdev;
+       struct xencons_interface *intf;
+       XENCONS_RING_IDX cons, prod;
+       unsigned int available;
+
+       UK_ASSERT(dev);
+
+       cfdev = to_consfront(dev);
+       UK_ASSERT(cfdev);
+
+       intf = cfdev->ring;
+       UK_ASSERT(intf);
+
+       cons = intf->out_cons;
+       prod = intf->out_prod;
+
+       /* Make sure we have cons & prod */
+       mb();
+       available = prod - cons;
+       /* Check if out ring is full */
+       if (available > sizeof(intf->out))
+               return 0;
+
+       return pvconsole_output(cfdev, buf, len);
+}
+
 static void consfront_close(struct uk_consdev *dev)
 {
        struct consfront_dev *cfdev;
@@ -278,6 +339,7 @@ static const struct uk_consdev_ops consfront_ops = {
        .release = consfront_release,
        .start = consfront_start,
        .stop = consfront_stop,
+       .write = consfront_write,
        .close = consfront_close,
 };
 
-- 
2.11.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.