Re: [hatari-devel] IDE IO register range access commit |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] IDE IO register range access commit
- From: Thomas Huth <th.huth@xxxxxxxxx>
- Date: Sat, 26 Sep 2020 17:15:09 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1601133310; bh=c2z2O8R9q46OmtW3hfdsVkocGi1e5IyUp6pcB/wdb3M=; h=Date:From:To:Subject:From; b=U/52wjB4+251hfNNkOAI+4h2VUohmHiATgXPj+SJCktyQyR8eMsVl48z0UXE09grM nU7U6mUFfZSQTR5sMtT3NlCkeZa89gXfTaGvGqhG+h/8nFwgFC4XjmGBCbuCmpt2ZW bq4nSivLpMGelrJPig3+J3bWgcN+d/0WUJ47YeJHRcfu3GhdPIAafD3Yj4ChX4r8IE ELCTKeX/zDQyAQCvbr5uCTC7FZPyGfoxWlvU81vxGdDD+f/Q7whVT2NRco/fVlY31u w8cYerQxEIJ/hJkFc2xEXTe7gBrrrpm7Or9BkLsclQi+bPs0OIuXTmanvvMYwzgHEY 7m7nLfOscPryA==
Am Thu, 24 Sep 2020 23:01:37 +0200
schrieb Nicolas Pomarède <npomarede@xxxxxxxxxxxx>:
> Le 24/09/2020 à 22:15, Thomas Huth a écrit :
> > Am Thu, 24 Sep 2020 21:57:15 +0300
> > schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
> >
> >> On 9/24/20 4:50 PM, Nicolas Pomarède wrote:
> >>> Le 24/09/2020 à 15:29, Nicolas Pomarède a écrit :
> >>>> I'm looking at it, but IdeInit() seems strange to me ; it doesn't
> >>>> create the "opaque_ide_if" struct if machine is falcon, only if
> >>>> Ide[0].bUseDevice (else it returns immediately)
> >>>>
> >>>> But Ide should be enabled on Falcon even if there's no disk on
> >>>> Ide[0]. It seems that sometimes IDE depends on Ide[0].bUseDevice
> >>>> and sometimes it depends on machine==falcon.
> >>
> >> Original ide.c code didn't do any checks for
> >> Falcon, only for IDE drives.
> >>
> >>
> >>>> I think it should check both in every places.
> >>>
> >>> I pushed a patch to fix this ; I'm not too familiar with ide.c
> >>> code, but I think the following needed to be changed/fixed :
> >>>
> >>> - In IdeInit, we should not return if machine==falcon, else
> >>> opaque_ide_if is not malloc'ed and hatari will crash later in
> >>> Ide_Mem_bget
> >>>
> >>> - Once we don't return in IdeInit() in case of falcon,
> >>> ide_init2 should not assume that hd_table[n] is initialized,
> >>> because it can be skipped in the "for" loop in IdeInit if
> >>> Ide[i].bUseDevice == false. So, I added a check for
> >>> Ide[i].bUseDevice in ide_init2 too
> >>
> >> Exiting there means that opaque_ide_if structure contains bogus
> >> (zero) values, and I think that to
> >> mean IDE register get/put functions not to work
> >> correctly.
> >>
> >>
> >> > (else there was another crash due to
> >> > bdrv_get_geometry() doing a division by 0
> >> > because "bs->sector_size==0")
> >>
> >> I think that's expected when there's no disk...
> >>
> >>
> >> What is supposed to happen on Falcon if when there's no disk but
> >> IDE registers are accessed?
> >>
> >> (Original code would in that case give bus error in register
> >> get/put functions.)
> >
> > Sorry for the late reply, it's yet another busy week for me...
> >
> > Original code caused a bus error in Falcon mode, too - but that was
> > clearly wrong. It happened to work since TOS 4.04 catches the bus
> > errors and ignores IDE in that case - but some hard disk drivers for
> > the Falcon crashed (I think it was Cecile IIRC) because they
> > accessed the registers without checking for bus errors.
> > The correct behavior is of course that we should always emulate an
> > IDE controller on the Falcon, which of course should not crash the
> > emulator if there is no IDE drive attached.
> > I can maybe have a look at this at the weekend, but if somebody else
> > currently has some spare time to fix the issues, you're welcome of
> > course, too.
>
> Hi
>
> I tried to fix this ide.c because it was a consequence of an STE demo
> crashing with bus error when blitter accessed the ide memory region
> and because region 0xF0xxxx was always mapped to ide registers, even
> for plain ST/STE with no ide drive (instead of mapping the whole
> region directly to bus error)
>
> As if pulling a thread, trying to fix this bus error region showed
> more side effect than expected in the ide.c code itself ;)
>
> I will try to give another look at the code I changed, it might not
> require that much change to make it work in all cases. Don't have
> much time too at the moment, so if you have any idea, don't hesitate
> to change my commits if you have a working solution :)
I've now had a look, and I think I've successfully fixed the issue
reported by Uwe, and another crash that occurred when there was only a
secondary IDE drive attached, without a primary one.
BTW, the hard disk driver Cecile now also seems to work fine in Falcon
mode when no IDE drive has been specified (it used to crash with a bus
error before) :-)
Thomas