From: Mihai Carabas <mihai.carabas@oracle.com>
To: peter.maydell@linaro.org, shannon.zhaosl@gmail.com,
mst@redhat.com, imammedo@redhat.com
Cc: Mihai Carabas <mihai.carabas@oracle.com>,
Peng Hao <peng.hao2@zte.com.cn>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH 3/8] hw/misc/pvpanic: Add the MMIO interface
Date: Thu, 22 Oct 2020 10:42:51 +0300 [thread overview]
Message-ID: <1603352576-21671-4-git-send-email-mihai.carabas@oracle.com> (raw)
In-Reply-To: <1603352576-21671-1-git-send-email-mihai.carabas@oracle.com>
From: Peng Hao <peng.hao2@zte.com.cn>
Add new pvpanic type: "TYPE_PVPANIC_MMIO".
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
---
hw/misc/pvpanic.c | 51 +++++++++++++++++++++++++++++++++++++++++++----
include/hw/misc/pvpanic.h | 3 ++-
2 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 2e085f4..136f1d6 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 <wency@cn.fujitsu.com>
* Hu Tao <hutao@cn.fujitsu.com>
+ * Peng Hao <peng.hao2@zte.com.cn>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
@@ -34,6 +36,10 @@ typedef struct PVPanicISAState PVPanicISAState;
DECLARE_INSTANCE_CHECKER(PVPanicISAState, PVPANIC_ISA_DEVICE,
TYPE_PVPANIC_ISA)
+typedef struct PVPanicMMIOState PVPanicMMIOState;
+DECLARE_INSTANCE_CHECKER(PVPanicMMIOState, PVPANIC_MMIO_DEVICE,
+ TYPE_PVPANIC_MMIO)
+
static void handle_event(int event)
{
static bool logged;
@@ -67,21 +73,32 @@ struct PVPanicISAState {
uint16_t ioport;
};
+/* PVPanicMMIOState for sysbus device and
+ * use mmio.
+ */
+typedef struct PVPanicMMIOState {
+ SysBusDevice parent_obj;
+ /*<private>*/
+
+ /* public */
+ MemoryRegion mr;
+} PVPanicMMIOState;
+
/* return supported events on read */
-static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size)
+static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
{
return PVPANIC_PANICKED;
}
-static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val,
+static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
{
handle_event(val);
}
static const MemoryRegionOps pvpanic_ops = {
- .read = pvpanic_ioport_read,
- .write = pvpanic_ioport_write,
+ .read = pvpanic_read,
+ .write = pvpanic_write,
.impl = {
.min_access_size = 1,
.max_access_size = 1,
@@ -136,9 +153,35 @@ static TypeInfo pvpanic_isa_info = {
.class_init = pvpanic_isa_class_init,
};
+static void pvpanic_mmio_initfn(Object *obj)
+{
+ PVPanicMMIOState *s = PVPANIC_MMIO_DEVICE(obj);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+
+ memory_region_init_io(&s->mr, OBJECT(s), &pvpanic_ops, s,
+ TYPE_PVPANIC_MMIO, 2);
+ sysbus_init_mmio(sbd, &s->mr);
+}
+
+static void pvpanic_mmio_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+}
+
+static TypeInfo pvpanic_mmio_info = {
+ .name = TYPE_PVPANIC_MMIO,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(PVPanicMMIOState),
+ .instance_init = pvpanic_mmio_initfn,
+ .class_init = pvpanic_mmio_class_init,
+};
+
static void pvpanic_register_types(void)
{
type_register_static(&pvpanic_isa_info);
+ type_register_static(&pvpanic_mmio_info);
}
type_init(pvpanic_register_types)
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
index 30e9f8f..ee645dc 100644
--- a/include/hw/misc/pvpanic.h
+++ b/include/hw/misc/pvpanic.h
@@ -18,12 +18,13 @@
#include "qom/object.h"
#define TYPE_PVPANIC_ISA "pvpanic"
+#define TYPE_PVPANIC_MMIO "pvpanic-mmio"
#define PVPANIC_IOPORT_PROP "ioport"
static inline uint16_t pvpanic_port(void)
{
- Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL);
+ Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA, NULL);
if (!o) {
return 0;
}
--
1.8.3.1
next prev parent reply other threads:[~2020-10-22 8:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-22 7:42 [PATCH 0/8] Add support for pvpanic mmio device Mihai Carabas
2020-10-22 7:42 ` [PATCH 1/8] hw/misc/pvpanic: Build the pvpanic device for any machine Mihai Carabas
2020-10-22 7:42 ` [PATCH 2/8] hw/misc/pvpanic: Cosmetic renaming Mihai Carabas
2020-10-22 7:42 ` Mihai Carabas [this message]
2020-10-22 7:42 ` [PATCH 4/8] hw/arm/virt: Use the pvpanic device Mihai Carabas
2020-10-22 7:42 ` [PATCH 5/8] hw/arm/virt: add pvpanic device in virt acpi table Mihai Carabas
2020-10-22 7:42 ` [PATCH 6/8] hw/arm/virt: add configure interface for pvpanic-mmio Mihai Carabas
2020-10-22 7:42 ` [PATCH 7/8] pvpanic : update pvpanic document Mihai Carabas
2020-10-22 7:42 ` [PATCH 8/8] pvpanic: break dependency on ISA_BUS Mihai Carabas
2020-10-22 10:17 ` [PATCH 0/8] Add support for pvpanic mmio device Peter Maydell
2020-10-26 13:50 ` Mihai Carabas
2020-10-26 14:32 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1603352576-21671-4-git-send-email-mihai.carabas@oracle.com \
--to=mihai.carabas@oracle.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=peng.hao2@zte.com.cn \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhaosl@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).