Changeset 188 for trunk/kernel/vfs/devfs.h
- Timestamp:
- Jul 12, 2017, 8:12:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/devfs.h
r23 r188 26 26 #define _DEVFS_H_ 27 27 28 ////////////////////////////////////////////////////////////////////////////////////////// /29 // The DEVFS File System contains inodes a ssociated to all chdev descriptors availables30 // in the target architecture. It is a three levels tree structure:31 // - The "dev" directory inode is stored in cluster_ 0. It is the root of the devfs32 // file system. The parent inode is the "/" globalroot.28 ////////////////////////////////////////////////////////////////////////////////////////// 29 // The DEVFS File System contains inodes and dentries associated to all chdev descriptors 30 // availables in the architecture. It is structured as a three levels tree structure : 31 // - The "dev" directory inode is stored in cluster_IO. It is the root of the DEVFS 32 // file system. The parent inode is the "/" VFS root. 33 33 // - There is one "internal_cxy" directory inode per cluster, that is the parent of 34 // the local children inodes associated to the local chdev descriptors.35 // The parent inode and dentry are stored in cluster_0.34 // the local children inodes associated to the local, internal chdev descriptors. 35 // The parent dentry is stored in cluster_IO. 36 36 // - The I/O cluster contains one "external" directory inode, that is the parent of 37 // the remote children inodes associated to the remote external descriptors.38 // The parent inode and dentry are stored in cluster_0.37 // the remote children inodes associated to the remote external chdev descriptors. 38 // The parent dentry is stored in cluster_IO. 39 39 // 40 // The DEVFS File system does not require a context extension, but requires an inode 41 // extension to store the pointer on the associated chdev descriptor. 42 /////////////////////////////////////////////////////////////////////////////////////////// 40 // The DEVFS file system uses the DEVFS context extension to register an extended pointer 41 // on the DEVFS "dev" inode, and and another extended pointer on the "external" inode. 42 // 43 // The DEVFS file system uses the VFS inode extension to store the pointer 44 // on the associated chdev descriptor. 45 ////////////////////////////////////////////////////////////////////////////////////////// 43 46 44 /************** Forward declarations ************************************************/ 47 /***************************************************************************************** 48 * This structure defines the DEVFS context extension. 49 ****************************************************************************************/ 45 50 46 struct chdev_s; 47 48 /****************************************************************************************** 49 * This structure defines the DEVFS inode descriptor extension. 50 *****************************************************************************************/ 51 52 typedef struct devfs_inode_ext_s 51 typedef struct devfs_ctx_s 53 52 { 54 struct chdev_s * chdev; /* extended pointer on associated chdev */ 53 xptr_t root_inode_xp; /*! extended pointer on DEVFS root inode */ 54 xptr_t external_inode_xp; /*! extended pointer on DEVFS external inode */ 55 55 } 56 devfs_ inode_t;56 devfs_ctx_t; 57 57 58 58 59 60 61 62 ////////////////////////////////////////////////////////////////////////////////////////// 63 // These functions are called by the VFS. 64 ////////////////////////////////////////////////////////////////////////////////////////// 65 66 /****************************************************************************************** 67 * This function does not exist for the DEVFS file system, as this File System 68 * cannot be mounted as the root FS. 69 *****************************************************************************************/ 70 xptr_t devfs_init(); 71 72 73 /****************************************************************************************** 74 * This function mount the DEVFS file system on the root FS. 75 * It is executed cooperatively during kernel init by all CP0s in all clusters, 76 * to create the DEVFS 3-levels tree structure. 77 * This is a four phases procedure, and it uses the global barrier to synchronize 78 * the cooperating kernel instances when required. 79 * - phase 1 : In all clusters, it creates the local extension of the DEVFS context, 80 * and initialises it. 81 * - phase 2 : In cluster_0 only, it creates the dentry and the associated inode for 82 * the DEVFS root directory. 83 * - phase 3 : In all cluster(x,y), it creates the dentry and the associated inode for 84 * the "internal_cxy" directory. It also creates the dentry and associated inode 85 * for all local internal chdevs. 86 * - phase 4 : In cluster_io only, it creates the dentry and the associated inode 87 * for the "external" directory. It also creates the dentry and associated inode 88 * for all external chdevs. 89 ****************************************************************************************** 90 * @ parent_inode_xp : extended pointer on the parent inode in root FS. 91 * @ devfs_root_name : DEVFS root directory name. 92 *****************************************************************************************/ 93 error_t devfs_mount( xptr_t parent_inode_xp, 94 char * devfs_root_name ); 59 /***************************************************************************************** 60 * This fuction allocates memory from local cluster for a DEVFS context descriptor. 61 ***************************************************************************************** 62 * @ return a pointer on the created context / return NULL if failure. 63 ****************************************************************************************/ 64 devfs_ctx_t * devfs_ctx_alloc(); 95 65 96 66 /***************************************************************************************** 97 * This function initiali zes all fields of the VFS context.98 * No extra memory is allocated for a DEVFS context.67 * This function initialises the DEVFS context from arguments values, and link it 68 * to the relevant VFS context in the local cluster. 99 69 ***************************************************************************************** 100 * @ vfs_ctx : local pointer on VFS context for FATFS. 101 * @ root_inode_xp : extended pointer on the VFS root inode. 70 * @ devfs_ctx : local pointer on DEVFS context. 71 * @ devfs_root_inode_xp : [out] extended pointer on created <dev> inode. 72 * @ devfs_external_inode_xp : [out] extended pointer on created <external> inode. 102 73 ****************************************************************************************/ 103 error_t devfs_ctx_init( struct vfs_ctx_s * vfs_ctx, 104 xptr_t root_inode_xp ); 74 void devfs_ctx_init( devfs_ctx_t * devfs_ctx, 75 xptr_t devfs_root_inode_xp, 76 xptr_t devfs_external_inode_xp ); 105 77 106 78 /***************************************************************************************** 107 * This function does not exist for a DEVFS context, as there is no DEVFS context. 79 * This function releases memory dynamically allocated for the DEVFS context. 80 ***************************************************************************************** 81 * @ devfs_ctx : local pointer on DEVFS context. 108 82 ****************************************************************************************/ 109 error_t devfs_ctx_destroy();83 void devfs_ctx_destroy( devfs_ctx_t * devfs_ctx ); 110 84 111 85 /***************************************************************************************** 112 * This function allocates memory for a DEVFS inode, initialise it, 113 * and link it to the VFS inode. 86 * This function start to create the DEVFS subtree. 87 * This function should be called once in the cluster containing the VFS parent inode. 88 * More precisely, it creates in cluster IO the "dev" and "external" DEVFS directories. 89 * For each one, it creates the inode and link the associated dentry to parent inode. 90 * The DEVFS root inode is linked to the VFS parent inode identified by <parent_inode_xp>. 114 91 ***************************************************************************************** 115 * @ inode : local pointer on the VFS inode. 116 * @ chdev : local pointer on the chdev to be inserted in DEVFS. 92 * @ parent_inode_xp : extended pointer on the parent VFS inode. 93 * @ devfs_root_inode_xp : [out] extended pointer on created <dev> inode. 94 * @ devfs_external_inode_xp : [out] extended pointer on created <external> inode. 117 95 ****************************************************************************************/ 118 error_t devfs_inode_create( struct vfs_inode_s * inode, 119 struct chdev_s * chdev ); 96 void devfs_global_init( xptr_t parent_inode_xp, 97 xptr_t * devfs_root_inode_xp, 98 xptr_t * devfs_external_inode_xp ); 120 99 121 100 /***************************************************************************************** 122 * This function releases memory allocated for a DEVFS inode. 101 * This function completes the initialisation of the DEVFS subtree. 102 * It should be called once in each cluster. 103 * 1. In each cluster (i), it creates the "internal" directory, 104 * linked to the DEVFS "dev" parent directory. 105 * 2. In each cluster (i), it creates - for each external chdev in cluster (i) - 106 * a pseudo-file, linked to the DEVFS "external" parent directory. 107 * 3. In each cluster (i), it creates - for each internal chdev in cluster (i) - 108 * a pseudo-file, linked to the DEVFS "internal" parent directory. 123 109 ***************************************************************************************** 124 * @ inode : local pointer on vfs_inode. 110 * @ devfs_root_inode_xp : extended pointer on DEVFS root inode. 111 * @ devfs_external_inode_xp : extended pointer on DEVFS external inode. 125 112 ****************************************************************************************/ 126 void devfs_inode_destroy( struct vfs_inode_s * inode ); 127 128 /***************************************************************************************** 129 * This function does not exist for the DEVFS File System. 130 ****************************************************************************************/ 131 error_t devfs_write_page( struct page_s * page ); 132 133 /***************************************************************************************** 134 * This function does not exist for the DEVFS File System. 135 ****************************************************************************************/ 136 error_t devfs_read_page( struct page_s * page ); 137 138 139 113 void devfs_local_init( xptr_t devfs_root_inode_xp, 114 xptr_t devfs_external_inode_xp ); 115 140 116 #endif /* _DEVFS_H_ */
Note: See TracChangeset
for help on using the changeset viewer.