Re: [hatari-devel] Lockup demo

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Le 04/12/2020 à 21:56, Nicolas Pomarède a écrit :
Le 04/12/2020 à 21:51, Laurent Sallafranque a écrit :
Hi,


My version of the demo was corrupted (2 bombs).

I've downloaded another one.


I've fixed the DSP Host interrupts and now, I have the demo with the tridi.

It was present but had never been tested before.

The demo runs super well ;)


Still have to give a try to the timer now to have the music.


Eero, can I comit my changes into the DSP interrupts ?

Hi

can you send the corresponding patch here ?

Nicolas


Here's the patch that Laurent sent me ; mariusz can you try it (if you can compile Hatari youself ?), maybe you have some other pieces of code to check if this patch improves DSP interrupts in your cases ?

Nicolas
diff --git a/src/falcon/dsp_core.c b/src/falcon/dsp_core.c
index ed1c529d..3473df28 100644
--- a/src/falcon/dsp_core.c
+++ b/src/falcon/dsp_core.c
@@ -1001,11 +1001,6 @@ static void dsp_core_dsp2host(void)
 	/* Set HTDE bit to say that DSP can write */
 	dsp_core.periph[DSP_SPACE_X][DSP_HOST_HSR] |= 1<<DSP_HOST_HSR_HTDE;
 
-	/* Is there an interrupt to send ? */
-	if (dsp_core.periph[DSP_SPACE_X][DSP_HOST_HCR] & (1<<DSP_HOST_HCR_HTIE)) {
-		dsp_add_interrupt(DSP_INTER_HOST_TRX_DATA);
-	}
-
 	/* Set RXDF bit to say that host can read */
 	dsp_core.hostport[CPU_HOST_ISR] |= 1<<CPU_HOST_ISR_RXDF;
 	dsp_core_hostport_update_hreq();
@@ -1033,11 +1028,6 @@ static void dsp_core_host2dsp(void)
 	/* Set HRDF bit to say that DSP can read */
 	dsp_core.periph[DSP_SPACE_X][DSP_HOST_HSR] |= 1<<DSP_HOST_HSR_HRDF;
 
-	/* Is there an interrupt to send ? */
-	if (dsp_core.periph[DSP_SPACE_X][DSP_HOST_HCR] & (1<<DSP_HOST_HCR_HRIE)) {
-		dsp_add_interrupt(DSP_INTER_HOST_RCV_DATA);
-	}
-
 	/* Set TXDE bit to say that host can write */
 	dsp_core.hostport[CPU_HOST_ISR] |= 1<<CPU_HOST_ISR_TXDE;
 	dsp_core_hostport_update_hreq();
@@ -1157,11 +1147,6 @@ void dsp_core_write_host(int addr, Uint8 value)
 					/* Set HRDF bit to say that DSP can read */
 					dsp_core.periph[DSP_SPACE_X][DSP_HOST_HSR] |= 1<<DSP_HOST_HSR_HRDF;
 
