From patchwork Thu Jun 5 14:36:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 356482 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 0EF5514008F for ; Fri, 6 Jun 2014 01:02:34 +1000 (EST) Received: from localhost ([::1]:41777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsYq9-00064E-6s for incoming@patchwork.ozlabs.org; Thu, 05 Jun 2014 10:40:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsYmN-0000i3-MS for qemu-devel@nongnu.org; Thu, 05 Jun 2014 10:36:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsYmG-0006ii-62 for qemu-devel@nongnu.org; Thu, 05 Jun 2014 10:36:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsYmF-0006iP-Tc for qemu-devel@nongnu.org; Thu, 05 Jun 2014 10:36:24 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s55EaMV3016032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Jun 2014 10:36:22 -0400 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s55EaDTL006438; Thu, 5 Jun 2014 10:36:20 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Jun 2014 16:36:05 +0200 Message-Id: <1401978968-7733-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1401978968-7733-1-git-send-email-imammedo@redhat.com> References: <1401978968-7733-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pkrempa@redhat.com, mst@redhat.com, armbru@redhat.com, lcapitulino@redhat.com, vasilis.liaskovitis@profitbricks.com Subject: [Qemu-devel] [PATCH 2/5] acpi: introduce TYPE_ACPI_DEVICE_IF 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org ... it will be used to abstract generic ACPI bits from device that implements ACPI interface. ACPIOSTInfo type is used for passing-through raw _OST event/status codes reported by guest OS to a management layer. It lets management tools to interpret values as specified by ACPI spec if it interested in it. QEMU doesn't encode these values as enum, since it doesn't need to handle them and it allows interface to scale well without any changes in QEMU while guest OS and management evolves in time. Signed-off-by: Igor Mammedov Reviewed-by: Eric Blake --- v2: - fix doc comments, describe not described fields - add slot-type field with DIMM type for now, which later we could extend to PCI slots and probably to CPUs - extend commit message describing why source/status are raw integers vs enum. --- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi_interface.c | 15 ++++++++++++ include/hw/acpi/acpi_dev_interface.h | 43 ++++++++++++++++++++++++++++++++++ qapi-schema.json | 31 ++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 0 deletions(-) create mode 100644 hw/acpi/acpi_interface.c create mode 100644 include/hw/acpi/acpi_dev_interface.h diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 004e1b2..acd2389 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -1,2 +1,3 @@ common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o cpu_hotplug.o common-obj-$(CONFIG_ACPI) += memory_hotplug.o +common-obj-$(CONFIG_ACPI) += acpi_interface.o diff --git a/hw/acpi/acpi_interface.c b/hw/acpi/acpi_interface.c new file mode 100644 index 0000000..c181bb2 --- /dev/null +++ b/hw/acpi/acpi_interface.c @@ -0,0 +1,15 @@ +#include "hw/acpi/acpi_dev_interface.h" +#include "qemu/module.h" + +static void register_types(void) +{ + static const TypeInfo acpi_dev_if_info = { + .name = TYPE_ACPI_DEVICE_IF, + .parent = TYPE_INTERFACE, + .class_size = sizeof(AcpiDeviceIfClass), + }; + + type_register_static(&acpi_dev_if_info); +} + +type_init(register_types) diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h new file mode 100644 index 0000000..f245f8d --- /dev/null +++ b/include/hw/acpi/acpi_dev_interface.h @@ -0,0 +1,43 @@ +#ifndef ACPI_DEV_INTERFACE_H +#define ACPI_DEV_INTERFACE_H + +#include "qom/object.h" +#include "qapi-types.h" + +#define TYPE_ACPI_DEVICE_IF "acpi-device-interface" + +#define ACPI_DEVICE_IF_CLASS(klass) \ + OBJECT_CLASS_CHECK(AcpiDeviceIfClass, (klass), \ + TYPE_ACPI_DEVICE_IF) +#define ACPI_DEVICE_IF_GET_CLASS(obj) \ + OBJECT_GET_CLASS(AcpiDeviceIfClass, (obj), \ + TYPE_ACPI_DEVICE_IF) +#define ACPI_DEVICE_IF(obj) \ + INTERFACE_CHECK(AcpiDeviceIf, (obj), \ + TYPE_ACPI_DEVICE_IF) + + +typedef struct AcpiDeviceIf { + /* */ + Object Parent; +} AcpiDeviceIf; + +/** + * AcpiDeviceIfClass: + * + * ospm_status: returns status of ACPI device objects, reported + * via _OST method if device supports it. + * + * Interface is designed for providing unified interface + * to generic ACPI functionality that could be used without + * knowledge about internals of actual device that implements + * ACPI interface. + */ +typedef struct AcpiDeviceIfClass { + /* */ + InterfaceClass parent_class; + + /* */ + void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); +} AcpiDeviceIfClass; +#endif diff --git a/qapi-schema.json b/qapi-schema.json index beb2de8..6d5651e 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4775,3 +4775,34 @@ # Since: 2.1 ## { 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] } + +## @ACPISlotType +# +# @DIMM: memory slot +# +{ 'enum': 'ACPISlotType', 'data': [ 'DIMM' ] } + +## @ACPIOSTInfo +# +# OSPM Status Indication for a device +# For description of possible values of @source and @status fields +# see "_OST (OSPM Status Indication)" chapter of ACPI5.0 spec. +# +# @device: device ID accossiated with slot +# +# @slot: slot ID, unique per slot of a given @slot-type +# +# @slot-type: type of the slot +# +# @source: an integer containing the source event +# +# @status: an integer containing the status code +# +# Since: 2.1 +## +{ 'type': 'ACPIOSTInfo', + 'data' : { '*device': 'str', + 'slot': 'str', + 'slot-type': 'ACPISlotType', + 'source': 'int', + 'status': 'int' } }