Page 1 of 1

DMA DEI

Posted: Sat Feb 06, 2021 1:16 pm
by ob1
Hello fellows.
The Hitachi SH-7604 Hardware Manual defines the IE bit (bit #2) in CHCR register (§9.2.4) as :
Interrupt Enable Bit (IE): Determines whether or not to request a CPU interrupt at the end of a DMA transfer. When the IE bit is set to 1, an interrupt (DEI) request is setnt to the CPU when the TE bit is set.
(typo theirs)

Then, the VCRDMA register (§9.2.5) :
When a transfer-end interrupt occurs, exception handling and interrupt control fetch the vector number and control is transferred to the specified interrupt handling routine.
Finally, regarding the DMA Transfer Flow (§9.3.1)
If the IE bit in CHCR is set to 1 at this time (end of transfer), a DEI interrupt is sent to the CPU.
So, I have tried to raise a DEI at the end of a DMA (initiated by the 32X, with the DREQ circuitry).
I've set the IE bit,
I have defined a vector in the VCRDMA,
defined a function address in the VBR,
then set up CHRC as $44E5 instead of $44E1.

But it failed.

So, my questions are,
- is DEI implemented in any emulator ?
- has anyone ever tested it on real hardware ?

The idea would be to purge the cache lines of the uploaded data as soon as the DMA is complete.

For now, I bypass this with polling : as soon as the 32x is asked for a DMA, I enable HINT. When I HINT, I check CHCR. If CHCR.TE is set, the DMA is finished and I can purge the cache.

I have searched some commercial ROMs (VR, Kolibri, Knuckles), but none of them seem to use the DREQ :/

Re: DMA DEI

Posted: Sat Feb 06, 2021 1:19 pm
by ob1
ob1 wrote:
Sat Feb 06, 2021 1:16 pm
- is DEI implemented in any emulator ?
Regarding Gens 2.15.4, it looks like it is not implemented.
In sh2a.asm, line 5736 :

Code: Select all

ALIGN32

; void FASTCALL SH2_DMA0_Request(SH2_CONTEXT *sh2, UINT8 state)
; ecx = context pointer
; edx = request line for external (0 = off, !0 = on)
;
; RETURN:
; nothing ...

DECLF SH2_DMA0_Request, 8

	FUNC_IN
	push ebp
	mov [ecx + SH2.DREQ0], dl
	mov ebp, ecx
	mov edx, [ecx + SH2.CHCR0]
	mov ecx, 0xFFFFFF8C
	FUNC_CALL_IN
	call [ebp + SH2.Write_Long + 0xFF * 4]
	FUNC_CALL_OUT
	pop ebp
	FUNC_OUT
I don't see anything related to CHCR.IE, DEI or VCRDMA.

Re: DMA DEI

Posted: Sat Feb 06, 2021 11:39 pm
by Stef
Indeed, Gens only implemented what was used by 32X :oops: and honestly not much was used so the Gens SH-2 core is pretty incomplete on IO side !

Re: DMA DEI

Posted: Wed Feb 10, 2021 7:52 am
by srg320
Some tests of Mars Check Program use the DREQ and almost all 32X hardware. And source code of Mars Check Program is in 32X-DDK.

Re: DMA DEI

Posted: Thu Feb 11, 2021 2:54 pm
by ob1
Thank you.
I have retrieved the DDK.
Though it seems to use all the 32X resources, the SH2 DEI seems left untouched.
Indeed, I found no trace of something like "MOV.*_DMAVECTORN0", _DMAVECTORN0 being the label of DMAVCR0.
Plus, the only value for CHCR I found excluded the IE bit.

So, I guess it's fair to say the DEI was never used on the 32X.

Re: DMA DEI

Posted: Wed May 19, 2021 7:06 am
by ob1
I've set the IE bit,
I have defined a vector in the VCRDMA,
defined a function address in the VBR,
then set up CHRC as $44E5 instead of $44E1.
I've done the same test on real PAL hardware, and it doesn't seem to work either :/

Re: DMA DEI

Posted: Mon Jan 15, 2024 11:36 am
by Vic
Chilly's sound driver uses DMA end interrupts to pass data to the PWM: http://gendev.spritesmind.net/forum/vie ... php?t=1253 , so we do know that setting the 2-nd bitflag in CHCR works on real hardware. Alas, Gens indeed doesn't support this feature, hence no sound effectx in Doom 32X Resurrection there. Works fine everywhere else though.