<html>
<body>
  <div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src</tt></b></td></tr>
<tr><td><tt><a href="#file1">eventq.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+2</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-2</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">2dc47c67bb93 -> 266e7a1bae90</td></tr>
<tr class="alt" style=";" ><td><tt>sh4/<a href="#file2">intc.c</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+4</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-4</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">2dc47c67bb93 -> 266e7a1bae90</td></tr>
<tr><td><tt>   /<a href="#file3">sh4.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+15</td><td></td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">2dc47c67bb93 -> 266e7a1bae90</td></tr>
<tr class="alt" style=";" ><td><tt>   /<a href="#file4">sh4.h</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+11</td><td></td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">2dc47c67bb93 -> 266e7a1bae90</td></tr>
<tr><td><tt>   /<a href="#file5">sh4core.in</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+2</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-14</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">2dc47c67bb93 -> 266e7a1bae90</td></tr>
<tr class="alt" style=";" ><td><tt>   /<a href="#file6">sh4trans.c</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+2</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-10</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">2dc47c67bb93 -> 266e7a1bae90</td></tr>
<tr><td></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+36</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-30</td><td></td></tr>
</table>
<small id="info" style="color: #888888;" >6 modified files</small><br />
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
Refactor event processing into sh4_handle_pending_events()
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>eventq.c</b></big> <small id="info" style="color: #888888;" >2dc47c67bb93 -> 266e7a1bae90</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/eventq.c
+++ lxdream/src/eventq.c
@@ -60,12 +60,12 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
     if( event_head == NULL ) {
         if( !(sh4r.event_types & PENDING_IRQ) ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-            sh4r.event_pending = NOT_SCHEDULED;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+            sh4_set_event_pending(NOT_SCHEDULED);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         }
         sh4r.event_types &= (~PENDING_EVENT);
     } else {
         if( !(sh4r.event_types & PENDING_IRQ) ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-            sh4r.event_pending = event_head->nanosecs;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+            sh4_set_event_pending(event_head->nanosecs);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         }
         sh4r.event_types |= PENDING_EVENT;
     }
</pre></div>
<hr /><a name="file2" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/sh4</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>intc.c</b></big> <small id="info" style="color: #888888;" >2dc47c67bb93 -> 266e7a1bae90</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/sh4/intc.c
+++ lxdream/src/sh4/intc.c
@@ -110,7 +110,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     intc_state.num_pending = 0;
     for( i=0; i<INT_NUM_SOURCES; i++ )
         intc_state.priority[i] = intc_default_priority[i];
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    sh4r.event_pending = event_get_next_time();
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    sh4_set_event_pending( event_get_next_time() );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     sh4r.event_types &= (~PENDING_IRQ);
 }
 
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -154,7 +154,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     intc_state.pending[i] = which;
 
     if( i == intc_state.num_pending && (sh4r.sr&SR_BL)==0 && SH4_INTMASK() < pri ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        sh4r.event_pending = 0;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        sh4_set_event_pending(0);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         sh4r.event_types |= PENDING_IRQ;
     }
 
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -189,11 +189,11 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {   
     if( intc_state.num_pending > 0 && (sh4r.sr&SR_BL)==0 &&
             SH4_INTMASK() < PRIORITY(intc_state.pending[intc_state.num_pending-1]) ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        sh4r.event_pending = 0;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        sh4_set_event_pending(0);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         sh4r.event_types |= PENDING_IRQ ;
     }
     else {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        sh4r.event_pending = event_get_next_time();
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        sh4_set_event_pending(event_get_next_time());
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         sh4r.event_types &= (~PENDING_IRQ);
     }
 }
</pre></div>
<hr /><a name="file3" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/sh4</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>sh4.c</b></big> <small id="info" style="color: #888888;" >2dc47c67bb93 -> 266e7a1bae90</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/sh4/sh4.c
+++ lxdream/src/sh4/sh4.c
@@ -403,6 +403,11 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     sh4r.new_pc = pc+2;
 }
 
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+void sh4_set_event_pending( uint32_t cycles )
+{
+    sh4r.event_pending = cycles;
+}
+
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > /**
  * Dump all SH4 core information for crash-dump purposes
  */
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -664,6 +669,16 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     return addr != MMU_VMA_ERROR && mem_has_page(addr);
 }
 
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+void sh4_handle_pending_events() {
+    if( sh4r.event_types & PENDING_EVENT ) {
+        event_execute();
+    }
+    /* Eventq execute may (quite likely) deliver an immediate IRQ */
+    if( sh4r.event_types & PENDING_IRQ ) {
+        sh4_accept_interrupt();
+    }
+}
+
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > /**
  * Go through ext_address_space page by page
  */
