From patchwork Fri Feb 10 23:31:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 652359 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp1244382wrr; Fri, 10 Feb 2023 15:32:09 -0800 (PST) X-Google-Smtp-Source: AK7set8QDzhhgTE3uIDdB1Zr3KThmn7pwszNqvEwiK+fCPRPQ+vIfqyNtm0i6fb/5B3AeFSrBf7T X-Received: by 2002:a05:622a:4cc:b0:3a9:818f:db3d with SMTP id q12-20020a05622a04cc00b003a9818fdb3dmr28368284qtx.53.1676071928920; Fri, 10 Feb 2023 15:32:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676071928; cv=none; d=google.com; s=arc-20160816; b=UD15wywwvT34ArH0ST5jkLmQy0Gm7tCIqe294RFLNxkaUT1XAlCLPT4ExwAygkbSlk RYpGvkKCpwWnvmZ5a4S3cgSt5sSNVsy8xbuxnbPheiyEJp2w8V1gclc4LvKwf5mzVIiD qbSVe5coRU5U1x07Ta1fQJN+7SNqWUBBQrswvvoGU5rD/cIR0C4m+lFgqclVLoWD8Av8 qRvlF1FqpY/IDZg1AbBfpqFp1Ex1s3daCZ7L81+MhgNxCANqkozXyR/rUaCiR/GQo9b2 hKGZgp8fWi6j7BPfk1w34mve4HHsESVp53UUbRkdvEIm7gKP9Lt/Y1WB7T9zfHNrkCEh jTdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Hr4ahbd9BnJloRVtV9Nrdh7BCCM/TxPydcu4B3q+EU0=; b=bbHAQacwaK1Pzq4kFQ3X94LGYcYd/zIpOgcDYETE5X0azszO8M6NYWvxYJuhbvEfRx yL3B2FN8XjLaXcUWwVcmsk31+XR6msjiW+WggrED/8b3sJ0CKurw/eQwwCm25nBoaQti yOYffm6cl7UIeKOKNIiG/pgYhzzuWPnRRzUEX8pwAn2LPrfuPFsj7S2JwDn4pEf54fMd caifeDT6B5AFEFy/jUcyO8y0s6k0xlfMUtP3xWWICmJ5DwWwadQ9sDrJVyvBMB5bXQXW 712ZH9dDZZVf7STsvWFPNXB9r+w7esvDUfFeI/AKGN3XPVLcfiFazAJqK8BgopmrQjGM PC7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H7Ewl9LO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h5-20020ac85845000000b003b86d8b2547si4676374qth.420.2023.02.10.15.32.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Feb 2023 15:32:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H7Ewl9LO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQcrf-0006AC-HL; Fri, 10 Feb 2023 18:31:35 -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 1pQcrd-00068m-6E for qemu-devel@nongnu.org; Fri, 10 Feb 2023 18:31:33 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQcrb-0007qf-5p for qemu-devel@nongnu.org; Fri, 10 Feb 2023 18:31:32 -0500 Received: by mail-wr1-x431.google.com with SMTP id ba1so6673932wrb.5 for ; Fri, 10 Feb 2023 15:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=Hr4ahbd9BnJloRVtV9Nrdh7BCCM/TxPydcu4B3q+EU0=; b=H7Ewl9LOwb8k2lnQujRAsbyCbsV8F+3pJoQFvNNix/r+aXrATJ2QKmy91yD46KYvJg +sIS9voAERzJEOQz4nlAeT1mhV532DPMumyDtwpwoSU2PUjjnsxQclwOpLhHgTXLZWH4 zZKbl4cDG968H57uMtpRhMCQCkq+Jxm4DC7dqwVhHbgvR7+M4z+LhYie3eBKpAWbwZlf Gzm4WTlcZrtr/8tRJK3lIVEr0Nd49X/OhF4P/2xu/dp5Zu7SIqQJdv2lnsv+IfWVUTnt XhU4xJR2AbywsumMMgwef5E2WCzE6O7vizCVvVggvdrq+RHa5W31LVBZXU4Y9ROZhh7D eQ6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Hr4ahbd9BnJloRVtV9Nrdh7BCCM/TxPydcu4B3q+EU0=; b=fbOpGmeKJbThndFiJbdZhPYqkDrXXn9tjjNOq9/LMyFcMscc7WkjW0CV/yTqyDgzo+ MGXY3s7QVuENrY3/+Ac3cHla/qc2HNMsRS6EU4Tzqer4x/IRmT2aLbdsmsRUYdYB7LNu CAgejf8FcRANWrKvMNl5wgEvIuKYDBZdM+hwUrqAsHW8ObVLg4Ygsaj7zMBWvfVsQJl3 +EIB58VfLaiEf0aHNmKtRxHuSUjawLD+07dXcjauLiIGw1liIXg36h6y3ueC3pvw4uWP ojRK2i8JmfNg5EJUDNsZV5F20O0RqqCgz6S6OEX5ez4LofzMGkZdfcKL2iExFFx/uUIz N+YQ== X-Gm-Message-State: AO0yUKUYcMXOoMp0B6mW8hbOxoR+oiXUqQc/DDGH/hs2hchcSfDd2T4g YhvrUykn112RgkAq88R0JMZgd8W1PGx0JINZ X-Received: by 2002:a5d:6203:0:b0:2c1:28dc:1561 with SMTP id y3-20020a5d6203000000b002c128dc1561mr14901627wru.44.1676071889536; Fri, 10 Feb 2023 15:31:29 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id w11-20020adff9cb000000b002c54e9f6bc2sm225092wrr.77.2023.02.10.15.31.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Feb 2023 15:31:29 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , "Michael S. Tsirkin" , Thomas Huth , Eduardo Habkost , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sergio Lopez , Marcel Apfelbaum Subject: [PATCH 2/3] hw/rtc/mc146818rtc: Pass MC146818RtcState instead of ISADevice argument Date: Sat, 11 Feb 2023 00:31:15 +0100 Message-Id: <20230210233116.80311-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230210233116.80311-1-philmd@linaro.org> References: <20230210233116.80311-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org rtc_get_memory() and rtc_set_memory() methods can not take any TYPE_ISA_DEVICE object. They expect a TYPE_MC146818_RTC one. Simplify the API by passing a MC146818RtcState. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/i386/microvm.c | 6 ++---- hw/i386/pc.c | 16 +++++++++------- hw/i386/x86.c | 4 +++- hw/ppc/prep.c | 3 +-- hw/rtc/mc146818rtc.c | 13 ++++++------- include/hw/rtc/mc146818rtc.h | 8 ++++---- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 29f30dd6d3..04b453cde5 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -57,7 +57,7 @@ #define MICROVM_QBOOT_FILENAME "qboot.rom" #define MICROVM_BIOS_FILENAME "bios-microvm.bin" -static void microvm_set_rtc(MicrovmMachineState *mms, ISADevice *s) +static void microvm_set_rtc(MicrovmMachineState *mms, MC146818RtcState *s) { X86MachineState *x86ms = X86_MACHINE(mms); int val; @@ -161,7 +161,6 @@ static void microvm_devices_init(MicrovmMachineState *mms) const char *default_firmware; X86MachineState *x86ms = X86_MACHINE(mms); ISABus *isa_bus; - ISADevice *rtc_state; GSIState *gsi_state; int ioapics; int i; @@ -267,8 +266,7 @@ static void microvm_devices_init(MicrovmMachineState *mms) if (mms->rtc == ON_OFF_AUTO_ON || (mms->rtc == ON_OFF_AUTO_AUTO && !kvm_enabled())) { - rtc_state = mc146818_rtc_init(isa_bus, 2000, NULL); - microvm_set_rtc(mms, rtc_state); + microvm_set_rtc(mms, mc146818_rtc_init(isa_bus, 2000, NULL)); } if (mms->isa_serial) { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 6e592bd969..606686dafc 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -439,7 +439,7 @@ static uint64_t ioportF0_read(void *opaque, hwaddr addr, unsigned size) #define REG_EQUIPMENT_BYTE 0x14 -static void cmos_init_hd(ISADevice *s, int type_ofs, int info_ofs, +static void cmos_init_hd(MC146818RtcState *s, int type_ofs, int info_ofs, int16_t cylinders, int8_t heads, int8_t sectors) { rtc_set_memory(s, type_ofs, 47); @@ -471,7 +471,8 @@ static int boot_device2nibble(char boot_device) return 0; } -static void set_boot_dev(ISADevice *s, const char *boot_device, Error **errp) +static void set_boot_dev(MC146818RtcState *s, const char *boot_device, + Error **errp) { #define PC_MAX_BOOT_DEVICES 3 int nbds, bds[3] = { 0, }; @@ -499,7 +500,7 @@ static void pc_boot_set(void *opaque, const char *boot_device, Error **errp) set_boot_dev(opaque, boot_device, errp); } -static void pc_cmos_init_floppy(ISADevice *rtc_state, ISADevice *floppy) +static void pc_cmos_init_floppy(MC146818RtcState *rtc_state, ISADevice *floppy) { int val, nb, i; FloppyDriveType fd_type[2] = { FLOPPY_DRIVE_TYPE_NONE, @@ -537,7 +538,7 @@ static void pc_cmos_init_floppy(ISADevice *rtc_state, ISADevice *floppy) } typedef struct pc_cmos_init_late_arg { - ISADevice *rtc_state; + MC146818RtcState *rtc_state; BusState *idebus[2]; } pc_cmos_init_late_arg; @@ -604,7 +605,7 @@ static ISADevice *pc_find_fdc0(void) static void pc_cmos_init_late(void *opaque) { pc_cmos_init_late_arg *arg = opaque; - ISADevice *s = arg->rtc_state; + MC146818RtcState *s = arg->rtc_state; int16_t cylinders; int8_t heads, sectors; int val; @@ -646,11 +647,12 @@ static void pc_cmos_init_late(void *opaque) void pc_cmos_init(PCMachineState *pcms, BusState *idebus0, BusState *idebus1, - ISADevice *s) + ISADevice *rtc) { int val; static pc_cmos_init_late_arg arg; X86MachineState *x86ms = X86_MACHINE(pcms); + MC146818RtcState *s = MC146818_RTC(rtc); /* various important CMOS locations needed by PC/Bochs bios */ @@ -1304,7 +1306,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT); rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT); } - *rtc_state = mc146818_rtc_init(isa_bus, 2000, rtc_irq); + *rtc_state = ISA_DEVICE(mc146818_rtc_init(isa_bus, 2000, rtc_irq)); qemu_register_boot_set(pc_boot_set, *rtc_state); diff --git a/hw/i386/x86.c b/hw/i386/x86.c index eaff4227bd..5dbdd75bfc 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -151,8 +151,10 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) } } -void x86_rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count) +void x86_rtc_set_cpus_count(ISADevice *s, uint16_t cpus_count) { + MC146818RtcState *rtc = MC146818_RTC(s); + if (cpus_count > 0xff) { /* * If the number of CPUs can't be represented in 8 bits, the diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index fcbe4c5837..076e2d0d22 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -212,10 +212,9 @@ static int PPC_NVRAM_set_params (Nvram *nvram, uint16_t NVRAM_size, static int prep_set_cmos_checksum(DeviceState *dev, void *opaque) { uint16_t checksum = *(uint16_t *)opaque; - ISADevice *rtc; if (object_dynamic_cast(OBJECT(dev), TYPE_MC146818_RTC)) { - rtc = ISA_DEVICE(dev); + MC146818RtcState *rtc = MC146818_RTC(dev); rtc_set_memory(rtc, 0x2e, checksum & 0xff); rtc_set_memory(rtc, 0x3e, checksum & 0xff); rtc_set_memory(rtc, 0x2f, checksum >> 8); diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index 08f6c0e0c5..478eee97e4 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -739,16 +739,14 @@ static uint64_t cmos_ioport_read(void *opaque, hwaddr addr, } } -void rtc_set_memory(ISADevice *dev, int addr, int val) +void rtc_set_memory(MC146818RtcState *s, int addr, int val) { - MC146818RtcState *s = MC146818_RTC(dev); if (addr >= 0 && addr <= 127) s->cmos_data[addr] = val; } -int rtc_get_memory(ISADevice *dev, int addr) +int rtc_get_memory(MC146818RtcState *s, int addr) { - MC146818RtcState *s = MC146818_RTC(dev); assert(addr >= 0 && addr <= 127); return s->cmos_data[addr]; } @@ -858,7 +856,7 @@ static const VMStateDescription vmstate_rtc = { static void rtc_notify_suspend(Notifier *notifier, void *data) { MC146818RtcState *s = container_of(notifier, MC146818RtcState, suspend_notifier); - rtc_set_memory(ISA_DEVICE(s), 0xF, 0xFE); + rtc_set_memory(s, 0xF, 0xFE); } static const MemoryRegionOps cmos_ops = { @@ -945,7 +943,8 @@ static void rtc_realizefn(DeviceState *dev, Error **errp) QLIST_INSERT_HEAD(&rtc_devices, s, link); } -ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) +MC146818RtcState *mc146818_rtc_init(ISABus *bus, int base_year, + qemu_irq intercept_irq) { DeviceState *dev; ISADevice *isadev; @@ -965,7 +964,7 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) object_property_add_alias(qdev_get_machine(), "rtc-time", OBJECT(isadev), "date"); - return isadev; + return s; } static Property mc146818rtc_properties[] = { diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h index 11631af7e3..a6b0c135c0 100644 --- a/include/hw/rtc/mc146818rtc.h +++ b/include/hw/rtc/mc146818rtc.h @@ -51,10 +51,10 @@ struct MC146818RtcState { #define RTC_ISA_IRQ 8 -ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, - qemu_irq intercept_irq); -void rtc_set_memory(ISADevice *dev, int addr, int val); -int rtc_get_memory(ISADevice *dev, int addr); +MC146818RtcState *mc146818_rtc_init(ISABus *bus, int base_year, + qemu_irq intercept_irq); +void rtc_set_memory(MC146818RtcState *s, int addr, int val); +int rtc_get_memory(MC146818RtcState *s, int addr); void qmp_rtc_reset_reinjection(Error **errp); #endif /* HW_RTC_MC146818RTC_H */