Index: trunk/hal/tsar_mips32/drivers/soclib_pic.c
===================================================================
--- trunk/hal/tsar_mips32/drivers/soclib_pic.c	(revision 406)
+++ trunk/hal/tsar_mips32/drivers/soclib_pic.c	(revision 407)
@@ -43,4 +43,6 @@
 extern  lapic_input_t  lapic_input;  // defined in dev_pic.h / allocated in kernel_init.c
  
+
+
 //////////////////////////////////////////////////////////////////////////////////////
 //        SOCLIB PIC private functions 
@@ -127,5 +129,5 @@
                            &pti_status );
 
-    irq_dmsg("\n[DMSG] %s : enter for core[%x,%d] / WTI = %x / HWI = %x / WTI = %x\n",
+    irq_dmsg("\n[DBG] %s : core[%x,%d] enter / WTI = %x / HWI = %x / WTI = %x\n",
              __FUNCTION__ , local_cxy , core->lid , wti_status , hwi_status , pti_status );
 
@@ -140,5 +142,5 @@
             assert( (index == core->lid) , __FUNCTION__ , "illegal IPI index" );
 
-            irq_dmsg("\n[DMSG] %s : core[%x,%d] received an IPI / cycle %d\n",
+            irq_dmsg("\n[DBG] %s : core[%x,%d] received an IPI / cycle %d\n",
              __FUNCTION__ , local_cxy , core->lid , hal_time_stamp() );
 
@@ -168,5 +170,5 @@
             else                                 // call relevant ISR
             {
-                irq_dmsg("\n[DMSG] %s : core[%x,%d] received external WTI %d / cycle %d\n",
+                irq_dmsg("\n[DBG] %s : core[%x,%d] received external WTI %d / cycle %d\n",
                 __FUNCTION__ , local_cxy , core->lid , index , hal_time_stamp() );
 
@@ -196,5 +198,5 @@
         else                    // call relevant ISR
         {
-            irq_dmsg("\n[DMSG] %s : core[%x,%d] received HWI %d / cycle %d\n",
+            irq_dmsg("\n[DBG] %s : core[%x,%d] received HWI %d / cycle %d\n",
             __FUNCTION__ , local_cxy , core->lid , index , hal_time_stamp() );
 
@@ -208,5 +210,5 @@
         index = pti_status - 1;
 
-        irq_dmsg("\n[DMSG] %s : core[%x,%d] received PTI %d / cycle %d\n",
+        irq_dmsg("\n[DBG] %s : core[%x,%d] received PTI %d / cycle %d\n",
         __FUNCTION__ , core->lid , local_cxy , index , hal_time_stamp() );
 
@@ -248,5 +250,5 @@
     uint32_t * iopic_seg_ptr = (uint32_t *)GET_PTR( pic->base );
 
-    // reset the IOPIC component registers : mask all input IRQs
+    // reset the IOPIC component registers : disable all input IRQs
     for( i = 0 ; i < CONFIG_MAX_EXTERNAL_IRQS ; i++ )
     {
@@ -364,10 +366,11 @@
     {
         // get external IRQ index
-        uint32_t  irq_id;   
-        if     (  func == DEV_FUNC_IOC            ) irq_id = iopic_input.ioc[channel];
-        else if(  func == DEV_FUNC_TXT            ) irq_id = iopic_input.txt[channel];
-        else if( (func == DEV_FUNC_NIC) &&  is_rx ) irq_id = iopic_input.nic_rx[channel];
-        else if( (func == DEV_FUNC_NIC) && !is_rx ) irq_id = iopic_input.nic_tx[channel];
-        else if(  func == DEV_FUNC_IOB            ) irq_id = iopic_input.iob;
+        uint32_t  hwi_id;   
+        if     (  func == DEV_FUNC_IOC            ) hwi_id = iopic_input.ioc[channel];
+        else if(  func == DEV_FUNC_TXT  &&  is_rx ) hwi_id = iopic_input.txt_rx[channel];
+        else if(  func == DEV_FUNC_TXT  && !is_rx ) hwi_id = iopic_input.txt_tx[channel];
+        else if( (func == DEV_FUNC_NIC) &&  is_rx ) hwi_id = iopic_input.nic_rx[channel];
+        else if( (func == DEV_FUNC_NIC) && !is_rx ) hwi_id = iopic_input.nic_tx[channel];
+        else if(  func == DEV_FUNC_IOB            ) hwi_id = iopic_input.iob;
         else      assert( false , __FUNCTION__ , "illegal device functionnal type\n");
 
@@ -385,15 +388,19 @@
         uint32_t lsb_wdata = (uint32_t)wti_xp;
         uint32_t msb_wdata = (uint32_t)(wti_xp >> 32);
-        xptr_t   lsb_xp = XPTR( seg_pic_cxy , seg_pic_ptr+irq_id*IOPIC_SPAN+IOPIC_ADDRESS );
-        xptr_t   msb_xp = XPTR( seg_pic_cxy , seg_pic_ptr+irq_id*IOPIC_SPAN+IOPIC_EXTEND );
+        xptr_t   lsb_xp = XPTR( seg_pic_cxy , seg_pic_ptr+hwi_id*IOPIC_SPAN+IOPIC_ADDRESS );
+        xptr_t   msb_xp = XPTR( seg_pic_cxy , seg_pic_ptr+hwi_id*IOPIC_SPAN+IOPIC_EXTEND );
         hal_remote_sw( lsb_xp , lsb_wdata );
         hal_remote_sw( msb_xp , msb_wdata );
 
-        // unmask IRQ in IOPIC
-        hal_remote_sw( XPTR( seg_pic_cxy , seg_pic_ptr+irq_id*IOPIC_SPAN+IOPIC_MASK ), 1 );
+        // enable IRQ in IOPIC
+        hal_remote_sw( XPTR( seg_pic_cxy , seg_pic_ptr+hwi_id*IOPIC_SPAN+IOPIC_MASK ), 1 );
 
         // update the WTI interrupt vector for core[lid]
         core_t * core = &LOCAL_CLUSTER->core_tbl[lid];
         ((soclib_pic_core_t *)core->pic_extend)->wti_vector[wti_id] = src_chdev;
+
+pic_dmsg("\n[DBG] %s : %s / channel = %d / rx = %d / hwi_id = %d / wti_id = %d / cluster = %x\n",
+__FUNCTION__ , chdev_func_str( func ) , channel , is_rx , hwi_id , wti_id , local_cxy );
+
     }
     else if( (func == DEV_FUNC_DMA) || (func == DEV_FUNC_MMC) )   // internal IRQ => HWI
@@ -411,4 +418,8 @@
         core_t * core = &LOCAL_CLUSTER->core_tbl[lid];
         ((soclib_pic_core_t *)core->pic_extend)->wti_vector[hwi_id] = src_chdev;
+
+pic_dmsg("\n[DBG] %s : %s / channel = %d / hwi_id = %d / cluster = %x\n",
+__FUNCTION__ , chdev_func_str( func ) , channel , hwi_id , local_cxy );
+
     }
     else
@@ -494,5 +505,5 @@
 
     // set period value in XCU (in cycles)
-    uint32_t cycles = period * SOCLIB_CYCLES_PER_MS * CONFIG_SCHED_TICK_MS_PERIOD;
+    uint32_t cycles = period * SOCLIB_CYCLES_PER_MS;
     base[(XCU_PTI_PER << 5) | lid] = cycles;
 
@@ -525,4 +536,19 @@
 }
 
-
-
+/////////////////////////
+void soclib_pic_ack_ipi()
+{
+    // get calling core local index
+    lid_t      lid  = CURRENT_THREAD->core->lid;
+
+    // get pointer on local XCU segment base
+    uint32_t * base = soclib_pic_xcu_base();
+
+    // acknowlege IPI
+    uint32_t   ack  = base[(XCU_WTI_REG << 5) | lid];
+
+    // we must make a fake use for ack value to avoid a warning
+    if( (ack + 1) == 0 ) panic("this should never happen");
+}
+    
+
