Index: trunk/kernel/drivers/soclib/soclib_nic.c
===================================================================
--- trunk/kernel/drivers/soclib/soclib_nic.c	(revision 1)
+++ trunk/kernel/drivers/soclib/soclib_nic.c	(revision 4)
@@ -25,5 +25,5 @@
 #include <hal_remote.h>
 #include <hal_special.h>
-#include <device.h>
+#include <chdev.h>
 #include <dev_nic.h>
 #include <spinlock.h>
@@ -34,21 +34,13 @@
 #include <soclib_nic.h>
 
-
-/////////////////////////////////////
-void soclib_nic_init( xptr_t dev_xp )
+///////////////////////////////////////
+void soclib_nic_init( chdev_t * chdev )
 {
     uint32_t    i;
     kmem_req_t  req;
     
-    // get NIC device descriptor cluster and local pointer
-    cxy_t      dev_cxy  = GET_CXY( dev_xp );
-    device_t * dev_ptr  = (device_t *)GET_PTR( dev_xp );
-  
-    // get hardware device base address
-	xptr_t     base = hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
-
     // get hardware device cluster and local pointer
-    cxy_t      nic_cxy  = GET_CXY( base );
-    uint32_t * nic_ptr  = (uint32_t *)GET_PTR( base );
+    cxy_t      nic_cxy  = GET_CXY( chdev->base );
+    uint32_t * nic_ptr  = (uint32_t *)GET_PTR( chdev->base );
 
     // initialize Soclib NIC global registers 
@@ -57,9 +49,6 @@
 
     // allocate memory for chbuf descriptor (one page)
-    if( sizeof(nic_chbuf_t) > CONFIG_PPM_PAGE_SIZE )
-    {
-        printk("\n[PANIC] in %s : chbuf descriptor exceeds one page\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (sizeof(nic_chbuf_t) <= CONFIG_PPM_PAGE_SIZE ) , __FUNCTION__ ,
+            "chbuf descriptor exceeds one page" );
 
     req.type   = KMEM_PAGE;
@@ -69,8 +58,6 @@
     nic_chbuf_t * chbuf = (nic_chbuf_t *)kmem_alloc( &req );
 
-    if( chbuf == NULL )
-    {
-        hal_core_sleep("%s : no more memory for chbuf desccriptor\n", __FUNCTION__ );
-    }
+    assert( (chbuf != NULL) , __FUNCTION__ , 
+             "cannot allocate chbuf descriptor" );
 
     // initialise chbuf state
@@ -81,8 +68,6 @@
     // allocate containers (one page per container)
     // and complete chbuf descriptor initialization
-    if( CONFIG_PPM_PAGE_SIZE != 4096 )
-    {
-        hal_core_sleep("%s : chbuf container must be 4 Kbytes\n", __FUNCTION__ );
-    }
+    assert( (CONFIG_PPM_PAGE_SIZE == 4096) , __FUNCTION__ ,
+            "chbuf container must be 4 Kbytes" );
 
     for( i = 0 ; i < CONFIG_NIC_CHBUF_DEPTH ; i++ )
@@ -90,13 +75,10 @@
         uint32_t * container = (uint32_t *)kmem_alloc( &req );   
 
-        if( container == NULL )
-        {
-            hal_core_sleep("%s : no more memory for container\n", __FUNCTION__ );
-        }
+        assert( (container != NULL) , __FUNCTION__ , 
+                "cannot allocate container" );
         
         chbuf->cont[i] = container;
         chbuf->full[i] = (paddr_t)XPTR( local_cxy , container );
     }
-
 } // end soclib_nic_init()
 
@@ -121,11 +103,11 @@
 
     // get command arguments
-    cmd    = thread_ptr->dev.nic.cmd;
-    buffer = thread_ptr->dev.nic.buffer;
-    length = thread_ptr->dev.nic.length;
-    dev_xp = thread_ptr->dev.nic.dev_xp;
+    cmd    = thread_ptr->command.nic.cmd;
+    buffer = thread_ptr->command.nic.buffer;
+    length = thread_ptr->command.nic.length;
+    dev_xp = thread_ptr->command.nic.dev_xp;
 
     // get local pointer for device
-    device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );
+    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
 
     // get chbuf descriptor pointer
@@ -226,5 +208,5 @@
             {
                 // return chbuf writable
-                thread_ptr->dev.nic.status = true;
+                thread_ptr->command.nic.status = true;
             }
             else                    // current container not writable
@@ -244,10 +226,10 @@
                      
                     // return chbuf writable
-                    thread_ptr->dev.nic.status = true;
+                    thread_ptr->command.nic.status = true;
                 }
                 else                            // next container full     
                 {
                     // return chbuf non writable
-                    thread_ptr->dev.nic.status = false;
+                    thread_ptr->command.nic.status = false;
                 }
             }
@@ -270,5 +252,5 @@
             {
                 // return chbuf readable     
-                thread_ptr->dev.nic.status = true;
+                thread_ptr->command.nic.status = true;
             }
             else                        // current container non readable
@@ -288,10 +270,10 @@
                      
                     // return chbuf readable
-                    thread_ptr->dev.nic.status = true;
+                    thread_ptr->command.nic.status = true;
                 }
                 else                            // next container empty    
                 {
                     // return chbuf non readable
-                    thread_ptr->dev.nic.status = false;
+                    thread_ptr->command.nic.status = false;
                 }
             }
@@ -303,11 +285,11 @@
 
 
-////////////////////////////////////////////////////////////////
-void __attribute__ ((noinline)) soclib_nic_isr( device_t * dev )
+/////////////////////////////////////////////////////////////////
+void __attribute__ ((noinline)) soclib_nic_isr( chdev_t * chdev )
 {
     // get base, size, channel, is_rx from NIC channel device NIC 
-    xptr_t     base    = dev->base;
-    uint32_t   channel = dev->channel;
-    bool_t     is_rx   = dev->is_rx;
+    xptr_t     base    = chdev->base;
+    uint32_t   channel = chdev->channel;
+    bool_t     is_rx   = chdev->is_rx;
 
     // get NIC peripheral cluster and local pointer
@@ -326,5 +308,5 @@
     
     // unblock server thread 
-    thread_t * server = dev->server;
+    thread_t * server = chdev->server;
     thread_unblock( XPTR( local_cxy , server ) , THREAD_BLOCKED_IO );
 
