Index: trunk/hal/tsar_mips32/drivers/soclib_pic.c
===================================================================
--- trunk/hal/tsar_mips32/drivers/soclib_pic.c	(revision 679)
+++ trunk/hal/tsar_mips32/drivers/soclib_pic.c	(revision 686)
@@ -2,5 +2,5 @@
  * soclib_pic.c - soclib PIC driver implementation.
  *
- * Author  Alain Greiner (2016,2017,2018,2019)
+ * Author  Alain Greiner (2016,2017,2018,2019,2020)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -39,5 +39,5 @@
 //////////////////////////////////////////////////////////////////////////////////////
 
-extern  chdev_directory_t chdev_dir;    // defined in chdev.h / allocated in kerneL-init.c
+extern  chdev_directory_t chdev_dir;  // defined in chdev.h / allocated in kerneL-init.c
 
 extern  iopic_input_t  iopic_input;  // defined in dev_pic.h / allocated in kernel_init.c
@@ -58,6 +58,6 @@
     soclib_pic_cluster_t * ext_ptr = LOCAL_CLUSTER->pic_extend;
 
-    assert( __FUNCTION__, (ext_ptr->first_free_wti < ext_ptr->wti_nr) ,
-            "no free WTI found : too much external IRQs\n");
+assert( __FUNCTION__, (ext_ptr->first_free_wti < ext_ptr->wti_nr) ,
+"no free WTI found : too much external IRQs");
 
     // update WTI allocator
