From patchwork Sat Feb 5 17:59:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1588823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=qC3OprRv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JrgGf6jrrz9s9c for ; Sun, 6 Feb 2022 05:02:18 +1100 (AEDT) Received: from localhost ([::1]:33004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGPO4-000777-MV for incoming@patchwork.ozlabs.org; Sat, 05 Feb 2022 13:02:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGPLr-00071z-Ef for qemu-devel@nongnu.org; Sat, 05 Feb 2022 12:59:59 -0500 Received: from [2a00:1450:4864:20::530] (port=42841 helo=mail-ed1-x530.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGPLp-0000yd-DB for qemu-devel@nongnu.org; Sat, 05 Feb 2022 12:59:58 -0500 Received: by mail-ed1-x530.google.com with SMTP id cf2so4458487edb.9 for ; Sat, 05 Feb 2022 09:59:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q3MrjCZrAbDfZ1Y9hI3wwet8JsGPnh1sGD0GDaFDA+s=; b=qC3OprRv9HzJ1HakaiwMPzjqPLzKVude3EFTKhSf0Y4v/W89pjiaR1h8rXJGTEudKW OoKGj2uUUPg/HA5e+izozuv/diyAFB6TS4Id6+zifyBAgZXEHSL/RjH1xfsIDNH5efc/ eTRs0kCbrxLTRpHNELdciRkj4JXA4vHSvBjXJyHXveWvuOspkO+7ixHty5caVhPvzj0u r2pClvAAKt5IGKk41M/rE5HyMqhvwAgs1D+9nN+JYPK0mCc1NErDCDyBK0MpsIxLlVHs DZOPzhWHlvC+GkjCCgg9GHKPujcZWm1SUOqd0v3YQcByyv3v4YpyfJA0kqw4J8/fxpcp I17g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q3MrjCZrAbDfZ1Y9hI3wwet8JsGPnh1sGD0GDaFDA+s=; b=1JVT0EKIoJBzHvqDzJrRiN5SO8TsYY2jn6nkHazI4VpXjdY6rAr0UB3PcW6xBQzyUh qppQPv2BUGLgjG/uo3d3H0pJcmdFLK09G0rngfz01witXEfXrRTSiP0GJiXYNQb9Y6sF m4O/8ijUKWxbcvnik4Prm8WWYClop675aX26d5Pz2lkqShybCb+vhrVEDSR9sMi3Q4hc fqchqUqdKaHpo48+GCnhxFoZ0c/rnH2X602/Tfcg6mOcP/DMq48WHKo/CMozgOE0hEWm 972oxeMt6TmufaYTQ72qUGP9GKmrhE1OV4ZmHnHFbcdb8nzJ/Ocnmnk6bVMlvF9nBxDL DI9w== X-Gm-Message-State: AOAM531xK8Os9YRrSoP5nND765lwSb7daq/H+QefgbRPYLLfrR3RfXot 1FRjmOoaMDfNoF71y/+RLkwbFYOhHg/usw== X-Google-Smtp-Source: ABdhPJzkAVX7ie8So//ttwlUACxak0+jiHsf5i17BED0p9lfK1GVcH+okvYTKuY7U0pQmCX7IUYWTA== X-Received: by 2002:aa7:d993:: with SMTP id u19mr519657eds.293.1644083996018; Sat, 05 Feb 2022 09:59:56 -0800 (PST) Received: from Provence.localdomain (dynamic-089-012-230-134.89.12.pool.telefonica.de. [89.12.230.134]) by smtp.gmail.com with ESMTPSA id e2sm1820660ejr.210.2022.02.05.09.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Feb 2022 09:59:55 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Subject: [PATCH 1/2] isa/piix4: Resolve RTCState attribute Date: Sat, 5 Feb 2022 18:59:12 +0100 Message-Id: <20220205175913.31738-2-shentey@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220205175913.31738-1-shentey@gmail.com> References: <20220205175913.31738-1-shentey@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::530 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=shentey@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, 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: , Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Bernhard Beschow , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Assuming that mc146818_rtc_init() is "syntactic sugar" for code that could be converted into configuration in the future, this patch is a step towards this future by freeing piix4 to care about the inner details of mc146818. Furthermore, by reusing mc146818_rtc_init(), piix4's code becomes more homogenious to other code using the mc146818. So piix4 can be refactored in the same way as code already using mc146818_rtc_init(). Signed-off-by: Bernhard Beschow --- hw/isa/piix4.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 0fe7b69bc4..08b4262467 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -46,7 +46,6 @@ struct PIIX4State { qemu_irq cpu_intr; qemu_irq *isa; - RTCState rtc; /* Reset Control Register */ MemoryRegion rcr_mem; uint8_t rcr; @@ -193,22 +192,11 @@ static void piix4_realize(PCIDevice *dev, Error **errp) i8257_dma_init(isa_bus, 0); /* RTC */ - qdev_prop_set_int32(DEVICE(&s->rtc), "base_year", 2000); - if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) { - return; - } - isa_init_irq(ISA_DEVICE(&s->rtc), &s->rtc.irq, RTC_ISA_IRQ); + mc146818_rtc_init(isa_bus, 2000, NULL); piix4_dev = dev; } -static void piix4_init(Object *obj) -{ - PIIX4State *s = PIIX4_PCI_DEVICE(obj); - - object_initialize(&s->rtc, sizeof(s->rtc), TYPE_MC146818_RTC); -} - static void piix4_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -233,7 +221,6 @@ static const TypeInfo piix4_info = { .name = TYPE_PIIX4_PCI_DEVICE, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PIIX4State), - .instance_init = piix4_init, .class_init = piix4_class_init, .interfaces = (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, From patchwork Sat Feb 5 17:59:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1588824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=HON3ferH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JrgMW4Hywz9s8q for ; Sun, 6 Feb 2022 05:06:31 +1100 (AEDT) Received: from localhost ([::1]:39502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGPS8-0003In-Va for incoming@patchwork.ozlabs.org; Sat, 05 Feb 2022 13:06:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGPLx-0007F8-B9 for qemu-devel@nongnu.org; Sat, 05 Feb 2022 13:00:05 -0500 Received: from [2a00:1450:4864:20::531] (port=39507 helo=mail-ed1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGPLv-00010k-0o for qemu-devel@nongnu.org; Sat, 05 Feb 2022 13:00:04 -0500 Received: by mail-ed1-x531.google.com with SMTP id u18so20186826edt.6 for ; Sat, 05 Feb 2022 10:00:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gdaiRf8PkxIZRVB4nxAd0RX/qVncmh/Pfk2cqHlLhF8=; b=HON3ferHI0+yyBFBDO8y7xjYpyhl+HZ87eyewHOXKtptYFaYTMT9eVOqfVxRCQsjK1 +phR0C1YaQwBaWaloAbjOeg4RH5Xuhdvng6rdeh+sPK9wJgUudF4+4Xa86otnqwJ1O2v LhpkZNH5adnt4BRJEsUfwd8T5ROWZ2jYJT+ZKZnMdyxOsfRKERF1za6e7U8YmRobZoNo 7mDIwbcztoeZ5VgkoKZUwI5CXMns/K3KkLXxJZ36T5v6z/Rupwv0xK0bDDvxfwUnTVXt 8+qpxpbw417w4w67qrgoFDh7Rp9E1zKuwicYzXLFNUK9XR2YrBHKrbp2In5PyB1V1qro cP0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gdaiRf8PkxIZRVB4nxAd0RX/qVncmh/Pfk2cqHlLhF8=; b=eBJAbYPy52G7nfGMaxDmJiJ1pypRkoFziPBomfbMJ28ppwoUov1uVDvimsYJg4JW/+ P96vJtLtYqFSWIjutapSyobgNkE2f7HivGwysvOac+Fp5RSMDL8iAwNBqlMlE1teB9sC vTW03ALDxS25y4TsOEtfKo4nVKFkLnpqUo4pLv86g5tU1E/wTeRzGdTnZHR5wEaUEQuT oVQdV+gvrEmQx8z414Hepumo3SNJgDRCvfuMzXZPHnyMdwx2jC6iqLGIkKlydN57lKs2 p2yCtzdDuGUFGxVbHIX3QhoWeeB/R+I3Bq/JucRNe4hzR62LDPhLM4yzn02MWifjUDSs 9ygQ== X-Gm-Message-State: AOAM532dRtgsOoXByRtyAFcGiBeY58YRg5JPH77xM7FCqkETFxES/aJ0 CpMqHNkqcHkxl6751YNmWJPwFC6OUHO5LA== X-Google-Smtp-Source: ABdhPJwxMtetDhTBdKWQ9PfHMZvvc82n4qQNyEhMbemM3eZKsoO0fdLF9YyB6WSmtxFlArtMNaaGNw== X-Received: by 2002:aa7:dc05:: with SMTP id b5mr5576141edu.197.1644084001431; Sat, 05 Feb 2022 10:00:01 -0800 (PST) Received: from Provence.localdomain (dynamic-089-012-230-134.89.12.pool.telefonica.de. [89.12.230.134]) by smtp.gmail.com with ESMTPSA id e2sm1820660ejr.210.2022.02.05.10.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Feb 2022 10:00:01 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Subject: [PATCH 2/2] mc146818rtc: Unexport RTCState Date: Sat, 5 Feb 2022 18:59:13 +0100 Message-Id: <20220205175913.31738-3-shentey@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220205175913.31738-1-shentey@gmail.com> References: <20220205175913.31738-1-shentey@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::531 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=shentey@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, 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: , Cc: Paolo Bonzini , Bernhard Beschow , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that RTCState isn't used outside mc146818rtc.c any more, it can be unexported to prevent outside code to depend on its details. Signed-off-by: Bernhard Beschow --- hw/rtc/mc146818rtc.c | 34 ++++++++++++++++++++++++++++++++++ include/hw/rtc/mc146818rtc.h | 35 +---------------------------------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index e61a0cced4..e3980ac663 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -26,6 +26,7 @@ #include "qemu/cutils.h" #include "qemu/module.h" #include "qemu/bcd.h" +#include "qemu/queue.h" #include "hw/acpi/aml-build.h" #include "hw/irq.h" #include "hw/qdev-properties.h" @@ -41,7 +42,9 @@ #include "migration/vmstate.h" #include "qapi/error.h" #include "qapi/qapi-events-misc-target.h" +#include "qapi/qapi-types-machine.h" #include "qapi/visitor.h" +#include "qom/object.h" #include "hw/rtc/mc146818rtc_regs.h" #ifdef TARGET_I386 @@ -74,6 +77,37 @@ #define RTC_CLOCK_RATE 32768 #define UIP_HOLD_LENGTH (8 * NANOSECONDS_PER_SECOND / 32768) +OBJECT_DECLARE_SIMPLE_TYPE(RTCState, MC146818_RTC) + +struct RTCState { + ISADevice parent_obj; + + MemoryRegion io; + MemoryRegion coalesced_io; + uint8_t cmos_data[128]; + uint8_t cmos_index; + int32_t base_year; + uint64_t base_rtc; + uint64_t last_update; + int64_t offset; + qemu_irq irq; + int it_shift; + /* periodic timer */ + QEMUTimer *periodic_timer; + int64_t next_periodic_time; + /* update-ended timer */ + QEMUTimer *update_timer; + uint64_t next_alarm_time; + uint16_t irq_reinject_on_ack_count; + uint32_t irq_coalesced; + uint32_t period; + QEMUTimer *coalesced_timer; + Notifier clock_reset_notifier; + LostTickPolicy lost_tick_policy; + Notifier suspend_notifier; + QLIST_ENTRY(RTCState) link; +}; + static void rtc_set_time(RTCState *s); static void rtc_update_time(RTCState *s); static void rtc_set_cmos(RTCState *s, const struct tm *tm); diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h index 5b45b22924..0dc2cb2605 100644 --- a/include/hw/rtc/mc146818rtc.h +++ b/include/hw/rtc/mc146818rtc.h @@ -9,43 +9,10 @@ #ifndef HW_RTC_MC146818RTC_H #define HW_RTC_MC146818RTC_H -#include "qapi/qapi-types-machine.h" -#include "qemu/queue.h" -#include "qemu/timer.h" #include "hw/isa/isa.h" -#include "qom/object.h" +#include "qemu/typedefs.h" #define TYPE_MC146818_RTC "mc146818rtc" -OBJECT_DECLARE_SIMPLE_TYPE(RTCState, MC146818_RTC) - -struct RTCState { - ISADevice parent_obj; - - MemoryRegion io; - MemoryRegion coalesced_io; - uint8_t cmos_data[128]; - uint8_t cmos_index; - int32_t base_year; - uint64_t base_rtc; - uint64_t last_update; - int64_t offset; - qemu_irq irq; - int it_shift; - /* periodic timer */ - QEMUTimer *periodic_timer; - int64_t next_periodic_time; - /* update-ended timer */ - QEMUTimer *update_timer; - uint64_t next_alarm_time; - uint16_t irq_reinject_on_ack_count; - uint32_t irq_coalesced; - uint32_t period; - QEMUTimer *coalesced_timer; - Notifier clock_reset_notifier; - LostTickPolicy lost_tick_policy; - Notifier suspend_notifier; - QLIST_ENTRY(RTCState) link; -}; #define RTC_ISA_IRQ 8 #define RTC_ISA_BASE 0x70