qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] fdc: fix MAX_FD probelm


From: Stuart Brady
Subject: Re: [Qemu-devel] [PATCH] fdc: fix MAX_FD probelm
Date: Sun, 13 Sep 2009 01:10:29 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]