Index: trunk/kernel/devices/dev_pic.c
===================================================================
--- trunk/kernel/devices/dev_pic.c	(revision 23)
+++ trunk/kernel/devices/dev_pic.c	(revision 188)
@@ -24,10 +24,9 @@
 #include <hal_types.h>
 #include <hal_special.h>
-#include <dev_icu.h>
 #include <chdev.h>
-#include <memcpy.h>
 #include <printk.h>
 #include <soclib_pic.h>
 #include <dev_pic.h>
+#include <cluster.h>
 
 /////////////////////////////////////////////////////////////////////////////////////////
@@ -37,74 +36,101 @@
 extern chdev_directory_t  chdev_dir;         // allocated in kernel_init.c
 
-extern chdev_pic_input_t  chdev_pic_input;   // allocated in kernel_init.c
-
 ///////////////////////////////////
-void dev_pic_init( chdev_t * chdev,
-                   uint32_t  irq_nr )
+void dev_pic_init( chdev_t  * pic )
 {
-    // set PIC chdev extension field
-    chdev->ext.pic.irq_nr = irq_nr;
-
     // get implementation 
-    uint32_t impl = chdev->impl;
+    uint32_t impl = pic->impl;
 
     // set chdev name
-    strcpy( chdev->name , "pic" );
-  
-    // call the relevant driver init function
-    if( impl == IMPL_PIC_SOC )
+    strcpy( pic->name , "pic" );
+
+    // call the relevant driver init function,
+    // and register commands in PIC device extension
+    if( impl == IMPL_PIC_SCL )
     {
-        soclib_pic_init( chdev );
+        // call the PIC SOCLIB driver
+        soclib_pic_init( pic );
+
+        // update the PIC chdev extension
+        pic->ext.pic.enable_timer = &soclib_pic_enable_timer;
+        pic->ext.pic.enable_irq   = &soclib_pic_enable_irq;
+        pic->ext.pic.disable_irq  = &soclib_pic_disable_irq;
+        pic->ext.pic.bind_irq     = &soclib_pic_bind_irq;
+        pic->ext.pic.send_ipi     = &soclib_pic_send_ipi;
+        pic->ext.pic.extend_init  = &soclib_pic_extend_init;
+    }
+    else if( impl == IMPL_PIC_I86 )
+    {
+        assert( false , __FUNCTION__ , "missing implementation for X86\n" );
     }
     else
     {
-        assert( false , __FUNCTION__ , "illegal PIC device implementation" );
+        assert( false , __FUNCTION__ , "undefined PIC device implementation" );
     }
 } // end dev_pic_init()
 
-/////////////////////////////////////////
-void dev_pic_bind_irq( uint32_t   irq_id,
-                       cxy_t      cxy,
-                       uint32_t   wti_id )
+/////////////////////////////////////////////////
+void dev_pic_extend_init( uint32_t * lapic_base )
 {
-    // get extended pointer on WTI mailbox
-    xptr_t wti_xp = XPTR( cxy , dev_icu_wti_ptr( wti_id ) );
+    // get pointer on PIC chdev
+    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
 
-    // get extended pointer on PIC chdev from directory
-    xptr_t dev_xp = chdev_dir.pic;
+    // call relevant driver function
+    pic->ext.pic.extend_init( lapic_base );
+}
 
-    // get PIC chdev cluster and local pointer
-    cxy_t     dev_cxy = GET_CXY( dev_xp );
-    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
+/////////////////////////////////////
+void dev_pic_bind_irq( lid_t     lid,
+                       chdev_t * src_chdev )
+{
+    // get pointer on PIC chdev
+    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
 
-    // get implementation index and segment base 
-    uint32_t impl   = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
+    // call relevant driver function
+    pic->ext.pic.bind_irq( lid , src_chdev );
+}  
 
-    // call the implementation specific driver function
-    if( impl == IMPL_PIC_SOC )
-    {
-        soclib_pic_bind_irq( dev_xp , irq_id , wti_xp );
-    }
-}  // end dev_pic_link_wti()
+///////////////////////////////////////
+void dev_pic_enable_irq( lid_t     lid,
+                         chdev_t * src_chdev )
+{
+    // get pointer on PIC chdev
+    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
 
-//////////////////////////////////////////
-void dev_pic_unbind_irq( uint32_t irq_id )
+    // call relevant driver function
+    pic->ext.pic.enable_irq( src_chdev );
+}
+
+////////////////////////////////////////
+void dev_pic_disable_irq( lid_t     lid,
+                          chdev_t * src_chdev )
 {
-    // get extended pointer on PIC chdev from directory
-    xptr_t dev_xp = chdev_dir.pic;
+    // get pointer on PIC chdev
+    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
 
-    // get PIC chdev cluster and local pointer
-    cxy_t     dev_cxy = GET_CXY( dev_xp );
-    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
+    // call relevant driver function
+    pic->ext.pic.disable_irq( src_chdev );
+}
 
-    // get implementation index 
-    uint32_t impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
+////////////////////////////////////////////
+void dev_pic_enable_timer( uint32_t period )
+{
+    // get pointer on PIC chdev
+    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
 
-    // call the implementation specific driver function
-    if( impl == IMPL_PIC_SOC )
-    {
-        soclib_pic_unbind_irq( dev_xp , irq_id );
-    }
-} // end dev_pic_disable_irq()
+    // call relevant driver function
+    pic->ext.pic.enable_timer( period );
+}
+
+//////////////////////////////////
+void dev_pic_send_ipi( cxy_t  cxy,
+                       lid_t  lid )
+{
+    // get pointer on PIC chdev
+    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
+
+    // call relevant driver function
+    pic->ext.pic.send_ipi( cxy , lid );
+}
 
 
