Commit f6c70fd91accbc32c369faeaea2c8fe5d2e7ade2
authorMichel Pollet <buserror@gmail.com>
Wed, 15 Feb 2017 12:16:47 +0000 (12:16 +0000)
committerMichel Pollet <buserror@gmail.com>
Wed, 15 Feb 2017 13:03:52 +0000 (13:03 +0000)
Nothing functional there, apart from tweaking traces

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/sim_interrupts.c

index 651af3ee8115775c32f6d9ce88779b8d190a82f3..8cd0dd1fef1d9635d4f885e90ba62c83b0f8f5aa 100644 (file)
@@ -72,10 +72,12 @@ avr_register_vector(
                        AVR_INT_IRQ_COUNT, names);
        table->vector[table->vector_count++] = vector;
        if (vector->trace)
-               printf("%s register vector %d (enabled %04x:%d)\n", __FUNCTION__, vector->vector, vector->enable.reg, vector->enable.bit);
+               printf("IRQ%d registered (enabled %04x:%d)\n",
+                       vector->vector, vector->enable.reg, vector->enable.bit);
 
        if (!vector->enable.reg)
-               AVR_LOG(avr, LOG_WARNING, "INT: avr_register_vector: No 'enable' bit on vector %d !\n", vector->vector);
+               AVR_LOG(avr, LOG_WARNING, "IRQ%d No 'enable' bit !\n",
+                       vector->vector);
 }
 
 int
@@ -83,7 +85,7 @@ avr_has_pending_interrupts(
                avr_t * avr)
 {
        avr_int_table_p table = &avr->interrupts;
-       return !avr_int_pending_isempty(&table->pending); // table->pending_r != table->pending_w;
+       return !avr_int_pending_isempty(&table->pending);
 }
 
 int
@@ -109,13 +111,16 @@ avr_raise_interrupt(
 {
        if (!vector || !vector->vector)
                return 0;
-       if (vector->trace)
-               printf("%s raising %d (enabled %d)\n", __FUNCTION__, vector->vector, avr_regbit_get(avr, vector->enable));
        if (vector->pending) {
                if (vector->trace)
-                       printf("%s trying to double raise %d (enabled %d)\n", __FUNCTION__, vector->vector, avr_regbit_get(avr, vector->enable));
+                       printf("IRQ%d:I=%d already raised (enabled %d) (cycle %lld pc 0x%x)\n",
+                               vector->vector, !!avr->sreg[S_I], avr_regbit_get(avr, vector->enable),
+                               (long long int)avr->cycle, avr->pc);
                return 0;
        }
+       if (vector->trace)
+               printf("IRQ%d raising (enabled %d)\n",
+                       vector->vector, avr_regbit_get(avr, vector->enable));
        // always mark the 'raised' flag to one, even if the interrupt is disabled
        // this allow "polling" for the "raised" flag, like for non-interrupt
        // driven UART and so so. These flags are often "write one to clear"
@@ -138,7 +143,8 @@ avr_raise_interrupt(
                        avr->interrupt_state = 1;
                if (avr->state == cpu_Sleeping) {
                        if (vector->trace)
-                               printf("Waking CPU due to interrupt\n");
+                               printf("IRQ%d Waking CPU due to interrupt\n",
+                                       vector->vector);
                        avr->state = cpu_Running;       // in case we were sleeping
                }
        }
@@ -154,7 +160,7 @@ avr_clear_interrupt(
        if (!vector)
                return;
        if (vector->trace)
-               printf("%s cleared %d\n", __FUNCTION__, vector->vector);
+               printf("IRQ%d cleared\n", vector->vector);
        vector->pending = 0;
 
        avr_raise_irq(vector->irq + AVR_INT_IRQ_PENDING, 0);
@@ -260,7 +266,7 @@ avr_service_interrupts(
                avr->interrupt_state = avr_has_pending_interrupts(avr);
        } else {
                if (vector && vector->trace)
-                       printf("%s calling %d\n", __FUNCTION__, (int)vector->vector);
+                       printf("IRQ%d calling\n", vector->vector);
                _avr_push_addr(avr, avr->pc);
                avr_sreg_set(avr, S_I, 0);
                avr->pc = vector->vector * avr->vector_size;