|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v2 5/7] lib/ukconsdev: Start console device
This patch brings device start, needed in order to
start reading or writting.
The device needs to be configured before starting.
Signed-off-by: Birlea Costin <costin.birlea@xxxxxxxxx>
---
lib/ukconsdev/consdev.c | 52 +++++++++++++++++++++++++++++++++
lib/ukconsdev/exportsyms.uk | 2 ++
lib/ukconsdev/include/uk/consdev.h | 29 ++++++++++++++++++
lib/ukconsdev/include/uk/consdev_core.h | 9 ++++++
4 files changed, 92 insertions(+)
diff --git a/lib/ukconsdev/consdev.c b/lib/ukconsdev/consdev.c
index 98c063f4..1de68b77 100644
--- a/lib/ukconsdev/consdev.c
+++ b/lib/ukconsdev/consdev.c
@@ -297,6 +297,56 @@ out:
return rc;
}
+int uk_consdev_start(struct uk_consdev *dev)
+{
+ int rc = 0;
+
+ UK_ASSERT(dev);
+ UK_ASSERT(dev->_data);
+ UK_ASSERT(dev->ops);
+ UK_ASSERT(dev->ops->start);
+ UK_ASSERT(dev->_data->state == UK_CONSDEV_CONFIGURED);
+
+ rc = dev->ops->start(dev);
+ if (rc < 0) {
+ uk_pr_err("consdev%"PRIu16": Failed to start interface %d\n",
+ dev->_data->id, rc);
+ goto out;
+ }
+
+ dev->_data->state = UK_CONSDEV_RUNNING;
+ uk_pr_info("consdev%"PRIu16": Started interface\n",
+ dev->_data->id);
+
+out:
+ return rc;
+}
+
+int uk_consdev_stop(struct uk_consdev *dev)
+{
+ int rc = 0;
+
+ UK_ASSERT(dev);
+ UK_ASSERT(dev->_data);
+ UK_ASSERT(dev->ops);
+ UK_ASSERT(dev->ops->stop);
+ UK_ASSERT(dev->_data->state == UK_CONSDEV_RUNNING);
+
+ rc = dev->ops->stop(dev);
+ if (rc < 0) {
+ uk_pr_err("Failed to stop consdev%"PRIu16" device %d\n",
+ dev->_data->id, rc);
+ goto out;
+ }
+
+ dev->_data->state = UK_CONSDEV_CONFIGURED;
+ uk_pr_info("Stopped consdev%"PRIu16" device\n",
+ dev->_data->id);
+
+out:
+ return rc;
+}
+
unsigned int uk_consdev_count(void)
{
return (unsigned int) consdev_count;
@@ -371,6 +421,8 @@ int uk_consdev_drv_register(struct uk_consdev *dev, struct
uk_alloc *a,
UK_ASSERT(dev->ops->rxq_configure);
UK_ASSERT(dev->ops->txq_configure);
UK_ASSERT(dev->ops->unconfigure);
+ UK_ASSERT(dev->ops->start);
+ UK_ASSERT(dev->ops->stop);
dev->_data = _alloc_data(a, consdev_count, drv_name);
if (!dev->_data)
diff --git a/lib/ukconsdev/exportsyms.uk b/lib/ukconsdev/exportsyms.uk
index f023aff3..55e744fd 100644
--- a/lib/ukconsdev/exportsyms.uk
+++ b/lib/ukconsdev/exportsyms.uk
@@ -5,6 +5,8 @@ uk_consdev_txq_info_get
uk_consdev_rxq_configure
uk_consdev_txq_configure
uk_consdev_unconfigure
+uk_consdev_start
+uk_consdev_stop
uk_consdev_count
uk_consdev_get
uk_consdev_id_get
diff --git a/lib/ukconsdev/include/uk/consdev.h
b/lib/ukconsdev/include/uk/consdev.h
index e2d523eb..24ac21b9 100644
--- a/lib/ukconsdev/include/uk/consdev.h
+++ b/lib/ukconsdev/include/uk/consdev.h
@@ -190,6 +190,35 @@ int uk_consdev_txq_configure(struct uk_consdev *dev,
int uk_consdev_unconfigure(struct uk_consdev *dev);
/**
+ * Start a Console device.
+ *
+ * After a console device was configured, the device can be started.
+ * On success, all operational functions exported by the
+ * Unikraft console API (interrupts, receive/transmit, and so on) can be
invoked
+ * afterwards.
+ *
+ * @param dev
+ * The Unikraft Console Device in configured state.
+ * @return
+ * - (0): Success, Unikraft console device started.
+ * - (<0): Error code of the driver device start function.
+ */
+int uk_consdev_start(struct uk_consdev *dev);
+
+/**
+ * Stop an Unikraft console device, and set its state to UK_CONSDEV_CONFIGURED
+ * state.
+ * The device can be restarted with a call to uk_consdev_start().
+ *
+ * @param dev
+ * The Unikraft Console Device in running state.
+ * @return
+ * - (0): Success, Unikraft console device stopped.
+ * - (<0): Error code of the driver device stop function.
+ */
+int uk_consdev_stop(struct uk_consdev *dev);
+
+/**
* Get the number of available Unikraft Console devices.
*
* @return
diff --git a/lib/ukconsdev/include/uk/consdev_core.h
b/lib/ukconsdev/include/uk/consdev_core.h
index cc34697b..a8353d10 100644
--- a/lib/ukconsdev/include/uk/consdev_core.h
+++ b/lib/ukconsdev/include/uk/consdev_core.h
@@ -170,6 +170,12 @@ typedef int (*uk_consdev_txq_configure_t)(struct
uk_consdev *dev,
/** Driver callback type to unconfigure a configured Unikraft console device */
typedef int (*uk_consdev_unconfigure_t)(struct uk_consdev *dev);
+/** Driver callback type to start a configured Unikraft console device. */
+typedef int (*uk_consdev_start_t)(struct uk_consdev *dev);
+
+/** Driver callback type to stop a running Unikraft console device. */
+typedef int (*uk_consdev_stop_t)(struct uk_consdev *dev);
+
struct uk_consdev_ops {
uk_consdev_info_t info_get;
uk_consdev_configure_t configure;
@@ -178,6 +184,9 @@ struct uk_consdev_ops {
uk_consdev_rxq_configure_t rxq_configure;
uk_consdev_txq_configure_t txq_configure;
uk_consdev_unconfigure_t unconfigure;
+ uk_consdev_start_t start;
+ uk_consdev_stop_t stop;
+};
/**
* @internal
--
2.11.0
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |