From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj59e-0001oD-9x for qemu-devel@nongnu.org; Thu, 24 Mar 2016 09:18:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj59Z-000576-KE for qemu-devel@nongnu.org; Thu, 24 Mar 2016 09:18:26 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:36217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj59Z-000570-9V for qemu-devel@nongnu.org; Thu, 24 Mar 2016 09:18:21 -0400 Received: by mail-wm0-x243.google.com with SMTP id l68so12175215wml.3 for ; Thu, 24 Mar 2016 06:18:21 -0700 (PDT) From: Baptiste Reynal Date: Thu, 24 Mar 2016 14:16:42 +0100 Message-Id: <1458825402-9592-5-git-send-email-b.reynal@virtualopensystems.com> In-Reply-To: <1458825402-9592-1-git-send-email-b.reynal@virtualopensystems.com> References: <1458825402-9592-1-git-send-email-b.reynal@virtualopensystems.com> Subject: [Qemu-devel] [RFC 4/4] hw/misc: sdm signal nboot List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, Jani.Kokkonen@huawei.com, tech@virtualopensystems.com, Claudio.Fontana@huawei.com, b.reynal@virtualopensystems.com This patch introduces a new signal for SDM device, which triggers the boot of a machine using a network memory. Signed-off-by: Baptiste Reynal --- hw/misc/Makefile.objs | 1 + hw/misc/sdm-signal-nboot.c | 62 ++++++++++++++++++++++++++++++++++++++ include/hw/misc/sdm-signal-nboot.h | 28 +++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 hw/misc/sdm-signal-nboot.c create mode 100644 include/hw/misc/sdm-signal-nboot.h diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs index 20a7d82..12d955e 100644 --- a/hw/misc/Makefile.objs +++ b/hw/misc/Makefile.objs @@ -28,6 +28,7 @@ obj-$(CONFIG_SDM) += sdm-platform.o obj-$(CONFIG_SDM) += sdm-communication-local.o obj-$(CONFIG_SDM) += sdm-communication-socket.o obj-$(CONFIG_SDM) += sdm-signal-shboot.o +obj-$(CONFIG_SDM) += sdm-signal-nboot.o obj-$(CONFIG_REALVIEW) += arm_sysctl.o obj-$(CONFIG_NSERIES) += cbus.o diff --git a/hw/misc/sdm-signal-nboot.c b/hw/misc/sdm-signal-nboot.c new file mode 100644 index 0000000..c04d1b4 --- /dev/null +++ b/hw/misc/sdm-signal-nboot.c @@ -0,0 +1,62 @@ +/* + * SDM Signal network boot + * + * Copyright (C) 2016 - Virtual Open Systems + * + * Author: Baptiste Reynal + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ +#include "hw/misc/sdm-signal-nboot.h" + +static int sdm_signal_nboot_hw_ops(SDMSignal *signal, SDMSignalData *data) +{ + SDMSignalNBoot *snb = SDM_SIGNAL_NBOOT(signal); + HostMemoryBackendNetworkClass *nhmc = + MEMORY_BACKEND_NETWORK_GET_CLASS(snb->nhm); + + nhmc->boot(snb->nhm); + + return 0; +} + +static bool sdm_signal_nboot_hw_only(SDMSignal *signal) +{ + return true; +} + +static void sdm_signal_nboot_init(Object *obj) +{ + SDMSignalNBoot *signal = SDM_SIGNAL_NBOOT(obj); + + object_property_add_link(obj, "nhm", + TYPE_MEMORY_BACKEND_NETWORK, + (Object **)&signal->nhm, + object_property_allow_set_link, + OBJ_PROP_LINK_UNREF_ON_RELEASE, + &error_abort); +} + +static void sdm_signal_nboot_class_init(ObjectClass *oc, void *data) +{ + SDMSignalClass *signalc = SDM_SIGNAL_CLASS(oc); + + signalc->hw_ops = sdm_signal_nboot_hw_ops; + signalc->hw_only = sdm_signal_nboot_hw_only; +} + +static const TypeInfo sdm_signal_nboot_info = { + .name = TYPE_SDM_SIGNAL_NBOOT, + .parent = TYPE_SDM_SIGNAL, + .class_init = sdm_signal_nboot_class_init, + .instance_size = sizeof(SDMSignalNBoot), + .instance_init = sdm_signal_nboot_init, +}; + +static void register_types(void) +{ + type_register_static(&sdm_signal_nboot_info); +} + +type_init(register_types); diff --git a/include/hw/misc/sdm-signal-nboot.h b/include/hw/misc/sdm-signal-nboot.h new file mode 100644 index 0000000..a56ce44 --- /dev/null +++ b/include/hw/misc/sdm-signal-nboot.h @@ -0,0 +1,28 @@ +/* + * SDM Signal network boot + * + * Copyright (C) 2016 - Virtual Open Systems + * + * Author: Baptiste Reynal + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ +#ifndef HW_SDM_SIGNAL_NBOOT_H +#define HW_SDM_SIGNAL_NBOOT_H + +#include "hw/misc/sdm-signal.h" +#include "sysemu/hostmem-network.h" + +#define TYPE_SDM_SIGNAL_NBOOT "sdm-signal-nboot" +#define SDM_SIGNAL_NBOOT(obj) \ + OBJECT_CHECK(SDMSignalNBoot, (obj), TYPE_SDM_SIGNAL) + +typedef struct SDMSignalNBoot SDMSignalNBoot; + +struct SDMSignalNBoot { + SDMSignal parent; + + HostMemoryBackendNetwork *nhm; +}; +#endif -- 2.7.4