qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stuart Brady <sdbrady@ntlworld.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] fdc: fix MAX_FD probelm
Date: Sun, 13 Sep 2009 01:10:29 +0100	[thread overview]
Message-ID: <20090913001029.GA15792@miranda.arrow> (raw)
In-Reply-To: <200909121952.AA00105@YOUR-BD18D6DD63.m1.interq.or.jp>

On Sun, Sep 13, 2009 at 04:52:51AM +0900, 武田 俊也 wrote:
> +    if (fdctrl->num_floppies == 4) {
> +        fdctrl->fifo[2] = drv2(fdctrl)->track;
> +        fdctrl->fifo[3] = drv3(fdctrl)->track;
> +    } else {
> +        fdctrl->fifo[2] = 0;
> +        fdctrl->fifo[3] = 0;
> +    }

With real hardware, only a single drive might be connected, three drives
might be connected, or possibly none at all.  I don't even see why you
couldn't connect only drives 0 and 2 -- there could well be hardware
worth emulating that does something like that, but I don't know...

Perhaps something similar to the following should be used? :-

    static inline int drive_attached(fdctrl_t *fdctrl, int drv) {
        /* Assume that drives are attached contiguously,
           starting with drive 0. */
        return drv < fdctrl->num_floppies;
    }

And then:

    fdctrl->fifo[0] = drive_attached(0) ? drv0(fdctrl)->track : 0;
    fdctrl->fifo[1] = drive_attached(1) ? drv1(fdctrl)->track : 0;
    fdctrl->fifo[2] = drive_attached(2) ? drv2(fdctrl)->track : 0;
    fdctrl->fifo[3] = drive_attached(3) ? drv3(fdctrl)->track : 0;

You would need to modify that to take account the remapping of drives
performed by drv0(), drv1(), etc., though.

I'd suggest something similar in other places that test num_floppies,
although fdctrl_connect_drives() would of course be an exception.

Arguably, there should be something in fdrive_t (or fdctrl_t) to
indicate whether a particular drive is connected, but unfortunately the
'drive' member of fdrive_t holds the value FDRIVE_DRV_NONE even if the
drive exists, but no disk is inserted...

Cheers,
-- 
Stuart Brady

  reply	other threads:[~2009-09-13  0:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-12 19:52 [Qemu-devel] [PATCH] fdc: fix MAX_FD probelm 武田 俊也
2009-09-13  0:10 ` Stuart Brady [this message]
2009-09-13 10:07   ` 武田 俊也
2009-09-13 14:44     ` Stuart Brady
2009-09-13 15:42       ` TAKEDA, toshiya
2009-09-13 17:13         ` Stuart Brady
2009-09-15 12:35           ` Natalia Portillo
2009-09-15 12:32         ` Natalia Portillo

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=20090913001029.GA15792@miranda.arrow \
    --to=sdbrady@ntlworld.com \
    --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 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).