From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624625771945537.4618187280008; Fri, 25 Jun 2021 05:56:11 -0700 (PDT) Received: from localhost ([::1]:54574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwlNS-00016q-R1 for importer@patchew.org; Fri, 25 Jun 2021 08:56:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMG-000757-6k for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:54:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36569) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlME-0004MU-Kg for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:54:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-pMrZzls6MheEhOYfyNclPw-1; Fri, 25 Jun 2021 08:54:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1779D800D62; Fri, 25 Jun 2021 12:54:51 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id C58D46091B; Fri, 25 Jun 2021 12:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624625694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WfXOlf+jKUAYFuH1QZ7zUAcyM96HlipP65ByavaT6XQ=; b=BfY9zOFf/NoceOWzSeGQEeL/XE+hsdk1CtcykEc3L4II8KxJ81al4VDPpsOUj7RBcGhnuq ek5dfRC45/GWYmcPeO1lvrAIMQYjra069DL6QizKilCIWFtNNXyODa9/wVw58BTSg3nFOT WFzZmGOzLwvxsH89y7o/8bnukpwDkZY= X-MC-Unique: pMrZzls6MheEhOYfyNclPw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 1/6] hw/isa/Kconfig: Fix missing dependency ISA_SUPERIO -> FDC Date: Fri, 25 Jun 2021 08:54:36 -0400 Message-Id: <20210625125441.756802-2-jsnow@redhat.com> In-Reply-To: <20210625125441.756802-1-jsnow@redhat.com> References: <20210625125441.756802-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Aleksandar Rikalo , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Max Reitz , Artyom Tarasenko , Thomas Huth , Paolo Bonzini , John Snow , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 isa_superio_realize() calls isa_fdc_init_drives(), which is defined in hw/block/fdc.c, so ISA_SUPERIO needs to select the FDC symbol. Reported-by: John Snow Reviewed-by: Thomas Huth Acked-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210614193220.2007159-2-philmd@redhat.com Fixes: c0ff3795143 ("Introduce a CONFIG_ISA_SUPERIO switch for isa-superio.= c") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- hw/isa/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig index 55e0003ce4..7216f66a54 100644 --- a/hw/isa/Kconfig +++ b/hw/isa/Kconfig @@ -17,6 +17,7 @@ config ISA_SUPERIO bool select ISA_BUS select PCKBD + select FDC =20 config PC87312 bool --=20 2.31.1 From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624625938871200.64804033347866; Fri, 25 Jun 2021 05:58:58 -0700 (PDT) Received: from localhost ([::1]:33646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwlQ9-0005y1-1P for importer@patchew.org; Fri, 25 Jun 2021 08:58:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlML-0007GA-3g for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27783) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMI-0004Nn-4m for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-BB4uQZvePB-XQ1xXpyn5MQ-1; Fri, 25 Jun 2021 08:54:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A352F8C874E; Fri, 25 Jun 2021 12:54:53 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62CF960CEC; Fri, 25 Jun 2021 12:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624625697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/hI4Px8CRZKesi/eJF/+0SNp6iGf+qkEIqQy/gKgzps=; b=FCNn5NhBdVUSFBCFCFnpoZGRFaxDkpir/zVxa+jRNswDOHH1zKnlFvUwNgHnQKfGCybogz 5D6LNWEVveSldXgfhAgdI8Ak1IfnteJ/fULaD0SgfeHzoPEtMp1LILo87A9S2e3a70ozz1 n7ThasJV317cYEVCxymcn5YCGeDnRgU= X-MC-Unique: BB4uQZvePB-XQ1xXpyn5MQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 2/6] hw/block/fdc: Replace disabled fprintf() by trace event Date: Fri, 25 Jun 2021 08:54:37 -0400 Message-Id: <20210625125441.756802-3-jsnow@redhat.com> In-Reply-To: <20210625125441.756802-1-jsnow@redhat.com> References: <20210625125441.756802-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Aleksandar Rikalo , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Max Reitz , Artyom Tarasenko , Paolo Bonzini , John Snow , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Reviewed-by: John Snow Acked-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Acked-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210614193220.2007159-3-philmd@redhat.com Signed-off-by: John Snow --- hw/block/fdc.c | 7 +------ hw/block/trace-events | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index a825c2acba..1d3a047367 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -1242,12 +1242,7 @@ static void fdctrl_external_reset_isa(DeviceState *d) =20 static void fdctrl_handle_tc(void *opaque, int irq, int level) { - //FDCtrl *s =3D opaque; - - if (level) { - // XXX - FLOPPY_DPRINTF("TC pulsed\n"); - } + trace_fdctrl_tc_pulse(level); } =20 /* Change IRQ state */ diff --git a/hw/block/trace-events b/hw/block/trace-events index 70bed9ddb7..6a0d973805 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -3,6 +3,7 @@ # fdc.c fdc_ioport_read(uint8_t reg, uint8_t value) "read reg 0x%02x val 0x%02x" fdc_ioport_write(uint8_t reg, uint8_t value) "write reg 0x%02x val 0x%02x" +fdctrl_tc_pulse(int level) "TC pulse: %u" =20 # pflash_cfi01.c # pflash_cfi02.c --=20 2.31.1 From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624625939131942.7262219085402; Fri, 25 Jun 2021 05:58:59 -0700 (PDT) Received: from localhost ([::1]:33656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwlQ9-0005yL-W4 for importer@patchew.org; Fri, 25 Jun 2021 08:58:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMN-0007NA-42 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36087) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMJ-0004Om-Lw for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-86-N4yefwUtNASTi1XM-NaMrw-1; Fri, 25 Jun 2021 08:54:57 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF2831084F4B; Fri, 25 Jun 2021 12:54:55 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0A8B6091B; Fri, 25 Jun 2021 12:54:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624625699; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Js4++Apqx0GrEMnIJ0e4BLu1+pP3R9isU1O3JNbelWU=; b=MBNVmQ5r2t0bwfBL/OOHlQ3rcO6dlJWThQ5jfjy2gCFolPuhGOkbPN9CVknOK653sjFb96 ZlTW4xlW5NFy7lTV3CNGRyOQOQ0UB9NqrRKs8IjOHKWc0W0+xj5k10iMNkG4Lv/ZYW9/ZT DekWz8AaEfHeaKUi4L5Y39cRf1bwu4s= X-MC-Unique: N4yefwUtNASTi1XM-NaMrw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 3/6] hw/block/fdc: Declare shared prototypes in fdc-internal.h Date: Fri, 25 Jun 2021 08:54:38 -0400 Message-Id: <20210625125441.756802-4-jsnow@redhat.com> In-Reply-To: <20210625125441.756802-1-jsnow@redhat.com> References: <20210625125441.756802-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Aleksandar Rikalo , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Max Reitz , Artyom Tarasenko , Paolo Bonzini , John Snow , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 We want to extract ISA/SysBus code from the generic fdc.c file. First, declare the prototypes we will access from the new units into a new local header: "fdc-internal.h". Acked-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Acked-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210614193220.2007159-4-philmd@redhat.com Signed-off-by: John Snow --- hw/block/fdc-internal.h | 158 ++++++++++++++++++++++++++++++++++++++++ hw/block/fdc.c | 131 +++------------------------------ MAINTAINERS | 1 + 3 files changed, 168 insertions(+), 122 deletions(-) create mode 100644 hw/block/fdc-internal.h diff --git a/hw/block/fdc-internal.h b/hw/block/fdc-internal.h new file mode 100644 index 0000000000..036392e9fc --- /dev/null +++ b/hw/block/fdc-internal.h @@ -0,0 +1,158 @@ +/* + * QEMU Floppy disk emulator (Intel 82078) + * + * Copyright (c) 2003, 2007 Jocelyn Mayer + * Copyright (c) 2008 Herv=C3=A9 Poussineau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#ifndef HW_BLOCK_FDC_INTERNAL_H +#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" + +typedef struct FDCtrl FDCtrl; + +/* Floppy bus emulation */ + +typedef struct FloppyBus { + BusState bus; + FDCtrl *fdc; +} FloppyBus; + +/* Floppy disk drive emulation */ + +typedef enum FDriveRate { + FDRIVE_RATE_500K =3D 0x00, /* 500 Kbps */ + FDRIVE_RATE_300K =3D 0x01, /* 300 Kbps */ + FDRIVE_RATE_250K =3D 0x02, /* 250 Kbps */ + FDRIVE_RATE_1M =3D 0x03, /* 1 Mbps */ +} FDriveRate; + +typedef enum FDriveSize { + FDRIVE_SIZE_UNKNOWN, + FDRIVE_SIZE_350, + FDRIVE_SIZE_525, +} FDriveSize; + +typedef struct FDFormat { + FloppyDriveType drive; + uint8_t last_sect; + uint8_t max_track; + uint8_t max_head; + FDriveRate rate; +} FDFormat; + +typedef enum FDiskFlags { + FDISK_DBL_SIDES =3D 0x01, +} FDiskFlags; + +typedef struct FDrive { + FDCtrl *fdctrl; + BlockBackend *blk; + BlockConf *conf; + /* Drive status */ + FloppyDriveType drive; /* CMOS drive type */ + uint8_t perpendicular; /* 2.88 MB access mode */ + /* Position */ + uint8_t head; + uint8_t track; + uint8_t sect; + /* Media */ + FloppyDriveType disk; /* Current disk type */ + FDiskFlags flags; + uint8_t last_sect; /* Nb sector per track */ + uint8_t max_track; /* Nb of tracks */ + uint16_t bps; /* Bytes per sector */ + uint8_t ro; /* Is read-only */ + uint8_t media_changed; /* Is media changed */ + uint8_t media_rate; /* Data rate of medium */ + + bool media_validated; /* Have we validated the media? */ +} FDrive; + +struct FDCtrl { + MemoryRegion iomem; + qemu_irq irq; + /* Controller state */ + QEMUTimer *result_timer; + int dma_chann; + uint8_t phase; + IsaDma *dma; + /* Controller's identification */ + uint8_t version; + /* HW */ + uint8_t sra; + uint8_t srb; + uint8_t dor; + uint8_t dor_vmstate; /* only used as temp during vmstate */ + uint8_t tdr; + uint8_t dsr; + uint8_t msr; + uint8_t cur_drv; + uint8_t status0; + uint8_t status1; + uint8_t status2; + /* Command FIFO */ + uint8_t *fifo; + int32_t fifo_size; + uint32_t data_pos; + uint32_t data_len; + uint8_t data_state; + uint8_t data_dir; + uint8_t eot; /* last wanted sector */ + /* States kept only to be returned back */ + /* precompensation */ + uint8_t precomp_trk; + uint8_t config; + uint8_t lock; + /* Power down config (also with status regB access mode */ + uint8_t pwrd; + /* Floppy drives */ + FloppyBus bus; + uint8_t num_floppies; + FDrive drives[MAX_FD]; + struct { + FloppyDriveType type; + } qdev_for_drives[MAX_FD]; + int reset_sensei; + FloppyDriveType fallback; /* type=3Dauto failure fallback */ + /* Timers state */ + uint8_t timer0; + uint8_t timer1; + PortioList portio_list; +}; + +extern const FDFormat fd_formats[]; +extern const VMStateDescription vmstate_fdc; + +uint32_t fdctrl_read(void *opaque, uint32_t reg); +void fdctrl_write(void *opaque, uint32_t reg, uint32_t value); +void fdctrl_reset(FDCtrl *fdctrl, int do_irq); +void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp); + +int fdctrl_transfer_handler(void *opaque, int nchan, int dma_pos, int dma_= len); + +void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds); + +#endif diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 1d3a047367..20ddeb98d8 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -48,6 +48,7 @@ #include "qemu/module.h" #include "trace.h" #include "qom/object.h" +#include "fdc-internal.h" =20 /********************************************************/ /* debug Floppy devices */ @@ -68,15 +69,8 @@ #define TYPE_FLOPPY_BUS "floppy-bus" OBJECT_DECLARE_SIMPLE_TYPE(FloppyBus, FLOPPY_BUS) =20 -typedef struct FDCtrl FDCtrl; -typedef struct FDrive FDrive; static FDrive *get_drv(FDCtrl *fdctrl, int unit); =20 -struct FloppyBus { - BusState bus; - FDCtrl *fdc; -}; - static const TypeInfo floppy_bus_info =3D { .name =3D TYPE_FLOPPY_BUS, .parent =3D TYPE_BUS, @@ -93,32 +87,11 @@ static void floppy_bus_create(FDCtrl *fdc, FloppyBus *b= us, DeviceState *dev) /********************************************************/ /* Floppy drive emulation */ =20 -typedef enum FDriveRate { - FDRIVE_RATE_500K =3D 0x00, /* 500 Kbps */ - FDRIVE_RATE_300K =3D 0x01, /* 300 Kbps */ - FDRIVE_RATE_250K =3D 0x02, /* 250 Kbps */ - FDRIVE_RATE_1M =3D 0x03, /* 1 Mbps */ -} FDriveRate; - -typedef enum FDriveSize { - FDRIVE_SIZE_UNKNOWN, - FDRIVE_SIZE_350, - FDRIVE_SIZE_525, -} FDriveSize; - -typedef struct FDFormat { - FloppyDriveType drive; - uint8_t last_sect; - uint8_t max_track; - uint8_t max_head; - FDriveRate rate; -} FDFormat; - /* In many cases, the total sector size of a format is enough to uniquely * identify it. However, there are some total sector collisions between * formats of different physical size, and these are noted below by * highlighting the total sector size for entries with collisions. */ -static const FDFormat fd_formats[] =3D { +const FDFormat fd_formats[] =3D { /* First entry is default format */ /* 1.44 MB 3"1/2 floppy disks */ { FLOPPY_DRIVE_TYPE_144, 18, 80, 1, FDRIVE_RATE_500K, }, /* 3.5" 2880 = */ @@ -186,35 +159,6 @@ static FDriveSize drive_size(FloppyDriveType drive) #define FD_SECTOR_SC 2 /* Sector size code */ #define FD_RESET_SENSEI_COUNT 4 /* Number of sense interrupts on RESET = */ =20 -/* Floppy disk drive emulation */ -typedef enum FDiskFlags { - FDISK_DBL_SIDES =3D 0x01, -} FDiskFlags; - -struct FDrive { - FDCtrl *fdctrl; - BlockBackend *blk; - BlockConf *conf; - /* Drive status */ - FloppyDriveType drive; /* CMOS drive type */ - uint8_t perpendicular; /* 2.88 MB access mode */ - /* Position */ - uint8_t head; - uint8_t track; - uint8_t sect; - /* Media */ - FloppyDriveType disk; /* Current disk type */ - FDiskFlags flags; - uint8_t last_sect; /* Nb sector per track */ - uint8_t max_track; /* Nb of tracks */ - uint16_t bps; /* Bytes per sector */ - uint8_t ro; /* Is read-only */ - uint8_t media_changed; /* Is media changed */ - uint8_t media_rate; /* Data rate of medium */ - - bool media_validated; /* Have we validated the media? */ -}; - =20 static FloppyDriveType get_fallback_drive_type(FDrive *drv); =20 @@ -626,10 +570,7 @@ static const TypeInfo floppy_drive_info =3D { /********************************************************/ /* Intel 82078 floppy disk controller emulation */ =20 -static void fdctrl_reset(FDCtrl *fdctrl, int do_irq); static void fdctrl_to_command_phase(FDCtrl *fdctrl); -static int fdctrl_transfer_handler (void *opaque, int nchan, - int dma_pos, int dma_len); static void fdctrl_raise_irq(FDCtrl *fdctrl); static FDrive *get_cur_drv(FDCtrl *fdctrl); =20 @@ -828,58 +769,6 @@ enum { #define FD_MULTI_TRACK(state) ((state) & FD_STATE_MULTI) #define FD_FORMAT_CMD(state) ((state) & FD_STATE_FORMAT) =20 -struct FDCtrl { - MemoryRegion iomem; - qemu_irq irq; - /* Controller state */ - QEMUTimer *result_timer; - int dma_chann; - uint8_t phase; - IsaDma *dma; - /* Controller's identification */ - uint8_t version; - /* HW */ - uint8_t sra; - uint8_t srb; - uint8_t dor; - uint8_t dor_vmstate; /* only used as temp during vmstate */ - uint8_t tdr; - uint8_t dsr; - uint8_t msr; - uint8_t cur_drv; - uint8_t status0; - uint8_t status1; - uint8_t status2; - /* Command FIFO */ - uint8_t *fifo; - int32_t fifo_size; - uint32_t data_pos; - uint32_t data_len; - uint8_t data_state; - uint8_t data_dir; - uint8_t eot; /* last wanted sector */ - /* States kept only to be returned back */ - /* precompensation */ - uint8_t precomp_trk; - uint8_t config; - uint8_t lock; - /* Power down config (also with status regB access mode */ - uint8_t pwrd; - /* Floppy drives */ - FloppyBus bus; - uint8_t num_floppies; - FDrive drives[MAX_FD]; - struct { - FloppyDriveType type; - } qdev_for_drives[MAX_FD]; - int reset_sensei; - FloppyDriveType fallback; /* type=3Dauto failure fallback */ - /* Timers state */ - uint8_t timer0; - uint8_t timer1; - PortioList portio_list; -}; - static FloppyDriveType get_fallback_drive_type(FDrive *drv) { return drv->fdctrl->fallback; @@ -909,7 +798,7 @@ struct FDCtrlISABus { int32_t bootindexB; }; =20 -static uint32_t fdctrl_read (void *opaque, uint32_t reg) +uint32_t fdctrl_read(void *opaque, uint32_t reg) { FDCtrl *fdctrl =3D opaque; uint32_t retval; @@ -946,7 +835,7 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg) return retval; } =20 -static void fdctrl_write (void *opaque, uint32_t reg, uint32_t value) +void fdctrl_write(void *opaque, uint32_t reg, uint32_t value) { FDCtrl *fdctrl =3D opaque; =20 @@ -1178,7 +1067,7 @@ static const VMStateDescription vmstate_fdc_phase =3D= { } }; =20 -static const VMStateDescription vmstate_fdc =3D { +const VMStateDescription vmstate_fdc =3D { .name =3D "fdc", .version_id =3D 2, .minimum_version_id =3D 2, @@ -1268,7 +1157,7 @@ static void fdctrl_raise_irq(FDCtrl *fdctrl) } =20 /* Reset controller */ -static void fdctrl_reset(FDCtrl *fdctrl, int do_irq) +void fdctrl_reset(FDCtrl *fdctrl, int do_irq) { int i; =20 @@ -1747,8 +1636,7 @@ static void fdctrl_start_transfer_del(FDCtrl *fdctrl,= int direction) } =20 /* handlers for DMA transfers */ -static int fdctrl_transfer_handler (void *opaque, int nchan, - int dma_pos, int dma_len) +int fdctrl_transfer_handler(void *opaque, int nchan, int dma_pos, int dma_= len) { FDCtrl *fdctrl; FDrive *cur_drv; @@ -2484,7 +2372,7 @@ static void fdctrl_result_timer(void *opaque) =20 /* Init functions */ =20 -static void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds) +void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds) { DeviceState *dev; int i; @@ -2542,8 +2430,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, fdctrl_init_drives(&sys->state.bus, fds); } =20 -static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, - Error **errp) +void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp) { int i, j; FDrive *drive; diff --git a/MAINTAINERS b/MAINTAINERS index 3443d2a5b5..0dee966a31 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1671,6 +1671,7 @@ M: John Snow L: qemu-block@nongnu.org S: Supported F: hw/block/fdc.c +F: hw/block/fdc-internal.h F: include/hw/block/fdc.h F: tests/qtest/fdc-test.c T: git https://gitlab.com/jsnow/qemu.git ide --=20 2.31.1 From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624625799093535.6876566317117; Fri, 25 Jun 2021 05:56:39 -0700 (PDT) Received: from localhost ([::1]:55548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwlNs-0001l1-EB for importer@patchew.org; Fri, 25 Jun 2021 08:56:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMS-0007ds-LS for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49437) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMN-0004Qg-Rq for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-541-untqJu1ONWKLb8xljFbZeg-1; Fri, 25 Jun 2021 08:55:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46CE7804140; Fri, 25 Jun 2021 12:54:59 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEB2760C9B; Fri, 25 Jun 2021 12:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624625703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6E/YmOrcD28IdFUDKI6A/KZi/OUy/ZFZdIIFaHoXOkE=; b=B7XsO6zAgDbBOCuOfnBanlSsJBvr7CY3TJWhUnSa60AofKlCVUYWBX4zkonyOZ61QyfecZ /Y2W9R7BNj7RhnTnkBUGjdtMgG0dBvAb/zykB47fuEKnE3fxf5//po75Vm6i3du/53ICy+ Sy5oQVUkxYNnC0TN1vsnui5I5P6OIEY= X-MC-Unique: untqJu1ONWKLb8xljFbZeg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 4/6] hw/block/fdc: Extract ISA floppy controllers to fdc-isa.c Date: Fri, 25 Jun 2021 08:54:39 -0400 Message-Id: <20210625125441.756802-5-jsnow@redhat.com> In-Reply-To: <20210625125441.756802-1-jsnow@redhat.com> References: <20210625125441.756802-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Aleksandar Rikalo , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Max Reitz , Artyom Tarasenko , Paolo Bonzini , John Snow , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Some machines use floppy controllers via the SysBus interface, and don't need to pull in all the ISA code. Extract the ISA specific code to a new unit: fdc-isa.c, and add a new Kconfig symbol: "FDC_ISA". This allows us to remove the FIXME from commit dd0ff8191ab ("isa: express SuperIO dependencies with Kconfig"). Reviewed-by: John Snow Acked-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Acked-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210614193220.2007159-5-philmd@redhat.com Signed-off-by: John Snow --- hw/block/fdc-isa.c | 319 +++++++++++++++++++++++++++++++++++++++++++ hw/block/fdc.c | 265 ----------------------------------- MAINTAINERS | 1 + hw/block/Kconfig | 8 +- hw/block/meson.build | 1 + hw/i386/Kconfig | 2 +- hw/isa/Kconfig | 8 +- hw/sparc64/Kconfig | 2 +- 8 files changed, 332 insertions(+), 274 deletions(-) create mode 100644 hw/block/fdc-isa.c diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c new file mode 100644 index 0000000000..0e22a10732 --- /dev/null +++ b/hw/block/fdc-isa.c @@ -0,0 +1,319 @@ +/* + * QEMU Floppy disk emulator (Intel 82078) + * + * Copyright (c) 2003, 2007 Jocelyn Mayer + * Copyright (c) 2008 Herv=C3=A9 Poussineau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +/* + * The controller is used in Sun4m systems in a slightly different + * way. There are changes in DOR register and DMA is not available. + */ + +#include "qemu/osdep.h" +#include "hw/block/fdc.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" +#include "hw/acpi/aml-build.h" +#include "hw/irq.h" +#include "hw/isa/isa.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" +#include "migration/vmstate.h" +#include "hw/block/block.h" +#include "sysemu/block-backend.h" +#include "sysemu/blockdev.h" +#include "sysemu/sysemu.h" +#include "qemu/log.h" +#include "qemu/main-loop.h" +#include "qemu/module.h" +#include "trace.h" +#include "qom/object.h" +#include "fdc-internal.h" + +OBJECT_DECLARE_SIMPLE_TYPE(FDCtrlISABus, ISA_FDC) + +struct FDCtrlISABus { + /*< private >*/ + ISADevice parent_obj; + /*< public >*/ + + uint32_t iobase; + uint32_t irq; + uint32_t dma; + struct FDCtrl state; + int32_t bootindexA; + int32_t bootindexB; +}; + +static void fdctrl_external_reset_isa(DeviceState *d) +{ + FDCtrlISABus *isa =3D ISA_FDC(d); + FDCtrl *s =3D &isa->state; + + fdctrl_reset(s, 0); +} + +void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds) +{ + fdctrl_init_drives(&ISA_FDC(fdc)->state.bus, fds); +} + +static const MemoryRegionPortio fdc_portio_list[] =3D { + { 1, 5, 1, .read =3D fdctrl_read, .write =3D fdctrl_write }, + { 7, 1, 1, .read =3D fdctrl_read, .write =3D fdctrl_write }, + PORTIO_END_OF_LIST(), +}; + +static void isabus_fdc_realize(DeviceState *dev, Error **errp) +{ + ISADevice *isadev =3D ISA_DEVICE(dev); + FDCtrlISABus *isa =3D ISA_FDC(dev); + FDCtrl *fdctrl =3D &isa->state; + Error *err =3D NULL; + + isa_register_portio_list(isadev, &fdctrl->portio_list, + isa->iobase, fdc_portio_list, fdctrl, + "fdc"); + + isa_init_irq(isadev, &fdctrl->irq, isa->irq); + fdctrl->dma_chann =3D isa->dma; + if (fdctrl->dma_chann !=3D -1) { + IsaDmaClass *k; + fdctrl->dma =3D isa_get_dma(isa_bus_from_device(isadev), isa->dma); + if (!fdctrl->dma) { + error_setg(errp, "ISA controller does not support DMA"); + return; + } + k =3D ISADMA_GET_CLASS(fdctrl->dma); + k->register_channel(fdctrl->dma, fdctrl->dma_chann, + &fdctrl_transfer_handler, fdctrl); + } + + qdev_set_legacy_instance_id(dev, isa->iobase, 2); + + fdctrl_realize_common(dev, fdctrl, &err); + if (err !=3D NULL) { + error_propagate(errp, err); + return; + } +} + +FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i) +{ + FDCtrlISABus *isa =3D ISA_FDC(fdc); + + return isa->state.drives[i].drive; +} + +static void isa_fdc_get_drive_max_chs(FloppyDriveType type, uint8_t *maxc, + uint8_t *maxh, uint8_t *maxs) +{ + const FDFormat *fdf; + + *maxc =3D *maxh =3D *maxs =3D 0; + for (fdf =3D fd_formats; fdf->drive !=3D FLOPPY_DRIVE_TYPE_NONE; fdf++= ) { + if (fdf->drive !=3D type) { + continue; + } + if (*maxc < fdf->max_track) { + *maxc =3D fdf->max_track; + } + if (*maxh < fdf->max_head) { + *maxh =3D fdf->max_head; + } + if (*maxs < fdf->last_sect) { + *maxs =3D fdf->last_sect; + } + } + (*maxc)--; +} + +static Aml *build_fdinfo_aml(int idx, FloppyDriveType type) +{ + Aml *dev, *fdi; + uint8_t maxc, maxh, maxs; + + isa_fdc_get_drive_max_chs(type, &maxc, &maxh, &maxs); + + dev =3D aml_device("FLP%c", 'A' + idx); + + aml_append(dev, aml_name_decl("_ADR", aml_int(idx))); + + fdi =3D aml_package(16); + aml_append(fdi, aml_int(idx)); /* Drive Number */ + aml_append(fdi, + aml_int(cmos_get_fd_drive_type(type))); /* Device Type */ + /* + * the values below are the limits of the drive, and are thus independ= ent + * of the inserted media + */ + aml_append(fdi, aml_int(maxc)); /* Maximum Cylinder Number */ + aml_append(fdi, aml_int(maxs)); /* Maximum Sector Number */ + aml_append(fdi, aml_int(maxh)); /* Maximum Head Number */ + /* + * SeaBIOS returns the below values for int 0x13 func 0x08 regardless = of + * the drive type, so shall we + */ + aml_append(fdi, aml_int(0xAF)); /* disk_specify_1 */ + aml_append(fdi, aml_int(0x02)); /* disk_specify_2 */ + aml_append(fdi, aml_int(0x25)); /* disk_motor_wait */ + aml_append(fdi, aml_int(0x02)); /* disk_sector_siz */ + aml_append(fdi, aml_int(0x12)); /* disk_eot */ + aml_append(fdi, aml_int(0x1B)); /* disk_rw_gap */ + aml_append(fdi, aml_int(0xFF)); /* disk_dtl */ + aml_append(fdi, aml_int(0x6C)); /* disk_formt_gap */ + aml_append(fdi, aml_int(0xF6)); /* disk_fill */ + aml_append(fdi, aml_int(0x0F)); /* disk_head_sttl */ + aml_append(fdi, aml_int(0x08)); /* disk_motor_strt */ + + aml_append(dev, aml_name_decl("_FDI", fdi)); + return dev; +} + +int cmos_get_fd_drive_type(FloppyDriveType fd0) +{ + int val; + + switch (fd0) { + case FLOPPY_DRIVE_TYPE_144: + /* 1.44 Mb 3"5 drive */ + val =3D 4; + break; + case FLOPPY_DRIVE_TYPE_288: + /* 2.88 Mb 3"5 drive */ + val =3D 5; + break; + case FLOPPY_DRIVE_TYPE_120: + /* 1.2 Mb 5"5 drive */ + val =3D 2; + break; + case FLOPPY_DRIVE_TYPE_NONE: + default: + val =3D 0; + break; + } + return val; +} + +static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope) +{ + Aml *dev; + Aml *crs; + int i; + +#define ACPI_FDE_MAX_FD 4 + uint32_t fde_buf[5] =3D { + 0, 0, 0, 0, /* presence of floppy drives #0 - #3 */ + cpu_to_le32(2) /* tape presence (2 =3D=3D never present) */ + }; + + crs =3D aml_resource_template(); + aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04)); + aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01)); + aml_append(crs, aml_irq_no_flags(6)); + aml_append(crs, + aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2)); + + dev =3D aml_device("FDC0"); + aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700"))); + aml_append(dev, aml_name_decl("_CRS", crs)); + + for (i =3D 0; i < MIN(MAX_FD, ACPI_FDE_MAX_FD); i++) { + FloppyDriveType type =3D isa_fdc_get_drive_type(isadev, i); + + if (type < FLOPPY_DRIVE_TYPE_NONE) { + fde_buf[i] =3D cpu_to_le32(1); /* drive present */ + aml_append(dev, build_fdinfo_aml(i, type)); + } + } + aml_append(dev, aml_name_decl("_FDE", + aml_buffer(sizeof(fde_buf), (uint8_t *)fde_buf))); + + aml_append(scope, dev); +} + +static const VMStateDescription vmstate_isa_fdc =3D { + .name =3D "fdc", + .version_id =3D 2, + .minimum_version_id =3D 2, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(state, FDCtrlISABus, 0, vmstate_fdc, FDCtrl), + VMSTATE_END_OF_LIST() + } +}; + +static Property isa_fdc_properties[] =3D { + DEFINE_PROP_UINT32("iobase", FDCtrlISABus, iobase, 0x3f0), + DEFINE_PROP_UINT32("irq", FDCtrlISABus, irq, 6), + DEFINE_PROP_UINT32("dma", FDCtrlISABus, dma, 2), + DEFINE_PROP_SIGNED("fdtypeA", FDCtrlISABus, state.qdev_for_drives[0].t= ype, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_SIGNED("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].t= ype, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_SIGNED("fallback", FDCtrlISABus, state.fallback, + FLOPPY_DRIVE_TYPE_288, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_END_OF_LIST(), +}; + +static void isabus_fdc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ISADeviceClass *isa =3D ISA_DEVICE_CLASS(klass); + + dc->realize =3D isabus_fdc_realize; + dc->fw_name =3D "fdc"; + dc->reset =3D fdctrl_external_reset_isa; + dc->vmsd =3D &vmstate_isa_fdc; + isa->build_aml =3D fdc_isa_build_aml; + device_class_set_props(dc, isa_fdc_properties); + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); +} + +static void isabus_fdc_instance_init(Object *obj) +{ + FDCtrlISABus *isa =3D ISA_FDC(obj); + + device_add_bootindex_property(obj, &isa->bootindexA, + "bootindexA", "/floppy@0", + DEVICE(obj)); + device_add_bootindex_property(obj, &isa->bootindexB, + "bootindexB", "/floppy@1", + DEVICE(obj)); +} + +static const TypeInfo isa_fdc_info =3D { + .name =3D TYPE_ISA_FDC, + .parent =3D TYPE_ISA_DEVICE, + .instance_size =3D sizeof(FDCtrlISABus), + .class_init =3D isabus_fdc_class_init, + .instance_init =3D isabus_fdc_instance_init, +}; + +static void isa_fdc_register_types(void) +{ + type_register_static(&isa_fdc_info); +} + +type_init(isa_fdc_register_types) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 20ddeb98d8..aa70eb97c6 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -32,7 +32,6 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/timer.h" -#include "hw/acpi/aml-build.h" #include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" @@ -785,19 +784,6 @@ struct FDCtrlSysBus { struct FDCtrl state; }; =20 -OBJECT_DECLARE_SIMPLE_TYPE(FDCtrlISABus, ISA_FDC) - -struct FDCtrlISABus { - ISADevice parent_obj; - - uint32_t iobase; - uint32_t irq; - uint32_t dma; - struct FDCtrl state; - int32_t bootindexA; - int32_t bootindexB; -}; - uint32_t fdctrl_read(void *opaque, uint32_t reg) { FDCtrl *fdctrl =3D opaque; @@ -1121,14 +1107,6 @@ static void fdctrl_external_reset_sysbus(DeviceState= *d) fdctrl_reset(s, 0); } =20 -static void fdctrl_external_reset_isa(DeviceState *d) -{ - FDCtrlISABus *isa =3D ISA_FDC(d); - FDCtrl *s =3D &isa->state; - - fdctrl_reset(s, 0); -} - static void fdctrl_handle_tc(void *opaque, int irq, int level) { trace_fdctrl_tc_pulse(level); @@ -2389,11 +2367,6 @@ void fdctrl_init_drives(FloppyBus *bus, DriveInfo **= fds) } } =20 -void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds) -{ - fdctrl_init_drives(&ISA_FDC(fdc)->state.bus, fds); -} - void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, hwaddr mmio_base, DriveInfo **fds) { @@ -2464,14 +2437,6 @@ void fdctrl_realize_common(DeviceState *dev, FDCtrl = *fdctrl, Error **errp) fdctrl->config =3D FD_CONFIG_EIS | FD_CONFIG_EFIFO; /* Implicit seek, = polling & FIFO enabled */ fdctrl->num_floppies =3D MAX_FD; =20 - if (fdctrl->dma_chann !=3D -1) { - IsaDmaClass *k; - assert(fdctrl->dma); - k =3D ISADMA_GET_CLASS(fdctrl->dma); - k->register_channel(fdctrl->dma, fdctrl->dma_chann, - &fdctrl_transfer_handler, fdctrl); - } - floppy_bus_create(fdctrl, &fdctrl->bus, dev); =20 for (i =3D 0; i < MAX_FD; i++) { @@ -2482,41 +2447,6 @@ void fdctrl_realize_common(DeviceState *dev, FDCtrl = *fdctrl, Error **errp) } } =20 -static const MemoryRegionPortio fdc_portio_list[] =3D { - { 1, 5, 1, .read =3D fdctrl_read, .write =3D fdctrl_write }, - { 7, 1, 1, .read =3D fdctrl_read, .write =3D fdctrl_write }, - PORTIO_END_OF_LIST(), -}; - -static void isabus_fdc_realize(DeviceState *dev, Error **errp) -{ - ISADevice *isadev =3D ISA_DEVICE(dev); - FDCtrlISABus *isa =3D ISA_FDC(dev); - FDCtrl *fdctrl =3D &isa->state; - Error *err =3D NULL; - - isa_register_portio_list(isadev, &fdctrl->portio_list, - isa->iobase, fdc_portio_list, fdctrl, - "fdc"); - - isa_init_irq(isadev, &fdctrl->irq, isa->irq); - fdctrl->dma_chann =3D isa->dma; - if (fdctrl->dma_chann !=3D -1) { - fdctrl->dma =3D isa_get_dma(isa_bus_from_device(isadev), isa->dma); - if (!fdctrl->dma) { - error_setg(errp, "ISA controller does not support DMA"); - return; - } - } - - qdev_set_legacy_instance_id(dev, isa->iobase, 2); - fdctrl_realize_common(dev, fdctrl, &err); - if (err !=3D NULL) { - error_propagate(errp, err); - return; - } -} - static void sysbus_fdc_initfn(Object *obj) { SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); @@ -2564,200 +2494,6 @@ static void sysbus_fdc_common_realize(DeviceState *= dev, Error **errp) fdctrl_realize_common(dev, fdctrl, errp); } =20 -FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i) -{ - FDCtrlISABus *isa =3D ISA_FDC(fdc); - - return isa->state.drives[i].drive; -} - -static void isa_fdc_get_drive_max_chs(FloppyDriveType type, uint8_t *maxc, - uint8_t *maxh, uint8_t *maxs) -{ - const FDFormat *fdf; - - *maxc =3D *maxh =3D *maxs =3D 0; - for (fdf =3D fd_formats; fdf->drive !=3D FLOPPY_DRIVE_TYPE_NONE; fdf++= ) { - if (fdf->drive !=3D type) { - continue; - } - if (*maxc < fdf->max_track) { - *maxc =3D fdf->max_track; - } - if (*maxh < fdf->max_head) { - *maxh =3D fdf->max_head; - } - if (*maxs < fdf->last_sect) { - *maxs =3D fdf->last_sect; - } - } - (*maxc)--; -} - -static Aml *build_fdinfo_aml(int idx, FloppyDriveType type) -{ - Aml *dev, *fdi; - uint8_t maxc, maxh, maxs; - - isa_fdc_get_drive_max_chs(type, &maxc, &maxh, &maxs); - - dev =3D aml_device("FLP%c", 'A' + idx); - - aml_append(dev, aml_name_decl("_ADR", aml_int(idx))); - - fdi =3D aml_package(16); - aml_append(fdi, aml_int(idx)); /* Drive Number */ - aml_append(fdi, - aml_int(cmos_get_fd_drive_type(type))); /* Device Type */ - /* - * the values below are the limits of the drive, and are thus independ= ent - * of the inserted media - */ - aml_append(fdi, aml_int(maxc)); /* Maximum Cylinder Number */ - aml_append(fdi, aml_int(maxs)); /* Maximum Sector Number */ - aml_append(fdi, aml_int(maxh)); /* Maximum Head Number */ - /* - * SeaBIOS returns the below values for int 0x13 func 0x08 regardless = of - * the drive type, so shall we - */ - aml_append(fdi, aml_int(0xAF)); /* disk_specify_1 */ - aml_append(fdi, aml_int(0x02)); /* disk_specify_2 */ - aml_append(fdi, aml_int(0x25)); /* disk_motor_wait */ - aml_append(fdi, aml_int(0x02)); /* disk_sector_siz */ - aml_append(fdi, aml_int(0x12)); /* disk_eot */ - aml_append(fdi, aml_int(0x1B)); /* disk_rw_gap */ - aml_append(fdi, aml_int(0xFF)); /* disk_dtl */ - aml_append(fdi, aml_int(0x6C)); /* disk_formt_gap */ - aml_append(fdi, aml_int(0xF6)); /* disk_fill */ - aml_append(fdi, aml_int(0x0F)); /* disk_head_sttl */ - aml_append(fdi, aml_int(0x08)); /* disk_motor_strt */ - - aml_append(dev, aml_name_decl("_FDI", fdi)); - return dev; -} - -int cmos_get_fd_drive_type(FloppyDriveType fd0) -{ - int val; - - switch (fd0) { - case FLOPPY_DRIVE_TYPE_144: - /* 1.44 Mb 3"5 drive */ - val =3D 4; - break; - case FLOPPY_DRIVE_TYPE_288: - /* 2.88 Mb 3"5 drive */ - val =3D 5; - break; - case FLOPPY_DRIVE_TYPE_120: - /* 1.2 Mb 5"5 drive */ - val =3D 2; - break; - case FLOPPY_DRIVE_TYPE_NONE: - default: - val =3D 0; - break; - } - return val; -} - -static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope) -{ - Aml *dev; - Aml *crs; - int i; - -#define ACPI_FDE_MAX_FD 4 - uint32_t fde_buf[5] =3D { - 0, 0, 0, 0, /* presence of floppy drives #0 - #3 */ - cpu_to_le32(2) /* tape presence (2 =3D=3D never present) */ - }; - - crs =3D aml_resource_template(); - aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04)); - aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01)); - aml_append(crs, aml_irq_no_flags(6)); - aml_append(crs, - aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2)); - - dev =3D aml_device("FDC0"); - aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700"))); - aml_append(dev, aml_name_decl("_CRS", crs)); - - for (i =3D 0; i < MIN(MAX_FD, ACPI_FDE_MAX_FD); i++) { - FloppyDriveType type =3D isa_fdc_get_drive_type(isadev, i); - - if (type < FLOPPY_DRIVE_TYPE_NONE) { - fde_buf[i] =3D cpu_to_le32(1); /* drive present */ - aml_append(dev, build_fdinfo_aml(i, type)); - } - } - aml_append(dev, aml_name_decl("_FDE", - aml_buffer(sizeof(fde_buf), (uint8_t *)fde_buf))); - - aml_append(scope, dev); -} - -static const VMStateDescription vmstate_isa_fdc =3D{ - .name =3D "fdc", - .version_id =3D 2, - .minimum_version_id =3D 2, - .fields =3D (VMStateField[]) { - VMSTATE_STRUCT(state, FDCtrlISABus, 0, vmstate_fdc, FDCtrl), - VMSTATE_END_OF_LIST() - } -}; - -static Property isa_fdc_properties[] =3D { - DEFINE_PROP_UINT32("iobase", FDCtrlISABus, iobase, 0x3f0), - DEFINE_PROP_UINT32("irq", FDCtrlISABus, irq, 6), - DEFINE_PROP_UINT32("dma", FDCtrlISABus, dma, 2), - DEFINE_PROP_SIGNED("fdtypeA", FDCtrlISABus, state.qdev_for_drives[0].t= ype, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_SIGNED("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].t= ype, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_SIGNED("fallback", FDCtrlISABus, state.fallback, - FLOPPY_DRIVE_TYPE_288, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_END_OF_LIST(), -}; - -static void isabus_fdc_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - ISADeviceClass *isa =3D ISA_DEVICE_CLASS(klass); - - dc->realize =3D isabus_fdc_realize; - dc->fw_name =3D "fdc"; - dc->reset =3D fdctrl_external_reset_isa; - dc->vmsd =3D &vmstate_isa_fdc; - isa->build_aml =3D fdc_isa_build_aml; - device_class_set_props(dc, isa_fdc_properties); - set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); -} - -static void isabus_fdc_instance_init(Object *obj) -{ - FDCtrlISABus *isa =3D ISA_FDC(obj); - - device_add_bootindex_property(obj, &isa->bootindexA, - "bootindexA", "/floppy@0", - DEVICE(obj)); - device_add_bootindex_property(obj, &isa->bootindexB, - "bootindexB", "/floppy@1", - DEVICE(obj)); -} - -static const TypeInfo isa_fdc_info =3D { - .name =3D TYPE_ISA_FDC, - .parent =3D TYPE_ISA_DEVICE, - .instance_size =3D sizeof(FDCtrlISABus), - .class_init =3D isabus_fdc_class_init, - .instance_init =3D isabus_fdc_instance_init, -}; - static const VMStateDescription vmstate_sysbus_fdc =3D{ .name =3D "fdc", .version_id =3D 2, @@ -2841,7 +2577,6 @@ static const TypeInfo sysbus_fdc_type_info =3D { =20 static void fdc_register_types(void) { - type_register_static(&isa_fdc_info); type_register_static(&sysbus_fdc_type_info); type_register_static(&sysbus_fdc_info); type_register_static(&sun4m_fdc_info); diff --git a/MAINTAINERS b/MAINTAINERS index 0dee966a31..12399d9903 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1672,6 +1672,7 @@ L: qemu-block@nongnu.org S: Supported F: hw/block/fdc.c F: hw/block/fdc-internal.h +F: hw/block/fdc-isa.c F: include/hw/block/fdc.h F: tests/qtest/fdc-test.c T: git https://gitlab.com/jsnow/qemu.git ide diff --git a/hw/block/Kconfig b/hw/block/Kconfig index 295441e64a..8c3be60a19 100644 --- a/hw/block/Kconfig +++ b/hw/block/Kconfig @@ -1,8 +1,10 @@ config FDC bool - # FIXME: there is no separate file for the MMIO floppy disk controller= , so - # select ISA_BUS here instead of polluting each board that requires one - select ISA_BUS + +config FDC_ISA + bool + depends on ISA_BUS + select FDC =20 config SSI_M25P80 bool diff --git a/hw/block/meson.build b/hw/block/meson.build index 8b0de54db1..8cc79b5fcb 100644 --- a/hw/block/meson.build +++ b/hw/block/meson.build @@ -5,6 +5,7 @@ softmmu_ss.add(files( )) softmmu_ss.add(when: 'CONFIG_ECC', if_true: files('ecc.c')) softmmu_ss.add(when: 'CONFIG_FDC', if_true: files('fdc.c')) +softmmu_ss.add(when: 'CONFIG_FDC_ISA', if_true: files('fdc-isa.c')) softmmu_ss.add(when: 'CONFIG_NAND', if_true: files('nand.c')) softmmu_ss.add(when: 'CONFIG_ONENAND', if_true: files('onenand.c')) softmmu_ss.add(when: 'CONFIG_PFLASH_CFI01', if_true: files('pflash_cfi01.c= ')) diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 66838fa397..aacb6f6d96 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -24,7 +24,7 @@ config PC imply VGA_PCI imply VIRTIO_VGA imply NVDIMM - select FDC + select FDC_ISA select I8259 select I8254 select PCKBD diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig index 7216f66a54..96db170eff 100644 --- a/hw/isa/Kconfig +++ b/hw/isa/Kconfig @@ -17,7 +17,7 @@ config ISA_SUPERIO bool select ISA_BUS select PCKBD - select FDC + select FDC_ISA =20 config PC87312 bool @@ -28,7 +28,7 @@ config PC87312 select MC146818RTC select SERIAL_ISA select PARALLEL - select FDC + select FDC_ISA select IDE_ISA =20 config PIIX3 @@ -47,7 +47,7 @@ config VT82C686 select ISA_SUPERIO select ACPI_SMBUS select SERIAL_ISA - select FDC + select FDC_ISA select USB_UHCI select APM =20 @@ -56,7 +56,7 @@ config SMC37C669 select ISA_SUPERIO select SERIAL_ISA select PARALLEL - select FDC + select FDC_ISA =20 config LPC_ICH9 bool diff --git a/hw/sparc64/Kconfig b/hw/sparc64/Kconfig index 980a201bb7..7e557ad17b 100644 --- a/hw/sparc64/Kconfig +++ b/hw/sparc64/Kconfig @@ -6,7 +6,7 @@ config SUN4U imply PARALLEL select M48T59 select ISA_BUS - select FDC + select FDC_ISA select SERIAL_ISA select PCI_SABRE select IDE_CMD646 --=20 2.31.1 From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624625954512636.3804632695636; Fri, 25 Jun 2021 05:59:14 -0700 (PDT) Received: from localhost ([::1]:34378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwlQP-0006Rq-EV for importer@patchew.org; Fri, 25 Jun 2021 08:59:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMS-0007dJ-I1 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMP-0004Qx-2b for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-UISBmR4aOVaN2RUrz2ekAQ-1; Fri, 25 Jun 2021 08:55:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6AA3D800D62; Fri, 25 Jun 2021 12:55:01 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71C6260939; Fri, 25 Jun 2021 12:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624625704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=im4hRy/G8ScUSG7gu9Vxr5i1MBrMH80A4dHSyDLxg1E=; b=eN9gflg4F/V+9zQhAJI97+ORGee5LxhZFTVrMB+21H3pK8iCbJKDSqCKCIJaSlInnAgoLv Uom/TckJQESq4m3pUP6qPyHfVnD40z/L+Z0Id0j8U7rp3c8LiLWdG1ro6xqwBMqbPkwj4n nHq//ldjSefD7wVjp+Xx/JI/ujlf+fY= X-MC-Unique: UISBmR4aOVaN2RUrz2ekAQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 5/6] hw/block/fdc: Extract SysBus floppy controllers to fdc-sysbus.c Date: Fri, 25 Jun 2021 08:54:40 -0400 Message-Id: <20210625125441.756802-6-jsnow@redhat.com> In-Reply-To: <20210625125441.756802-1-jsnow@redhat.com> References: <20210625125441.756802-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Aleksandar Rikalo , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Max Reitz , Artyom Tarasenko , Paolo Bonzini , John Snow , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Some machines use floppy controllers via the SysBus interface, and don't need to pull in all the SysBus code. Extract the SysBus specific code to a new unit: fdc-sysbus.c, and add a new Kconfig symbol: "FDC_SYSBUS". Reviewed-by: John Snow Acked-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Acked-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210614193220.2007159-6-philmd@redhat.com Signed-off-by: John Snow --- hw/block/fdc-sysbus.c | 249 ++++++++++++++++++++++++++++++++++++++++++ hw/block/fdc.c | 220 ------------------------------------- MAINTAINERS | 1 + hw/block/Kconfig | 4 + hw/block/meson.build | 1 + hw/block/trace-events | 2 + hw/mips/Kconfig | 2 +- hw/sparc/Kconfig | 2 +- 8 files changed, 259 insertions(+), 222 deletions(-) create mode 100644 hw/block/fdc-sysbus.c diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c new file mode 100644 index 0000000000..c6308f5300 --- /dev/null +++ b/hw/block/fdc-sysbus.c @@ -0,0 +1,249 @@ +/* + * QEMU Floppy disk emulator (Intel 82078) + * + * Copyright (c) 2003, 2007 Jocelyn Mayer + * Copyright (c) 2008 Herv=C3=A9 Poussineau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qom/object.h" +#include "hw/sysbus.h" +#include "hw/block/fdc.h" +#include "migration/vmstate.h" +#include "fdc-internal.h" +#include "trace.h" + +#define TYPE_SYSBUS_FDC "base-sysbus-fdc" +typedef struct FDCtrlSysBusClass FDCtrlSysBusClass; +typedef struct FDCtrlSysBus FDCtrlSysBus; +DECLARE_OBJ_CHECKERS(FDCtrlSysBus, FDCtrlSysBusClass, + SYSBUS_FDC, TYPE_SYSBUS_FDC) + +struct FDCtrlSysBusClass { + /*< private >*/ + SysBusDeviceClass parent_class; + /*< public >*/ + + bool use_strict_io; +}; + +struct FDCtrlSysBus { + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + + struct FDCtrl state; +}; + +static uint64_t fdctrl_read_mem(void *opaque, hwaddr reg, unsigned ize) +{ + return fdctrl_read(opaque, (uint32_t)reg); +} + +static void fdctrl_write_mem(void *opaque, hwaddr reg, + uint64_t value, unsigned size) +{ + fdctrl_write(opaque, (uint32_t)reg, value); +} + +static const MemoryRegionOps fdctrl_mem_ops =3D { + .read =3D fdctrl_read_mem, + .write =3D fdctrl_write_mem, + .endianness =3D DEVICE_NATIVE_ENDIAN, +}; + +static const MemoryRegionOps fdctrl_mem_strict_ops =3D { + .read =3D fdctrl_read_mem, + .write =3D fdctrl_write_mem, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; + +static void fdctrl_external_reset_sysbus(DeviceState *d) +{ + FDCtrlSysBus *sys =3D SYSBUS_FDC(d); + FDCtrl *s =3D &sys->state; + + fdctrl_reset(s, 0); +} + +static void fdctrl_handle_tc(void *opaque, int irq, int level) +{ + trace_fdctrl_tc_pulse(level); +} + +void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, + hwaddr mmio_base, DriveInfo **fds) +{ + FDCtrl *fdctrl; + DeviceState *dev; + SysBusDevice *sbd; + FDCtrlSysBus *sys; + + dev =3D qdev_new("sysbus-fdc"); + sys =3D SYSBUS_FDC(dev); + fdctrl =3D &sys->state; + fdctrl->dma_chann =3D dma_chann; /* FIXME */ + sbd =3D SYS_BUS_DEVICE(dev); + sysbus_realize_and_unref(sbd, &error_fatal); + sysbus_connect_irq(sbd, 0, irq); + sysbus_mmio_map(sbd, 0, mmio_base); + + fdctrl_init_drives(&sys->state.bus, fds); +} + +void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, + DriveInfo **fds, qemu_irq *fdc_tc) +{ + DeviceState *dev; + FDCtrlSysBus *sys; + + dev =3D qdev_new("sun-fdtwo"); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sys =3D SYSBUS_FDC(dev); + sysbus_connect_irq(SYS_BUS_DEVICE(sys), 0, irq); + sysbus_mmio_map(SYS_BUS_DEVICE(sys), 0, io_base); + *fdc_tc =3D qdev_get_gpio_in(dev, 0); + + fdctrl_init_drives(&sys->state.bus, fds); +} + +static void sysbus_fdc_common_instance_init(Object *obj) +{ + DeviceState *dev =3D DEVICE(obj); + FDCtrlSysBusClass *sbdc =3D SYSBUS_FDC_GET_CLASS(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + FDCtrlSysBus *sys =3D SYSBUS_FDC(obj); + FDCtrl *fdctrl =3D &sys->state; + + qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */ + + memory_region_init_io(&fdctrl->iomem, obj, + sbdc->use_strict_io ? &fdctrl_mem_strict_ops + : &fdctrl_mem_ops, + fdctrl, "fdc", 0x08); + sysbus_init_mmio(sbd, &fdctrl->iomem); + + sysbus_init_irq(sbd, &fdctrl->irq); + qdev_init_gpio_in(dev, fdctrl_handle_tc, 1); +} + +static void sysbus_fdc_realize(DeviceState *dev, Error **errp) +{ + FDCtrlSysBus *sys =3D SYSBUS_FDC(dev); + FDCtrl *fdctrl =3D &sys->state; + + fdctrl_realize_common(dev, fdctrl, errp); +} + +static const VMStateDescription vmstate_sysbus_fdc =3D { + .name =3D "fdc", + .version_id =3D 2, + .minimum_version_id =3D 2, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(state, FDCtrlSysBus, 0, vmstate_fdc, FDCtrl), + VMSTATE_END_OF_LIST() + } +}; + +static void sysbus_fdc_common_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D sysbus_fdc_realize; + dc->reset =3D fdctrl_external_reset_sysbus; + dc->vmsd =3D &vmstate_sysbus_fdc; + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); +} + +static const TypeInfo sysbus_fdc_common_typeinfo =3D { + .name =3D TYPE_SYSBUS_FDC, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(FDCtrlSysBus), + .instance_init =3D sysbus_fdc_common_instance_init, + .abstract =3D true, + .class_init =3D sysbus_fdc_common_class_init, + .class_size =3D sizeof(FDCtrlSysBusClass), +}; + +static Property sysbus_fdc_properties[] =3D { + DEFINE_PROP_SIGNED("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].t= ype, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_SIGNED("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].t= ype, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_SIGNED("fallback", FDCtrlSysBus, state.fallback, + FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_END_OF_LIST(), +}; + +static void sysbus_fdc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + device_class_set_props(dc, sysbus_fdc_properties); +} + +static const TypeInfo sysbus_fdc_typeinfo =3D { + .name =3D "sysbus-fdc", + .parent =3D TYPE_SYSBUS_FDC, + .class_init =3D sysbus_fdc_class_init, +}; + +static Property sun4m_fdc_properties[] =3D { + DEFINE_PROP_SIGNED("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].ty= pe, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_SIGNED("fallback", FDCtrlSysBus, state.fallback, + FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_END_OF_LIST(), +}; + +static void sun4m_fdc_class_init(ObjectClass *klass, void *data) +{ + FDCtrlSysBusClass *sbdc =3D SYSBUS_FDC_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); + + sbdc->use_strict_io =3D true; + device_class_set_props(dc, sun4m_fdc_properties); +} + +static const TypeInfo sun4m_fdc_typeinfo =3D { + .name =3D "sun-fdtwo", + .parent =3D TYPE_SYSBUS_FDC, + .class_init =3D sun4m_fdc_class_init, +}; + +static void sysbus_fdc_register_types(void) +{ + type_register_static(&sysbus_fdc_common_typeinfo); + type_register_static(&sysbus_fdc_typeinfo); + type_register_static(&sun4m_fdc_typeinfo); +} + +type_init(sysbus_fdc_register_types) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index aa70eb97c6..9014cd30b3 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -36,7 +36,6 @@ #include "hw/isa/isa.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" -#include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/block/block.h" #include "sysemu/block-backend.h" @@ -773,17 +772,6 @@ static FloppyDriveType get_fallback_drive_type(FDrive = *drv) return drv->fdctrl->fallback; } =20 -#define TYPE_SYSBUS_FDC "base-sysbus-fdc" -OBJECT_DECLARE_SIMPLE_TYPE(FDCtrlSysBus, SYSBUS_FDC) - -struct FDCtrlSysBus { - /*< private >*/ - SysBusDevice parent_obj; - /*< public >*/ - - struct FDCtrl state; -}; - uint32_t fdctrl_read(void *opaque, uint32_t reg) { FDCtrl *fdctrl =3D opaque; @@ -848,34 +836,6 @@ void fdctrl_write(void *opaque, uint32_t reg, uint32_t= value) } } =20 -static uint64_t fdctrl_read_mem (void *opaque, hwaddr reg, - unsigned ize) -{ - return fdctrl_read(opaque, (uint32_t)reg); -} - -static void fdctrl_write_mem (void *opaque, hwaddr reg, - uint64_t value, unsigned size) -{ - fdctrl_write(opaque, (uint32_t)reg, value); -} - -static const MemoryRegionOps fdctrl_mem_ops =3D { - .read =3D fdctrl_read_mem, - .write =3D fdctrl_write_mem, - .endianness =3D DEVICE_NATIVE_ENDIAN, -}; - -static const MemoryRegionOps fdctrl_mem_strict_ops =3D { - .read =3D fdctrl_read_mem, - .write =3D fdctrl_write_mem, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 1, - }, -}; - static bool fdrive_media_changed_needed(void *opaque) { FDrive *drive =3D opaque; @@ -1099,19 +1059,6 @@ const VMStateDescription vmstate_fdc =3D { } }; =20 -static void fdctrl_external_reset_sysbus(DeviceState *d) -{ - FDCtrlSysBus *sys =3D SYSBUS_FDC(d); - FDCtrl *s =3D &sys->state; - - fdctrl_reset(s, 0); -} - -static void fdctrl_handle_tc(void *opaque, int irq, int level) -{ - trace_fdctrl_tc_pulse(level); -} - /* Change IRQ state */ static void fdctrl_reset_irq(FDCtrl *fdctrl) { @@ -2367,42 +2314,6 @@ void fdctrl_init_drives(FloppyBus *bus, DriveInfo **= fds) } } =20 -void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, - hwaddr mmio_base, DriveInfo **fds) -{ - FDCtrl *fdctrl; - DeviceState *dev; - SysBusDevice *sbd; - FDCtrlSysBus *sys; - - dev =3D qdev_new("sysbus-fdc"); - sys =3D SYSBUS_FDC(dev); - fdctrl =3D &sys->state; - fdctrl->dma_chann =3D dma_chann; /* FIXME */ - sbd =3D SYS_BUS_DEVICE(dev); - sysbus_realize_and_unref(sbd, &error_fatal); - sysbus_connect_irq(sbd, 0, irq); - sysbus_mmio_map(sbd, 0, mmio_base); - - fdctrl_init_drives(&sys->state.bus, fds); -} - -void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, - DriveInfo **fds, qemu_irq *fdc_tc) -{ - DeviceState *dev; - FDCtrlSysBus *sys; - - dev =3D qdev_new("sun-fdtwo"); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - sys =3D SYSBUS_FDC(dev); - sysbus_connect_irq(SYS_BUS_DEVICE(sys), 0, irq); - sysbus_mmio_map(SYS_BUS_DEVICE(sys), 0, io_base); - *fdc_tc =3D qdev_get_gpio_in(dev, 0); - - fdctrl_init_drives(&sys->state.bus, fds); -} - void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp) { int i, j; @@ -2447,139 +2358,8 @@ void fdctrl_realize_common(DeviceState *dev, FDCtrl= *fdctrl, Error **errp) } } =20 -static void sysbus_fdc_initfn(Object *obj) -{ - SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); - FDCtrlSysBus *sys =3D SYSBUS_FDC(obj); - FDCtrl *fdctrl =3D &sys->state; - - fdctrl->dma_chann =3D -1; - - memory_region_init_io(&fdctrl->iomem, obj, &fdctrl_mem_ops, fdctrl, - "fdc", 0x08); - sysbus_init_mmio(sbd, &fdctrl->iomem); -} - -static void sun4m_fdc_initfn(Object *obj) -{ - SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); - FDCtrlSysBus *sys =3D SYSBUS_FDC(obj); - FDCtrl *fdctrl =3D &sys->state; - - fdctrl->dma_chann =3D -1; - - memory_region_init_io(&fdctrl->iomem, obj, &fdctrl_mem_strict_ops, - fdctrl, "fdctrl", 0x08); - sysbus_init_mmio(sbd, &fdctrl->iomem); -} - -static void sysbus_fdc_common_initfn(Object *obj) -{ - DeviceState *dev =3D DEVICE(obj); - SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); - FDCtrlSysBus *sys =3D SYSBUS_FDC(obj); - FDCtrl *fdctrl =3D &sys->state; - - qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */ - - sysbus_init_irq(sbd, &fdctrl->irq); - qdev_init_gpio_in(dev, fdctrl_handle_tc, 1); -} - -static void sysbus_fdc_common_realize(DeviceState *dev, Error **errp) -{ - FDCtrlSysBus *sys =3D SYSBUS_FDC(dev); - FDCtrl *fdctrl =3D &sys->state; - - fdctrl_realize_common(dev, fdctrl, errp); -} - -static const VMStateDescription vmstate_sysbus_fdc =3D{ - .name =3D "fdc", - .version_id =3D 2, - .minimum_version_id =3D 2, - .fields =3D (VMStateField[]) { - VMSTATE_STRUCT(state, FDCtrlSysBus, 0, vmstate_fdc, FDCtrl), - VMSTATE_END_OF_LIST() - } -}; - -static Property sysbus_fdc_properties[] =3D { - DEFINE_PROP_SIGNED("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].t= ype, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_SIGNED("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].t= ype, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_SIGNED("fallback", FDCtrlSysBus, state.fallback, - FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_END_OF_LIST(), -}; - -static void sysbus_fdc_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - - device_class_set_props(dc, sysbus_fdc_properties); - set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); -} - -static const TypeInfo sysbus_fdc_info =3D { - .name =3D "sysbus-fdc", - .parent =3D TYPE_SYSBUS_FDC, - .instance_init =3D sysbus_fdc_initfn, - .class_init =3D sysbus_fdc_class_init, -}; - -static Property sun4m_fdc_properties[] =3D { - DEFINE_PROP_SIGNED("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].ty= pe, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_SIGNED("fallback", FDCtrlSysBus, state.fallback, - FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_END_OF_LIST(), -}; - -static void sun4m_fdc_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - - device_class_set_props(dc, sun4m_fdc_properties); - set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); -} - -static const TypeInfo sun4m_fdc_info =3D { - .name =3D "sun-fdtwo", - .parent =3D TYPE_SYSBUS_FDC, - .instance_init =3D sun4m_fdc_initfn, - .class_init =3D sun4m_fdc_class_init, -}; - -static void sysbus_fdc_common_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - - dc->realize =3D sysbus_fdc_common_realize; - dc->reset =3D fdctrl_external_reset_sysbus; - dc->vmsd =3D &vmstate_sysbus_fdc; -} - -static const TypeInfo sysbus_fdc_type_info =3D { - .name =3D TYPE_SYSBUS_FDC, - .parent =3D TYPE_SYS_BUS_DEVICE, - .instance_size =3D sizeof(FDCtrlSysBus), - .instance_init =3D sysbus_fdc_common_initfn, - .abstract =3D true, - .class_init =3D sysbus_fdc_common_class_init, -}; - static void fdc_register_types(void) { - type_register_static(&sysbus_fdc_type_info); - type_register_static(&sysbus_fdc_info); - type_register_static(&sun4m_fdc_info); type_register_static(&floppy_bus_info); type_register_static(&floppy_drive_info); } diff --git a/MAINTAINERS b/MAINTAINERS index 12399d9903..7ab02764b2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1673,6 +1673,7 @@ S: Supported F: hw/block/fdc.c F: hw/block/fdc-internal.h F: hw/block/fdc-isa.c +F: hw/block/fdc-sysbus.c F: include/hw/block/fdc.h F: tests/qtest/fdc-test.c T: git https://gitlab.com/jsnow/qemu.git ide diff --git a/hw/block/Kconfig b/hw/block/Kconfig index 8c3be60a19..9e8f28f982 100644 --- a/hw/block/Kconfig +++ b/hw/block/Kconfig @@ -6,6 +6,10 @@ config FDC_ISA depends on ISA_BUS select FDC =20 +config FDC_SYSBUS + bool + select FDC + config SSI_M25P80 bool =20 diff --git a/hw/block/meson.build b/hw/block/meson.build index 8cc79b5fcb..2389326112 100644 --- a/hw/block/meson.build +++ b/hw/block/meson.build @@ -6,6 +6,7 @@ softmmu_ss.add(files( softmmu_ss.add(when: 'CONFIG_ECC', if_true: files('ecc.c')) softmmu_ss.add(when: 'CONFIG_FDC', if_true: files('fdc.c')) softmmu_ss.add(when: 'CONFIG_FDC_ISA', if_true: files('fdc-isa.c')) +softmmu_ss.add(when: 'CONFIG_FDC_SYSBUS', if_true: files('fdc-sysbus.c')) softmmu_ss.add(when: 'CONFIG_NAND', if_true: files('nand.c')) softmmu_ss.add(when: 'CONFIG_ONENAND', if_true: files('onenand.c')) softmmu_ss.add(when: 'CONFIG_PFLASH_CFI01', if_true: files('pflash_cfi01.c= ')) diff --git a/hw/block/trace-events b/hw/block/trace-events index 6a0d973805..d86b53520c 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -3,6 +3,8 @@ # fdc.c fdc_ioport_read(uint8_t reg, uint8_t value) "read reg 0x%02x val 0x%02x" fdc_ioport_write(uint8_t reg, uint8_t value) "write reg 0x%02x val 0x%02x" + +# fdc-sysbus.c fdctrl_tc_pulse(int level) "TC pulse: %u" =20 # pflash_cfi01.c diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig index aadd436bf4..c245e881a2 100644 --- a/hw/mips/Kconfig +++ b/hw/mips/Kconfig @@ -20,7 +20,7 @@ config JAZZ select G364FB select DP8393X select ESP - select FDC + select FDC_SYSBUS select MC146818RTC select PCKBD select SERIAL diff --git a/hw/sparc/Kconfig b/hw/sparc/Kconfig index 8dcb10086f..79d58beb7a 100644 --- a/hw/sparc/Kconfig +++ b/hw/sparc/Kconfig @@ -8,7 +8,7 @@ config SUN4M select UNIMP select ESCC select ESP - select FDC + select FDC_SYSBUS select SLAVIO select LANCE select M48T59 --=20 2.31.1 From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624626153478562.9386137044836; Fri, 25 Jun 2021 06:02:33 -0700 (PDT) Received: from localhost ([::1]:40476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwlTc-0002L5-C9 for importer@patchew.org; Fri, 25 Jun 2021 09:02:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMe-0007wg-0u for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwlMb-0004XN-2d for qemu-devel@nongnu.org; Fri, 25 Jun 2021 08:55:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-223-GswKt8vlPsifwx11UN1PGw-1; Fri, 25 Jun 2021 08:55:14 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C922A5074D; Fri, 25 Jun 2021 12:55:12 +0000 (UTC) Received: from scv.redhat.com (ovpn-118-71.rdu2.redhat.com [10.10.118.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 957CB6091B; Fri, 25 Jun 2021 12:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624625716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2qA5ucowGbStGzmxgQSM1Fyb4WNrMPIx0Ma9164cWGQ=; b=WUaT93b+YNIHVpKQRNpLNhBk6z1lWioy1GqFWQNv/JcIT67VySVl5EIBxbzyOfCcwE7Byf dgbrkYFHiClqfSt6QkRV2PydGs8himpGCYRrhPumzsQzqojba2Ke5Olh6Cvxd/NOg7ixzX JJ1O3u+qvnS+EsWu4yZzfy5bB3XjJ2Q= X-MC-Unique: GswKt8vlPsifwx11UN1PGw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 6/6] hw/block/fdc: Add description to floppy controllers Date: Fri, 25 Jun 2021 08:54:41 -0400 Message-Id: <20210625125441.756802-7-jsnow@redhat.com> In-Reply-To: <20210625125441.756802-1-jsnow@redhat.com> References: <20210625125441.756802-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.362, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Aleksandar Rikalo , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Max Reitz , Artyom Tarasenko , Paolo Bonzini , John Snow , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Change the '-device help' output from: Storage devices: name "floppy", bus floppy-bus, desc "virtual floppy drive" name "isa-fdc", bus ISA to: Storage devices: name "floppy", bus floppy-bus, desc "virtual floppy drive" name "isa-fdc", bus ISA, desc "virtual floppy controller" Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210614193220.2007159-7-philmd@redhat.com Signed-off-by: John Snow --- hw/block/fdc-isa.c | 1 + hw/block/fdc-sysbus.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c index 0e22a10732..3bf64e0665 100644 --- a/hw/block/fdc-isa.c +++ b/hw/block/fdc-isa.c @@ -282,6 +282,7 @@ static void isabus_fdc_class_init(ObjectClass *klass, v= oid *data) DeviceClass *dc =3D DEVICE_CLASS(klass); ISADeviceClass *isa =3D ISA_DEVICE_CLASS(klass); =20 + dc->desc =3D "virtual floppy controller"; dc->realize =3D isabus_fdc_realize; dc->fw_name =3D "fdc"; dc->reset =3D fdctrl_external_reset_isa; diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c index c6308f5300..57fc8773f1 100644 --- a/hw/block/fdc-sysbus.c +++ b/hw/block/fdc-sysbus.c @@ -205,6 +205,7 @@ static void sysbus_fdc_class_init(ObjectClass *klass, v= oid *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 + dc->desc =3D "virtual floppy controller"; device_class_set_props(dc, sysbus_fdc_properties); } =20 @@ -230,6 +231,7 @@ static void sun4m_fdc_class_init(ObjectClass *klass, vo= id *data) DeviceClass *dc =3D DEVICE_CLASS(klass); =20 sbdc->use_strict_io =3D true; + dc->desc =3D "virtual floppy controller"; device_class_set_props(dc, sun4m_fdc_properties); } =20 --=20 2.31.1