From nobody Thu Nov 6 08:24:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539868167671915.9524961017369; Thu, 18 Oct 2018 06:09:27 -0700 (PDT) Received: from localhost ([::1]:42337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD83K-0001kl-Ch for importer@patchew.org; Thu, 18 Oct 2018 09:09:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD7z3-0006qv-L5 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 09:05:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD7yy-0003Jx-Td for qemu-devel@nongnu.org; Thu, 18 Oct 2018 09:05:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64507) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD7yy-0003Gv-Kf for qemu-devel@nongnu.org; Thu, 18 Oct 2018 09:04:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD9B03D97F; Thu, 18 Oct 2018 13:04:55 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.158]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA0851042557; Thu, 18 Oct 2018 13:04:53 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Peng Hao Date: Thu, 18 Oct 2018 15:04:33 +0200 Message-Id: <20181018130434.23237-4-philmd@redhat.com> In-Reply-To: <20181018130434.23237-1-philmd@redhat.com> References: <20181018130434.23237-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 18 Oct 2018 13:04:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 3/4] hw/misc/pvpanic: Add the MMIO 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: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Wen Congyang , Hu Tao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peng Hao Signed-off-by: Philippe Mathieu-Daud=C3=A9 [PMD: Use TYPE_PVPANIC definition, split in 2 patches] --- Peng: I hope this is now more obvious how you could reuse the pvpanic devic= e. hw/misc/pvpanic.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 4f552e1533..b81c5fa633 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -2,10 +2,12 @@ * QEMU simulated pvpanic device. * * Copyright Fujitsu, Corp. 2013 + * Copyright (c) 2018 ZTE Ltd. * * Authors: * Wen Congyang * Hu Tao + * Peng Hao * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -47,7 +49,10 @@ static void handle_event(int event) =20 typedef struct PVPanicState { /*< private >*/ - ISADevice isadev; + union { + ISADevice isadev; + SysBusDevice busdev; + }; =20 /*< public >*/ MemoryRegion mr; @@ -123,9 +128,54 @@ static TypeInfo pvpanic_isa_info =3D { .class_init =3D pvpanic_isa_class_init, }; =20 +static uint64_t pvpanic_mmio_read(void *opaque, hwaddr addr, unsigned size) +{ + return -1; +} + +static void pvpanic_mmio_write(void *opaque, hwaddr addr, uint64_t value, + unsigned size) +{ + handle_event(value); +} + +static const MemoryRegionOps pvpanic_mmio_ops =3D { + .read =3D pvpanic_mmio_read, + .write =3D pvpanic_mmio_write, + .impl =3D { + .max_access_size =3D 1, + }, +}; + +static void pvpanic_mmio_initfn(Object *obj) +{ + PVPanicState *s =3D PVPANIC(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + + memory_region_init_io(&s->mr, OBJECT(s), &pvpanic_mmio_ops, s, + TYPE_PVPANIC, 2); + sysbus_init_mmio(sbd, &s->mr); +} + +static void pvpanic_mmio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + set_bit(DEVICE_CATEGORY_MISC, dc->categories); +} + +static TypeInfo pvpanic_mmio_info =3D { + .name =3D TYPE_PVPANIC, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(PVPanicState), + .instance_init =3D pvpanic_mmio_initfn, + .class_init =3D pvpanic_mmio_class_init, +}; + static void pvpanic_register_types(void) { type_register_static(&pvpanic_isa_info); + type_register_static(&pvpanic_mmio_info); } =20 type_init(pvpanic_register_types) --=20 2.17.2