qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Max Reitz <mreitz@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: [PATCH 1/7] floppy: move isa_fdc_get_drive_type to separate source file.
Date: Wed,  4 Aug 2021 16:27:31 +0200	[thread overview]
Message-ID: <20210804142737.3366441-2-kraxel@redhat.com> (raw)
In-Reply-To: <20210804142737.3366441-1-kraxel@redhat.com>

isa_fdc_get_drive_type() is needed by pc machine types
when setting up the cmos.

Move to separate source file so we can keep it in core qemu
when building floppy as module.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/block/fdc-internal.h | 16 ++++++++++++++++
 hw/block/fdc-isa.c      | 22 ----------------------
 hw/block/fdc-module.c   | 39 +++++++++++++++++++++++++++++++++++++++
 hw/block/meson.build    |  1 +
 4 files changed, 56 insertions(+), 22 deletions(-)
 create mode 100644 hw/block/fdc-module.c

diff --git a/hw/block/fdc-internal.h b/hw/block/fdc-internal.h
index 036392e9fc10..a74cd5e4b9f2 100644
--- a/hw/block/fdc-internal.h
+++ b/hw/block/fdc-internal.h
@@ -29,6 +29,7 @@
 #include "exec/ioport.h"
 #include "hw/block/block.h"
 #include "hw/block/fdc.h"
+#include "hw/isa/isa.h"
 #include "qapi/qapi-types-block.h"
 
 typedef struct FDCtrl FDCtrl;
@@ -143,6 +144,21 @@ struct FDCtrl {
     PortioList portio_list;
 };
 
+OBJECT_DECLARE_SIMPLE_TYPE(FDCtrlISABus, ISA_FDC)
+
+struct FDCtrlISABus {
+    /*< private >*/
+    ISADevice parent_obj;
+    /*< public >*/
+
+    uint32_t iobase;
+    uint32_t irq;
+    uint32_t dma;
+    struct FDCtrl state;
+    int32_t bootindexA;
+    int32_t bootindexB;
+};
+
 extern const FDFormat fd_formats[];
 extern const VMStateDescription vmstate_fdc;
 
diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c
index 3bf64e06657b..dd7e1669f862 100644
--- a/hw/block/fdc-isa.c
+++ b/hw/block/fdc-isa.c
@@ -49,21 +49,6 @@
 #include "qom/object.h"
 #include "fdc-internal.h"
 
-OBJECT_DECLARE_SIMPLE_TYPE(FDCtrlISABus, ISA_FDC)
-
-struct FDCtrlISABus {
-    /*< private >*/
-    ISADevice parent_obj;
-    /*< public >*/
-
-    uint32_t iobase;
-    uint32_t irq;
-    uint32_t dma;
-    struct FDCtrl state;
-    int32_t bootindexA;
-    int32_t bootindexB;
-};
-
 static void fdctrl_external_reset_isa(DeviceState *d)
 {
     FDCtrlISABus *isa = ISA_FDC(d);
@@ -117,13 +102,6 @@ static void isabus_fdc_realize(DeviceState *dev, Error **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)
 {
diff --git a/hw/block/fdc-module.c b/hw/block/fdc-module.c
new file mode 100644
index 000000000000..93953bf0aa57
--- /dev/null
+++ b/hw/block/fdc-module.c
@@ -0,0 +1,39 @@
+/*
+ * QEMU Floppy disk emulator (Intel 82078)
+ *
+ * Some small helper functions which must be built into core qemu when
+ * building floppy as module.
+ *
+ * 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 "hw/isa/isa.h"
+#include "hw/block/fdc.h"
+#include "fdc-internal.h"
+
+FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
+{
+    FDCtrlISABus *isa = ISA_FDC(fdc);
+
+    return isa->state.drives[i].drive;
+}
diff --git a/hw/block/meson.build b/hw/block/meson.build
index 2389326112ae..8460042fe320 100644
--- a/hw/block/meson.build
+++ b/hw/block/meson.build
@@ -4,6 +4,7 @@ softmmu_ss.add(files(
   'hd-geometry.c'
 ))
 softmmu_ss.add(when: 'CONFIG_ECC', if_true: files('ecc.c'))
+softmmu_ss.add(when: 'CONFIG_FDC', if_true: files('fdc-module.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'))
-- 
2.31.1



  reply	other threads:[~2021-08-04 14:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 14:27 [PATCH 0/7] floppy: build as modules Gerd Hoffmann
2021-08-04 14:27 ` Gerd Hoffmann [this message]
2021-08-04 14:27 ` [PATCH 2/7] floppy: move isa_fdc_init_drives + fdctrl_init_drives Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 3/7] floppy: move fdctrl_init_sysbus Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 4/7] floppy: move sun4m_fdctrl_init Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 5/7] floppy: move cmos_get_fd_drive_type Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 6/7] floppy: build as modules Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 7/7] pc: add floppy=OnOffAuto Gerd Hoffmann
2021-08-04 15:19 ` [PATCH 0/7] floppy: build as modules Philippe Mathieu-Daudé
2021-08-05  7:11   ` Gerd Hoffmann
2021-08-16 21:55     ` John Snow
2021-08-17  9:09       ` Philippe Mathieu-Daudé
2021-08-17 13:19         ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210804142737.3366441-2-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).