[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 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 | 8 +++++ 4 files changed, 91 insertions(+) diff --git a/lib/ukconsdev/consdev.c b/lib/ukconsdev/consdev.c index 8542b0e8..6c1e8185 100644 --- a/lib/ukconsdev/consdev.c +++ b/lib/ukconsdev/consdev.c @@ -293,6 +293,56 @@ void uk_consdev_release(struct uk_consdev *dev) dev->_data->id); } +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; @@ -367,6 +417,8 @@ int uk_consdev_drv_register(struct uk_consdev *dev, struct uk_alloc *a, UK_ASSERT(dev->ops->rx_configure); UK_ASSERT(dev->ops->tx_configure); UK_ASSERT(dev->ops->release); + UK_ASSERT(dev->ops->start); + UK_ASSERT(dev->ops->stop); UK_ASSERT(dev->ops->close); dev->_data = _alloc_data(a, consdev_count, drv_name); diff --git a/lib/ukconsdev/exportsyms.uk b/lib/ukconsdev/exportsyms.uk index 6fc1b3f3..dff1c331 100644 --- a/lib/ukconsdev/exportsyms.uk +++ b/lib/ukconsdev/exportsyms.uk @@ -5,6 +5,8 @@ uk_consdev_configure uk_consdev_rx_configure uk_consdev_tx_configure uk_consdev_release +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 04b4c0dc..779ebdbc 100644 --- a/lib/ukconsdev/include/uk/consdev.h +++ b/lib/ukconsdev/include/uk/consdev.h @@ -190,6 +190,35 @@ int uk_consdev_tx_configure(struct uk_consdev *dev, void uk_consdev_release(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 1295a913..41f2ea3b 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_tx_configure_t)(struct uk_consdev *dev, /** Driver callback type to release a configured Unikraft console device */ typedef int (*uk_consdev_release_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); + /** Driver callback type to close an Unikraft console device. */ typedef void (*uk_consdev_close_t)(struct uk_consdev *dev); @@ -181,6 +187,8 @@ struct uk_consdev_ops { uk_consdev_release_t release; uk_consdev_rx_configure_t rx_configure; uk_consdev_tx_configure_t tx_configure; + uk_consdev_start_t start; + uk_consdev_stop_t stop; uk_consdev_close_t close; }; -- 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 |