From patchwork Fri Mar 18 09:13:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baptiste Reynal X-Patchwork-Id: 8617391 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 255649F44D for ; Fri, 18 Mar 2016 09:15:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB88D20374 for ; Fri, 18 Mar 2016 09:15:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E2A02035D for ; Fri, 18 Mar 2016 09:15:16 +0000 (UTC) Received: from localhost ([::1]:42370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqV1-00050C-DI for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Mar 2016 05:15:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqTD-0002OP-Jq for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:13:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agqTB-0003k8-NB for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:13:23 -0400 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:35496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqTB-0003k3-Cl for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:13:21 -0400 Received: by mail-wm0-x230.google.com with SMTP id l68so23094436wml.0 for ; Fri, 18 Mar 2016 02:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualopensystems-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OwRd7G+q0pwoI8CDigNN2wda7NaPN9tKBRrpxZxzsKg=; b=P1Wz4k8Ljml342EsqX8eRjFzI71MOUoSnpQp+D67/WGqypG41LxTxtxEqnsjraWeSs eD2N5+v//WT2okxEk4VIkXIh3d+/E4LOKlU/Hv7ZMaDH3rYV/MWz05SeqW1mHxWOO7ka fHvTlnzDEW+k391Ku66x+k46yWnxHWsLVAN8CtuPBNURpfUc/7NTHHpFMn45Mzq/Fatv TzS7sjU4c34ogKxMIccT37VONKlFtPh/RlU4h42tt6tSPC3dToP/ZVYQGY5p0k2BRRef BC/CzqVLZbk4oPAR9+j5EKT00iOIYwnh1404ODbmmjyxrKuAety0ZePb/osfj+ejls0H iFiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OwRd7G+q0pwoI8CDigNN2wda7NaPN9tKBRrpxZxzsKg=; b=Lf8u4UPBnF9bAIBJ/xK44U/6gtv4EQ2/ZGuwGAl1ulkZ8qL0RakTlAhySVlaEbmZSO KxSKrfng2ZcUQ42md0x8wLthZpNW2NhfE+S/4TTD35zV9k9Hsk9gKtfRpfJV4U5+Erxt dWWK/av+0dOQXqRPt1V5ToTQL0++FHiaYaUeEDMxzXfqf07rMHj9JGokE+Xlm4VxkJ59 lDYHQ02l6gxnYGlD8afR1RVREsKpl8OczUq4ugbVvRMHU7Gxc1YUcAEoA2/ZNF5IthSD pFYhZ+EcRZJ2QG81iJI2QHeuVV2BOwUz8LK5RHC4xO/ePhxIYmyDSnfC2BO/GMiOXD70 Avqg== X-Gm-Message-State: AD7BkJJdjQeHP+bD4J6UeGlkp357ejske2AsBLan2jItHn49/VXQVlNj4kLtcz2O36B3Nw== X-Received: by 10.28.111.12 with SMTP id k12mr15231549wmc.35.1458292400874; Fri, 18 Mar 2016 02:13:20 -0700 (PDT) Received: from localhost (LMontsouris-657-1-4-224.w90-63.abo.wanadoo.fr. [90.63.239.224]) by smtp.gmail.com with ESMTPSA id t7sm11328204wjf.39.2016.03.18.02.13.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 02:13:20 -0700 (PDT) From: Baptiste Reynal To: qemu-devel@nongnu.org Date: Fri, 18 Mar 2016 10:13:00 +0100 Message-Id: <1458292385-13802-2-git-send-email-b.reynal@virtualopensystems.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458292385-13802-1-git-send-email-b.reynal@virtualopensystems.com> References: <1458292385-13802-1-git-send-email-b.reynal@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::230 Cc: b.reynal@virtualopensystems.com, Jani.Kokkonen@huawei.com, tech@virtualopensystems.com, Claudio.Fontana@huawei.com Subject: [Qemu-devel] [RFC v2 1/6] hw/misc: sdm interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch forms the common skeleton code for the SDM interface. The SDMDevice represents the interface with the machine, the SDMCommunication the communication channel and the SDMSignal represents an action to perform when a signal is received (for example to boot the machine). Signed-off-by: Baptiste Reynal --- default-configs/arm-softmmu.mak | 1 + hw/misc/Makefile.objs | 4 +++ hw/misc/sdm-communication.c | 55 +++++++++++++++++++++++++++++++ hw/misc/sdm-device.c | 66 +++++++++++++++++++++++++++++++++++++ hw/misc/sdm-signal.c | 52 +++++++++++++++++++++++++++++ include/hw/misc/sdm-communication.h | 54 ++++++++++++++++++++++++++++++ include/hw/misc/sdm-device.h | 58 ++++++++++++++++++++++++++++++++ include/hw/misc/sdm-signal.h | 60 +++++++++++++++++++++++++++++++++ 8 files changed, 350 insertions(+) create mode 100644 hw/misc/sdm-communication.c create mode 100644 hw/misc/sdm-device.c create mode 100644 hw/misc/sdm-signal.c create mode 100644 include/hw/misc/sdm-communication.h create mode 100644 include/hw/misc/sdm-device.h create mode 100644 include/hw/misc/sdm-signal.h diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index d9b90a5..4002e2b 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -109,3 +109,4 @@ CONFIG_IOH3420=y CONFIG_I82801B11=y CONFIG_ACPI=y CONFIG_SMBIOS=y +CONFIG_SDM=y diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs index 4aa76ff..6e73901 100644 --- a/hw/misc/Makefile.objs +++ b/hw/misc/Makefile.objs @@ -21,6 +21,10 @@ common-obj-$(CONFIG_MACIO) += macio/ obj-$(CONFIG_IVSHMEM) += ivshmem.o +obj-$(CONFIG_SDM) += sdm-device.o +obj-$(CONFIG_SDM) += sdm-communication.o +obj-$(CONFIG_SDM) += sdm-signal.o + obj-$(CONFIG_REALVIEW) += arm_sysctl.o obj-$(CONFIG_NSERIES) += cbus.o obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o diff --git a/hw/misc/sdm-communication.c b/hw/misc/sdm-communication.c new file mode 100644 index 0000000..4c80ed8 --- /dev/null +++ b/hw/misc/sdm-communication.c @@ -0,0 +1,55 @@ +/* + * SDM Communication + * + * 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-communication.h" +#include "qom/object_interfaces.h" + +int sdm_communication_signal(SDMCommunication *sdmc, SDMDevice *sdm, + SDMSignalData *signal) +{ + SDMCommunicationClass *sdmck = SDM_COMMUNICATION_GET_CLASS(sdmc); + + if (sdmck->signal) { + return sdmck->signal(sdmc, sdm, signal); + } else { + return -1; + } +} + +int sdm_communication_connect(SDMCommunication *sdmc, SDMDevice *sdm) +{ + SDMCommunicationClass *sdmck = SDM_COMMUNICATION_GET_CLASS(sdmc); + + if (sdmck->connect) { + return sdmck->connect(sdmc, sdm); + } else { + return -1; + } +} + +static const TypeInfo sdm_communication_info = { + .name = TYPE_SDM_COMMUNICATION, + .parent = TYPE_OBJECT, + .abstract = true, + .class_size = sizeof(SDMCommunicationClass), + .instance_size = sizeof(SDMCommunication), + .interfaces = (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } +}; + +static void register_types(void) +{ + type_register_static(&sdm_communication_info); +} + +type_init(register_types); diff --git a/hw/misc/sdm-device.c b/hw/misc/sdm-device.c new file mode 100644 index 0000000..639f1f7 --- /dev/null +++ b/hw/misc/sdm-device.c @@ -0,0 +1,66 @@ +/* + * 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-device.h" + +int sdm_device_notify(SDMDevice *sdm, SDMSignalData *signal) +{ + SDMDeviceClass *sdmc = SDM_DEVICE_GET_CLASS(sdm); + + if (sdmc->notify) { + return sdmc->notify(sdm, signal); + } else { + return -1; + } +} + +int sdm_device_accept(SDMDevice *sdm) +{ + SDMDeviceClass *sdmc = SDM_DEVICE_GET_CLASS(sdm); + + if (sdmc->accept) { + return sdmc->accept(sdm); + } else { + return -1; + } +} + +int sdm_device_get_num_slaves(SDMDevice *sdm) +{ + SDMDeviceClass *sdmc = SDM_DEVICE_GET_CLASS(sdm); + + if (sdmc->get_num_slaves) { + return sdmc->get_num_slaves(sdm); + } else { + return 0; + } +} + +bool sdm_device_is_master(SDMDevice *sdm) +{ + SDMDeviceClass *sdmc = SDM_DEVICE_GET_CLASS(sdm); + + if (sdmc->is_master) { + return sdmc->is_master(sdm); + } else { + return false; + } +} + +static void register_types(void) +{ + static const TypeInfo sdm_device_info = { + .name = TYPE_SDM_DEVICE, + .parent = TYPE_INTERFACE, + .class_size = sizeof(SDMDeviceClass), + }; + + type_register_static(&sdm_device_info); +} + +type_init(register_types) diff --git a/hw/misc/sdm-signal.c b/hw/misc/sdm-signal.c new file mode 100644 index 0000000..55c9995 --- /dev/null +++ b/hw/misc/sdm-signal.c @@ -0,0 +1,52 @@ +/* + * SDM Signal + * + * 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.h" +#include "qom/object_interfaces.h" + +int sdm_signal_hw_ops(SDMSignal *signal, SDMSignalData *data) +{ + SDMSignalClass *signalc = SDM_SIGNAL_GET_CLASS(signal); + + if (signalc->hw_ops) { + return signalc->hw_ops(signal, data); + } else { + return 0; + } +} + +bool sdm_signal_hw_only(SDMSignal *signal) +{ + SDMSignalClass *signalc = SDM_SIGNAL_GET_CLASS(signal); + + if (signalc->hw_only) { + return signalc->hw_only(signal); + } else { + return false; + } +} + +static const TypeInfo sdm_signal_info = { + .name = TYPE_SDM_SIGNAL, + .parent = TYPE_OBJECT, + .class_size = sizeof(SDMSignalClass), + .instance_size = sizeof(SDMSignal), + .interfaces = (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } +}; + +static void register_types(void) +{ + type_register_static(&sdm_signal_info); +} + +type_init(register_types); diff --git a/include/hw/misc/sdm-communication.h b/include/hw/misc/sdm-communication.h new file mode 100644 index 0000000..6ebc732 --- /dev/null +++ b/include/hw/misc/sdm-communication.h @@ -0,0 +1,54 @@ +/* + * SDM Communication + * + * 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_COMM_H +#define HW_SDM_COMM_H + +#include "hw/misc/sdm-device.h" + +#define TYPE_SDM_COMMUNICATION "sdm-communication" +#define SDM_COMMUNICATION(obj) \ + OBJECT_CHECK(SDMCommunication, (obj), TYPE_SDM_COMMUNICATION) +#define SDM_COMMUNICATION_GET_CLASS(obj) \ + OBJECT_GET_CLASS(SDMCommunicationClass, (obj), TYPE_SDM_COMMUNICATION) +#define SDM_COMMUNICATION_CLASS(klass) \ + OBJECT_CLASS_CHECK(SDMCommunicationClass, (klass), \ + TYPE_SDM_COMMUNICATION); + +typedef struct SDMCommunication SDMCommunication; +typedef struct SDMCommunicationClass SDMCommunicationClass; + +/** + * @SDMCommunicationClass + * + * @parent_class: opaque parent class container + */ +struct SDMCommunicationClass { + ObjectClass parent_class; + + int (*signal)(SDMCommunication *sdmc, SDMDevice *sdm, + SDMSignalData *signal); + int (*connect)(SDMCommunication *sdmc, SDMDevice *sdm); +}; + +/** + * @SDMCommunication + * + * @parent: opaque parent object container + */ +struct SDMCommunication { + /* private */ + Object parent; +}; + +int sdm_communication_signal(SDMCommunication *sdmc, SDMDevice *sdm, + SDMSignalData *signal); +int sdm_communication_connect(SDMCommunication *sdmc, SDMDevice *sdm); +#endif diff --git a/include/hw/misc/sdm-device.h b/include/hw/misc/sdm-device.h new file mode 100644 index 0000000..9f51938 --- /dev/null +++ b/include/hw/misc/sdm-device.h @@ -0,0 +1,58 @@ +/* + * SDM Device + * + * 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_H +#define HW_SDM_H + +#include "qemu-common.h" +#include "qom/object.h" +#include "hw/misc/sdm-signal.h" + +#define TYPE_SDM_DEVICE "sdm-device" +#define SDM_DEVICE_CLASS(klass) \ + OBJECT_CLASS_CHECK(SDMDeviceClass, (klass), TYPE_SDM_DEVICE); +#define SDM_DEVICE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(SDMDeviceClass, (obj), TYPE_SDM_DEVICE) +#define SDM_DEVICE(obj) \ + INTERFACE_CHECK(SDMDevice, (obj), TYPE_SDM_DEVICE) + +typedef struct SDMDevice SDMDevice; +typedef struct SDMDeviceClass SDMDeviceClass; + +/** + * SDMDeviceClass + * + * @parent_class: opaque parent class container + */ +struct SDMDeviceClass { + InterfaceClass parent_class; + + int (**signal_hw_ops)(SDMDevice *sdm, SDMSignalData *signal); + + /* Notify the device about a new signal. If the signal cannot + * be handled by device (busy), returns -1. The communication + * channel should then try to deliver the signal again later. + */ + int (*notify)(SDMDevice *sdm, SDMSignalData *signal); + int (*accept)(SDMDevice *sdm); + int (*get_num_slaves)(SDMDevice *sdm); + bool (*is_master)(SDMDevice *sdm); +}; + +struct SDMDevice { + /* private */ + Object parent; +}; + +int sdm_device_notify(SDMDevice *sdm, SDMSignalData *signal); +int sdm_device_accept(SDMDevice *sdm); +int sdm_device_get_num_slaves(SDMDevice *sdm); +bool sdm_device_is_master(SDMDevice *sdm); +#endif diff --git a/include/hw/misc/sdm-signal.h b/include/hw/misc/sdm-signal.h new file mode 100644 index 0000000..f9b82eb --- /dev/null +++ b/include/hw/misc/sdm-signal.h @@ -0,0 +1,60 @@ +/* + * SDM Signal + * + * 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_H +#define HW_SDM_SIGNAL_H + +#include "qemu-common.h" +#include "qom/object.h" + +#define TYPE_SDM_SIGNAL "sdm-signal" +#define SDM_SIGNAL(obj) \ + OBJECT_CHECK(SDMSignal, (obj), TYPE_SDM_SIGNAL) +#define SDM_SIGNAL_GET_CLASS(obj) \ + OBJECT_GET_CLASS(SDMSignalClass, (obj), TYPE_SDM_SIGNAL) +#define SDM_SIGNAL_CLASS(klass) \ + OBJECT_CLASS_CHECK(SDMSignalClass, (klass), \ + TYPE_SDM_SIGNAL) + +typedef struct SDMSignalData SDMSignalData; +typedef struct SDMSignal SDMSignal; +typedef struct SDMSignalClass SDMSignalClass; + +struct SDMSignalData { + uint32_t type; + uint32_t slave; + uint32_t payload[2]; +}; + +/** + * @SDMSignalClass + * + * @parent_class: opaque parent class container + */ +struct SDMSignalClass { + ObjectClass parent_class; + + int (*hw_ops)(SDMSignal *signal, SDMSignalData *data); + bool (*hw_only)(SDMSignal *signal); +}; + +/** + * @SDMSignal + * + * @parent: opaque parent object container + */ +struct SDMSignal { + /* private */ + Object parent; +}; + +int sdm_signal_hw_ops(SDMSignal *signal, SDMSignalData *data); +bool sdm_signal_hw_only(SDMSignal *signal); +#endif