From patchwork Mon May 17 17:49:40 2021 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: 1479713 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bn4ZcXVX; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkRWL18RGz9sX1 for ; Tue, 18 May 2021 03:50:54 +1000 (AEST) Received: from localhost ([::1]:33718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihOG-00076o-4U for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 13:50:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNT-00071X-MB for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNP-0002wL-TP for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621273799; 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=wKTvIJltaWyJ3tXssokHbyKTt2E/IQqH3Pybl80dLEU=; b=bn4ZcXVXZKqyPv2ebdHn0YOLwvqtVgGQIoZEJYv7X+mVSM9auo1BaGCon7O3J42oBgJbvj jwrt2xzQrCqk0bMo+sBmuJEIzJpXR+a1lcyAq7poPYHeFPPp7EDz+NHA9ZsY90bQKJC8JS JBA1gJqth+Wqilu+5vhiXAZCNvYIzu0= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-545-b1qeFzEbMAWo9RAoOKWzVQ-1; Mon, 17 May 2021 13:49:55 -0400 X-MC-Unique: b1qeFzEbMAWo9RAoOKWzVQ-1 Received: by mail-ed1-f69.google.com with SMTP id y19-20020a0564022713b029038a9f36060dso4333247edd.4 for ; Mon, 17 May 2021 10:49:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wKTvIJltaWyJ3tXssokHbyKTt2E/IQqH3Pybl80dLEU=; b=iE2/+DGfuFRjwdUhJIZhPAMfBm90PYbkAfVMSPyLhyRP05ih5+nOkBrR7/mmQDi+X9 PFvZ5kT1FyqV/nssBuW0Pf0roYl12/oBJMaVQfo6NitM6QvIpmJwIaN6UQ4/aR0SGQO0 LCXVim0VMb2rDZsn3dAlusvNbEhiVATHxo3NyzIPtw0aYCHSe3UU3LLl5MeIn9meTVBb gaVL65lAvRC4sa6kDVH/bSJf1S04Y0Oeci/25ABvcVF4TJQVbxz9NONpglbTubJ5mySs 4QXPWHYJ4tKm8CByndWlOD3bNOk9AETYLjNPv+hrZTxwzK8qfkQ1nWPaGNwMiVVUIJ5p ddKw== X-Gm-Message-State: AOAM5300h5MfJkdPAOqw0pchr5n3u2zR4ayhdUH5EjM1PH4vIIEXbtEt iair4rMR1XYQ+VxchHGqT1hwaYH7TnktvIiTnfSgzTIMiDExzt7LIMZ9wq+X//tLiQHrkTozCHf rpDVqojxEcdTNkgfP1hWQN2E/Sf1G4hhwlN/+/TsTj/4DkayTFcdsjI/XnVSMSCee X-Received: by 2002:aa7:c782:: with SMTP id n2mr1505896eds.77.1621273794404; Mon, 17 May 2021 10:49:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj5JLSE+WMRh8WJJp+/HYGYmcfXFusRt9aLzm6vIieAb6mRxvMgOK/punaML/5gRG+21bsgg== X-Received: by 2002:aa7:c782:: with SMTP id n2mr1505863eds.77.1621273794193; Mon, 17 May 2021 10:49:54 -0700 (PDT) Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id b9sm2759384edt.71.2021.05.17.10.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:49:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, John Snow Subject: [PATCH v3 1/8] hw/block/fdc: Replace disabled fprintf() by trace event Date: Mon, 17 May 2021 19:49:40 +0200 Message-Id: <20210517174947.1199649-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517174947.1199649-1-philmd@redhat.com> References: <20210517174947.1199649-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@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.374, 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: John Snow Acked-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Signed-off-by: Philippe Mathieu-Daudé --- 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 a825c2acbae..1d3a0473678 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -1242,12 +1242,7 @@ static void fdctrl_external_reset_isa(DeviceState *d) static void fdctrl_handle_tc(void *opaque, int irq, int level) { - //FDCtrl *s = opaque; - - if (level) { - // XXX - FLOPPY_DPRINTF("TC pulsed\n"); - } + trace_fdctrl_tc_pulse(level); } /* Change IRQ state */ diff --git a/hw/block/trace-events b/hw/block/trace-events index fa12e3a67a7..306989c193c 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" # pflash_cfi01.c # pflash_cfi02.c From patchwork Mon May 17 17:49:41 2021 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: 1479716 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HUT5c8xq; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkRZG0vgmz9sWW for ; Tue, 18 May 2021 03:53:26 +1000 (AEST) Received: from localhost ([::1]:41914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihQi-0004HZ-4M for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 13:53:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNV-00075x-JE for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNS-0002xd-T6 for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621273802; 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=tuur5ZsnbARdY5KvIOeccLdQReUN8QEIerCNAY+4WFM=; b=HUT5c8xqU6pPmo10OkmqvPUgpTelN5bBSeu5Nc3DyzxXq+IrBCJxvfE5NutpSmZARm29cx s1FFhTbodBvP+bzormQL6dru5BD+Y4HfY14TkGNqnG2NsrBf2aLiUCzvgodKjs39DXiBT9 lQYViyZ2BdrX7tV2Zbp6CQ2iDr+3DO0= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-MDG6nrKyMyG9ldslQ1D-XQ-1; Mon, 17 May 2021 13:50:00 -0400 X-MC-Unique: MDG6nrKyMyG9ldslQ1D-XQ-1 Received: by mail-ed1-f72.google.com with SMTP id u14-20020a05640207ceb029038d4bfbf3a6so770031edy.9 for ; Mon, 17 May 2021 10:50:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tuur5ZsnbARdY5KvIOeccLdQReUN8QEIerCNAY+4WFM=; b=b++Ogn8/j3/bOoDARUtlvhpCUZPF9VbRsf1P/AV0Mf3CCG22/eOKY6tkdmnSV+6QRK somLRe/b3F39kPoonS7mArcsqjxGzCC/B4SEq5U1EJpp5Ig2THNbocTo4PDZtrRaR1dG Ps7QkyMnhhDqAg6sA1SF3s3OMqbm2FEAalYyGN02ZVrhy/J3ZPP01s4Qxi4i/oQS0akm xjrEB9ygCLvQYQvoBRTkSWUzA+kvualYuL6njJ/+0iuBAZfkA9TJzHAWCSVbMZJj9RXp uj4LATXtDHa6xHffZ0r0YC2g+YQa/priNjYZvaTzGgCGBlTIdPEINPRoia0FZz/4oxds jZDQ== X-Gm-Message-State: AOAM5315iIYJdRGsuHqANfqkflOQ0PqV1oM8WZGIK62D8jezE172YpFk me3sBqiRVIQMcZsJtjHzrDj3h62J6QcRYZsD2MCAVsl2ty9vCPrTEwmkfpohyVUyxb+9mBd5Zdw aI64Y/cKDJjZiXCVLZEhvpmwEdrqOZTUJpSdtCMHwP0HiRVXiLGHpRvt2Djaf0q2X X-Received: by 2002:a17:906:7c4b:: with SMTP id g11mr1096299ejp.461.1621273799059; Mon, 17 May 2021 10:49:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSg3GQ+a5y/ijsUgDTrxu3yhJqgwf8ED0S7k5ebNdd6aOLSGAUzVAUq4PtOTSIKwewW8hGYw== X-Received: by 2002:a17:906:7c4b:: with SMTP id g11mr1096271ejp.461.1621273798745; Mon, 17 May 2021 10:49:58 -0700 (PDT) Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id e23sm3635702eds.2.2021.05.17.10.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:49:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, John Snow Subject: [PATCH v3 2/8] hw/block/fdc: Declare shared prototypes in fdc-internal.h Date: Mon, 17 May 2021 19:49:41 +0200 Message-Id: <20210517174947.1199649-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517174947.1199649-1-philmd@redhat.com> References: <20210517174947.1199649-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@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.374, 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Signed-off-by: Philippe Mathieu-Daudé --- hw/block/fdc-internal.h | 156 ++++++++++++++++++++++++++++++++++++++++ hw/block/fdc.c | 126 +++----------------------------- MAINTAINERS | 1 + 3 files changed, 165 insertions(+), 118 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 00000000000..278de725e69 --- /dev/null +++ b/hw/block/fdc-internal.h @@ -0,0 +1,156 @@ +/* + * QEMU Floppy disk emulator (Intel 82078) + * + * Copyright (c) 2003, 2007 Jocelyn Mayer + * Copyright (c) 2008 Hervé Poussineau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = 0x00, /* 500 Kbps */ + FDRIVE_RATE_300K = 0x01, /* 300 Kbps */ + FDRIVE_RATE_250K = 0x02, /* 250 Kbps */ + FDRIVE_RATE_1M = 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 = 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=auto 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); + +void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds); + +#endif diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 1d3a0473678..300f39672af 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" /********************************************************/ /* debug Floppy devices */ @@ -68,15 +69,8 @@ #define TYPE_FLOPPY_BUS "floppy-bus" OBJECT_DECLARE_SIMPLE_TYPE(FloppyBus, FLOPPY_BUS) -typedef struct FDCtrl FDCtrl; -typedef struct FDrive FDrive; static FDrive *get_drv(FDCtrl *fdctrl, int unit); -struct FloppyBus { - BusState bus; - FDCtrl *fdc; -}; - static const TypeInfo floppy_bus_info = { .name = TYPE_FLOPPY_BUS, .parent = TYPE_BUS, @@ -93,32 +87,11 @@ static void floppy_bus_create(FDCtrl *fdc, FloppyBus *bus, DeviceState *dev) /********************************************************/ /* Floppy drive emulation */ -typedef enum FDriveRate { - FDRIVE_RATE_500K = 0x00, /* 500 Kbps */ - FDRIVE_RATE_300K = 0x01, /* 300 Kbps */ - FDRIVE_RATE_250K = 0x02, /* 250 Kbps */ - FDRIVE_RATE_1M = 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[] = { +const FDFormat fd_formats[] = { /* 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 */ -/* Floppy disk drive emulation */ -typedef enum FDiskFlags { - FDISK_DBL_SIDES = 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? */ -}; - static FloppyDriveType get_fallback_drive_type(FDrive *drv); @@ -626,7 +570,6 @@ static const TypeInfo floppy_drive_info = { /********************************************************/ /* Intel 82078 floppy disk controller emulation */ -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); @@ -828,58 +771,6 @@ enum { #define FD_MULTI_TRACK(state) ((state) & FD_STATE_MULTI) #define FD_FORMAT_CMD(state) ((state) & FD_STATE_FORMAT) -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=auto 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 +800,7 @@ struct FDCtrlISABus { int32_t bootindexB; }; -static uint32_t fdctrl_read (void *opaque, uint32_t reg) +uint32_t fdctrl_read(void *opaque, uint32_t reg) { FDCtrl *fdctrl = opaque; uint32_t retval; @@ -946,7 +837,7 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg) return retval; } -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 = opaque; @@ -1178,7 +1069,7 @@ static const VMStateDescription vmstate_fdc_phase = { } }; -static const VMStateDescription vmstate_fdc = { +const VMStateDescription vmstate_fdc = { .name = "fdc", .version_id = 2, .minimum_version_id = 2, @@ -1268,7 +1159,7 @@ static void fdctrl_raise_irq(FDCtrl *fdctrl) } /* Reset controller */ -static void fdctrl_reset(FDCtrl *fdctrl, int do_irq) +void fdctrl_reset(FDCtrl *fdctrl, int do_irq) { int i; @@ -2484,7 +2375,7 @@ static void fdctrl_result_timer(void *opaque) /* Init functions */ -static void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds) +void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds) { DeviceState *dev; int i; @@ -2542,8 +2433,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, fdctrl_init_drives(&sys->state.bus, fds); } -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 78561a223f9..b1b50c6c334 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1659,6 +1659,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 From patchwork Mon May 17 17:49:42 2021 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: 1479714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ADL8Kvre; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkRWS4GTYz9sWl for ; Tue, 18 May 2021 03:51:00 +1000 (AEST) Received: from localhost ([::1]:33958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihOM-0007Ht-6R for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 13:50:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNb-0007D6-Qo for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNY-000302-3M for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621273807; 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=gT49at1ZiBLXRwL/Q7LvKGO02eQio9BN4c7BLzyroRA=; b=ADL8KvreZ+RQggn5RZi2a5c/dE0kb+tr9uScrbGEJUDIyUATERiGAlILKotz7PpyRkCeoO aOsa291i9DMXYDZzo/XuZHL0GR3eg6MgZ3ifKv1pwnJ493YIUFTBQ4hllVIqCAkEUStbCV ZQGKmUVoTcFEqBpHnqYCPH0HotElgfA= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-MAEez4oPNgWjiXpfZ3QPEA-1; Mon, 17 May 2021 13:50:05 -0400 X-MC-Unique: MAEez4oPNgWjiXpfZ3QPEA-1 Received: by mail-ej1-f72.google.com with SMTP id p25-20020a1709061419b0290378364a6464so1330085ejc.15 for ; Mon, 17 May 2021 10:50:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gT49at1ZiBLXRwL/Q7LvKGO02eQio9BN4c7BLzyroRA=; b=uRj4HdaL2VW4T/Xp2/pIyyxhzUseSqqvh8oHR/rvpClA+JJsIprIUSMI3dKMF3P9d5 ijTVHn3q//a58U8zMoI/kllzilY/7G2fpmR93K4x16ejpBY87FSXSTG96TA336VBFa6o T0WLvEazKmhgfZHgn+WgoVhpUyzHDLkle2cZ4Vummt37Cw2yjLHgVMNur7vJj5f7vSMa BWTi0nd0MUZv0pjZMjZeef9O4N8mgLVPgedYs+6/jQqwnLx0cglyoo8puIvyEtyqCxpf gKD22fKT3PJYbTTRKiihuFCLkB85dNK0ji+9ZNKJ83t/eHQK/DDlYNT9Ufb7GTdjQG89 C1Hw== X-Gm-Message-State: AOAM5309cIkrzvJblmywXasJSwWijcKAmoL/JBEoFcXok10B5gSnaPrX sN+styAz5n546vI8VR1f6dIfmNYYJEDgzre6KRhUcA/fZAualQxEI3PStVEVOHqKMlZ5FqFy1n3 kB2/eeNt+XPwPKTdGDkalA/7pfq0hfEwc7RQeXGymJ+EoxQIXe/eMvQDpz6NEy9l2 X-Received: by 2002:a17:906:134e:: with SMTP id x14mr1140512ejb.190.1621273803882; Mon, 17 May 2021 10:50:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK5Tc2UrfGtr7H72iXO4m3fCkKwQuP4DpWhT9RioGq6rrdSyvkg6M0mw/xZMruOVABdaQNqA== X-Received: by 2002:a17:906:134e:: with SMTP id x14mr1140480ejb.190.1621273803465; Mon, 17 May 2021 10:50:03 -0700 (PDT) Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id d15sm11486463edu.86.2021.05.17.10.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:50:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, John Snow Subject: [PATCH v3 3/8] hw/block/fdc: Extract ISA floppy controllers to fdc-isa.c Date: Mon, 17 May 2021 19:49:42 +0200 Message-Id: <20210517174947.1199649-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517174947.1199649-1-philmd@redhat.com> References: <20210517174947.1199649-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@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.374, 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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". Reviewed-by: John Snow Acked-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Signed-off-by: Philippe Mathieu-Daudé --- hw/block/fdc-isa.c | 313 +++++++++++++++++++++++++++++++++++++++++++ hw/block/fdc.c | 257 ----------------------------------- MAINTAINERS | 1 + hw/block/Kconfig | 4 + hw/block/meson.build | 1 + hw/i386/Kconfig | 2 +- hw/isa/Kconfig | 6 +- hw/sparc64/Kconfig | 2 +- 8 files changed, 324 insertions(+), 262 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 00000000000..97f3f9e5c0a --- /dev/null +++ b/hw/block/fdc-isa.c @@ -0,0 +1,313 @@ +/* + * QEMU Floppy disk emulator (Intel 82078) + * + * Copyright (c) 2003, 2007 Jocelyn Mayer + * Copyright (c) 2008 Hervé Poussineau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 { + ISADevice parent_obj; + + 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 = ISA_FDC(d); + FDCtrl *s = &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[] = { + { 1, 5, 1, .read = fdctrl_read, .write = fdctrl_write }, + { 7, 1, 1, .read = fdctrl_read, .write = fdctrl_write }, + PORTIO_END_OF_LIST(), +}; + +static void isabus_fdc_realize(DeviceState *dev, Error **errp) +{ + ISADevice *isadev = ISA_DEVICE(dev); + FDCtrlISABus *isa = ISA_FDC(dev); + FDCtrl *fdctrl = &isa->state; + Error *err = 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 = isa->dma; + if (fdctrl->dma_chann != -1) { + fdctrl->dma = 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 != NULL) { + error_propagate(errp, err); + return; + } +} + +FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i) +{ + FDCtrlISABus *isa = 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 = *maxh = *maxs = 0; + for (fdf = fd_formats; fdf->drive != FLOPPY_DRIVE_TYPE_NONE; fdf++) { + if (fdf->drive != type) { + continue; + } + if (*maxc < fdf->max_track) { + *maxc = fdf->max_track; + } + if (*maxh < fdf->max_head) { + *maxh = fdf->max_head; + } + if (*maxs < fdf->last_sect) { + *maxs = 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 = aml_device("FLP%c", 'A' + idx); + + aml_append(dev, aml_name_decl("_ADR", aml_int(idx))); + + fdi = 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 independent + * 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 = 4; + break; + case FLOPPY_DRIVE_TYPE_288: + /* 2.88 Mb 3"5 drive */ + val = 5; + break; + case FLOPPY_DRIVE_TYPE_120: + /* 1.2 Mb 5"5 drive */ + val = 2; + break; + case FLOPPY_DRIVE_TYPE_NONE: + default: + val = 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] = { + 0, 0, 0, 0, /* presence of floppy drives #0 - #3 */ + cpu_to_le32(2) /* tape presence (2 == never present) */ + }; + + crs = 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 = aml_device("FDC0"); + aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700"))); + aml_append(dev, aml_name_decl("_CRS", crs)); + + for (i = 0; i < MIN(MAX_FD, ACPI_FDE_MAX_FD); i++) { + FloppyDriveType type = isa_fdc_get_drive_type(isadev, i); + + if (type < FLOPPY_DRIVE_TYPE_NONE) { + fde_buf[i] = 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 = { + .name = "fdc", + .version_id = 2, + .minimum_version_id = 2, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(state, FDCtrlISABus, 0, vmstate_fdc, FDCtrl), + VMSTATE_END_OF_LIST() + } +}; + +static Property isa_fdc_properties[] = { + 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].type, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_SIGNED("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].type, + 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 = DEVICE_CLASS(klass); + ISADeviceClass *isa = ISA_DEVICE_CLASS(klass); + + dc->realize = isabus_fdc_realize; + dc->fw_name = "fdc"; + dc->reset = fdctrl_external_reset_isa; + dc->vmsd = &vmstate_isa_fdc; + isa->build_aml = 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 = 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 = { + .name = TYPE_ISA_FDC, + .parent = TYPE_ISA_DEVICE, + .instance_size = sizeof(FDCtrlISABus), + .class_init = isabus_fdc_class_init, + .instance_init = 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 300f39672af..50567d972ff 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" @@ -787,19 +786,6 @@ struct FDCtrlSysBus { struct FDCtrl state; }; -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 = opaque; @@ -1123,14 +1109,6 @@ static void fdctrl_external_reset_sysbus(DeviceState *d) fdctrl_reset(s, 0); } -static void fdctrl_external_reset_isa(DeviceState *d) -{ - FDCtrlISABus *isa = ISA_FDC(d); - FDCtrl *s = &isa->state; - - fdctrl_reset(s, 0); -} - static void fdctrl_handle_tc(void *opaque, int irq, int level) { trace_fdctrl_tc_pulse(level); @@ -2392,11 +2370,6 @@ void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds) } } -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) { @@ -2485,41 +2458,6 @@ void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp) } } -static const MemoryRegionPortio fdc_portio_list[] = { - { 1, 5, 1, .read = fdctrl_read, .write = fdctrl_write }, - { 7, 1, 1, .read = fdctrl_read, .write = fdctrl_write }, - PORTIO_END_OF_LIST(), -}; - -static void isabus_fdc_realize(DeviceState *dev, Error **errp) -{ - ISADevice *isadev = ISA_DEVICE(dev); - FDCtrlISABus *isa = ISA_FDC(dev); - FDCtrl *fdctrl = &isa->state; - Error *err = 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 = isa->dma; - if (fdctrl->dma_chann != -1) { - fdctrl->dma = 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 != NULL) { - error_propagate(errp, err); - return; - } -} - static void sysbus_fdc_initfn(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); @@ -2567,200 +2505,6 @@ static void sysbus_fdc_common_realize(DeviceState *dev, Error **errp) fdctrl_realize_common(dev, fdctrl, errp); } -FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i) -{ - FDCtrlISABus *isa = 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 = *maxh = *maxs = 0; - for (fdf = fd_formats; fdf->drive != FLOPPY_DRIVE_TYPE_NONE; fdf++) { - if (fdf->drive != type) { - continue; - } - if (*maxc < fdf->max_track) { - *maxc = fdf->max_track; - } - if (*maxh < fdf->max_head) { - *maxh = fdf->max_head; - } - if (*maxs < fdf->last_sect) { - *maxs = 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 = aml_device("FLP%c", 'A' + idx); - - aml_append(dev, aml_name_decl("_ADR", aml_int(idx))); - - fdi = 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 independent - * 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 = 4; - break; - case FLOPPY_DRIVE_TYPE_288: - /* 2.88 Mb 3"5 drive */ - val = 5; - break; - case FLOPPY_DRIVE_TYPE_120: - /* 1.2 Mb 5"5 drive */ - val = 2; - break; - case FLOPPY_DRIVE_TYPE_NONE: - default: - val = 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] = { - 0, 0, 0, 0, /* presence of floppy drives #0 - #3 */ - cpu_to_le32(2) /* tape presence (2 == never present) */ - }; - - crs = 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 = aml_device("FDC0"); - aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700"))); - aml_append(dev, aml_name_decl("_CRS", crs)); - - for (i = 0; i < MIN(MAX_FD, ACPI_FDE_MAX_FD); i++) { - FloppyDriveType type = isa_fdc_get_drive_type(isadev, i); - - if (type < FLOPPY_DRIVE_TYPE_NONE) { - fde_buf[i] = 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 ={ - .name = "fdc", - .version_id = 2, - .minimum_version_id = 2, - .fields = (VMStateField[]) { - VMSTATE_STRUCT(state, FDCtrlISABus, 0, vmstate_fdc, FDCtrl), - VMSTATE_END_OF_LIST() - } -}; - -static Property isa_fdc_properties[] = { - 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].type, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_SIGNED("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].type, - 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 = DEVICE_CLASS(klass); - ISADeviceClass *isa = ISA_DEVICE_CLASS(klass); - - dc->realize = isabus_fdc_realize; - dc->fw_name = "fdc"; - dc->reset = fdctrl_external_reset_isa; - dc->vmsd = &vmstate_isa_fdc; - isa->build_aml = 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 = 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 = { - .name = TYPE_ISA_FDC, - .parent = TYPE_ISA_DEVICE, - .instance_size = sizeof(FDCtrlISABus), - .class_init = isabus_fdc_class_init, - .instance_init = isabus_fdc_instance_init, -}; - static const VMStateDescription vmstate_sysbus_fdc ={ .name = "fdc", .version_id = 2, @@ -2844,7 +2588,6 @@ static const TypeInfo sysbus_fdc_type_info = { 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 b1b50c6c334..0590cbde003 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1660,6 +1660,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 4fcd1521668..0a2c046fa6c 100644 --- a/hw/block/Kconfig +++ b/hw/block/Kconfig @@ -1,5 +1,9 @@ config FDC bool + +config FDC_ISA + bool + select FDC # 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 diff --git a/hw/block/meson.build b/hw/block/meson.build index 5b4a7699f98..f33a665c945 100644 --- a/hw/block/meson.build +++ b/hw/block/meson.build @@ -5,6 +5,7 @@ )) 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 7f91f30877f..bb475648c97 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -23,7 +23,7 @@ config PC imply TPM_TIS_ISA imply VGA_PCI imply VIRTIO_VGA - select FDC + select FDC_ISA select I8259 select I8254 select PCKBD diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig index 55e0003ce40..cb1c5e40d2a 100644 --- a/hw/isa/Kconfig +++ b/hw/isa/Kconfig @@ -27,7 +27,7 @@ config PC87312 select MC146818RTC select SERIAL_ISA select PARALLEL - select FDC + select FDC_ISA select IDE_ISA config PIIX3 @@ -46,7 +46,7 @@ config VT82C686 select ISA_SUPERIO select ACPI_SMBUS select SERIAL_ISA - select FDC + select FDC_ISA select USB_UHCI select APM @@ -55,7 +55,7 @@ config SMC37C669 select ISA_SUPERIO select SERIAL_ISA select PARALLEL - select FDC + select FDC_ISA config LPC_ICH9 bool diff --git a/hw/sparc64/Kconfig b/hw/sparc64/Kconfig index 980a201bb73..7e557ad17b0 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 From patchwork Mon May 17 17:49:43 2021 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: 1479715 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Q7jeFZDu; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkRWc4ZrMz9sWc for ; Tue, 18 May 2021 03:51:08 +1000 (AEST) Received: from localhost ([::1]:34540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihOU-0007jT-Ky for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 13:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNf-0007Jz-G5 for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNc-00031H-6f for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621273811; 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=qsjVmNyt2RvJZpbgrVA73zwoNPAL1GWOK/xDhDEI+0c=; b=Q7jeFZDuQbHyhpLcxifPR8hIhIxylq0LY/q0SzOLbeAHy4QMpr8HD6AhZj31bsco9MK1GD NN9ENxsy2ApvBex7b09I1VaJhgFvKeFWFr+Onr2G43bqf31a3ck7TeFyXajL5rokjPX5NS O8OMAU26bjTxMmaSJoxmWTgVB77z6WU= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-81PlwSebNIi-ipISPvaJXQ-1; Mon, 17 May 2021 13:50:10 -0400 X-MC-Unique: 81PlwSebNIi-ipISPvaJXQ-1 Received: by mail-ej1-f71.google.com with SMTP id sd18-20020a170906ce32b02903cedf584542so1341428ejb.9 for ; Mon, 17 May 2021 10:50:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qsjVmNyt2RvJZpbgrVA73zwoNPAL1GWOK/xDhDEI+0c=; b=HfdHIhqTcDlteRDl5LDrFNKpf5dAvDZcl0Al1PZKT6SCbeWkNGDgx76eJDTF07RQAL 2iKQWfO0cut251ZAg2HdpCeOh4+dzPXiE5hSZ+S4+/U5tILVoFJ/4l4Hz9rm6ek7Lfgc prof3mo0CYOC8CyamDaL8MKEqnhA2M5y6oyOsgJcRJisKb0RWWLE5MN4DdorVwZROOOG Vk+3abQv58q82vrGzE+1hKYvvrA3oOt+GcnNkB92wD382W8tXJXvXHoJEs+RPrndmG4l BNVWio/L9N1RYrf+NIdKPB6wBBE/X9qYI373MFeU0OiuQSA4hbBQ1ivB0e8pwmEYdTkz CKXg== X-Gm-Message-State: AOAM530vAOO/FKLyrf4m9KuTUTjbbqg1VXfI2FMeR+pvcFlqtgxdsoAY KSJpHTfsE8Pv64WyinkTptbTzpdrVCX4QhANimDoSQgGbGTvYRAIh+JsWmQoRtK4vZTEG6rWDxH NMcYHEHVAIbGEOVkH+znC+VJIOIX4ZXDRztM7afz1YVxqoJyUkFT70GYevgNHvUoh X-Received: by 2002:a17:906:600b:: with SMTP id o11mr1120133ejj.345.1621273808387; Mon, 17 May 2021 10:50:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyV3mAevRg3Jf3QxZKKXDJemqroen2UP+t83tTFbFC1wMZ2vSCmVgJgahL1hQRGOGJYSn+0ww== X-Received: by 2002:a17:906:600b:: with SMTP id o11mr1120106ejj.345.1621273808123; Mon, 17 May 2021 10:50:08 -0700 (PDT) Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id by3sm2388761edb.38.2021.05.17.10.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:50:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, John Snow Subject: [PATCH v3 4/8] hw/block/fdc: Extract SysBus floppy controllers to fdc-sysbus.c Date: Mon, 17 May 2021 19:49:43 +0200 Message-Id: <20210517174947.1199649-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517174947.1199649-1-philmd@redhat.com> References: <20210517174947.1199649-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@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.374, 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Signed-off-by: Philippe Mathieu-Daudé --- hw/block/fdc-sysbus.c | 252 ++++++++++++++++++++++++++++++++++++++++++ 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, 262 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 00000000000..71755fd6ae4 --- /dev/null +++ b/hw/block/fdc-sysbus.c @@ -0,0 +1,252 @@ +/* + * QEMU Floppy disk emulator (Intel 82078) + * + * Copyright (c) 2003, 2007 Jocelyn Mayer + * Copyright (c) 2008 Hervé Poussineau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = { + .read = fdctrl_read_mem, + .write = fdctrl_write_mem, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + +static const MemoryRegionOps fdctrl_mem_strict_ops = { + .read = fdctrl_read_mem, + .write = fdctrl_write_mem, + .endianness = DEVICE_NATIVE_ENDIAN, + .valid = { + .min_access_size = 1, + .max_access_size = 1, + }, +}; + +static void fdctrl_external_reset_sysbus(DeviceState *d) +{ + FDCtrlSysBus *sys = SYSBUS_FDC(d); + FDCtrl *s = &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 = qdev_new("sysbus-fdc"); + sys = SYSBUS_FDC(dev); + fdctrl = &sys->state; + fdctrl->dma_chann = dma_chann; /* FIXME */ + sbd = 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 = qdev_new("sun-fdtwo"); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sys = SYSBUS_FDC(dev); + sysbus_connect_irq(SYS_BUS_DEVICE(sys), 0, irq); + sysbus_mmio_map(SYS_BUS_DEVICE(sys), 0, io_base); + *fdc_tc = qdev_get_gpio_in(dev, 0); + + fdctrl_init_drives(&sys->state.bus, fds); +} + +static void sysbus_fdc_common_initfn(Object *obj) +{ + DeviceState *dev = DEVICE(obj); + FDCtrlSysBusClass *sbdc = SYSBUS_FDC_GET_CLASS(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + FDCtrlSysBus *sys = SYSBUS_FDC(obj); + FDCtrl *fdctrl = &sys->state; + + fdctrl->dma_chann = -1; + + 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_common_realize(DeviceState *dev, Error **errp) +{ + FDCtrlSysBus *sys = SYSBUS_FDC(dev); + FDCtrl *fdctrl = &sys->state; + + fdctrl_realize_common(dev, fdctrl, errp); +} + +static const VMStateDescription vmstate_sysbus_fdc = { + .name = "fdc", + .version_id = 2, + .minimum_version_id = 2, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(state, FDCtrlSysBus, 0, vmstate_fdc, FDCtrl), + VMSTATE_END_OF_LIST() + } +}; + +static Property sysbus_fdc_properties[] = { + DEFINE_PROP_SIGNED("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].type, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_SIGNED("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].type, + 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 = DEVICE_CLASS(klass); + + device_class_set_props(dc, sysbus_fdc_properties); + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); +} + +static const TypeInfo sysbus_fdc_info = { + .name = "sysbus-fdc", + .parent = TYPE_SYSBUS_FDC, + .class_init = sysbus_fdc_class_init, +}; + +static void sysbus_fdc_common_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->realize = sysbus_fdc_common_realize; + dc->reset = fdctrl_external_reset_sysbus; + dc->vmsd = &vmstate_sysbus_fdc; +} + +static const TypeInfo sysbus_fdc_type_info = { + .name = TYPE_SYSBUS_FDC, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(FDCtrlSysBus), + .instance_init = sysbus_fdc_common_initfn, + .abstract = true, + .class_init = sysbus_fdc_common_class_init, + .class_size = sizeof(FDCtrlSysBusClass), +}; + +static Property sun4m_fdc_properties[] = { + DEFINE_PROP_SIGNED("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].type, + 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 = SYSBUS_FDC_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); + + sbdc->use_strict_io = true; + device_class_set_props(dc, sun4m_fdc_properties); + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); +} + +static const TypeInfo sun4m_fdc_info = { + .name = "sun-fdtwo", + .parent = TYPE_SYSBUS_FDC, + .class_init = sun4m_fdc_class_init, +}; + +static void sysbus_fdc_register_types(void) +{ + type_register_static(&sun4m_fdc_info); + type_register_static(&sysbus_fdc_type_info); + type_register_static(&sysbus_fdc_info); +} + +type_init(sysbus_fdc_register_types) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 50567d972ff..64af4d194ce 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" @@ -775,17 +774,6 @@ static FloppyDriveType get_fallback_drive_type(FDrive *drv) return drv->fdctrl->fallback; } -#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 = opaque; @@ -850,34 +838,6 @@ void fdctrl_write(void *opaque, uint32_t reg, uint32_t value) } } -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 = { - .read = fdctrl_read_mem, - .write = fdctrl_write_mem, - .endianness = DEVICE_NATIVE_ENDIAN, -}; - -static const MemoryRegionOps fdctrl_mem_strict_ops = { - .read = fdctrl_read_mem, - .write = fdctrl_write_mem, - .endianness = DEVICE_NATIVE_ENDIAN, - .valid = { - .min_access_size = 1, - .max_access_size = 1, - }, -}; - static bool fdrive_media_changed_needed(void *opaque) { FDrive *drive = opaque; @@ -1101,19 +1061,6 @@ const VMStateDescription vmstate_fdc = { } }; -static void fdctrl_external_reset_sysbus(DeviceState *d) -{ - FDCtrlSysBus *sys = SYSBUS_FDC(d); - FDCtrl *s = &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) { @@ -2370,42 +2317,6 @@ void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds) } } -void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, - hwaddr mmio_base, DriveInfo **fds) -{ - FDCtrl *fdctrl; - DeviceState *dev; - SysBusDevice *sbd; - FDCtrlSysBus *sys; - - dev = qdev_new("sysbus-fdc"); - sys = SYSBUS_FDC(dev); - fdctrl = &sys->state; - fdctrl->dma_chann = dma_chann; /* FIXME */ - sbd = 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 = qdev_new("sun-fdtwo"); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - sys = SYSBUS_FDC(dev); - sysbus_connect_irq(SYS_BUS_DEVICE(sys), 0, irq); - sysbus_mmio_map(SYS_BUS_DEVICE(sys), 0, io_base); - *fdc_tc = 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; @@ -2458,139 +2369,8 @@ void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp) } } -static void sysbus_fdc_initfn(Object *obj) -{ - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - FDCtrlSysBus *sys = SYSBUS_FDC(obj); - FDCtrl *fdctrl = &sys->state; - - fdctrl->dma_chann = -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 = SYS_BUS_DEVICE(obj); - FDCtrlSysBus *sys = SYSBUS_FDC(obj); - FDCtrl *fdctrl = &sys->state; - - fdctrl->dma_chann = -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 = DEVICE(obj); - SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - FDCtrlSysBus *sys = SYSBUS_FDC(obj); - FDCtrl *fdctrl = &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 = SYSBUS_FDC(dev); - FDCtrl *fdctrl = &sys->state; - - fdctrl_realize_common(dev, fdctrl, errp); -} - -static const VMStateDescription vmstate_sysbus_fdc ={ - .name = "fdc", - .version_id = 2, - .minimum_version_id = 2, - .fields = (VMStateField[]) { - VMSTATE_STRUCT(state, FDCtrlSysBus, 0, vmstate_fdc, FDCtrl), - VMSTATE_END_OF_LIST() - } -}; - -static Property sysbus_fdc_properties[] = { - DEFINE_PROP_SIGNED("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].type, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_SIGNED("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].type, - 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 = DEVICE_CLASS(klass); - - device_class_set_props(dc, sysbus_fdc_properties); - set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); -} - -static const TypeInfo sysbus_fdc_info = { - .name = "sysbus-fdc", - .parent = TYPE_SYSBUS_FDC, - .instance_init = sysbus_fdc_initfn, - .class_init = sysbus_fdc_class_init, -}; - -static Property sun4m_fdc_properties[] = { - DEFINE_PROP_SIGNED("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].type, - 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 = DEVICE_CLASS(klass); - - device_class_set_props(dc, sun4m_fdc_properties); - set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); -} - -static const TypeInfo sun4m_fdc_info = { - .name = "sun-fdtwo", - .parent = TYPE_SYSBUS_FDC, - .instance_init = sun4m_fdc_initfn, - .class_init = sun4m_fdc_class_init, -}; - -static void sysbus_fdc_common_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc = DEVICE_CLASS(klass); - - dc->realize = sysbus_fdc_common_realize; - dc->reset = fdctrl_external_reset_sysbus; - dc->vmsd = &vmstate_sysbus_fdc; -} - -static const TypeInfo sysbus_fdc_type_info = { - .name = TYPE_SYSBUS_FDC, - .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(FDCtrlSysBus), - .instance_init = sysbus_fdc_common_initfn, - .abstract = true, - .class_init = 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 0590cbde003..b3c1242efcf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1661,6 +1661,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 0a2c046fa6c..d50be837666 100644 --- a/hw/block/Kconfig +++ b/hw/block/Kconfig @@ -8,6 +8,10 @@ config FDC_ISA # select ISA_BUS here instead of polluting each board that requires one select ISA_BUS +config FDC_SYSBUS + bool + select FDC + config SSI_M25P80 bool diff --git a/hw/block/meson.build b/hw/block/meson.build index f33a665c945..c3935350485 100644 --- a/hw/block/meson.build +++ b/hw/block/meson.build @@ -6,6 +6,7 @@ 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 306989c193c..266b34393a3 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" # pflash_cfi01.c diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig index aadd436bf4e..c245e881a2b 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 8dcb10086fd..79d58beb7a6 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 From patchwork Mon May 17 17:49:44 2021 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: 1479717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cndDn0Ez; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkRZG53dvz9sWc for ; Tue, 18 May 2021 03:53:26 +1000 (AEST) Received: from localhost ([::1]:42004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihQi-0004Lq-Ko for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 13:53:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNj-0007YH-0i for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNg-000330-IA for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621273815; 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=Fhf+AVXUBClcrbXUaAt1JBIAw3G0Rh6YDh+yCprkS/g=; b=cndDn0EzXIS8KLGkvcZk1uDN+n7G6rT4lOeuFe+OUbZszQuj+KF2ZYGrOLH9nCA7urT7oB heu+HaC0vAV5MU0IkWzbMXu03vtjVGk5hb94sy2SoQC+ojd6ZDLRmANHq9JXy3U9p8lTZ4 DfhVcGinVoseLwwKTZqNk6+4hfPL1eU= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-dPL0RlmmP2eWnIr_eAoIqg-1; Mon, 17 May 2021 13:50:14 -0400 X-MC-Unique: dPL0RlmmP2eWnIr_eAoIqg-1 Received: by mail-ed1-f69.google.com with SMTP id d8-20020a0564020008b0290387d38e3ce0so4347081edu.1 for ; Mon, 17 May 2021 10:50:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fhf+AVXUBClcrbXUaAt1JBIAw3G0Rh6YDh+yCprkS/g=; b=RbavD+FgLQO8TOgtTBZUi0EvlqRdTLf6KWzQWH9XUCFWTvagO1+qdaXekVRkoiL6S6 K9P0yFmiecJwdQXd43gwUo9/m4ffTUo4czbLY14cYFkNI0adp6wcsuxQmoMz62T2bjIM Z+hPJwRnbxaUD+XCeYRVbQ0OaXEC4cRgeA/9EUd2DOxNjqCkz2/rW56GLAUX7XWsrlDF g+DJIztQZRuuXUC6MXd+m0xIUNytJtMvUiv6KRBywxUjCrgMxXdWYACh/EzePMiWV+MK ZA4n9lR+S2NtOnVLYSXQJwqEyCM3MvZONyB/ob6A5Kv/CaFEgPynCu9DTsphZsXzfi5y eAeQ== X-Gm-Message-State: AOAM533HPE+6nCsxpsxLYrEOoP1AWzfTpjpTOoeNiDTyl9CLndeM6/KM 7HT2jjyHBJ5xGJSQHEwoaV6vthmIwIQaoHwtxAV1FWow/P86Wi1IJQl6o6JxnX6qZ0fvpmvzAtI 2ZEqxQ3qsQe6/G8arQJE68JQnJLMr1dtluB4MI3OTrLeJK8Kv1FzXWSl/yhWD8YpC X-Received: by 2002:aa7:da8e:: with SMTP id q14mr1499497eds.13.1621273812882; Mon, 17 May 2021 10:50:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCC71n6xVzcfe/mBFv6ZisP9EWYSa0DW+ItSM+g1cIFO6xdp4CvnsHwVj+J3l6lIQmBJTW6g== X-Received: by 2002:aa7:da8e:: with SMTP id q14mr1499478eds.13.1621273812689; Mon, 17 May 2021 10:50:12 -0700 (PDT) Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id cw12sm2703174ejc.17.2021.05.17.10.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:50:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, John Snow Subject: [PATCH v3 5/8] hw/block/fdc: Add sysbus_fdc_init_drives() method Date: Mon, 17 May 2021 19:49:44 +0200 Message-Id: <20210517174947.1199649-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517174947.1199649-1-philmd@redhat.com> References: <20210517174947.1199649-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@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.374, 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" FDCtrlSysBus's FDCtrl state is a private field. However it is accessed by the public fdctrl_init_sysbus() and sun4m_fdctrl_init() methods. To be able to move them out of fdc-sysbus.c, first add the sysbus_fdc_init_drives() method and use it in these 2 functions. Reviewed-by: Mark Cave-Ayland Signed-off-by: Philippe Mathieu-Daudé --- include/hw/block/fdc.h | 2 ++ hw/block/fdc-sysbus.c | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h index 1ecca7cac7f..52e45c53078 100644 --- a/include/hw/block/fdc.h +++ b/include/hw/block/fdc.h @@ -3,6 +3,7 @@ #include "exec/hwaddr.h" #include "qapi/qapi-types-block.h" +#include "hw/sysbus.h" /* fdc.c */ #define MAX_FD 2 @@ -10,6 +11,7 @@ #define TYPE_ISA_FDC "isa-fdc" void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds); +void sysbus_fdc_init_drives(SysBusDevice *dev, DriveInfo **fds); void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, hwaddr mmio_base, DriveInfo **fds); void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c index 71755fd6ae4..1163e53165d 100644 --- a/hw/block/fdc-sysbus.c +++ b/hw/block/fdc-sysbus.c @@ -94,6 +94,15 @@ static void fdctrl_handle_tc(void *opaque, int irq, int level) trace_fdctrl_tc_pulse(level); } +void sysbus_fdc_init_drives(SysBusDevice *dev, DriveInfo **fds) +{ + FDCtrlSysBus *fdc; + + fdc = SYSBUS_FDC(dev); + + fdctrl_init_drives(&fdc->state.bus, fds); +} + void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, hwaddr mmio_base, DriveInfo **fds) { @@ -111,23 +120,23 @@ void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, sysbus_connect_irq(sbd, 0, irq); sysbus_mmio_map(sbd, 0, mmio_base); - fdctrl_init_drives(&sys->state.bus, fds); + sysbus_fdc_init_drives(sbd, fds); } void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, DriveInfo **fds, qemu_irq *fdc_tc) { DeviceState *dev; - FDCtrlSysBus *sys; + SysBusDevice *sbd; dev = qdev_new("sun-fdtwo"); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - sys = SYSBUS_FDC(dev); - sysbus_connect_irq(SYS_BUS_DEVICE(sys), 0, irq); - sysbus_mmio_map(SYS_BUS_DEVICE(sys), 0, io_base); + sbd = SYS_BUS_DEVICE(dev); + sysbus_realize_and_unref(sbd, &error_fatal); + sysbus_connect_irq(sbd, 0, irq); + sysbus_mmio_map(sbd, 0, io_base); *fdc_tc = qdev_get_gpio_in(dev, 0); - fdctrl_init_drives(&sys->state.bus, fds); + sysbus_fdc_init_drives(sbd, fds); } static void sysbus_fdc_common_initfn(Object *obj) From patchwork Mon May 17 17:49:45 2021 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: 1479720 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KfjQX1Aw; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkRdj6bdmz9sPf for ; Tue, 18 May 2021 03:56:25 +1000 (AEST) Received: from localhost ([::1]:51240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihTb-00028f-O6 for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 13:56:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNr-0007oP-5I for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNl-00035z-Uh for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621273821; 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=Mwkhq1zzg8MDDjVW8AOR0NelXXYM0Xsfxsfa4jWuzBw=; b=KfjQX1Aw5PNWZjnSW3/TcHOjzPL0AKiQ9yi399TzPJGYdFBLiKKXwbY/Kkwn6ysDRSSbi6 VU1mGj6gIWPuAaFvy12rykqAuJi9BpsEZTZE3Rs886Hz87uLtiIs9zseqfCIGffljW7zy0 tX5lhvZRp6Y1Uxq9YbELs10NwDQO/bU= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-361-8cOFO2NoPUSpbAqZ-dQqiw-1; Mon, 17 May 2021 13:50:19 -0400 X-MC-Unique: 8cOFO2NoPUSpbAqZ-dQqiw-1 Received: by mail-ej1-f71.google.com with SMTP id la2-20020a170906ad82b02903d4bcc8de3bso1348460ejb.4 for ; Mon, 17 May 2021 10:50:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mwkhq1zzg8MDDjVW8AOR0NelXXYM0Xsfxsfa4jWuzBw=; b=OQFQ/7jUeE90N8S0atz9iUTfl/PblKmGVTCPEp6qyw3E3tm7r3ymcpzTtBxPiGXwWJ yPUq89OUOhR+2wGLDVVdf3/REY9zTxrpUGe3G82R4VxbJTz0+nN0cySwYeNprNyhvJGt sTfd8zI163qfGO0q5NX/Aklg+dr0e0vrhJ2BUfO94sznEEj+dxJGzBjwGJWdz3TDHxGJ iubioGnM591Nb3sBMptZcNkiM33lbmKfRQHDI2yRlOmRwJfD7RpGxPQfm62Eo4e218IA 1uxw5ii1GykS2LIxkN7CXZcCBN7/gr6DHk35/fENWljNOEmqTR1Td2gXUdUjjziOl3MZ Yx/g== X-Gm-Message-State: AOAM531b+1kHSgZC066B+XAGAqY7/udONBa9u306R7Wbb8gcJ8dIIYvy 22TDqFhqkLPDKVDNXOz4dokYQ2cCo8kHaaIAVtYFLj0IzMNbYVcmVAL4jRIMnxrdqXnmoXUF4Pi 7ye/TVIjQGrgl2IAnxhmdU9lVFFZyeMfl7nn/+g5Yp677NavYE/URjEGMmN/n85p/ X-Received: by 2002:a05:6402:cb8:: with SMTP id cn24mr1421530edb.325.1621273817450; Mon, 17 May 2021 10:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyryAMoN9Q8R4kGyfjyAIC1fA08fGqs1LrNVL4jLrkRuggitFpYC7RHtuzgrCcuEGMY4ZiS+A== X-Received: by 2002:a05:6402:cb8:: with SMTP id cn24mr1421499edb.325.1621273817235; Mon, 17 May 2021 10:50:17 -0700 (PDT) Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id f7sm11693938edd.5.2021.05.17.10.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:50:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, John Snow Subject: [PATCH v3 6/8] hw/sparc/sun4m: Inline sun4m_fdctrl_init() Date: Mon, 17 May 2021 19:49:45 +0200 Message-Id: <20210517174947.1199649-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517174947.1199649-1-philmd@redhat.com> References: <20210517174947.1199649-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@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.374, 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There is only one call site for sun4m_fdctrl_init(), and this function is specific to the sun4m machines, not part of the SYSBUS_FDC API. Move it locally with the machine code, and remove its declaration in "hw/block/fdc.h". Suggested-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Signed-off-by: Philippe Mathieu-Daudé --- include/hw/block/fdc.h | 2 -- hw/block/fdc-sysbus.c | 16 ---------------- hw/sparc/sun4m.c | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h index 52e45c53078..06612218630 100644 --- a/include/hw/block/fdc.h +++ b/include/hw/block/fdc.h @@ -14,8 +14,6 @@ void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds); void sysbus_fdc_init_drives(SysBusDevice *dev, DriveInfo **fds); void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, hwaddr mmio_base, DriveInfo **fds); -void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, - DriveInfo **fds, qemu_irq *fdc_tc); FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i); int cmos_get_fd_drive_type(FloppyDriveType fd0); diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c index 1163e53165d..8f94c2efb63 100644 --- a/hw/block/fdc-sysbus.c +++ b/hw/block/fdc-sysbus.c @@ -123,22 +123,6 @@ void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, sysbus_fdc_init_drives(sbd, fds); } -void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, - DriveInfo **fds, qemu_irq *fdc_tc) -{ - DeviceState *dev; - SysBusDevice *sbd; - - dev = qdev_new("sun-fdtwo"); - sbd = SYS_BUS_DEVICE(dev); - sysbus_realize_and_unref(sbd, &error_fatal); - sysbus_connect_irq(sbd, 0, irq); - sysbus_mmio_map(sbd, 0, io_base); - *fdc_tc = qdev_get_gpio_in(dev, 0); - - sysbus_fdc_init_drives(sbd, fds); -} - static void sysbus_fdc_common_initfn(Object *obj) { DeviceState *dev = DEVICE(obj); diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 42e139849ed..c08c650da72 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -816,6 +816,22 @@ static void dummy_fdc_tc(void *opaque, int irq, int level) { } +static void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, + DriveInfo **fds, qemu_irq *fdc_tc) +{ + DeviceState *dev; + SysBusDevice *sbd; + + dev = qdev_new("sun-fdtwo"); + sbd = SYS_BUS_DEVICE(dev); + sysbus_realize_and_unref(sbd, &error_fatal); + sysbus_connect_irq(sbd, 0, irq); + sysbus_mmio_map(sbd, 0, io_base); + *fdc_tc = qdev_get_gpio_in(dev, 0); + + sysbus_fdc_init_drives(sbd, fds); +} + static void sun4m_hw_init(MachineState *machine) { const struct sun4m_hwdef *hwdef = SUN4M_MACHINE_GET_CLASS(machine)->hwdef; From patchwork Mon May 17 17:49:46 2021 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: 1479718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JgcsvZpk; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkRb70Syfz9sPf for ; Tue, 18 May 2021 03:54:11 +1000 (AEST) Received: from localhost ([::1]:43562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihRQ-0005O4-Sa for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 13:54:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNt-0007tB-GP for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNq-00037m-Fq for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621273825; 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=Z14YRAeNHkM20zQ1K99pTtwaHYhMgqGiS7m7zkt7SV4=; b=JgcsvZpkDKxfsHU+LzG1Q9Lh930+DZQL6g3WwyMrhJ38+RgEQ6FQJttBaAoIxQ/st7DUlp YkNXKNmm1LBMLXuRtCyVcDIJO3Y578+N8eTgWJNxU6ZZpDZd/mHztUrsq9vn9upwdHmyyW P5szGrg4YsewKubXVw3aRcYWGhE1950= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-rbqQBOwNO7m0Dk3NncS3nQ-1; Mon, 17 May 2021 13:50:23 -0400 X-MC-Unique: rbqQBOwNO7m0Dk3NncS3nQ-1 Received: by mail-ej1-f69.google.com with SMTP id i23-20020a17090685d7b02903d089ab83fcso1327513ejy.19 for ; Mon, 17 May 2021 10:50:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z14YRAeNHkM20zQ1K99pTtwaHYhMgqGiS7m7zkt7SV4=; b=LeWn1ywfmEN0ZyFMrq3wFJlVZsTaJxjHWH3QqkLtUjpuNoNLClsGG3ldUJ45Rsty4F DUfSKXl01tImM40iaAeBTrLCWWixFfsLRi6NTnVk2qp3uFmPlGXgEfX9BKdAlKlCIRxP eSlfHTYSXOz/kzm0aV3gwmSuxvQoWjYvQ+HWoxYgSr/9p+ShQ05k8T7KoV6qcMHilXoR Ga6T3KN8R+Jf7j3CHCC7wpwGX+wU8+RqCN1wH5fVnTTBiEMdUcWEqFU0BitF6MlbFLlp 6lA3T2uhpUC/4v9zdMGsFRaJFY1GRIrHpyvcIq06RH/EUJOy8kET5Pz4AvTX6ZM1SaRE LakA== X-Gm-Message-State: AOAM533mXZiAC09OD80SreHfe7sGy9t1SIMknVZNRx51vsDbs5juKvJe bcsUo4o0MaipHtvEp7EM+oMftZWOCd9OUqK9TAgfN7+gj1F/5N8YzWRFW89D97weL4uI35T+/Fn xPl+hWloz7tumeDZFw9UnZOXFRDb+TA4+MCfIRTIJC8P0FSsC8BZidkYNq16rpJkw X-Received: by 2002:aa7:c787:: with SMTP id n7mr1453596eds.309.1621273822150; Mon, 17 May 2021 10:50:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi2j1K+yCR15AGxnq0veIJwc1a53Y3utPJZB9BtNBPYrTMmmKWhTdMkaMl2/tYHjiG8XKKRg== X-Received: by 2002:aa7:c787:: with SMTP id n7mr1453573eds.309.1621273821957; Mon, 17 May 2021 10:50:21 -0700 (PDT) Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id dh21sm175127edb.28.2021.05.17.10.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:50:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, John Snow Subject: [PATCH v3 7/8] hw/block/fdc-sysbus: Add 'dma-channel' property Date: Mon, 17 May 2021 19:49:46 +0200 Message-Id: <20210517174947.1199649-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517174947.1199649-1-philmd@redhat.com> References: <20210517174947.1199649-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@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.374, 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" QDev properties to be set before the device is realized should be exposed as a Property with a DEFINE_PROP_XXX() macro, then accessed with the equivalent qdev_prop_set_xxx() API. Do this with the FDCtrlSysBus 'dma-channel' property: convert it to int32_t, default-initialize with DEFINE_PROP_INT32() and use qdev_prop_set_int32() to set its value in fdctrl_init_sysbus(). Reviewed-by: Mark Cave-Ayland Signed-off-by: Philippe Mathieu-Daudé --- hw/block/fdc-internal.h | 2 +- hw/block/fdc-sysbus.c | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/hw/block/fdc-internal.h b/hw/block/fdc-internal.h index 278de725e69..29b318f7525 100644 --- a/hw/block/fdc-internal.h +++ b/hw/block/fdc-internal.h @@ -96,7 +96,7 @@ struct FDCtrl { qemu_irq irq; /* Controller state */ QEMUTimer *result_timer; - int dma_chann; + int32_t dma_chann; uint8_t phase; IsaDma *dma; /* Controller's identification */ diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c index 8f94c2efb63..74c7c8f2e01 100644 --- a/hw/block/fdc-sysbus.c +++ b/hw/block/fdc-sysbus.c @@ -106,15 +106,11 @@ void sysbus_fdc_init_drives(SysBusDevice *dev, DriveInfo **fds) void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, hwaddr mmio_base, DriveInfo **fds) { - FDCtrl *fdctrl; DeviceState *dev; SysBusDevice *sbd; - FDCtrlSysBus *sys; dev = qdev_new("sysbus-fdc"); - sys = SYSBUS_FDC(dev); - fdctrl = &sys->state; - fdctrl->dma_chann = dma_chann; /* FIXME */ + qdev_prop_set_int32(dev, "dma-channel", dma_chann); sbd = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(sbd, &error_fatal); sysbus_connect_irq(sbd, 0, irq); @@ -131,8 +127,6 @@ static void sysbus_fdc_common_initfn(Object *obj) FDCtrlSysBus *sys = SYSBUS_FDC(obj); FDCtrl *fdctrl = &sys->state; - fdctrl->dma_chann = -1; - qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */ memory_region_init_io(&fdctrl->iomem, obj, @@ -173,6 +167,7 @@ static Property sysbus_fdc_properties[] = { DEFINE_PROP_SIGNED("fallback", FDCtrlSysBus, state.fallback, FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, FloppyDriveType), + DEFINE_PROP_INT32("dma-channel", FDCtrlSysBus, state.dma_chann, -1), DEFINE_PROP_END_OF_LIST(), }; From patchwork Mon May 17 17:49:47 2021 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: 1479721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TIw4iPIg; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkRgZ6bWBz9sWP for ; Tue, 18 May 2021 03:58:02 +1000 (AEST) Received: from localhost ([::1]:57488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lihVB-0006Jf-01 for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 13:58:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNz-0008GM-8H for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihNv-00039r-CA for qemu-devel@nongnu.org; Mon, 17 May 2021 13:50:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621273830; 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=hRToPB7aVX8q9xnZeseUZTykg3nheLziCrX7lqUCi3Q=; b=TIw4iPIggEwlCCzfmPWm8WonbeIOFwVQw3TahEprhzCXFFOEsIMJ5ZSXqAbEC8H9n7NoFt AlAeiuKhIS0YMa/JgHcBZywY721OOfgl3GmDjvMDfmAlu/+gJzk8yOAp9z/eYImiN5RTf4 IWMDl0QRKdBuV9XeTI7iJkGiZTD/nGE= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-W322edHPOGmPlMvjPa5pRg-1; Mon, 17 May 2021 13:50:28 -0400 X-MC-Unique: W322edHPOGmPlMvjPa5pRg-1 Received: by mail-ed1-f69.google.com with SMTP id ba15-20020a0564021acfb029038d3b33d7ffso1646481edb.23 for ; Mon, 17 May 2021 10:50:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hRToPB7aVX8q9xnZeseUZTykg3nheLziCrX7lqUCi3Q=; b=WNhvzbnEH5ymGB76HhVGxSf1NUISADjjmOImtNeb5+COxQsWnRHgeKnwZq9h4r1VD9 mrrkAVGY1APflNIinV8d0/DlVElv1yBwUKNqIJxUbfxZVULjOUZASBVIYNKieQ6NKrm2 vkVAtX7s4E/TU1Dsmbimv+0H5cAOycIA65bGhdbsI9WEfe5s3VKiuSwuE7mbhiD3TRnr rWqPVvbs8k5ALb+4P/fquJAVnOTu0RWMVnOP4lsyC8TDC3Rg9j8insCf0xC7KWpPXh0K rGOEI7zuc3bLR2QrQu/xFQY3JyKzafkFd+HL3Gy+KPGMsm7aq7Hdk6r63QCDrFUCIRnz WTsQ== X-Gm-Message-State: AOAM532gGVxfgIkNi++H7Ze3j4AzNqNlRTNAFJMIfWVMgbL/oAInLn7p m5D1hFuAF+Vj1VMugHssAQxDayH76pasbNxHLbI/fMSuOsY0gSsIdRWcu4LHQsPIZFjfhV+bHc0 Q3yYsVp9qROJRTCX7I0ssGCOp05JcGMofI2M+o1XzGmVYEt1Dte5ILnGO17PPv6G5 X-Received: by 2002:a17:907:7629:: with SMTP id jy9mr1194519ejc.34.1621273826984; Mon, 17 May 2021 10:50:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzODUm3mVPwuOlFVr10c9JlN9Z6uTvJ41uIv8E7SHmszJEhEAC2RWiHaq++zdOshgjCLcWwaQ== X-Received: by 2002:a17:907:7629:: with SMTP id jy9mr1194499ejc.34.1621273826749; Mon, 17 May 2021 10:50:26 -0700 (PDT) Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id x9sm11516147edv.22.2021.05.17.10.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:50:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, John Snow Subject: [PATCH v3 8/8] hw/mips/jazz: Inline fdctrl_init_sysbus() Date: Mon, 17 May 2021 19:49:47 +0200 Message-Id: <20210517174947.1199649-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517174947.1199649-1-philmd@redhat.com> References: <20210517174947.1199649-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@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.374, 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There is only one call site for fdctrl_init_sysbus(), and this function is specific to the jazz machines, not part of the SYSBUS_FDC API. Move it locally with the machine code, and remove its declaration in "hw/block/fdc.h". Suggested-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Signed-off-by: Philippe Mathieu-Daudé --- include/hw/block/fdc.h | 3 --- hw/block/fdc-sysbus.c | 16 ---------------- hw/mips/jazz.c | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h index 06612218630..ac99d6bcaa0 100644 --- a/include/hw/block/fdc.h +++ b/include/hw/block/fdc.h @@ -1,7 +1,6 @@ #ifndef HW_FDC_H #define HW_FDC_H -#include "exec/hwaddr.h" #include "qapi/qapi-types-block.h" #include "hw/sysbus.h" @@ -12,8 +11,6 @@ void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds); void sysbus_fdc_init_drives(SysBusDevice *dev, DriveInfo **fds); -void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, - hwaddr mmio_base, DriveInfo **fds); FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i); int cmos_get_fd_drive_type(FloppyDriveType fd0); diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c index 74c7c8f2e01..5c7e49bcc3f 100644 --- a/hw/block/fdc-sysbus.c +++ b/hw/block/fdc-sysbus.c @@ -103,22 +103,6 @@ void sysbus_fdc_init_drives(SysBusDevice *dev, DriveInfo **fds) fdctrl_init_drives(&fdc->state.bus, fds); } -void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, - hwaddr mmio_base, DriveInfo **fds) -{ - DeviceState *dev; - SysBusDevice *sbd; - - dev = qdev_new("sysbus-fdc"); - qdev_prop_set_int32(dev, "dma-channel", dma_chann); - sbd = SYS_BUS_DEVICE(dev); - sysbus_realize_and_unref(sbd, &error_fatal); - sysbus_connect_irq(sbd, 0, irq); - sysbus_mmio_map(sbd, 0, mmio_base); - - sysbus_fdc_init_drives(sbd, fds); -} - static void sysbus_fdc_common_initfn(Object *obj) { DeviceState *dev = DEVICE(obj); diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index dba2088ed1a..13f26c5991f 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -143,6 +143,22 @@ static void mips_jazz_do_transaction_failed(CPUState *cs, hwaddr physaddr, } #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ +static void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, + hwaddr mmio_base, DriveInfo **fds) +{ + DeviceState *dev; + SysBusDevice *sbd; + + dev = qdev_new("sysbus-fdc"); + qdev_prop_set_int32(dev, "dma-channel", dma_chann); + sbd = SYS_BUS_DEVICE(dev); + sysbus_realize_and_unref(sbd, &error_fatal); + sysbus_connect_irq(sbd, 0, irq); + sysbus_mmio_map(sbd, 0, mmio_base); + + sysbus_fdc_init_drives(sbd, fds); +} + static void mips_jazz_init(MachineState *machine, enum jazz_model_e jazz_model) {