From patchwork Mon Dec 18 18:51:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497374 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0AA14C35274 for ; Mon, 18 Dec 2023 18:52:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIiC-00066z-Ne; Mon, 18 Dec 2023 13:51:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIi8-00065Q-SS; Mon, 18 Dec 2023 13:51:29 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIi7-0008OK-BC; Mon, 18 Dec 2023 13:51:28 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40c31f18274so45074055e9.0; Mon, 18 Dec 2023 10:51:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925484; x=1703530284; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=35pwZ9lDGgY4cRkCVkGeA79o60zkVpVeGL4oTWNLKjs=; b=KGkOyk1nJ2i67kTfCYD7W6wjrIuLKK5Hxnns/dls+dsW4RqgTXLBtR5gy883TBa28i M5AWZ89VOtMDyos4nZcPEYZZrXxzcS1z0eNpdT4EhsTCJV65lZhjt5THRkH6LOK6cXqO GgDUStoNJWMUXqHFS6j0+Blk75/7KOptEGz5yaVEzA9JMcHxZkiF8imDfleiYSxYVdC8 M1mE7Nk/gvb7DuWnWiSkwbWC62KPwegO/wjUVRTShTjtXhXpPWByXqgNPQ5H93Tqe2Lg iXQXkozYVqvVXD+uJL073NS9eMFF9ifHfToUHw3AgSn9X4o7LDBurYqZCTLc13aY1nr4 dtGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925484; x=1703530284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=35pwZ9lDGgY4cRkCVkGeA79o60zkVpVeGL4oTWNLKjs=; b=KVENDU2GFXD4v2oEWOUxmp3zEMbYHhG+1yiD+y+bBUlkM/bGQ2C4GhL/NzAF/UyLR1 UY3Ez0+ILVmheYX2023QOJ7eg2Lme88cFMT5VSYdmNK+9N7ibixY3s0bN5ejK2NJ4v6C lzvgxKH8DFPx1Ee8OV3vXbl0mts9ePNaM7pF15cS7RjvBQqw5Ula0Ylf0qMm2QWmTvFC Udlxr/SglUAyY4o6Uk64MGiwy00wocs5TbokL47HbAGLnMxhVYp295CSwEKCC4B7uZ0I ztTzrkbVthLX66n6rRCx8I5hH4hn1FSFn7xBDF/N4AJDidh+Oa7StqNVDEKOIDoEdaWX B5AA== X-Gm-Message-State: AOJu0YzxG22GnPoxI51+eBExV7SQjAYSwHMV4DTtiqBSWQEW+B+IlK+D gNehMkn4jxOAOJZ2J7Y3oSFEXT0kq2k= X-Google-Smtp-Source: AGHT+IEPFRvqdNkXZwjnb/RCQrxgyji0eZOYyrdL9nzn+sdKy1dxuL5g95+Maha8BS04hIa5saW+HA== X-Received: by 2002:a7b:c44e:0:b0:408:4120:bad2 with SMTP id l14-20020a7bc44e000000b004084120bad2mr7949477wmi.9.1702925484384; Mon, 18 Dec 2023 10:51:24 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:23 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 01/12] hw/block/fdc-isa: Free struct FDCtrl from PortioList Date: Mon, 18 Dec 2023 19:51:03 +0100 Message-ID: <20231218185114.119736-2-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=shentey@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org FDCtrl::portio_list isn't used inside FDCtrl context but only inside FDCtrlISABus context, so more it there. Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan --- hw/block/fdc-internal.h | 2 -- hw/block/fdc-isa.c | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/block/fdc-internal.h b/hw/block/fdc-internal.h index 036392e9fc..fef2bfbbf5 100644 --- a/hw/block/fdc-internal.h +++ b/hw/block/fdc-internal.h @@ -26,7 +26,6 @@ #define HW_BLOCK_FDC_INTERNAL_H #include "exec/memory.h" -#include "exec/ioport.h" #include "hw/block/block.h" #include "hw/block/fdc.h" #include "qapi/qapi-types-block.h" @@ -140,7 +139,6 @@ struct FDCtrl { /* Timers state */ uint8_t timer0; uint8_t timer1; - PortioList portio_list; }; extern const FDFormat fd_formats[]; diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c index 7ec075e470..b4c92b40b3 100644 --- a/hw/block/fdc-isa.c +++ b/hw/block/fdc-isa.c @@ -42,6 +42,7 @@ #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "sysemu/sysemu.h" +#include "exec/ioport.h" #include "qemu/log.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -60,6 +61,7 @@ struct FDCtrlISABus { uint32_t irq; uint32_t dma; struct FDCtrl state; + PortioList portio_list; int32_t bootindexA; int32_t bootindexB; }; @@ -91,7 +93,7 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp) FDCtrl *fdctrl = &isa->state; Error *err = NULL; - isa_register_portio_list(isadev, &fdctrl->portio_list, + isa_register_portio_list(isadev, &isa->portio_list, isa->iobase, fdc_portio_list, fdctrl, "fdc"); From patchwork Mon Dec 18 18:51:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4A6CC35274 for ; Mon, 18 Dec 2023 18:53:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIiR-00068t-QP; Mon, 18 Dec 2023 13:51:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIiE-00067l-Pw; Mon, 18 Dec 2023 13:51:35 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiD-0008P9-1l; Mon, 18 Dec 2023 13:51:34 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40c60dfa5bfso43413675e9.0; Mon, 18 Dec 2023 10:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925490; x=1703530290; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h3iaY6aUrLWJnbiEuFPEJDzWzkJTCJ7nk9T2FrK86B4=; b=MMTA4uYA6Fx0VA3r8ogRW7hBh4DFtQgr3e0vX9BlfjaX1Dig4mS5Tlskma5yR4PD2+ StI8ZlFaZpDn9PKzFP7G5Gxrvt44xNsv8nFirATd6GZbJg8T+B5uVhttEhn+9KSaoTZL YYvDPOCMvsWZl+AoiadOxYIaCntpsCILsp58Muu6I6Kv0xAM/DCrhTqjUFY3huW66ZS0 PopI3BWJp3osnh+dmYPLTtALt+bLLc+IuDKm55FMQQ1hnh3in6rpSUhykLA3UDYEr3pH qMbkq3W+x5iSoyJnALGvA/hdHCIzody98Lrv2X/00r376ci2Kp5EbxBfhBS0VyU+ZCyi S/xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925490; x=1703530290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h3iaY6aUrLWJnbiEuFPEJDzWzkJTCJ7nk9T2FrK86B4=; b=oXirGqHhNHblpuERhPv3hDobMQwjrozIlDsCzWdgW1gMX2Vsnym/LA3820aXs5zlOU L43GZxf/pWJkN5OzrIzW0KibtIwaOM58n8awFpyilhmzTLkIhYoItNcOSOROy0GrZOMb QMCf4XlkasYJlXwwcBitvzXgRb/KWKXKaDYhNT3o7Syv9RrWh7oiaR2Ae5OTKHP5sOa5 F1cwzXEjfTScLXyGMo0XxPTYkTXPwgrJjdYhimSMOu/CPX7//HhiIV2RKqPxBz6Xw6m2 h065J4IFRF1N3ofq3vwEiC9Z8YUBuErkscMYypHlke7K/9olM4nKx0N/x/E6zIo8PsTS twyg== X-Gm-Message-State: AOJu0Yz9Kw6s8xrX+qdo1QakMxUY5bNEsmvF5GKjsFb1YSC9WkMBag0i S+nTvHMIeoIyOrwf6D5PuAF9Eq3l5LE= X-Google-Smtp-Source: AGHT+IEQoXW8mJA/XHXJVcdsWPvExsVqWGecHBQ1PCU9T5HPJ+LUqgasnKnpmYpHCtd8jLwaIrMBqw== X-Received: by 2002:a05:600c:4690:b0:40c:6c81:e6d with SMTP id p16-20020a05600c469000b0040c6c810e6dmr3061774wmo.6.1702925485603; Mon, 18 Dec 2023 10:51:25 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:25 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 02/12] hw/block/fdc-sysbus: Free struct FDCtrl from MemoryRegion Date: Mon, 18 Dec 2023 19:51:04 +0100 Message-ID: <20231218185114.119736-3-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=shentey@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org FDCtrl::iomem isn't used inside FDCtrl context but only inside FDCtrlSysBus context, so more it there. Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan --- hw/block/fdc-internal.h | 2 -- hw/block/fdc-sysbus.c | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/fdc-internal.h b/hw/block/fdc-internal.h index fef2bfbbf5..e219623dc7 100644 --- a/hw/block/fdc-internal.h +++ b/hw/block/fdc-internal.h @@ -25,7 +25,6 @@ #ifndef HW_BLOCK_FDC_INTERNAL_H #define HW_BLOCK_FDC_INTERNAL_H -#include "exec/memory.h" #include "hw/block/block.h" #include "hw/block/fdc.h" #include "qapi/qapi-types-block.h" @@ -91,7 +90,6 @@ typedef struct FDrive { } FDrive; struct FDCtrl { - MemoryRegion iomem; qemu_irq irq; /* Controller state */ QEMUTimer *result_timer; diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c index 86ea51d003..e197b97262 100644 --- a/hw/block/fdc-sysbus.c +++ b/hw/block/fdc-sysbus.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qom/object.h" +#include "exec/memory.h" #include "hw/sysbus.h" #include "hw/block/fdc.h" #include "migration/vmstate.h" @@ -52,6 +53,7 @@ struct FDCtrlSysBus { /*< public >*/ struct FDCtrl state; + MemoryRegion iomem; }; static uint64_t fdctrl_read_mem(void *opaque, hwaddr reg, unsigned ize) @@ -146,11 +148,11 @@ static void sysbus_fdc_common_instance_init(Object *obj) qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */ - memory_region_init_io(&fdctrl->iomem, obj, + memory_region_init_io(&sys->iomem, obj, sbdc->use_strict_io ? &fdctrl_mem_strict_ops : &fdctrl_mem_ops, fdctrl, "fdc", 0x08); - sysbus_init_mmio(sbd, &fdctrl->iomem); + sysbus_init_mmio(sbd, &sys->iomem); sysbus_init_irq(sbd, &fdctrl->irq); qdev_init_gpio_in(dev, fdctrl_handle_tc, 1); From patchwork Mon Dec 18 18:51:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99936C35274 for ; Mon, 18 Dec 2023 18:54:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIic-0006DR-46; Mon, 18 Dec 2023 13:51:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIiO-00068j-Ih; Mon, 18 Dec 2023 13:51:44 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiF-0008PI-R3; Mon, 18 Dec 2023 13:51:38 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40d1bcd93b0so9035365e9.0; Mon, 18 Dec 2023 10:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925492; x=1703530292; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zIi8YOFzybKW8Rq5OqDlw4D+FmT1OGY+fsh09ZFmm7A=; b=ghQyLiENFHrYnOx8Ude08DhBkjseivWv1+KjrDOp0vy3eRp0RjVx6ne8ZWQjfxa4Yy I0KkPFWakihjpPhnqV/40ZSW+asM05mCugd+Q25CgTTL2b3gRQpp4buXvb/xAEwQxX+C 5McOJc4RNIqhrRi/acXacVEZ9sdgURSuyU5AZfFYp9tA/ELHzJZTlVE8ZYqWzAMzv8F5 R7hBZDswEgVO7ui2M7TDKAdYQfTleyJOh95E05v3CuybhgLzJxqymp41AhI8FRV9B4MU KlHKRIOAt1hMCB06T1PV//M9TROeoZ7YmN/JGrSidEAhCuCIlfe9cPL5L4VtRy+oCCht y6Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925492; x=1703530292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zIi8YOFzybKW8Rq5OqDlw4D+FmT1OGY+fsh09ZFmm7A=; b=mbo2o2wG26s5YDBZfz6MSMoourqX1YD9GcHIK0lDY/qemdCkZa9QyNnHBp795r1Ge+ 2h1Vehb9xeqaFc3Z+3gHPqWWx0G84kNAngKSW0t/Dlahz2FKz8qt/sNgFPpDJu/7qfO6 HfJwdKEp0ravbTyUJrl4WgOTmIA7imzyekfi6UbLm88f3U4Xhk1tf7YSxmIoyGLZ2PuS ZxT81Zf6tuJyA+ejkMbYsAvpjYUKcbkNev8/xUOWngByWSHwN9v1rEgbsRM1VultjeW1 Z4mFd5hCocUQqXEIJCncCm1/Va8/zz8jCwu8RmdU/WUNAQULFB3b2tWngj22Oo4V1pOq ALAg== X-Gm-Message-State: AOJu0Yxc5oaripNzpve58WhSvv2gGxObHimrVUY8IGWi13v1DWnHpfEl bI/7IhRmISUEZX/rdw2hQCjDMbNSBgc= X-Google-Smtp-Source: AGHT+IG4kTMbTvX7SAcHRZnFfXBmGHBRdvlT6YE0D9Zb7OmxK2sxnmL8IKnopkXipSQ99wVPdKXpxg== X-Received: by 2002:a05:600c:458d:b0:40b:33c0:a22 with SMTP id r13-20020a05600c458d00b0040b33c00a22mr10089084wmo.28.1702925491867; Mon, 18 Dec 2023 10:51:31 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:30 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 03/12] hw/char/serial: Free struct SerialState from MemoryRegion Date: Mon, 18 Dec 2023 19:51:05 +0100 Message-ID: <20231218185114.119736-4-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=shentey@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org SerialState::io isn't used within TYPE_SERIAL directly. Push it to its users to make them the owner of the MemoryRegion. Signed-off-by: Bernhard Beschow --- include/hw/char/serial.h | 2 +- hw/char/serial-isa.c | 7 +++++-- hw/char/serial-pci-multi.c | 7 ++++--- hw/char/serial-pci.c | 7 +++++-- hw/char/serial.c | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index 8ba7eca3d6..eb4254edde 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -77,7 +77,6 @@ struct SerialState { int poll_msl; QEMUTimer *modem_status_poll; - MemoryRegion io; }; typedef struct SerialState SerialState; @@ -85,6 +84,7 @@ struct SerialMM { SysBusDevice parent; SerialState serial; + MemoryRegion io; uint8_t regshift; uint8_t endianness; diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index 141a6cb168..2be8be980b 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" +#include "exec/memory.h" #include "sysemu/sysemu.h" #include "hw/acpi/acpi_aml_interface.h" #include "hw/char/serial.h" @@ -43,6 +44,7 @@ struct ISASerialState { uint32_t iobase; uint32_t isairq; SerialState state; + MemoryRegion io; }; static const int isa_serial_io[MAX_ISA_SERIAL_PORTS] = { @@ -79,8 +81,9 @@ static void serial_isa_realizefn(DeviceState *dev, Error **errp) qdev_realize(DEVICE(s), NULL, errp); qdev_set_legacy_instance_id(dev, isa->iobase, 3); - memory_region_init_io(&s->io, OBJECT(isa), &serial_io_ops, s, "serial", 8); - isa_register_ioport(isadev, &s->io, isa->iobase); + memory_region_init_io(&isa->io, OBJECT(isa), &serial_io_ops, s, "serial", + 8); + isa_register_ioport(isadev, &isa->io, isa->iobase); } static void serial_isa_build_aml(AcpiDevAmlIf *adev, Aml *scope) diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index 5d65c534cb..16cb2faad7 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -44,6 +44,7 @@ typedef struct PCIMultiSerialState { uint32_t ports; char *name[PCI_SERIAL_MAX_PORTS]; SerialState state[PCI_SERIAL_MAX_PORTS]; + MemoryRegion io[PCI_SERIAL_MAX_PORTS]; uint32_t level[PCI_SERIAL_MAX_PORTS]; qemu_irq *irqs; uint8_t prog_if; @@ -58,7 +59,7 @@ static void multi_serial_pci_exit(PCIDevice *dev) for (i = 0; i < pci->ports; i++) { s = pci->state + i; qdev_unrealize(DEVICE(s)); - memory_region_del_subregion(&pci->iobar, &s->io); + memory_region_del_subregion(&pci->iobar, &pci->io[i]); g_free(pci->name[i]); } qemu_free_irqs(pci->irqs, pci->ports); @@ -112,9 +113,9 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp) } s->irq = pci->irqs[i]; pci->name[i] = g_strdup_printf("uart #%zu", i + 1); - memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s, + memory_region_init_io(&pci->io[i], OBJECT(pci), &serial_io_ops, s, pci->name[i], 8); - memory_region_add_subregion(&pci->iobar, 8 * i, &s->io); + memory_region_add_subregion(&pci->iobar, 8 * i, &pci->io[i]); pci->ports++; } } diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c index 087da3059a..ab3d0e56b5 100644 --- a/hw/char/serial-pci.c +++ b/hw/char/serial-pci.c @@ -28,6 +28,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" +#include "exec/memory.h" #include "hw/char/serial.h" #include "hw/irq.h" #include "hw/pci/pci_device.h" @@ -38,6 +39,7 @@ struct PCISerialState { PCIDevice dev; SerialState state; + MemoryRegion io; uint8_t prog_if; }; @@ -57,8 +59,9 @@ static void serial_pci_realize(PCIDevice *dev, Error **errp) pci->dev.config[PCI_INTERRUPT_PIN] = 0x01; s->irq = pci_allocate_irq(&pci->dev); - memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s, "serial", 8); - pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io); + memory_region_init_io(&pci->io, OBJECT(pci), &serial_io_ops, s, "serial", + 8); + pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->io); } static void serial_pci_exit(PCIDevice *dev) diff --git a/hw/char/serial.c b/hw/char/serial.c index a32eb25f58..83b642aec3 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -1045,10 +1045,10 @@ static void serial_mm_realize(DeviceState *dev, Error **errp) return; } - memory_region_init_io(&s->io, OBJECT(dev), + memory_region_init_io(&smm->io, OBJECT(dev), &serial_mm_ops[smm->endianness], smm, "serial", 8 << smm->regshift); - sysbus_init_mmio(SYS_BUS_DEVICE(smm), &s->io); + sysbus_init_mmio(SYS_BUS_DEVICE(smm), &smm->io); sysbus_init_irq(SYS_BUS_DEVICE(smm), &smm->serial.irq); } From patchwork Mon Dec 18 18:51:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D0C9C35274 for ; Mon, 18 Dec 2023 18:53:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIid-0006GT-9K; Mon, 18 Dec 2023 13:51:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIiU-00069i-3P; Mon, 18 Dec 2023 13:51:51 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiI-0008PT-7r; Mon, 18 Dec 2023 13:51:43 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40c68c1990dso41314295e9.0; Mon, 18 Dec 2023 10:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925494; x=1703530294; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/wCng+HnlULotarDqMS+lgXh7Jru+e0piPZCemAKRA4=; b=X6tRYI1LZwIg/34WKnMDylRud+L5Udshn+TSAugj92Q/YNTodQCKeluR5QdbKRYzb2 OeJhCsPI/XqDyb6E3sOdJwsi1hPFmEfGow0CZ2dqyyhTSM5HnFFiNlzeKE8uaigUp9rx qJJEjKGeVLVG1eZ2J4ISgPTA8wN1+x40Z/kR7wb0nNhGMilbOPDab1FYDrtqNcReS0az nDWaqitaJuEtrpnVbvovUq/sqkvKK55/99aFa1+/OlpdX1yke7DFVM5AVDG0YokSa4JM IMzrK5pgT4C1TETS7teWJWIylfAgqOZQOL2FUb2xXLwmDZSG/3aMSrPp0WLL/kb/tLx+ 7Llg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925494; x=1703530294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/wCng+HnlULotarDqMS+lgXh7Jru+e0piPZCemAKRA4=; b=CqMC//9y5X5utUDcARnVixOKUBMBVzmKY6i6qzxbbnguUf18MYbI2yft6JhYcgaOF4 fHA5cZM0cmHQcwzY85Pxdn6YtRwm7lPeXJ03DCkeQ3B1h/BemVfSDdIFwMXr342Lh02S 15BCzd7ytS+/nR/e7HuESKVawb34zVETXs2w1EdXofDmI4J9SAkFVOiz5Mp/MUdw7uqN ciM6qHTPUq0RaCjE0muSfjNWA+6u+PKbkk08EI81ftF1FhGT1rXVWXyf+7iLcaYaIGCk cEDm+i57pSGYSAj89CR6/IYx59ATRLUQeAZ+wnuYuggMIwjy1A7SS+n5b3TaP9qX0G9a RsAQ== X-Gm-Message-State: AOJu0YzzsNrtrsTuM6shN2TN5PykHWUG9XbxtzhVknPH7RoInFQW90tG Uza+JogyjctUAtzfbtWwzd3B6/55lT8= X-Google-Smtp-Source: AGHT+IHC0cN/2De5xen7ibNy+y6BllughOWYn6gEOWGq7LIQ0F28AK/jX+PE+yQRk6cY2E2tx8stBA== X-Received: by 2002:a05:600c:3794:b0:40c:32b3:f297 with SMTP id o20-20020a05600c379400b0040c32b3f297mr6064574wmr.55.1702925493665; Mon, 18 Dec 2023 10:51:33 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:32 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 04/12] hw/char/parallel: Free struct ParallelState from PortioList Date: Mon, 18 Dec 2023 19:51:06 +0100 Message-ID: <20231218185114.119736-5-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=shentey@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org ParallelState::portio_list isn't used inside ParallelState context but only inside ISAParallelState context, so more it there. Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan --- include/hw/char/parallel-isa.h | 2 ++ include/hw/char/parallel.h | 2 -- hw/char/parallel.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hw/char/parallel-isa.h b/include/hw/char/parallel-isa.h index d24ccecf05..3b783bd08d 100644 --- a/include/hw/char/parallel-isa.h +++ b/include/hw/char/parallel-isa.h @@ -12,6 +12,7 @@ #include "parallel.h" +#include "exec/ioport.h" #include "hw/isa/isa.h" #include "qom/object.h" @@ -25,6 +26,7 @@ struct ISAParallelState { uint32_t iobase; uint32_t isairq; ParallelState state; + PortioList portio_list; }; #endif /* HW_PARALLEL_ISA_H */ diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h index 7b5a309a03..cfb97cc7cc 100644 --- a/include/hw/char/parallel.h +++ b/include/hw/char/parallel.h @@ -1,7 +1,6 @@ #ifndef HW_PARALLEL_H #define HW_PARALLEL_H -#include "exec/ioport.h" #include "exec/memory.h" #include "hw/isa/isa.h" #include "hw/irq.h" @@ -22,7 +21,6 @@ typedef struct ParallelState { uint32_t last_read_offset; /* For debugging */ /* Memory-mapped interface */ int it_shift; - PortioList portio_list; } ParallelState; void parallel_hds_isa_init(ISABus *bus, int n); diff --git a/hw/char/parallel.c b/hw/char/parallel.c index 147c900f0d..c1747cbb75 100644 --- a/hw/char/parallel.c +++ b/hw/char/parallel.c @@ -532,7 +532,7 @@ static void parallel_isa_realizefn(DeviceState *dev, Error **errp) s->status = dummy; } - isa_register_portio_list(isadev, &s->portio_list, base, + isa_register_portio_list(isadev, &isa->portio_list, base, (s->hw_driver ? &isa_parallel_portio_hw_list[0] : &isa_parallel_portio_sw_list[0]), From patchwork Mon Dec 18 18:51:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7601FC35274 for ; Mon, 18 Dec 2023 18:53:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIid-0006Go-Fq; Mon, 18 Dec 2023 13:51:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIiW-0006A3-8z; Mon, 18 Dec 2023 13:51:53 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiM-0008Pe-3g; Mon, 18 Dec 2023 13:51:45 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40c3f68b69aso34818915e9.1; Mon, 18 Dec 2023 10:51:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925495; x=1703530295; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LzCBxca0nCRHR665JCCwURJqMXPSu7RYmWln7L2TOQo=; b=E26h59jBb+5M/4+VT+NqbBE8mO2CkylG9pJXSSXhC4Ru7gtbKj2UzhfgEwdzqVq+CN YsyP3rv2/SWEtwxwfFrObDlKBzwPfDBowzYEwnqD9rgiWy6RLyPHQfZnb1mdTUOuJRHm GgX4lFstqbuqzDnpypcGEvhiIcc+YJZAFTFqZd+LkpTQkhun+0JiUOx42Joj+opsY3z9 2MD2ftQ9TslWYsGh9/tFdRa/HD26SO6uqZXp6dddmBZP7OWSQ46ZJcfms4kzEK6dJEEf frPtBWDcEyvl1xtt+PMhynQlpUcceMP81umT5xmGQwRVck3KiHTDC01QoMRJiJCo3NYK rUzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925495; x=1703530295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LzCBxca0nCRHR665JCCwURJqMXPSu7RYmWln7L2TOQo=; b=cBS7LlhKgzI6rKA19gzsfR0T82oYWIq01sGHADDsZK3li3kaTOC556qrhkgbABpjLX 5/+vqZe+ePco6QAc8dbSIgZThwyEEdgE7MzWLiSjmRE0R7FWjS5HUWCvxWmIJsKaLAoK BH6mlvhVX2f3NLfdTBNVmb8ujsKQd7tXldIFYvM1/muxoc9zUJkNi+9qTmjjQLieeU1C 1e6nDFKtrnNBcoQdF4f+A/2GgjJvISPKit7vW7cXQ/1jK0p+Bb9J7rbwkYD3VPF4bp/I F9t+ni+WZKE1UilBoH0gGLYU6YI8C9uwlYYQYY54bTYNMQgUnHWA5FZT8QJODv1voViu mYHQ== X-Gm-Message-State: AOJu0Yz/sq9UAIIPoSZTwrdE5a3Jn3n24lU/Q4RrFqo8LVC6X9pxU+8h /lttfcupLvSV8RgFHuzvKeinvCCgCNc= X-Google-Smtp-Source: AGHT+IGsWFEirahMFrh58jiwkZNyscmLG2VaPeyxApkkWpaqR9Yo5bn2LMrWqYF8KB7AdccwOWx6kw== X-Received: by 2002:a05:600c:1d10:b0:40c:50c:9f3f with SMTP id l16-20020a05600c1d1000b0040c050c9f3fmr9680834wms.95.1702925495291; Mon, 18 Dec 2023 10:51:35 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:34 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 05/12] exec/ioport: Resolve redundant .base attribute in struct MemoryRegionPortio Date: Mon, 18 Dec 2023 19:51:07 +0100 Message-ID: <20231218185114.119736-6-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=shentey@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org portio_list_add_1() creates a MemoryRegionPortioList instance which holds a MemoryRegion `mr` and an array of MemoryRegionPortio elements named `ports`. Each element in the array gets assigned the same value for its .base attribute. The same value also ends up as the .addr attribute of `mr` due to the memory_region_add_subregion() call. This means that all .base attributes are the same as `mr.addr`. The only usages of MemoryRegionPortio::base were in portio_read() and portio_write(). Both functions get above MemoryRegionPortioList as their opaque parameter. In both cases find_portio() can only return one of the MemoryRegionPortio elements of the `ports` array. Due to above observation any element will have the same .base value equal to `mr.addr` which is also accessible. Hence, `mrpio->mr.addr` is equivalent to `mrp->base` and MemoryRegionPortio::base is redundant and can be removed. Signed-off-by: Bernhard Beschow --- include/exec/ioport.h | 1 - system/ioport.c | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/exec/ioport.h b/include/exec/ioport.h index e34f668998..95f1dc30d0 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -35,7 +35,6 @@ typedef struct MemoryRegionPortio { unsigned size; uint32_t (*read)(void *opaque, uint32_t address); void (*write)(void *opaque, uint32_t address, uint32_t data); - uint32_t base; /* private field */ } MemoryRegionPortio; #define PORTIO_END_OF_LIST() { } diff --git a/system/ioport.c b/system/ioport.c index 1824aa808c..a59e58b716 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -181,13 +181,13 @@ static uint64_t portio_read(void *opaque, hwaddr addr, unsigned size) data = ((uint64_t)1 << (size * 8)) - 1; if (mrp) { - data = mrp->read(mrpio->portio_opaque, mrp->base + addr); + data = mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr); } else if (size == 2) { mrp = find_portio(mrpio, addr, 1, false); if (mrp) { - data = mrp->read(mrpio->portio_opaque, mrp->base + addr); + data = mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr); if (addr + 1 < mrp->offset + mrp->len) { - data |= mrp->read(mrpio->portio_opaque, mrp->base + addr + 1) << 8; + data |= mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr + 1) << 8; } else { data |= 0xff00; } @@ -203,13 +203,13 @@ static void portio_write(void *opaque, hwaddr addr, uint64_t data, const MemoryRegionPortio *mrp = find_portio(mrpio, addr, size, true); if (mrp) { - mrp->write(mrpio->portio_opaque, mrp->base + addr, data); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr, data); } else if (size == 2) { mrp = find_portio(mrpio, addr, 1, true); if (mrp) { - mrp->write(mrpio->portio_opaque, mrp->base + addr, data & 0xff); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr, data & 0xff); if (addr + 1 < mrp->offset + mrp->len) { - mrp->write(mrpio->portio_opaque, mrp->base + addr + 1, data >> 8); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr + 1, data >> 8); } } } @@ -244,7 +244,6 @@ static void portio_list_add_1(PortioList *piolist, /* Adjust the offsets to all be zero-based for the region. */ for (i = 0; i < count; ++i) { mrpio->ports[i].offset -= off_low; - mrpio->ports[i].base = start + off_low; } /* From patchwork Mon Dec 18 18:51:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52920C35274 for ; Mon, 18 Dec 2023 18:53:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIie-0006HQ-AH; Mon, 18 Dec 2023 13:52:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIiU-00069p-Tx; Mon, 18 Dec 2023 13:51:51 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiN-0008Pr-Bv; Mon, 18 Dec 2023 13:51:47 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33662243274so953503f8f.1; Mon, 18 Dec 2023 10:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925497; x=1703530297; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=17iaMgElBiTn1QygUisbFlOq9KXGCt1sZ32e3Q8CD7c=; b=ej1D1nkAkf69vA/SrhPAV/sLf6zEM+P8JIvbBPBkr3ZhZWl2ZlYOzBy+C/SsG4044F ThPawZPCH7DSGBXGzW8Si/0UBZ2tn0zhJ+TOWJ/GszOvwQeF2vQGc5pocuQ4KG6Wmn3N UsZXTNmjIumy7ANsG9TiGif9Gtth5U+hu+osd1lKzgnwwJ6Qrk0djKwVOPa1vhoNwsY2 DFq4R3Iwlx6f2PnoCXnFTYJHPkv0HLEyFEcPP4yqLE+b6KyiCKACDYsH1cmjJ7DLoix1 5FVTqppDKdNGLXMGol5Qz/whYhcvTp/yqB/kxuZCyHgRPd1b05PjO7jbcZ4aXIk/cS2o yr/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925497; x=1703530297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=17iaMgElBiTn1QygUisbFlOq9KXGCt1sZ32e3Q8CD7c=; b=SBZesYX8Zr6rKJDuuZkc4N1Scgxd4Wkc9veoUrnq05EHtK0/IMdcZV2QDdMM889W+K W+hiQAmVyAN/Tczdu+XcFfM8IcalOI4jWBGgy6dpQGkJzEleZZXV40DL9MiP8hYVELpb Wtqrkg+Q6MC6Fca5M1UuTZ0JercatJ0nVVtEr+1dOHKyeRFC/AuMe+FRC8uNDQH7RjLu nQiTnppz3e/mX99m+mre+GPFUU8X7UzCu7iYUe9qvbxV+3S6n442M74RpT8HZhcHleRk Ao1wwbvL/yFirYhlqXtcM3OFqnjXvdFlPpVIwSPioBO9KbfnToJltXEyM0roBIbnWffz Lipg== X-Gm-Message-State: AOJu0Yy4/CYyuNRAZIBE4TBaHYHYtXUV8quQeWVIiHs9s5Gq3wOYC0Pd 73IEktA1cOjCVhG0V6F7KBK8e2FVoSQ= X-Google-Smtp-Source: AGHT+IG6plX8eBegqLonXYFEx0X9cXRItXD2Q015fHph4QTMR0KJGX40ZCjiS5zoBmqRVJ6eS1L9ig== X-Received: by 2002:a7b:c84a:0:b0:40b:5e26:2389 with SMTP id c10-20020a7bc84a000000b0040b5e262389mr8515133wml.58.1702925496862; Mon, 18 Dec 2023 10:51:36 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:36 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 06/12] exec/ioport: Add portio_list_set_address() Date: Mon, 18 Dec 2023 19:51:08 +0100 Message-ID: <20231218185114.119736-7-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=shentey@gmail.com; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Some SuperI/O devices such as the VIA south bridges or the PC87312 controller are able to relocate their SuperI/O functions. Add a convenience function for implementing this in the VIA south bridges. This convenience function relies on previous simplifications in exec/ioport which avoids some duplicate synchronization of I/O port base addresses. The naming of the function is inspired by its memory_region_set_address() pendant. Signed-off-by: Bernhard Beschow --- docs/devel/migration.rst | 1 + include/exec/ioport.h | 2 ++ system/ioport.c | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index ec55089b25..389fa24bde 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -464,6 +464,7 @@ Examples of such memory API functions are: - memory_region_set_enabled() - memory_region_set_address() - memory_region_set_alias_offset() + - portio_list_set_address() Iterative device migration -------------------------- diff --git a/include/exec/ioport.h b/include/exec/ioport.h index 95f1dc30d0..96858e5ac3 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -54,6 +54,7 @@ typedef struct PortioList { const struct MemoryRegionPortio *ports; Object *owner; struct MemoryRegion *address_space; + uint32_t addr; unsigned nr; struct MemoryRegion **regions; void *opaque; @@ -70,5 +71,6 @@ void portio_list_add(PortioList *piolist, struct MemoryRegion *address_space, uint32_t addr); void portio_list_del(PortioList *piolist); +void portio_list_set_address(PortioList *piolist, uint32_t addr); #endif /* IOPORT_H */ diff --git a/system/ioport.c b/system/ioport.c index a59e58b716..000e0ee1af 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -133,6 +133,7 @@ void portio_list_init(PortioList *piolist, piolist->nr = 0; piolist->regions = g_new0(MemoryRegion *, n); piolist->address_space = NULL; + piolist->addr = 0; piolist->opaque = opaque; piolist->owner = owner; piolist->name = name; @@ -282,6 +283,7 @@ void portio_list_add(PortioList *piolist, unsigned int off_low, off_high, off_last, count; piolist->address_space = address_space; + piolist->addr = start; /* Handle the first entry specially. */ off_last = off_low = pio_start->offset; @@ -322,6 +324,23 @@ void portio_list_del(PortioList *piolist) } } +void portio_list_set_address(PortioList *piolist, uint32_t addr) +{ + MemoryRegionPortioList *mrpio; + unsigned i, j; + + for (i = 0; i < piolist->nr; ++i) { + mrpio = container_of(piolist->regions[i], MemoryRegionPortioList, mr); + memory_region_set_address(&mrpio->mr, + mrpio->mr.addr - piolist->addr + addr); + for (j = 0; mrpio->ports[j].size; ++j) { + mrpio->ports[j].offset += addr - piolist->addr; + } + } + + piolist->addr = addr; +} + static void memory_region_portio_list_finalize(Object *obj) { MemoryRegionPortioList *mrpio = MEMORY_REGION_PORTIO_LIST(obj); From patchwork Mon Dec 18 18:51:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37D11C46CD3 for ; Mon, 18 Dec 2023 18:53:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIib-0006Fe-VG; Mon, 18 Dec 2023 13:51:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIiV-00069s-4s; Mon, 18 Dec 2023 13:51:51 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiP-0008Pz-00; Mon, 18 Dec 2023 13:51:47 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40c6e2a47f6so35948535e9.0; Mon, 18 Dec 2023 10:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925498; x=1703530298; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y238zjYlrP82jW+c2G5tr4kwW6UUjfsDc9YiHIQkqX4=; b=LiSNDQI8quzkubhgsunbWL02iF+r/Kd7ioCsxCNY2OFsggeTbjVeejBZQZx8VGyGpJ 3SI1vnN40eaD83+sQORVplmvz/SV0GZNhjAIVnZ6OQXa3soDS1NB2GtMNaqy2Nze7hwz AK9F1QysTaSZVEgU0czVMAeLD5d/agSe1SObISgF5eWGjD18hWPeGRLJ7Drg+a5F2vQw TNDU4dh+fF9tjZVGJEWKkA7Lf/92OHvGrn6p1MzXEQkjChMPqPhfrhEHk5Bg+zChbsBe pbNXZAsV4XvNF7vH2IjAwTWUuSGeNrQJj3JEo4nQb2fkJj1wSfzNHriLAN8SHnEfMJQ/ O9TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925498; x=1703530298; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y238zjYlrP82jW+c2G5tr4kwW6UUjfsDc9YiHIQkqX4=; b=au2FuXUE4pgiBi7qVwYuWu+SALiRes82dOxi9lAdIDYvWpC67kN0OXiTHu1T6kq8DW H0Ik0dnm8Srcz6XELpKkvsFz5jSGZx/GQowTz6U2KE1KejGu+DQFgJ6cvUyRLfLQQNSd 5WXr8ECK/H2hOhd80YElAhuSuZyvV8gle9c5MROxYCDQQ7bgxneLYXjN8TeUrSwCDVX6 8H4KU3Kjv3iMW/PLEUk5vjH4uXhIrKKeuVpDaTcvVCWFyCNOKphkpz8xMDryeaJiKa4D DdhAtAIrKfsboAlQXs4SAfIPh2Pr0wiPUlla2QIqftwAHqzYwkH3NKDSD3ITHJUkTIq3 uiRw== X-Gm-Message-State: AOJu0Ywei7oHio8Q+dKjcUE/GDJez91VUU8pMdyeHicv9nvwDZGUf4eV R/WycmOX/OV4EEJN9dx6bxA6lYPHYbI= X-Google-Smtp-Source: AGHT+IFwyt7ufTs/Oo+4mIFjJPSvAw1QBKAWdd5T5Z3PvLnegr+XbXuZdvZxnBc6i/NvZhW3Wos5Bw== X-Received: by 2002:a05:600c:444e:b0:40c:3d90:4a00 with SMTP id v14-20020a05600c444e00b0040c3d904a00mr4378865wmn.57.1702925498640; Mon, 18 Dec 2023 10:51:38 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:37 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 07/12] exec/ioport: Add portio_list_set_enabled() Date: Mon, 18 Dec 2023 19:51:09 +0100 Message-ID: <20231218185114.119736-8-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=shentey@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Some SuperI/O devices such as the VIA south bridges or the PC87312 controller allow to enable or disable their SuperI/O functions. Add a convenience function for implementing this in the VIA south bridges. The naming of the functions is inspired by its memory_region_set_enabled() pendant. Signed-off-by: Bernhard Beschow --- docs/devel/migration.rst | 1 + include/exec/ioport.h | 1 + system/ioport.c | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index 389fa24bde..466be609a2 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -465,6 +465,7 @@ Examples of such memory API functions are: - memory_region_set_address() - memory_region_set_alias_offset() - portio_list_set_address() + - portio_list_set_enabled() Iterative device migration -------------------------- diff --git a/include/exec/ioport.h b/include/exec/ioport.h index 96858e5ac3..4397f12f93 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -71,6 +71,7 @@ void portio_list_add(PortioList *piolist, struct MemoryRegion *address_space, uint32_t addr); void portio_list_del(PortioList *piolist); +void portio_list_set_enabled(PortioList *piolist, bool enabled); void portio_list_set_address(PortioList *piolist, uint32_t addr); #endif /* IOPORT_H */ diff --git a/system/ioport.c b/system/ioport.c index 000e0ee1af..fd551d0375 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -324,6 +324,15 @@ void portio_list_del(PortioList *piolist) } } +void portio_list_set_enabled(PortioList *piolist, bool enabled) +{ + unsigned i; + + for (i = 0; i < piolist->nr; ++i) { + memory_region_set_enabled(piolist->regions[i], enabled); + } +} + void portio_list_set_address(PortioList *piolist, uint32_t addr) { MemoryRegionPortioList *mrpio; From patchwork Mon Dec 18 18:51:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 829D9C35274 for ; Mon, 18 Dec 2023 18:53:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIiw-0006Vw-Ld; Mon, 18 Dec 2023 13:52:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIil-0006Le-O0; Mon, 18 Dec 2023 13:52:09 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiV-0008Q5-2q; Mon, 18 Dec 2023 13:52:04 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40c6a71e88cso44841905e9.0; Mon, 18 Dec 2023 10:51:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925500; x=1703530300; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2hxeuo8c4Hhd1U5I1nXh+SQy23QcDbLcnuSYji2d92Y=; b=KLhNt4Chd9pLC/MZqJsrsfY21HJPPHxIaQtxUAiIioXB2/YX2YZrZ1RaffRpUPO4LN zQe7KxDTIlfgn74E/8OjP0tx7pcOMNo++skT4J1PJ/VU+F1gSGc1NniRYGaisxn121WG 4+uzm16mNRDD8KvTTikWslymGEMf7s7+uz+EmLGf1hAm9MDYkqEQuCl4DNnvq07+mc1Z TzbghQpFJIn3dI46HvRWF34ZOmMApBDTRz/6ZMnvgsp+E/QP/1WwrRNyyBYjbnUTcvfY ligQocT5ysC8KvUIIgDgBGDmeauoajOWSCxVWKhoMD9rk8ZLxr2W2SF8OxJxdrcFRiut gXDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925500; x=1703530300; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2hxeuo8c4Hhd1U5I1nXh+SQy23QcDbLcnuSYji2d92Y=; b=ALtjJf8KGECtcPhsEW6aWxsUmLDFqQy9wGxvyXwVu3UnRuaOrWZt+ROiel16Q4+dpH gWzNCcq66WsZWdSnabXkBLed/2lbh3Alt13LUok13FOlHWk0zh1YoAf2Wd0vZDa8eAfx 1McP0+2NIM86JrAWXKJd5dhbX8xtzTWwaurzaufp7EVLLTFN5r3RRuFvy3PlLPlQKf6M 3SFSDq7lbWQBJBHJdhOL54q86XsqMIDw14OJBsvxhgdRr+DcI5yZlstRi/1KdBNN5BON VYzGaoVEk3D5UuOHZ25/ag+8s7sl5s99SuzkjUoT3gK7HlgPU+1UOegeCs3X6oDwhbYn PLdQ== X-Gm-Message-State: AOJu0Yy1g6GQIBHVr74e1Tw5dfdXnkqaEC7UESddUvTg9xPlBaPMV1jl zoOj9zvK78p7gufXEwRsNgEefXZXj28= X-Google-Smtp-Source: AGHT+IEUn1jcbNUfsQ8fivnVt89iRBlvSMw5wXEfeOIbn0L8jhkYbtSPPxxjClqFE+/WrUkFT5y+wA== X-Received: by 2002:a05:600c:3657:b0:405:3dbc:8823 with SMTP id y23-20020a05600c365700b004053dbc8823mr9481675wmq.12.1702925500317; Mon, 18 Dec 2023 10:51:40 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:39 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 08/12] hw/block/fdc-isa: Implement relocation and toggling for TYPE_ISA_FDC Date: Mon, 18 Dec 2023 19:51:10 +0100 Message-ID: <20231218185114.119736-9-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=shentey@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Implement isa_fdc_set_{enabled,iobase} in order to implement relocation and toggling of SuperI/O functions in the VIA south bridges without breaking encapsulation. Signed-off-by: Bernhard Beschow --- include/hw/block/fdc.h | 3 +++ hw/block/fdc-isa.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h index 35248c0837..c367c5efea 100644 --- a/include/hw/block/fdc.h +++ b/include/hw/block/fdc.h @@ -14,6 +14,9 @@ void fdctrl_init_sysbus(qemu_irq irq, hwaddr mmio_base, DriveInfo **fds); void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, DriveInfo **fds, qemu_irq *fdc_tc); +void isa_fdc_set_iobase(ISADevice *fdc, hwaddr iobase); +void isa_fdc_set_enabled(ISADevice *fdc, bool enabled); + FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i); int cmos_get_fd_drive_type(FloppyDriveType fd0); diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c index b4c92b40b3..c989325de3 100644 --- a/hw/block/fdc-isa.c +++ b/hw/block/fdc-isa.c @@ -192,6 +192,20 @@ static Aml *build_fdinfo_aml(int idx, FloppyDriveType type) return dev; } +void isa_fdc_set_iobase(ISADevice *fdc, hwaddr iobase) +{ + FDCtrlISABus *isa = ISA_FDC(fdc); + + fdc->ioport_id = iobase; + isa->iobase = iobase; + portio_list_set_address(&isa->portio_list, isa->iobase); +} + +void isa_fdc_set_enabled(ISADevice *fdc, bool enabled) +{ + portio_list_set_enabled(&ISA_FDC(fdc)->portio_list, enabled); +} + int cmos_get_fd_drive_type(FloppyDriveType fd0) { int val; From patchwork Mon Dec 18 18:51:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73C68C35274 for ; Mon, 18 Dec 2023 18:54:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIiu-0006SD-A1; Mon, 18 Dec 2023 13:52:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIii-0006Jk-BK; Mon, 18 Dec 2023 13:52:05 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiQ-0008QE-Kd; Mon, 18 Dec 2023 13:52:03 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3364c9ff8e1so2032829f8f.0; Mon, 18 Dec 2023 10:51:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925501; x=1703530301; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=loMZkXqxlBvl+ZoVdyMlIBzJJ+hfWEc5m/Rp26AxyIU=; b=UL6yyx5YiZCEfJ2QG2VfocwTxh9IQ1e/9IPTwNc44GeIzkNA6GJTKIk4YBOZBJa2J4 qnCgRvHERJy1UNQ5j1nsrmJjl6leJnCmlIlJgiFp1DQnMRRHqhWJ4p6Kow3t9q2L61O+ FJjevT7q6tIApvKBIRpJIlYbmJ1a4kVzEmWB+/Xhnmiw+Hx/MNmhCoWrmndO+wgNNnJQ vZYmS9OOuzcvRJc1W1D5E/iQYGB5z8/LKB3tJicEIlGO/uJ66nmPmdzE/51QTeitwJyS GD4V21JP4ZAPmA7lPGk3mXOpfXG3WEID1VJ6gr2FxTRi8UCaYLHk5+ly0Hov3WnrnL54 BgAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925501; x=1703530301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=loMZkXqxlBvl+ZoVdyMlIBzJJ+hfWEc5m/Rp26AxyIU=; b=PJRDsoYI34cxO9w0FBiq2862S+BR++XxQk9KyyZOCU0FUj2xPiWnVv1H9r9U4q0/58 xNyyDhtgVZb92407rq+v52gQIVXTwzROQd6jFCJXbt0nQN+FQjImbQrNKCAznNtJn45I qRicBNbFH7sS+GAjVTuByWCg33YKJadfYh3B8YhoQk9bA2o+PUL8sTZmHahSghIiZqXK 9/y2WGqKnakjfOwTrKXjug21FU+J6FCIUquO3+q1zkpNw0zOhRfsM7DXB34ODLOuHVKi dC+A3h/d/LeQCkHmMBDRHJ22VpYvYMdSBbHExWr5LAYAsRkAeCyXSv+yJMvk49ikgt8Q QRKQ== X-Gm-Message-State: AOJu0YxHSjmsrOrzo9Jm5XvaOOEakdp6j9Q35KaaFck8I72b7Kn9x+5s GMwgs6DLA11eHzw8ZZ2D2JocEmEe49o= X-Google-Smtp-Source: AGHT+IFB9iwxVPCcvv0LhH8O/b6Bsh3fQ2pTa5qQyyJP3cTfAlo3pVtSYd6JvjM4ul3ACQa1LyCLiA== X-Received: by 2002:a05:600c:3c8b:b0:40c:4b42:a20b with SMTP id bg11-20020a05600c3c8b00b0040c4b42a20bmr6162868wmb.8.1702925501511; Mon, 18 Dec 2023 10:51:41 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:41 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 09/12] hw/char/serial-isa: Implement relocation and toggling for TYPE_ISA_SERIAL Date: Mon, 18 Dec 2023 19:51:11 +0100 Message-ID: <20231218185114.119736-10-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=shentey@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Implement isa_serial_set_{enabled,iobase} in order to implement relocation and toggling of SuperI/O functions in the VIA south bridges without breaking encapsulation. Signed-off-by: Bernhard Beschow --- include/hw/char/serial.h | 2 ++ hw/char/serial-isa.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index eb4254edde..ba9f8f21d7 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -112,5 +112,7 @@ SerialMM *serial_mm_init(MemoryRegion *address_space, #define TYPE_ISA_SERIAL "isa-serial" void serial_hds_isa_init(ISABus *bus, int from, int to); +void isa_serial_set_iobase(ISADevice *serial, hwaddr iobase); +void isa_serial_set_enabled(ISADevice *serial, bool enabled); #endif diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index 2be8be980b..d51c9ec87c 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -187,3 +187,17 @@ void serial_hds_isa_init(ISABus *bus, int from, int to) } } } + +void isa_serial_set_iobase(ISADevice *serial, hwaddr iobase) +{ + ISASerialState *s = ISA_SERIAL(serial); + + serial->ioport_id = iobase; + s->iobase = iobase; + memory_region_set_address(&s->io, s->iobase); +} + +void isa_serial_set_enabled(ISADevice *serial, bool enabled) +{ + memory_region_set_enabled(&ISA_SERIAL(serial)->io, enabled); +} From patchwork Mon Dec 18 18:51:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1178BC46CA2 for ; Mon, 18 Dec 2023 18:53:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIit-0006QU-NU; Mon, 18 Dec 2023 13:52:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIii-0006Jl-Bd; Mon, 18 Dec 2023 13:52:05 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiR-0008QQ-2G; Mon, 18 Dec 2023 13:52:02 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40c41b43e1eso45000275e9.1; Mon, 18 Dec 2023 10:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925503; x=1703530303; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hPwHpCKMVQft6dmkR72MEXRun0g3aRwzuJ4tXisLRCE=; b=OwTMUM135eWiFq0dckXiCvddrxIVeIwpdTb7SyUlCM5+EKLvdim1OPn2UmgtCiOT6S jLWT5jjFFoix+4+5520juKzVgIGN0/aJu1aMkhp2cq4IAyPi6wJUwJc8JyQ+hMy9x4B8 qdPS2+VXQD9HI6S9GeASmUx4gUeCSgkocxRtQNeThbj6FG00TgAy8sCVl4a1gxzsAy+N 4WAfI/Vy3qzlHFGOqZq15X6zGxMOCmp4U1s9Y0lFFo7cIgXz/ulAvLVuljf7EFfFmi3S 9nZg/EbX0E1wVgghNbe5TNbNfujWrs95NUcfN3Iydx9pYGm2CQy/QeUwC1o9FZ7D3fzR I8xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925503; x=1703530303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hPwHpCKMVQft6dmkR72MEXRun0g3aRwzuJ4tXisLRCE=; b=vKYI6cskV7h8uKUYISmQEqO5394EWtZtwiCoGeBOOMB0feYSgInZe+aimt/2PRSx0N gEO6e2+ujqaMoKbq0ROro1kCBGUSrPXJjw9OvdtLIJ8H4dQ67+IM1+sbRjYuzEO5n5TD jjc7H3nwvvVn83Gdfej+CyLgoNpoitqJ0dO0Sg4SkE37k6A5tmA1C1yZuRW2SohWZ8vz 9+669fEWCT7P9UNRdPBtgWO+WQ7mcPyJ1ixr3Beg32dA77fFFhygpNG16OOvEx+ElR+x SQ2BbR3jT5zkDVwgdOZvRMmGZGBE8CEN579ytgmAjAqBvFmBh8r1V0dvWPqP81iHVCKK HjaQ== X-Gm-Message-State: AOJu0YzByCQLJkPKllJgTZkUQPffOXrjLa9DnJ7q9DDom1e2405rhLEZ 8ZcwO7PwoO90KMSeyo8Uw7CCUMRcsKQ= X-Google-Smtp-Source: AGHT+IGeJNTZzHuKLvGMnITTz3PB4FSAGA5kgYU8DwNQ9aZXAsonR5Mg3K0xJIqq8SqHf/kMC8zTPw== X-Received: by 2002:a05:600c:4fd6:b0:401:bdd7:49ae with SMTP id o22-20020a05600c4fd600b00401bdd749aemr8020872wmq.18.1702925503118; Mon, 18 Dec 2023 10:51:43 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:42 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 10/12] hw/char/parallel-isa: Implement relocation and toggling for TYPE_ISA_PARALLEL Date: Mon, 18 Dec 2023 19:51:12 +0100 Message-ID: <20231218185114.119736-11-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=shentey@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Implement isa_parallel_set_{enabled,iobase} in order to implement relocation and toggling of SuperI/O functions in the VIA south bridges without breaking encapsulation. Signed-off-by: Bernhard Beschow --- include/hw/char/parallel-isa.h | 3 +++ hw/char/parallel-isa.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/char/parallel-isa.h b/include/hw/char/parallel-isa.h index 3b783bd08d..5284b2ffec 100644 --- a/include/hw/char/parallel-isa.h +++ b/include/hw/char/parallel-isa.h @@ -29,4 +29,7 @@ struct ISAParallelState { PortioList portio_list; }; +void isa_parallel_set_iobase(ISADevice *parallel, hwaddr iobase); +void isa_parallel_set_enabled(ISADevice *parallel, bool enabled); + #endif /* HW_PARALLEL_ISA_H */ diff --git a/hw/char/parallel-isa.c b/hw/char/parallel-isa.c index ab0f879998..a5ce6ee13a 100644 --- a/hw/char/parallel-isa.c +++ b/hw/char/parallel-isa.c @@ -41,3 +41,17 @@ void parallel_hds_isa_init(ISABus *bus, int n) } } } + +void isa_parallel_set_iobase(ISADevice *parallel, hwaddr iobase) +{ + ISAParallelState *s = ISA_PARALLEL(parallel); + + parallel->ioport_id = iobase; + s->iobase = iobase; + portio_list_set_address(&s->portio_list, s->iobase); +} + +void isa_parallel_set_enabled(ISADevice *parallel, bool enabled) +{ + portio_list_set_enabled(&ISA_PARALLEL(parallel)->portio_list, enabled); +} From patchwork Mon Dec 18 18:51:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EEB0C35274 for ; Mon, 18 Dec 2023 18:52:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIiu-0006TD-Nv; Mon, 18 Dec 2023 13:52:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIim-0006Lp-1G; Mon, 18 Dec 2023 13:52:09 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiW-0008Qi-G0; Mon, 18 Dec 2023 13:52:04 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40c6736d10fso44887915e9.1; Mon, 18 Dec 2023 10:51:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925504; x=1703530304; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yF9fIF58tWpNQAnkVGixO0hH0AJ7bWtrwUxz8sAPbEk=; b=MQxGLMNgS5aS1hJZ2z6EWpUJaNBllV1dnT9sVTP0g2VX4Bqu3aivJKuoz9/WrBQfRv XjHDAg7VxCCIcKJfMN9K/VOrE5tdFoo34eRsZO1MVGzqig0+RYWVPuzFcPixilX2ilrx ITDk9Grp34kt/9kbkipxlGuBhEDeOWEBdsPH+D2hgbATYFF/AbJG50GEbjraTJkT7hXs zXuXaPcU9xo6Tsj5xsm6DO9vJRVcpW7wOzywdWZLxQ5V+6/uY9yZyql0mdYvNw0uR85m rG04StH1U/P+o/Yg0OUzJ1vnpKRFXYn3C4t2l6JsVeB/C1PExnoJJyw8jdN4Y+fhnKMj C2cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925504; x=1703530304; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yF9fIF58tWpNQAnkVGixO0hH0AJ7bWtrwUxz8sAPbEk=; b=YNisDCbWEP2FFd+ADENFcZ+79MyrlQvVkIUQDzh4tpdExwFuMzGESt0hG8r7kCg7dK 7ba8h/y12iQ2moX1oVen/adsA5CCW8Drzj4++U6VC4aKYbD4gU+SFpEf3IM/zt1WEhK+ r+yZvZsBTtNxutrc0K/RIrpcN6k4/2Yu6scppdNuLhmPpAwjL36bH3vGC3BhwZPgZ7lY DeAQbxc7TBgXRWzLzE49n6rZdtjEc8mJS1cz4j3QYgANmVKP1+q94/clT3nPNYQvfmKL VuldluD3VLYZVLbE3S1HH38cd80ovtp2PXjtXLVgWL7KfhwenS/vQexRDPQWHzA/Xin3 DTUA== X-Gm-Message-State: AOJu0YyYK/aTE6g1+ADN3Vw3K5FBKNuXIVzZkuco7j1euR8o6XMzczkl zB14r13xohx83n3dcIOHPUY/rjGFFMo= X-Google-Smtp-Source: AGHT+IE1UHu2Iz6/rzw1oAQlW0RzplKbWRBVQ87OCUNMfUgJ87knUf885VMLfNmlc5kbu574qoHHrA== X-Received: by 2002:a05:600c:3591:b0:40c:700c:82cd with SMTP id p17-20020a05600c359100b0040c700c82cdmr2669012wmq.70.1702925504448; Mon, 18 Dec 2023 10:51:44 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:44 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 11/12] hw/ppc/pegasos2: Let pegasos2 machine configure SuperI/O functions Date: Mon, 18 Dec 2023 19:51:13 +0100 Message-ID: <20231218185114.119736-12-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=shentey@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This is a preparation for implementing relocation and toggling of SuperI/O functions in the VT8231 device model. Upon reset, all SuperI/O functions will be deactivated, so in case if no -bios is given, let the machine configure those functions the same way pegasos2.rom would do. For now the meantime this will be a no-op. Signed-off-by: Bernhard Beschow --- hw/ppc/pegasos2.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 3203a4a728..0a40ebd542 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -285,6 +285,15 @@ static void pegasos2_pci_config_write(Pegasos2MachineState *pm, int bus, pegasos2_mv_reg_write(pm, pcicfg + 4, len, val); } +static void pegasos2_superio_write(Pegasos2MachineState *pm, uint32_t addr, + uint32_t val) +{ + AddressSpace *as = CPU(pm->cpu)->as; + + stb_phys(as, PCI1_IO_BASE + 0x3f0, addr); + stb_phys(as, PCI1_IO_BASE + 0x3f1, val); +} + static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason) { Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine); @@ -310,6 +319,12 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason) pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | PCI_INTERRUPT_LINE, 2, 0x9); + pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | + 0x50, 1, 0x6); + pegasos2_superio_write(pm, 0xf4, 0xbe); + pegasos2_superio_write(pm, 0xf6, 0xef); + pegasos2_superio_write(pm, 0xf7, 0xfc); + pegasos2_superio_write(pm, 0xf2, 0x14); pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | 0x50, 1, 0x2); pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | From patchwork Mon Dec 18 18:51:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13497387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE377C35274 for ; Mon, 18 Dec 2023 18:55:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFIiv-0006UI-M4; Mon, 18 Dec 2023 13:52:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFIim-0006Lq-1F; Mon, 18 Dec 2023 13:52:09 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFIiW-0008R4-4q; Mon, 18 Dec 2023 13:52:04 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40c29f7b068so39681285e9.0; Mon, 18 Dec 2023 10:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702925506; x=1703530306; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+d5kwvs9T12xN8vScAfTbA/o6dxLL3a/WbRQdEN799g=; b=Xy8auPibR3fSu806iIXUGi2Ecy0RqCUCMgsbWdYOmagBn/OnQd6SKTq+7Fd8Vm7211 T/0LGJ1r4snTVX556IjSNjibjKDWqAjTdfPx3hLvzYS5RClSmPK17Tgg87kBpdegjPQz IO9Gj8CnTU/wUuM/TxRuuM88BifPIyLIpXtHw12O6LVkBKPB64A7zHWaHdm1U+WUaqgy Vc+cme0C+Q90gLl7l0RXJHOCQRuZ8bxQYt/ed1YmGJ6vmIg/N0IxMD1fLa66jWh4TiHw NvTtKR8nGYORx2/EVZHGgfA3loQjqEb4EGNsR2PCNAXX/dyAzYo2PYP6zs3XnY1kXawn DjsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925506; x=1703530306; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+d5kwvs9T12xN8vScAfTbA/o6dxLL3a/WbRQdEN799g=; b=CrdSzHJDN0xHAXTWOlCbe7yHpz0DNabPoJphXhfmkd7UJomloCroa80gqM+27tz6hA nt0n2gEodBG03U8aEGebpVFo1C8gNcDzsJswQB8GPG342dQIGhan0Iz6Gm1JjVFPtki+ lt7PzuKN+nRc0YyaTk7KSDj+5Eiyu92Qsn6NRa60goo2nLHUOpKjkyFM/19vEbGeyseW PV21EFOsLczYbxYr1D2K5v6DPSiB/rPa539rXR+HRlUWqXMH+OIIM4K/6qxsEViXCVtV ReKFT5Z4VbD7/gemIjXTEtL4abzgRnSC0k4Nv+jIMDU/83x+0gmlviv2v0ZKhAvqbNLE rTNA== X-Gm-Message-State: AOJu0Yyux9ryKSwAJyemWrID9vlNV2N31kKyaVdqTp0tMpBJ3kdjWKZD a67tsi4HxPx+NVqal37va1NIfQgu86s= X-Google-Smtp-Source: AGHT+IFlyMU6cCN4Nx1XUiclJWuCbsFDv/Veku0P8VSQCpfYPtzrIsu/jX60RtLALDNgF5XXgHX4FQ== X-Received: by 2002:a05:600c:3011:b0:40b:5e59:b7d2 with SMTP id j17-20020a05600c301100b0040b5e59b7d2mr8434333wmh.175.1702925506062; Mon, 18 Dec 2023 10:51:46 -0800 (PST) Received: from Provence.localdomain (dynamic-092-224-039-156.92.224.pool.telefonica.de. [92.224.39.156]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0040c45071c18sm35134091wmo.39.2023.12.18.10.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:51:45 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Fabiano Rosas , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-ppc@nongnu.org, Paolo Bonzini , Leonardo Bras , Kevin Wolf , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Juan Quintela , John Snow , BALATON Zoltan , Jiaxun Yang , Hanna Reitz , qemu-block@nongnu.org, Bernhard Beschow Subject: [PATCH v2 12/12] hw/isa/vt82c686: Implement relocation and toggling of SuperI/O functions Date: Mon, 18 Dec 2023 19:51:14 +0100 Message-ID: <20231218185114.119736-13-shentey@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218185114.119736-1-shentey@gmail.com> References: <20231218185114.119736-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=shentey@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The VIA south bridges are able to relocate and toggle (enable or disable) their SuperI/O functions. So far this is hardcoded such that all functions are always enabled and are located at fixed addresses. Some PC BIOSes seem to probe for I/O occupancy before activating such a function and issue an error in case of a conflict. Since the functions are enabled on reset, conflicts are always detected. Prevent that by implementing relocation and toggling of the SuperI/O functions. Note that all SuperI/O functions are now deactivated upon reset (except for VT82C686B's serial ports where Fuloong 2e's rescue-yl seems to expect them to be enabled by default). Rely on firmware -- or in case of pegasos2 on board code if no -bios is given -- to configure the functions accordingly. Signed-off-by: Bernhard Beschow --- hw/isa/vt82c686.c | 121 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 90 insertions(+), 31 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 9c2333a277..be202d23cf 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -15,6 +15,9 @@ #include "qemu/osdep.h" #include "hw/isa/vt82c686.h" +#include "hw/block/fdc.h" +#include "hw/char/parallel-isa.h" +#include "hw/char/serial.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" #include "hw/ide/pci.h" @@ -343,6 +346,35 @@ static const TypeInfo via_superio_info = { #define TYPE_VT82C686B_SUPERIO "vt82c686b-superio" +static void vt82c686b_superio_update(ViaSuperIOState *s) +{ + isa_parallel_set_enabled(s->superio.parallel[0], + (s->regs[0xe2] & 0x3) != 3); + isa_serial_set_enabled(s->superio.serial[0], s->regs[0xe2] & BIT(2)); + isa_serial_set_enabled(s->superio.serial[1], s->regs[0xe2] & BIT(3)); + isa_fdc_set_enabled(s->superio.floppy, s->regs[0xe2] & BIT(4)); + + isa_fdc_set_iobase(s->superio.floppy, (s->regs[0xe3] & 0xfc) << 2); + isa_parallel_set_iobase(s->superio.parallel[0], s->regs[0xe6] << 2); + isa_serial_set_iobase(s->superio.serial[0], (s->regs[0xe7] & 0xfe) << 2); + isa_serial_set_iobase(s->superio.serial[1], (s->regs[0xe8] & 0xfe) << 2); +} + +static int vmstate_vt82c686b_superio_post_load(void *opaque, int version_id) +{ + ViaSuperIOState *s = opaque; + + vt82c686b_superio_update(s); + + return 0; +} + +static const VMStateDescription vmstate_vt82c686b_superio = { + .name = "vt82c686b_superio", + .version_id = 1, + .post_load = vmstate_vt82c686b_superio_post_load, +}; + static void vt82c686b_superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { @@ -368,7 +400,11 @@ static void vt82c686b_superio_cfg_write(void *opaque, hwaddr addr, case 0xfd ... 0xff: /* ignore write to read only registers */ return; - /* case 0xe6 ... 0xe8: Should set base port of parallel and serial */ + case 0xe2 ... 0xe3: + case 0xe6 ... 0xe8: + sc->regs[idx] = data; + vt82c686b_superio_update(sc); + return; default: qemu_log_mask(LOG_UNIMP, "via_superio_cfg: unimplemented register 0x%x\n", idx); @@ -393,25 +429,24 @@ static void vt82c686b_superio_reset(DeviceState *dev) memset(s->regs, 0, sizeof(s->regs)); /* Device ID */ - vt82c686b_superio_cfg_write(s, 0, 0xe0, 1); - vt82c686b_superio_cfg_write(s, 1, 0x3c, 1); - /* Function select - all disabled */ - vt82c686b_superio_cfg_write(s, 0, 0xe2, 1); - vt82c686b_superio_cfg_write(s, 1, 0x03, 1); + s->regs[0xe0] = 0x3c; + /* + * Function select - only serial enabled + * Fuloong 2e's rescue-yl prints to the serial console w/o enabling it. This + * suggests that the serial ports are enabled by default, so override the + * datasheet. + */ + s->regs[0xe2] = 0x0f; /* Floppy ctrl base addr 0x3f0-7 */ - vt82c686b_superio_cfg_write(s, 0, 0xe3, 1); - vt82c686b_superio_cfg_write(s, 1, 0xfc, 1); + s->regs[0xe3] = 0xfc; /* Parallel port base addr 0x378-f */ - vt82c686b_superio_cfg_write(s, 0, 0xe6, 1); - vt82c686b_superio_cfg_write(s, 1, 0xde, 1); + s->regs[0xe6] = 0xde; /* Serial port 1 base addr 0x3f8-f */ - vt82c686b_superio_cfg_write(s, 0, 0xe7, 1); - vt82c686b_superio_cfg_write(s, 1, 0xfe, 1); + s->regs[0xe7] = 0xfe; /* Serial port 2 base addr 0x2f8-f */ - vt82c686b_superio_cfg_write(s, 0, 0xe8, 1); - vt82c686b_superio_cfg_write(s, 1, 0xbe, 1); + s->regs[0xe8] = 0xbe; - vt82c686b_superio_cfg_write(s, 0, 0, 1); + vt82c686b_superio_update(s); } static void vt82c686b_superio_init(Object *obj) @@ -429,6 +464,7 @@ static void vt82c686b_superio_class_init(ObjectClass *klass, void *data) sc->parallel.count = 1; sc->ide.count = 0; /* emulated by via-ide */ sc->floppy.count = 1; + dc->vmsd = &vmstate_vt82c686b_superio; } static const TypeInfo vt82c686b_superio_info = { @@ -443,6 +479,33 @@ static const TypeInfo vt82c686b_superio_info = { #define TYPE_VT8231_SUPERIO "vt8231-superio" +static void vt8231_superio_update(ViaSuperIOState *s) +{ + isa_parallel_set_enabled(s->superio.parallel[0], + (s->regs[0xf2] & 0x3) != 3); + isa_serial_set_enabled(s->superio.serial[0], s->regs[0xf2] & BIT(2)); + isa_fdc_set_enabled(s->superio.floppy, s->regs[0xf2] & BIT(4)); + + isa_serial_set_iobase(s->superio.serial[0], (s->regs[0xf4] & 0xfe) << 2); + isa_parallel_set_iobase(s->superio.parallel[0], s->regs[0xf6] << 2); + isa_fdc_set_iobase(s->superio.floppy, (s->regs[0xf7] & 0xfc) << 2); +} + +static int vmstate_vt8231_superio_post_load(void *opaque, int version_id) +{ + ViaSuperIOState *s = opaque; + + vt8231_superio_update(s); + + return 0; +} + +static const VMStateDescription vmstate_vt8231_superio = { + .name = "vt8231_superio", + .version_id = 1, + .post_load = vmstate_vt8231_superio_post_load, +}; + static void vt8231_superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { @@ -465,6 +528,12 @@ static void vt8231_superio_cfg_write(void *opaque, hwaddr addr, case 0xfd: /* ignore write to read only registers */ return; + case 0xf2: + case 0xf4: + case 0xf6 ... 0xf7: + sc->regs[idx] = data; + vt8231_superio_update(sc); + return; default: qemu_log_mask(LOG_UNIMP, "via_superio_cfg: unimplemented register 0x%x\n", idx); @@ -493,19 +562,15 @@ static void vt8231_superio_reset(DeviceState *dev) /* Device revision */ s->regs[0xf1] = 0x01; /* Function select - all disabled */ - vt8231_superio_cfg_write(s, 0, 0xf2, 1); - vt8231_superio_cfg_write(s, 1, 0x03, 1); + s->regs[0xf2] = 0x03; /* Serial port base addr */ - vt8231_superio_cfg_write(s, 0, 0xf4, 1); - vt8231_superio_cfg_write(s, 1, 0xfe, 1); + s->regs[0xf4] = 0xfe; /* Parallel port base addr */ - vt8231_superio_cfg_write(s, 0, 0xf6, 1); - vt8231_superio_cfg_write(s, 1, 0xde, 1); + s->regs[0xf6] = 0xde; /* Floppy ctrl base addr */ - vt8231_superio_cfg_write(s, 0, 0xf7, 1); - vt8231_superio_cfg_write(s, 1, 0xfc, 1); + s->regs[0xf7] = 0xfc; - vt8231_superio_cfg_write(s, 0, 0, 1); + vt8231_superio_update(s); } static void vt8231_superio_init(Object *obj) @@ -513,12 +578,6 @@ static void vt8231_superio_init(Object *obj) VIA_SUPERIO(obj)->io_ops = &vt8231_superio_cfg_ops; } -static uint16_t vt8231_superio_serial_iobase(ISASuperIODevice *sio, - uint8_t index) -{ - return 0x2f8; /* FIXME: This should be settable via registers f2-f4 */ -} - static void vt8231_superio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -526,10 +585,10 @@ static void vt8231_superio_class_init(ObjectClass *klass, void *data) dc->reset = vt8231_superio_reset; sc->serial.count = 1; - sc->serial.get_iobase = vt8231_superio_serial_iobase; sc->parallel.count = 1; sc->ide.count = 0; /* emulated by via-ide */ sc->floppy.count = 1; + dc->vmsd = &vmstate_vt8231_superio; } static const TypeInfo vt8231_superio_info = {