All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/4] fdc: Add a floppy qbus
Date: Fri, 14 Oct 2016 17:32:55 -0400	[thread overview]
Message-ID: <045c1e41-4765-0953-c9c0-5f3b66cf0109@redhat.com> (raw)
In-Reply-To: <1475264368-9838-2-git-send-email-kwolf@redhat.com>



On 09/30/2016 03:39 PM, Kevin Wolf wrote:
> This adds a qbus to the floppy controller that should contain the floppy
> drives eventually. At the moment it just exists and is empty.
>

Not unlike myself.

> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  hw/block/fdc.c | 40 +++++++++++++++++++++++++++++++++++-----
>  1 file changed, 35 insertions(+), 5 deletions(-)
>
> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
> index b79873a..a3afb62 100644
> --- a/hw/block/fdc.c
> +++ b/hw/block/fdc.c
> @@ -52,6 +52,33 @@
>          }                                                       \
>      } while (0)
>
> +
> +/********************************************************/
> +/* qdev floppy bus                                      */
> +
> +#define TYPE_FLOPPY_BUS "Floppy"
> +#define FLOPPY_BUS(obj) OBJECT_CHECK(FloppyBus, (obj), TYPE_FLOPPY_BUS)
> +
> +typedef struct FDCtrl FDCtrl;
> +
> +typedef struct FloppyBus {
> +    BusState bus;
> +    FDCtrl *fdc;
> +} FloppyBus;
> +
> +static const TypeInfo floppy_bus_info = {
> +    .name = TYPE_FLOPPY_BUS,
> +    .parent = TYPE_BUS,
> +    .instance_size = sizeof(FloppyBus),
> +};
> +
> +static void floppy_bus_create(FDCtrl *fdc, FloppyBus *bus, DeviceState *dev)
> +{
> +    qbus_create_inplace(bus, sizeof(FloppyBus), TYPE_FLOPPY_BUS, dev, NULL);
> +    bus->fdc = fdc;
> +}
> +
> +
>  /********************************************************/
>  /* Floppy drive emulation                               */
>
> @@ -148,8 +175,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 */
>
> -typedef struct FDCtrl FDCtrl;
> -
>  /* Floppy disk drive emulation */
>  typedef enum FDiskFlags {
>      FDISK_DBL_SIDES  = 0x01,
> @@ -684,6 +709,7 @@ struct FDCtrl {
>      /* Power down config (also with status regB access mode */
>      uint8_t pwrd;
>      /* Floppy drives */
> +    FloppyBus bus;
>      uint8_t num_floppies;
>      FDrive drives[MAX_FD];
>      int reset_sensei;
> @@ -2442,7 +2468,8 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
>      *fdc_tc = qdev_get_gpio_in(dev, 0);
>  }
>
> -static void fdctrl_realize_common(FDCtrl *fdctrl, Error **errp)
> +static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
> +                                  Error **errp)
>  {
>      int i, j;
>      static int command_tables_inited = 0;
> @@ -2480,6 +2507,8 @@ static void fdctrl_realize_common(FDCtrl *fdctrl, Error **errp)
>          k->register_channel(fdctrl->dma, fdctrl->dma_chann,
>                              &fdctrl_transfer_handler, fdctrl);
>      }
> +
> +    floppy_bus_create(fdctrl, &fdctrl->bus, dev);
>      fdctrl_connect_drives(fdctrl, errp);
>  }
>
> @@ -2508,7 +2537,7 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp)
>      }
>
>      qdev_set_legacy_instance_id(dev, isa->iobase, 2);
> -    fdctrl_realize_common(fdctrl, &err);
> +    fdctrl_realize_common(dev, fdctrl, &err);
>      if (err != NULL) {
>          error_propagate(errp, err);
>          return;
> @@ -2559,7 +2588,7 @@ static void sysbus_fdc_common_realize(DeviceState *dev, Error **errp)
>      FDCtrlSysBus *sys = SYSBUS_FDC(dev);
>      FDCtrl *fdctrl = &sys->state;
>
> -    fdctrl_realize_common(fdctrl, errp);
> +    fdctrl_realize_common(dev, fdctrl, errp);
>  }
>
>  FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
> @@ -2744,6 +2773,7 @@ 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_init(fdc_register_types)
>

Reviewed-by: John Snow <jsnow@redhat.com>

  reply	other threads:[~2016-10-14 21:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30 19:39 [Qemu-devel] [PATCH v2 0/4] fdc: Use separate qdev device for drives Kevin Wolf
2016-09-30 19:39 ` [Qemu-devel] [PATCH v2 1/4] fdc: Add a floppy qbus Kevin Wolf
2016-10-14 21:32   ` John Snow [this message]
2016-09-30 19:39 ` [Qemu-devel] [PATCH v2 2/4] fdc: Add a floppy drive qdev Kevin Wolf
2016-10-14 22:09   ` John Snow
2016-09-30 19:39 ` [Qemu-devel] [PATCH v2 3/4] fdc: Move qdev properties to FloppyDrive Kevin Wolf
2016-10-14 22:32   ` John Snow
2016-10-17  8:53     ` Kevin Wolf
2016-09-30 19:39 ` [Qemu-devel] [PATCH v2 4/4] qemu-iotests: Test creating floppy drives Kevin Wolf
2016-10-14 11:11 ` [Qemu-devel] [PATCH v2 0/4] fdc: Use separate qdev device for drives Kevin Wolf

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=045c1e41-4765-0953-c9c0-5f3b66cf0109@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.