Index: trunk/kernel/libk/xhtab.c
===================================================================
--- trunk/kernel/libk/xhtab.c	(revision 492)
+++ trunk/kernel/libk/xhtab.c	(revision 563)
@@ -27,5 +27,5 @@
 #include <hal_remote.h>
 #include <xlist.h>
-#include <remote_rwlock.h>
+#include <remote_busylock.h>
 #include <string.h>
 #include <printk.h>
@@ -35,10 +35,11 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-// Item type specific functions (three functions for each item type).
-///////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////
-// This functions compute the hash index from the key when item is a vfs_dentry_t.
-// The key is the directory entry name.
+// Item type specific functions (four functions for each item type).
+// Example below is for <vfs_dentry_t> where the identifier is the dentry name.
+///////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////
+// vfs_dentry_t 
+// This functions compute the hash index from the key, that is the directory entry name.
 ///////////////////////////////////////////////////////////////////////////////////////////
 // @ key      : local pointer on name.
@@ -57,6 +58,7 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////
+// vfs_dentry_t
 // This functions returns the extended pointer on the item, from the extended pointer 
-// on xlist contained in the item, when the item is a vfs_entry_t.
+// on xlist contained in the item.
 ///////////////////////////////////////////////////////////////////////////////////////////
 // @ xlist_xp      : extended pointer on embedded xlist entry.
@@ -69,5 +71,6 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////////
-// This function compare the identifier of an item to a given <key>. For a vfs_entry_t,
+// vfs_dentry_t
+// This function compares the identifier of an item to a given <key>. 
 // it returns true when the directory name matches the name pointed by the <key> argument.
 ////////////////////////////////////////////////////////////////////////////////////////////
@@ -83,5 +86,5 @@
     // get dentry cluster and local pointer
     cxy_t          dentry_cxy = GET_CXY( item_xp );
-    vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );
+    vfs_dentry_t * dentry_ptr = GET_PTR( item_xp );
 
     // make a local copy of directory entry name
@@ -93,5 +96,6 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////////
-// This function print the item key, that is the name for a vfs_entry_t,
+// vfs_dentry_t
+// This function print the item key, that is the name for a vfs_dentry_t.
 ////////////////////////////////////////////////////////////////////////////////////////////
 // @ item_xp   : extended pointer on item.
@@ -103,5 +107,5 @@
     // get dentry cluster and local pointer
     cxy_t          dentry_cxy = GET_CXY( item_xp );
-    vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );
+    vfs_dentry_t * dentry_ptr = GET_PTR( item_xp );
     
     // make a local copy of directory entry name
@@ -124,5 +128,5 @@
 
     // initialize readlock
-    remote_rwlock_init( XPTR( local_cxy , &xhtab->lock) );
+    remote_busylock_init( XPTR( local_cxy , &xhtab->lock), LOCK_XHTAB_STATE );
 
     xhtab->items            = 0;
@@ -163,5 +167,5 @@
     // get hash table cluster and local pointer
     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_ptr = GET_PTR( xhtab_xp );
 
     // get pointer on "item_from_xlist" function
@@ -198,7 +202,11 @@
     index_from_key_t * index_from_key;     // function pointer
     
-    // get xhtab cluster and local pointer 
-    xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+#if DEBUG_XHTAB
+printk("\n[DBG] %s : enter / %s\n", __FUNCTION__, key );
+#endif
+
+    // get xhtab cluster and local pointer 
+    xhtab_cxy = GET_CXY( xhtab_xp );
+    xhtab_ptr = GET_PTR( xhtab_xp );
 
     // get pointer on "index_from_key" function
@@ -209,5 +217,5 @@
 
     // take the lock protecting hash table
