[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 04/10] plat/xen/drivers/cons: Init Xenbus state/info/etc
This patch introduces the Xenbus Device responsible for communication between consfront and backend through Xenstore. Initial information like backend/frontend path are introduced as well. Signed-off-by: Birlea Costin <costin.birlea@xxxxxxxxx> --- plat/xen/Makefile.uk | 1 + plat/xen/drivers/cons/consfront.c | 13 ++++++ plat/xen/drivers/cons/consfront.h | 2 + plat/xen/drivers/cons/consfront_xb.h | 61 +++++++++++++++++++++++++++++ plat/xen/drivers/cons/consfront_xs.c | 76 ++++++++++++++++++++++++++++++++++++ 5 files changed, 153 insertions(+) create mode 100644 plat/xen/drivers/cons/consfront_xb.h create mode 100644 plat/xen/drivers/cons/consfront_xs.c diff --git a/plat/xen/Makefile.uk b/plat/xen/Makefile.uk index ef0e076b..53f181f9 100644 --- a/plat/xen/Makefile.uk +++ b/plat/xen/Makefile.uk @@ -109,4 +109,5 @@ LIBXENCONSFRONT_ASINCLUDES-y += $(LIBXENPLAT_ASINCLUDES-y) LIBXENCONSFRONT_CFLAGS-y += $(LIBXENPLAT_CFLAGS-y) LIBXENCONSFRONT_CINCLUDES-y += $(LIBXENPLAT_CINCLUDES-y) LIBXENCONSFRONT_SRCS-y += $(LIBXENPLAT_BASE)/drivers/cons/consfront.c +LIBXENCONSFRONT_SRCS-y += $(LIBXENPLAT_BASE)/drivers/cons/consfront_xs.c endif \ No newline at end of file diff --git a/plat/xen/drivers/cons/consfront.c b/plat/xen/drivers/cons/consfront.c index 88949da3..8c0980b6 100644 --- a/plat/xen/drivers/cons/consfront.c +++ b/plat/xen/drivers/cons/consfront.c @@ -45,6 +45,7 @@ #include <xenbus/xenbus.h> #include "consfront.h" +#include "consfront_xb.h" #define DRIVER_NAME "xen-consfront" @@ -64,6 +65,7 @@ static void consfront_close(struct uk_consdev *dev) UK_ASSERT(cfdev); uk_consdev_drv_unregister(dev); + consfront_xb_fini(cfdev); uk_free(drv_allocator, cfdev); uk_pr_info(DRIVER_NAME": %"PRIu16" closed\n", cfdev->uid); @@ -86,6 +88,15 @@ static int consfront_add_dev(struct xenbus_device *xendev) goto out; } + cfdev->xendev = xendev; + + /* Xenbus initialization */ + rc = consfront_xb_init(cfdev); + if (rc < 0) { + uk_pr_err("Error initializing Xenbus data: %d\n", rc); + goto err_xenbus; + } + cfdev->consdev.ops = &consfront_ops; /* Register consdev */ @@ -102,6 +113,8 @@ static int consfront_add_dev(struct xenbus_device *xendev) out: return rc; err_register: + consfront_xb_fini(cfdev); +err_xenbus: uk_free(drv_allocator, cfdev); goto out; } diff --git a/plat/xen/drivers/cons/consfront.h b/plat/xen/drivers/cons/consfront.h index 001ee12b..3772c7a1 100644 --- a/plat/xen/drivers/cons/consfront.h +++ b/plat/xen/drivers/cons/consfront.h @@ -43,6 +43,8 @@ * Structure used to describe the Consfront device. */ struct consfront_dev { + /* Xenbus Device. */ + struct xenbus_device *xendev; /* Consdev Device. */ struct uk_consdev consdev; /* The consdev identifier */ diff --git a/plat/xen/drivers/cons/consfront_xb.h b/plat/xen/drivers/cons/consfront_xb.h new file mode 100644 index 00000000..0ca1abaf --- /dev/null +++ b/plat/xen/drivers/cons/consfront_xb.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Authors: Costin Birlea <costin.birlea@xxxxxxxxx> + * + * Copyright (c) 2019, University Politehnica of Bucharest. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY. + */ +#ifndef __CONSFRONT_XB_H__ +#define __CONSFRONT_XB_H__ + +/** + * Consfront interface for xenstore operations. + * + * This header contains all the functions needed by the consfront driver + * in order to access Xenstore data. + */ + +#include "consfront.h" + +/* + * Get initial info from the xenstore. + * Ex: backend path. + * + * Return 0 on success, a negative errno value on error. + */ +int consfront_xb_init(struct consfront_dev *cfdev); + +/* + * It deallocates the xendev structure members allocated during initialization. + * + */ +void consfront_xb_fini(struct consfront_dev *cfdev); + +#endif /* __CONSFRONT_XB_H__ */ diff --git a/plat/xen/drivers/cons/consfront_xs.c b/plat/xen/drivers/cons/consfront_xs.c new file mode 100644 index 00000000..066a23d9 --- /dev/null +++ b/plat/xen/drivers/cons/consfront_xs.c @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Authors: Costin Birlea <costin.birlea@xxxxxxxxx> + * + * Copyright (c) 2019, University Politehnica of Bucharest. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY. + */ +#include <stdio.h> +#include <string.h> +#include <uk/errptr.h> +#include <xenbus/xs.h> +#include <xenbus/client.h> + +#include "consfront_xb.h" + +int consfront_xb_init(struct consfront_dev *cfdev) +{ + struct xenbus_device *xendev; + int rc = 0; + + UK_ASSERT(cfdev); + + xendev = cfdev->xendev; + UK_ASSERT(xendev); + + xendev->otherend = xs_read(XBT_NIL, xendev->nodename, "backend"); + if (PTRISERR(xendev->otherend)) { + rc = PTR2ERR(xendev->otherend); + uk_pr_err("Error reading backend path\n"); + xendev->otherend = NULL; + } + + return rc; +} + +void consfront_xb_fini(struct consfront_dev *cfdev) +{ + struct xenbus_device *xendev; + + UK_ASSERT(cfdev); + + xendev = cfdev->xendev; + UK_ASSERT(xendev); + + if (xendev->otherend) { + free(xendev->otherend); + xendev->otherend = NULL; + } +} -- 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 |