-					/* Is there an interrupt to send ? */
-					if (dsp_core.periph[DSP_SPACE_X][DSP_HOST_HCR] & (1<<DSP_HOST_HCR_HRIE)) {
-						dsp_add_interrupt(DSP_INTER_HOST_RCV_DATA);
-					}
-
 					LOG_TRACE(TRACE_DSP_HOST_INTERFACE, "Dsp: (Host->DSP): Dsp HRDF set\n");
 				}
 				else{
diff --git a/src/falcon/dsp_cpu.c b/src/falcon/dsp_cpu.c
index 29f472d2..121299c8 100644
--- a/src/falcon/dsp_cpu.c
+++ b/src/falcon/dsp_cpu.c
@@ -954,6 +954,25 @@ static void dsp_postexecute_interrupts(void)
 	Uint32 index, instr, i;
 	Sint32 ipl_to_raise, ipl_sr;
 
+
+	if (dsp_core.interrupt_state == DSP_INTERRUPT_NONE) {
+		/* Is there a HostPort Transmit interrupt to triger ? */
+		if (dsp_core.periph[DSP_SPACE_X][DSP_HOST_HCR] & (1<<DSP_HOST_HCR_HTIE)) {
+			if (dsp_core.periph[DSP_SPACE_X][DSP_HOST_HSR] & (1<<DSP_HOST_HSR_HTDE)) {
+				dsp_add_interrupt(DSP_INTER_HOST_TRX_DATA);
+			}
+		}
+
+		/* Is there a HostPort Receive interrupt to triger ? */
+		if (dsp_core.periph[DSP_SPACE_X][DSP_HOST_HCR] & (1<<DSP_HOST_HCR_HRIE)) {
+			if (dsp_core.periph[DSP_SPACE_X][DSP_HOST_HSR] & (1<<DSP_HOST_HSR_HRDF)) {
+
+				dsp_add_interrupt(DSP_INTER_HOST_RCV_DATA);
+			}
+		}
+	}
+
+
 	/* REP is not interruptible */
 	if (dsp_core.loop_rep) {
 		return;
@@ -1035,57 +1054,60 @@ static void dsp_postexecute_interrupts(void)
 	}
 
 	/* search for an interrupt */
-	ipl_sr = (dsp_core.registers[DSP_REG_SR]>>DSP_SR_I0) & BITMASK(2);
-	index = 0xffff;
-	ipl_to_raise = -1;
+	if (dsp_core.interrupt_state == DSP_INTERRUPT_NONE) {
+		ipl_sr = (dsp_core.registers[DSP_REG_SR]>>DSP_SR_I0) & BITMASK(2);
+		index = 0xffff;
+		ipl_to_raise = -1;
+
+		/* Arbitrate between all pending interrupts */
+		for (i=0; i<12; i++) {
+			if (dsp_core.interrupt_isPending[i] == 1) {
+
+				/* level 3 interrupt ? */
+				if (dsp_core.interrupt_ipl[i] == 3) {
+					index = i;
+					break;
+				}
 
-	/* Arbitrate between all pending interrupts */
-	for (i=0; i<12; i++) {
-		if (dsp_core.interrupt_isPending[i] == 1) {
+				/* level 0, 1 ,2 interrupt ? */
+				/* if interrupt is masked in SR, don't process it */
+				if (dsp_core.interrupt_ipl[i] < ipl_sr)
+					continue;
 
-			/* level 3 interrupt ? */
-			if (dsp_core.interrupt_ipl[i] == 3) {
+				/* if interrupt is lower or equal than current arbitrated interrupt */
+				if (dsp_core.interrupt_ipl[i] <= ipl_to_raise)
+					continue;
+
+				/* save current arbitrated interrupt */
 				index = i;
-				break;
+				ipl_to_raise = dsp_core.interrupt_ipl[i];
 			}
+		}
 
-			/* level 0, 1 ,2 interrupt ? */
-			/* if interrupt is masked in SR, don't process it */
-			if (dsp_core.interrupt_ipl[i] < ipl_sr)
-				continue;
+		/* If there's no interrupt to process, return */
+		if (index == 0xffff) {
+			return;
+		}
 
-			/* if interrupt is lower or equal than current arbitrated interrupt */
-			if (dsp_core.interrupt_ipl[i] <= ipl_to_raise)
-				continue;
+		/* remove this interrupt from the pending interrupts table */
+		dsp_core.interrupt_isPending[index] = 0;
+		dsp_core.interrupt_counter --;
 
-			/* save current arbitrated interrupt */
-			index = i;
-			ipl_to_raise = dsp_core.interrupt_ipl[i];
+		/* process arbritrated interrupt */
+		ipl_to_raise = dsp_core.interrupt_ipl[index] + 1;
+		if (ipl_to_raise > 3) {
+			ipl_to_raise = 3;
 		}
-	}
 
-	/* If there's no interrupt to process, return */
-	if (index == 0xffff) {
-		return;
-	}
 
-	/* remove this interrupt from the pending interrupts table */
-	dsp_core.interrupt_isPending[index] = 0;
-	dsp_core.interrupt_counter --;
+		dsp_core.interrupt_instr_fetch = dsp_interrupt[index].vectorAddr;
+		dsp_core.interrupt_pipeline_count = 5;
+		dsp_core.interrupt_state = DSP_INTERRUPT_DISABLED;
+		dsp_core.interrupt_IplToRaise = ipl_to_raise;
 
-	/* process arbritrated interrupt */
-	ipl_to_raise = dsp_core.interrupt_ipl[index] + 1;
-	if (ipl_to_raise > 3) {
-		ipl_to_raise = 3;
+		LOG_TRACE(TRACE_DSP_INTERRUPT, "Dsp interrupt: %s\n", dsp_interrupt[index].name);
 	}
 
-	dsp_core.interrupt_instr_fetch = dsp_interrupt[index].vectorAddr;
-	dsp_core.interrupt_pipeline_count = 5;
-	dsp_core.interrupt_state = DSP_INTERRUPT_DISABLED;
-	dsp_core.interrupt_IplToRaise = ipl_to_raise;
-
-	LOG_TRACE(TRACE_DSP_INTERRUPT, "Dsp interrupt: %s\n", dsp_interrupt[index].name);
-
 	/* SSI receive data with exception ? */
 	if (dsp_core.interrupt_instr_fetch == 0xe) {
 		dsp_core.periph[DSP_SPACE_X][DSP_SSI_SR] &= 0xff-(1<<DSP_SSI_SR_ROE);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/