-    remote_rwlock_wr_lock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+    remote_busylock_acquire( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
 
     // search a matching item 
@@ -217,5 +225,5 @@
     {
         // release the lock protecting hash table
-        remote_rwlock_wr_unlock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+        remote_busylock_release( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
 
         return EINVAL;
@@ -230,5 +238,9 @@
 
         // release the lock protecting hash table
-        remote_rwlock_wr_unlock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+        remote_busylock_release( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+    
+#if DEBUG_XHTAB
+printk("\n[DBG] %s : success / %s\n", __FUNCTION__, key );
+#endif
 
         return 0;
@@ -249,5 +261,5 @@
     // get xhtab cluster and local pointer 
     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_ptr = GET_PTR( xhtab_xp );
 
     // get pointer on "index_from_key" function
@@ -258,5 +270,5 @@
 
     // take the lock protecting hash table
-    remote_rwlock_wr_lock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+    remote_busylock_acquire( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
 
     // get extended pointer on item to remove
@@ -266,5 +278,5 @@
     {
         // release the lock protecting hash table
-        remote_rwlock_wr_unlock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+        remote_busylock_release( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
 
         return EINVAL;
@@ -279,5 +291,5 @@
 
         // release the lock protecting hash table
-        remote_rwlock_wr_unlock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+        remote_busylock_release( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
 
         return 0;
@@ -297,5 +309,5 @@
     // get xhtab cluster and local pointer 
     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_ptr = GET_PTR( xhtab_xp );
 
     // get pointer on "index_from_key" function
@@ -304,13 +316,29 @@
     // compute index from key
 	index = index_from_key( key );
+    
+#if DEBUG_XHTAB
+printk("\n[DBG] %s : enter / %s\n", __FUNCTION__, key );
+#endif
 
     // take the lock protecting hash table
-    remote_rwlock_rd_lock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+    remote_busylock_acquire( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+    
+#if DEBUG_XHTAB
+printk("\n[DBG] %s : after lock acquire / %s\n", __FUNCTION__, key );
+#endif
 
     // scan sub-list
     item_xp = xhtab_scan( xhtab_xp , index , key );
 
+#if DEBUG_XHTAB
+printk("\n[DBG] %s : after xhtab scan / %s\n", __FUNCTION__, key );
+#endif
+
     // release the lock protecting hash table
-    remote_rwlock_rd_unlock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+    remote_busylock_release( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+
+#if DEBUG_XHTAB
+printk("\n[DBG] %s : after lock release / %s\n", __FUNCTION__, key );
+#endif
 
     return item_xp;
@@ -318,24 +346,24 @@
 }  // end xhtab_lookup()
 
-///////////////////////////////////////
-void xhtab_read_lock( xptr_t xhtab_xp )
+//////////////////////////////////
+void xhtab_lock( xptr_t xhtab_xp )
 {
     // get xhtab cluster and local pointer 
     cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_t * xhtab_ptr = GET_PTR( xhtab_xp );
 
     // take the lock protecting hash table
-    remote_rwlock_rd_lock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+    remote_busylock_acquire( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
 }
 
-/////////////////////////////////////////
-void xhtab_read_unlock( xptr_t xhtab_xp )
+////////////////////////////////////
+void xhtab_unlock( xptr_t xhtab_xp )
 {
     // get xhtab cluster and local pointer 
     cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_t * xhtab_ptr = GET_PTR( xhtab_xp );
 
     // release the lock protecting hash table
-    remote_rwlock_rd_unlock( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
+    remote_busylock_release( XPTR( xhtab_cxy , &xhtab_ptr->lock ) );
 }
 
@@ -353,5 +381,5 @@
     // get xhtab cluster and local pointer 
     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_ptr = GET_PTR( xhtab_xp );
 
     // get pointer on "item_from_xlist" function
@@ -373,6 +401,6 @@
 
             // register item in hash table header
-            hal_remote_sw ( XPTR( xhtab_cxy , &xhtab_ptr->current_index ) , index );
-            hal_remote_swd( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) , xlist_xp );
+            hal_remote_s32 ( XPTR( xhtab_cxy , &xhtab_ptr->current_index ) , index );
+            hal_remote_s64( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) , xlist_xp );
 
             return item_xp;
@@ -401,9 +429,9 @@
     // get xhtab cluster and local pointer 
     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_ptr = GET_PTR( xhtab_xp );
 
     // get current item pointers
-    current_index    = hal_remote_lw ( XPTR( xhtab_cxy , &xhtab_ptr->current_index ) ); 
-    current_xlist_xp = hal_remote_lwd( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) ); 
+    current_index    = hal_remote_l32 ( XPTR( xhtab_cxy , &xhtab_ptr->current_index ) ); 
+    current_xlist_xp = hal_remote_l64( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) ); 
 
     // get pointer on "item_from_xlist" function
@@ -426,6 +454,6 @@
 
             // register item in hash table header
-            hal_remote_sw ( XPTR( xhtab_cxy , &xhtab_ptr->current_index ) , index );
-            hal_remote_swd( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) , xlist_xp );
+            hal_remote_s32 ( XPTR( xhtab_cxy , &xhtab_ptr->current_index ) , index );
+            hal_remote_s64( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) , xlist_xp );
 
             return item_xp;
@@ -452,5 +480,5 @@
     // get xhtab cluster and local pointer 
     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_ptr = GET_PTR( xhtab_xp );
 
     // get pointer on "item_from_xlist" function
