From patchwork Fri Jun 17 15:54:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Pinto X-Patchwork-Id: 637180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rWQQ64vFbz9sCp for ; Sat, 18 Jun 2016 02:17:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=virtualopensystems-com.20150623.gappssmtp.com header.i=@virtualopensystems-com.20150623.gappssmtp.com header.b=Hg9oCvDL; dkim-atps=neutral Received: from localhost ([::1]:58784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDwSa-0003nY-Ay for incoming@patchwork.ozlabs.org; Fri, 17 Jun 2016 12:17:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDw7S-0006jB-AU for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:55:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDw7F-00017M-3P for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:55:41 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDw7E-00016r-Od for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:55:29 -0400 Received: by mail-wm0-x244.google.com with SMTP id k184so731014wme.2 for ; Fri, 17 Jun 2016 08:55:28 -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=bSlTHG2DNydA7aYSGfS4WhPu5Obzt554FxOQCJTTQAw=; b=Hg9oCvDLvayriBS0t9kI7gIhGf9ZLvi8TJBg9gz97MYVLTWwcaz70VTe5yGWXxIaBi kCLnBnzQ9/BCZYMN2EbRFMElQ0yvq+YgoPSpJIFwOtd/tfEVXu5Tw2Kgjaw+qiNy1Dhy ElFuaMXde9iKcPljIeRl7G4lC/zdcVmGcQ/2+4w8Aej9xV/2HSsCBgi6RYJzdx+N3HZI ORkxt8IVr69Z2Il+H1035ZP/mzzWRn25upwKGrGo5dFPY2pxoYPzxBNz+fuYGoQPooJT KIF2642tgSyIQy6U3bfBJ+ohH7s5KP3jUWlqwVcyQ3l7xLMBeyj8BRatZMt8rFCQLZ2J oh6Q== 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=bSlTHG2DNydA7aYSGfS4WhPu5Obzt554FxOQCJTTQAw=; b=kSFLd6Z2H6zfSUT4MQS1R2e4mMyOLTOuicD5ELSnbudLNBqgdPsn9fK2Lm/YbdILcX AgRH2XULuuYEboaPI8fD3b3I3SWRzrztd57yUIS1cJpxt6bC/i1IdCToiV6Sk7QcEMYZ smFfUnbWht9HUrEWy+ny+kob6T25PaF5rkpGc5QS+gfF3+w/gAgA8akyQwRX/BkWHZEN 8BR8D+vTwE2ig90kNguO2vImtJmzvYrpYRryCHyuh24kUMyWgEv33RNynYop2Ubl/8Qf 2fo0jRvrnd+ZWS92gk0iS+4WbEA19nYyBv43NwXxkSaG5vFuiSWsOF7BB+XbClCpaWSF YgEA== X-Gm-Message-State: ALyK8tLi4kzKd8kndCgx8zlgfK0vhuK2SVhqs/5gVeXq/6ZUC2jx8On+fPz2uyR+K1IbmQ== X-Received: by 10.28.125.71 with SMTP id y68mr342027wmc.103.1466178927614; Fri, 17 Jun 2016 08:55:27 -0700 (PDT) Received: from bumma.localdomain ([151.67.13.17]) by smtp.googlemail.com with ESMTPSA id q189sm254937wmd.19.2016.06.17.08.55.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jun 2016 08:55:26 -0700 (PDT) From: Christian Pinto To: qemu-devel@nongnu.org Date: Fri, 17 Jun 2016 17:54:58 +0200 Message-Id: <1466178903-2184-2-git-send-email-c.pinto@virtualopensystems.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466178903-2184-1-git-send-email-c.pinto@virtualopensystems.com> References: <1466178903-2184-1-git-send-email-c.pinto@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::244 Subject: [Qemu-devel] [RFC v3 1/6] hw/misc: sdm interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Claudio.Fontana@huawei.com, Jani.Kokkonen@huawei.com, tech@virtualopensystems.com, b.reynal@virtualopensystems.com, Christian Pinto Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Baptiste Reynal 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 Signed-off-by: Christian Pinto --- v2 -> v3: - Added sdm_device_set_num_slaves function to sdm-device class - Added sdm_communication_update_num_slaves to sdm-communication class --- --- default-configs/arm-softmmu.mak | 1 + hw/misc/Makefile.objs | 4 ++ hw/misc/sdm-communication.c | 68 ++++++++++++++++++++++++++++++++ hw/misc/sdm-device.c | 78 +++++++++++++++++++++++++++++++++++++ hw/misc/sdm-signal.c | 51 ++++++++++++++++++++++++ include/hw/misc/sdm-communication.h | 60 ++++++++++++++++++++++++++++ include/hw/misc/sdm-device.h | 61 +++++++++++++++++++++++++++++ include/hw/misc/sdm-signal.h | 60 ++++++++++++++++++++++++++++ 8 files changed, 383 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..ce2aa89 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..a85fe35 --- /dev/null +++ b/hw/misc/sdm-communication.c @@ -0,0 +1,68 @@ +/* + * SDM Communication + * + * Copyright (C) 2016 - Virtual Open Systems + * + * Author: Baptiste Reynal + * Christian Pinto + * + * 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; + } +} + +int sdm_communication_update_num_slaves(SDMCommunication *sdmc, SDMDevice *sdm, + uint16_t num_slaves) +{ + SDMCommunicationClass *sdmck = SDM_COMMUNICATION_GET_CLASS(sdmc); + + if (sdmck->update_num_slaves) { + return sdmck->update_num_slaves(sdmc, sdm, num_slaves); + } 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..01e0cbc --- /dev/null +++ b/hw/misc/sdm-device.c @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2016 - Virtual Open Systems + * + * Author: Baptiste Reynal + * Christian Pinto + * + * 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; + } +} + +int sdm_device_set_num_slaves(SDMDevice *sdm, uint16_t num_slaves) +{ + SDMDeviceClass *sdmc = SDM_DEVICE_GET_CLASS(sdm); + + if (sdmc->set_num_slaves) { + return sdmc->set_num_slaves(sdm, num_slaves); + } 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..c4af0ac --- /dev/null +++ b/hw/misc/sdm-signal.c @@ -0,0 +1,51 @@ +/* + * 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..e9b04a4 --- /dev/null +++ b/include/hw/misc/sdm-communication.h @@ -0,0 +1,60 @@ +/* + * SDM Communication + * + * Copyright (C) 2016 - Virtual Open Systems + * + * Author: Baptiste Reynal + * Christian Pinto + * + * 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); + int (*update_num_slaves)(SDMCommunication *sdmc, SDMDevice *sdm, + uint16_t num_slaves); +}; + +/** + * @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); +int sdm_communication_update_num_slaves(SDMCommunication *sdmc, + SDMDevice *sdm, uint16_t num_slaves); + +#endif diff --git a/include/hw/misc/sdm-device.h b/include/hw/misc/sdm-device.h new file mode 100644 index 0000000..a0aca28 --- /dev/null +++ b/include/hw/misc/sdm-device.h @@ -0,0 +1,61 @@ +/* + * SDM Device + * + * Copyright (C) 2016 - Virtual Open Systems + * + * Author: Baptiste Reynal + * Christian Pinto + * + * 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); + int (*set_num_slaves)(SDMDevice *sdm, uint16_t num_slaves); + 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); +int sdm_device_set_num_slaves(SDMDevice *sdm, uint16_t num_slaves); +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