</pre></div>
<hr /><a name="file4" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/sh4</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>sh4.h</b></big> <small id="info" style="color: #888888;" >2dc47c67bb93 -> 266e7a1bae90</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/sh4/sh4.h
+++ lxdream/src/sh4/sh4.h
@@ -124,6 +124,17 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > void sh4_set_pc( int pc );
 
 /**
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+ * Set the time of the next pending event within the current timeslice.
+ */
+void sh4_set_event_pending( uint32_t cycles );
+
+/**
+ * Handle an event that's due (note caller is responsible for ensuring that the
+ * event is in fact due).
+ */
+void sh4_handle_pending_event();
+
+/**
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >  * Execute (using the emulator) a single instruction (in other words, perform a
  * single-step operation). 
  */
</pre></div>
<hr /><a name="file5" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/sh4</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>sh4core.in</b></big> <small id="info" style="color: #888888;" >2dc47c67bb93 -> 266e7a1bae90</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/sh4/sh4core.in
+++ lxdream/src/sh4/sh4core.in
@@ -47,13 +47,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     if( sh4_breakpoint_count == 0 ) {
        for( ; sh4r.slice_cycle < nanosecs; sh4r.slice_cycle += sh4_cpu_period ) {
            if( SH4_EVENT_PENDING() ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-           if( sh4r.event_types & PENDING_EVENT ) {
-                   event_execute();
-               }
-               /* Eventq execute may (quite likely) deliver an immediate IRQ */
-               if( sh4r.event_types & PENDING_IRQ ) {
-                   sh4_accept_interrupt();
-               }
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+             sh4_handle_pending_events();
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >        }
            if( !sh4_execute_instruction() ) {
                break;
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -62,13 +56,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     } else {
        for( ;sh4r.slice_cycle < nanosecs; sh4r.slice_cycle += sh4_cpu_period ) {
            if( SH4_EVENT_PENDING() ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-           if( sh4r.event_types & PENDING_EVENT ) {
-                   event_execute();
-               }
-               /* Eventq execute may (quite likely) deliver an immediate IRQ */
-               if( sh4r.event_types & PENDING_IRQ ) {
-                   sh4_accept_interrupt();
-               }
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+             sh4_handle_pending_events();
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >        }
                  
            if( !sh4_execute_instruction() )
</pre></div>
<hr /><a name="file6" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/sh4</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>sh4trans.c</b></big> <small id="info" style="color: #888888;" >2dc47c67bb93 -> 266e7a1bae90</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/sh4/sh4trans.c
+++ lxdream/src/sh4/sh4trans.c
@@ -34,18 +34,10 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >  */
 uint32_t sh4_translate_run_slice( uint32_t nanosecs ) 
 {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    void * (*code)() = NULL;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     event_schedule( EVENT_ENDTIMESLICE, nanosecs );
     for(;;) {
         if( sh4r.event_pending <= sh4r.slice_cycle ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-            if( sh4r.event_types & PENDING_EVENT ) {
-                event_execute();
-            }
-            /* Eventq execute may (quite likely) deliver an immediate IRQ */
-            if( sh4r.event_types & PENDING_IRQ ) {
-                sh4_accept_interrupt();
-                code = NULL;
-            }
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+            sh4_handle_pending_events();
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             if( sh4r.slice_cycle >= nanosecs )
                 return nanosecs;
         }
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -57,7 +49,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             syscall_invoke( pc );
         }
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        <span id="removedchars" style="background-color:#ff9999;font-weight:bolder;" >code</span> = xlat_get_code_by_vma( sh4r.pc );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        <span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >void * (*code)()</span> = xlat_get_code_by_vma( sh4r.pc );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         if( code != NULL ) {
             while( sh4r.xlat_sh4_mode != XLAT_BLOCK_MODE(code) ) {
                 code = XLAT_BLOCK_CHAIN(code);
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>