@@ -147,5 +147,7 @@
         if( index < LOCAL_CLUSTER->cores_nr )   // it is an IPI
         {
-            assert( __FUNCTION__, (index == core->lid) , "illegal IPI index" );
+
+assert( __FUNCTION__, (index == core->lid),
+"illegal IPI index" );
 
 #if DEBUG_HAL_IRQS
@@ -170,7 +172,5 @@
 		    {
                 printk("\n[WARNING] in %s : no handler for WTI %d on core %d in cluster %x\n",
-                       __FUNCTION__ , index , core->lid , local_cxy );
-
-	            core->spurious_irqs ++;
+                 __FUNCTION__ , index , core->lid , local_cxy );
 
                 // disable WTI in local XCU controller 
@@ -204,7 +204,5 @@
 	 	{
             printk("\n[WARNING] in %s : no handler for HWI %d on core %d in cluster %x\n",
-                   __FUNCTION__ , index , core->lid , local_cxy );
-
-	        core->spurious_irqs ++;
+            __FUNCTION__ , index , core->lid , local_cxy );
 
             // disable HWI in local XCU controller
@@ -230,5 +228,6 @@
         index = pti_status - 1;
 
-        assert( __FUNCTION__, (index == core->lid) , "unconsistent PTI index\n");
+assert( __FUNCTION__, (index == core->lid),
+"unconsistent PTI index\n");
 
 #if DEBUG_HAL_IRQS
@@ -278,5 +277,4 @@
     soclib_pic_cluster_t * cluster_ext_ptr;   
     soclib_pic_core_t    * core_ext_ptr;
-    kmem_req_t             req;
     uint32_t               lid;
     uint32_t               idx;
@@ -288,8 +286,5 @@
     {
         // allocate memory for core extension
-        req.type     = KMEM_KCM;
-        req.order    = bits_log2( sizeof(soclib_pic_core_t) );
-        req.flags    = AF_KERNEL;
-        core_ext_ptr = kmem_alloc( &req );
+        core_ext_ptr = kmem_alloc( bits_log2( sizeof(soclib_pic_core_t)) , AF_KERNEL );
 
         if( core_ext_ptr == NULL )
@@ -308,8 +303,5 @@
 
     // allocate memory for cluster extension
-    req.type        = KMEM_KCM;
-    req.order       = bits_log2( sizeof(soclib_pic_cluster_t) );
-    req.flags       = AF_KERNEL;
-    cluster_ext_ptr = kmem_alloc( &req );
+    cluster_ext_ptr = kmem_alloc( bits_log2( sizeof(soclib_pic_cluster_t) ), AF_KERNEL );
 
     if( cluster_ext_ptr == NULL )
@@ -319,6 +311,4 @@
     }
     
-assert( __FUNCTION__, (cluster_ext_ptr != NULL) , "cannot allocate memory for cluster extension");
-
     // get XCU characteristics from the XCU config register 
     uint32_t  config = xcu_base[XCU_CONFIG<<5];
@@ -380,16 +370,22 @@
     bool_t   is_rx   = src_chdev->is_rx;
 
-    if( (func == DEV_FUNC_IOC && impl == IMPL_IOC_BDV) || (func == DEV_FUNC_NIC) ||
-        (func == DEV_FUNC_TXT && impl == IMPL_TXT_TTY) || (func == DEV_FUNC_IOB) ) // external IRQ => WTI
+    if( ((func == DEV_FUNC_IOC) && (impl == IMPL_IOC_BDV)) || 
+        (func == DEV_FUNC_NIC)                             ||
+        ((func == DEV_FUNC_TXT) && (impl == IMPL_TXT_TTY)) ||
+        (func == DEV_FUNC_IOB) ) // external IRQ => WTI
     {
         // get external IRQ index
         uint32_t  hwi_id = 0;   
         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_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( __FUNCTION__, false , "illegal device functionnal type\n");
+        else 
+        {
+            printk("\n[WARNING] from %s : illegal device / func %s / is_rx %d\n",
+            __FUNCTION__, chdev_func_str(func), is_rx );
+        }
 
         // get a WTI mailbox from local XCU descriptor  
@@ -420,10 +416,11 @@
 #if DEBUG_HAL_IRQS
 if( DEBUG_HAL_IRQS < cycle )
-printk("\n[DBG] %s : %s / channel = %d / rx = %d / hwi_id = %d / wti_id = %d / cluster = %x\n",
+printk("\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 );
 #endif
 
     }
-    else if( (func == DEV_FUNC_DMA) || (func == DEV_FUNC_MMC) ||
+    else if( (func == DEV_FUNC_DMA) || 
+             (func == DEV_FUNC_MMC) ||
              (func == DEV_FUNC_TXT && impl == IMPL_TXT_MTY) ||
              (func == DEV_FUNC_IOC && impl == IMPL_IOC_SPI) )   // internal IRQ => HWI
@@ -431,8 +428,8 @@
         // get internal IRQ index
         uint32_t hwi_id;
-        if( func == DEV_FUNC_DMA ) hwi_id = lapic_input.dma[channel];
+        if( func == DEV_FUNC_DMA )      hwi_id = lapic_input.dma[channel];
         else if (func == DEV_FUNC_TXT ) hwi_id = lapic_input.mtty;
         else if (func == DEV_FUNC_IOC ) hwi_id = lapic_input.sdcard;
-        else                       hwi_id = lapic_input.mmc;
+        else                            hwi_id = lapic_input.mmc;
 
         // register IRQ type and index in chdev
@@ -453,5 +450,6 @@
     else
     {
-        assert( __FUNCTION__, false , "illegal device functionnal type\n" );
+        printk("\n[WARNING] from %s : illegal device / func %s / is_rx %d / impl %d\n",
+        __FUNCTION__, chdev_func_str(func), is_rx, impl );
     } 
 }  // end soclib_pic_bind_irq();
@@ -477,5 +475,5 @@
         // in TSAR : XCU output [4*lid] is connected to core [lid]
         hal_remote_s32( XPTR( src_chdev_cxy , 
-                       &seg_xcu_ptr[ (XCU_MSK_HWI_ENABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
+        &seg_xcu_ptr[ (XCU_MSK_HWI_ENABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
     }
     else if( irq_type == SOCLIB_TYPE_WTI )
@@ -484,9 +482,10 @@
         // in TSAR : XCU output [4*lid] is connected to core [lid]
         hal_remote_s32( XPTR( src_chdev_cxy , 
-                       &seg_xcu_ptr[ (XCU_MSK_WTI_ENABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
+        &seg_xcu_ptr[ (XCU_MSK_WTI_ENABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
     }
     else
     {
-        assert( __FUNCTION__, false , "illegal IRQ type\n" );
+        printk("\n[WARNING] from %s : illegal IRQ type %d\n",
+        __FUNCTION__, irq_type );
     }
 } // end soclib_pic_enable_irq()
@@ -512,5 +511,5 @@
         // in TSAR : XCU output [4*lid] is connected to core [lid]
         hal_remote_s32( XPTR( src_chdev_cxy , 
-                       &seg_xcu_ptr[(XCU_MSK_HWI_DISABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
+        &seg_xcu_ptr[(XCU_MSK_HWI_DISABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
     }
     else if( irq_type == SOCLIB_TYPE_WTI )
@@ -519,9 +518,10 @@
         // in TSAR : XCU output [4*lid] is connected to core [lid]
         hal_remote_s32( XPTR( src_chdev_cxy , 
-                       &seg_xcu_ptr[(XCU_MSK_WTI_DISABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
+        &seg_xcu_ptr[(XCU_MSK_WTI_DISABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
     }
     else
     {
-        assert( __FUNCTION__, false , "illegal IRQ type\n" );
+        printk("\n[WARNING] from %s : illegal IRQ type %d\n",
+        __FUNCTION__, irq_type );
     }
 } // end soclib_pic_enable_irq()
@@ -570,5 +570,5 @@
 }
 
-/////////////////////////
+///////////////////////////////
 void soclib_pic_ack_ipi( void )
 {
@@ -582,5 +582,5 @@
     uint32_t   ack  = base[ (XCU_WTI_REG << 5) | lid ];
 
-    // we must make a fake use for ack value to avoid a warning
+    // we make a fake use for ack value to avoid a warning
     if( (ack + 1) == 0 ) asm volatile( "nop" );
 }
