Index: trunk/kernel/vfs/devfs.h
===================================================================
--- trunk/kernel/vfs/devfs.h	(revision 23)
+++ trunk/kernel/vfs/devfs.h	(revision 188)
@@ -26,115 +26,91 @@
 #define _DEVFS_H_
 
-///////////////////////////////////////////////////////////////////////////////////////////
-// The DEVFS File System contains inodes associated to all chdev descriptors availables
-// in the target architecture.  It is a three levels tree structure:
-// - The "dev" directory inode is stored in cluster_0. It is the root of the devfs
-//   file system. The parent inode is the "/" global root.
+//////////////////////////////////////////////////////////////////////////////////////////
+// The DEVFS File System contains inodes and dentries associated to all chdev descriptors 
+// availables in the architecture. It is structured as a three levels tree structure :
+// - The "dev" directory inode is stored in cluster_IO. It is the root of the DEVFS
+//   file system. The parent inode is the "/" VFS root.
 // - There is one "internal_cxy" directory inode per cluster, that is the parent of
-//   the local children inodes associated to the local chdev descriptors. 
-//   The parent inode and dentry are stored in cluster_0.
+//   the local children inodes associated to the local, internal chdev descriptors. 
+//   The parent dentry is stored in cluster_IO.
 // - The I/O cluster contains one "external" directory inode, that is the parent of 
-//   the remote children inodes associated to the remote external descriptors.
-//   The parent inode and dentry are stored in cluster_0.
+//   the remote children inodes associated to the remote external chdev descriptors.
+//   The parent dentry is stored in cluster_IO.
 //
-// The DEVFS File system does not require a context extension, but requires an inode
-// extension to store the pointer on the associated chdev descriptor.
-///////////////////////////////////////////////////////////////////////////////////////////
+// The DEVFS file system uses the DEVFS context extension to register an extended pointer
+// on the DEVFS "dev" inode, and and another extended pointer on the "external" inode.
+//
+// The DEVFS file system uses the VFS inode extension to store the pointer 
+// on the associated chdev descriptor.
+//////////////////////////////////////////////////////////////////////////////////////////
 
-/**************  Forward declarations     ************************************************/
+/*****************************************************************************************
+ * This structure defines the DEVFS context extension.
+ ****************************************************************************************/
 
-struct chdev_s;
-
-/******************************************************************************************
- * This structure defines the DEVFS inode descriptor extension.
- *****************************************************************************************/
-
-typedef struct devfs_inode_ext_s
+typedef struct devfs_ctx_s
 {
-    struct chdev_s * chdev;       /* extended pointer on associated chdev                */
+    xptr_t   root_inode_xp;              /*! extended pointer on DEVFS root inode       */ 
+    xptr_t   external_inode_xp;          /*! extended pointer on DEVFS external inode   */ 
 }
-devfs_inode_t;
+devfs_ctx_t;
 
 
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////////
-//                 These functions are called by the VFS.
-//////////////////////////////////////////////////////////////////////////////////////////
-
-/******************************************************************************************
- * This function  does not exist for the DEVFS file system, as this File System
- * cannot be mounted as the root FS.
- *****************************************************************************************/
-xptr_t devfs_init();
-
-
-/******************************************************************************************
- * This function mount the DEVFS file system on the root FS.
- * It is executed cooperatively during kernel init by all CP0s in all clusters, 
- * to create the DEVFS 3-levels tree structure. 
- * This is a four phases procedure, and it uses the global barrier to synchronize 
- * the cooperating kernel instances when required.
- * - phase 1 : In all clusters, it creates the local extension of the DEVFS context,
- *    and initialises it.
- * - phase 2 : In cluster_0 only, it creates the dentry and the associated inode for
- *   the DEVFS root directory. 
- * - phase 3 : In all cluster(x,y), it creates the dentry and the associated inode for 
- *   the "internal_cxy" directory. It also creates the dentry and associated inode
- *   for all local internal chdevs.
- * - phase 4 : In cluster_io only, it creates the dentry and the associated inode
- *   for the "external" directory. It also creates the dentry and associated inode
- *   for all external chdevs.
- ******************************************************************************************
- * @ parent_inode_xp   : extended pointer on the parent inode in root FS.
- * @ devfs_root_name   : DEVFS root directory name.
- *****************************************************************************************/
-error_t devfs_mount( xptr_t   parent_inode_xp,
-                     char   * devfs_root_name );
+/*****************************************************************************************
+ * This fuction allocates memory from local cluster for a DEVFS context descriptor.
+ *****************************************************************************************
+ * @ return a pointer on the created context / return NULL if failure.
+ ****************************************************************************************/
+devfs_ctx_t * devfs_ctx_alloc();
 
 /*****************************************************************************************
- * This function initializes all fields of the VFS context.
- * No extra memory is allocated for a DEVFS context.
+ * This function initialises the DEVFS context from arguments values, and link it
+ * to the relevant VFS context in the local cluster.
  *****************************************************************************************
- * @ vfs_ctx        : local pointer on VFS context for FATFS.
- * @ root_inode_xp  : extended pointer on the VFS root inode.
+ * @ devfs_ctx               : local pointer on DEVFS context.
+ * @ devfs_root_inode_xp     : [out] extended pointer on created <dev> inode.
+ * @ devfs_external_inode_xp : [out] extended pointer on created <external> inode.
  ****************************************************************************************/
-error_t devfs_ctx_init( struct vfs_ctx_s * vfs_ctx,
-                        xptr_t             root_inode_xp );
+void devfs_ctx_init( devfs_ctx_t * devfs_ctx,
+                     xptr_t        devfs_root_inode_xp,
+                     xptr_t        devfs_external_inode_xp );
 
 /*****************************************************************************************
- * This function does not exist for a DEVFS context, as there is no DEVFS context.
+ * This function releases memory dynamically allocated for the DEVFS context.
+ *****************************************************************************************
+ * @ devfs_ctx   : local pointer on DEVFS context.
  ****************************************************************************************/
-error_t devfs_ctx_destroy();
+void devfs_ctx_destroy( devfs_ctx_t * devfs_ctx );
 
 /*****************************************************************************************
- * This function allocates memory for a DEVFS inode, initialise it,
- * and link it to the VFS inode.
+ * This function start to create the DEVFS subtree. 
+ * This function should be called once in the cluster containing the VFS parent inode.
+ * More precisely, it creates in cluster IO the "dev" and "external" DEVFS directories.
+ * For each one, it creates the inode and link the associated dentry to parent inode.
+ * The DEVFS root inode is linked to the VFS parent inode identified by <parent_inode_xp>.
  *****************************************************************************************
- * @ inode          : local pointer on the VFS inode.
- * @ chdev          : local pointer on the chdev to be inserted in DEVFS.
+ * @ parent_inode_xp         : extended pointer on the parent VFS inode.
+ * @ devfs_root_inode_xp     : [out] extended pointer on created <dev> inode.
+ * @ devfs_external_inode_xp : [out] extended pointer on created <external> inode.
  ****************************************************************************************/
-error_t devfs_inode_create( struct vfs_inode_s * inode,
-                            struct chdev_s     * chdev );
+void devfs_global_init( xptr_t   parent_inode_xp,
+                        xptr_t * devfs_root_inode_xp,
+                        xptr_t * devfs_external_inode_xp );
 
 /*****************************************************************************************
- * This function releases memory allocated for a DEVFS inode.
+ * This function completes the initialisation of the DEVFS subtree.
+ * It should be called once in each cluster.
+ * 1. In each cluster (i), it creates the "internal" directory, 
+ *    linked to the DEVFS "dev" parent directory.
+ * 2. In each cluster (i), it creates - for each external chdev in cluster (i) - 
+ *    a pseudo-file, linked to the DEVFS "external" parent directory.
+ * 3. In each cluster (i), it creates - for each internal chdev in cluster (i) -
+ *    a pseudo-file, linked to the DEVFS "internal" parent directory.
  *****************************************************************************************
- * @ inode   : local pointer on vfs_inode.
+ * @ devfs_root_inode_xp     : extended pointer on DEVFS root inode.
+ * @ devfs_external_inode_xp : extended pointer on DEVFS external inode.
  ****************************************************************************************/
-void devfs_inode_destroy( struct vfs_inode_s * inode );
-
-/*****************************************************************************************
- * This function does not exist for the DEVFS File System.
- ****************************************************************************************/
-error_t devfs_write_page( struct page_s * page );
-
-/*****************************************************************************************
- * This function does not exist for the DEVFS File System.
- ****************************************************************************************/
-error_t devfs_read_page( struct page_s * page );
-
-
-
+void devfs_local_init( xptr_t devfs_root_inode_xp,
+                       xptr_t devfs_external_inode_xp );
+                       
 #endif	/* _DEVFS_H_ */
