Changeset 657 for trunk/kernel/fs/devfs.c
- Timestamp:
- Mar 18, 2020, 11:16:59 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r637 r657 3 3 * 4 4 * Author Mohamed Lamine Karaoui (2014,2015) 5 * Alain Greiner (2016,2017,2018,2019 )5 * Alain Greiner (2016,2017,2018,2019,2020) 6 6 * 7 7 * Copyright (c) Sorbonne Universites … … 53 53 #endif 54 54 55 /////////////////////////////////// //56 devfs_ctx_t * devfs_ctx_alloc( void)55 /////////////////////////////////// 56 xptr_t devfs_ctx_alloc( cxy_t cxy ) 57 57 { 58 58 kmem_req_t req; … … 62 62 req.flags = AF_KERNEL | AF_ZERO; 63 63 64 return kmem_alloc( &req ); 64 // allocates devfs context from target cluster 65 return XPTR( cxy , kmem_remote_alloc( cxy , &req ) ); 65 66 } 66 67 67 68 ///////////////////////////////////////////// 68 void devfs_ctx_init( devfs_ctx_t * devfs_ctx,69 xptr_t 70 xptr_t 69 void devfs_ctx_init( xptr_t devfs_ctx_xp, 70 xptr_t devfs_dev_inode_xp, 71 xptr_t devfs_external_inode_xp ) 71 72 { 72 devfs_ctx->dev_inode_xp = devfs_dev_inode_xp; 73 devfs_ctx->external_inode_xp = devfs_external_inode_xp; 74 75 fs_context[FS_TYPE_DEVFS].extend = devfs_ctx; 73 // get cluster and local pointer on remote devfs context 74 devfs_ctx_t * devfs_ctx_ptr = GET_PTR( devfs_ctx_xp ); 75 cxy_t devfs_ctx_cxy = GET_CXY( devfs_ctx_xp ); 76 77 // set values in remote devfs context 78 hal_remote_s64( XPTR( devfs_ctx_cxy , &devfs_ctx_ptr->dev_inode_xp ), 79 devfs_dev_inode_xp ); 80 81 hal_remote_s64( XPTR( devfs_ctx_cxy , &devfs_ctx_ptr->external_inode_xp ), 82 devfs_external_inode_xp ); 83 84 // register devfs context in the remote fs_context array[] 85 hal_remote_spt( XPTR( devfs_ctx_cxy , &fs_context[FS_TYPE_DEVFS].extend ), 86 devfs_ctx_ptr ); 76 87 } 77 88 78 ////////////////////////////////////////////// ///79 void devfs_ctx_destroy( devfs_ctx_t * devfs_ctx)89 ////////////////////////////////////////////// 90 void devfs_ctx_destroy( xptr_t devfs_ctx_xp ) 80 91 { 81 92 kmem_req_t req; 82 93 94 // get cluster and local pointer on devfs context 95 devfs_ctx_t * devfs_ctx_ptr = GET_PTR( devfs_ctx_xp ); 96 cxy_t devfs_ctx_cxy = GET_CXY( devfs_ctx_xp ); 97 83 98 req.type = KMEM_KCM; 84 req.ptr = devfs_ctx; 85 kmem_free( &req ); 99 req.ptr = devfs_ctx_ptr; 100 101 // release devfs context descriptor to remote cluster 102 kmem_remote_free( devfs_ctx_cxy , &req ); 86 103 } 87 104 … … 95 112 vfs_inode_t * inode; 96 113 114 // get 115 97 116 // create DEVFS "dev" inode in cluster 0 98 117 error = vfs_add_child_in_parent( 0, // cxy … … 158 177 /////////////////////////////////////////////////// 159 178 void devfs_local_init( xptr_t devfs_dev_inode_xp, 160 xptr_t devfs_external_inode_xp, 161 xptr_t * devfs_internal_inode_xp ) 179 xptr_t devfs_external_inode_xp ) 162 180 { 181 xptr_t internal_inode_xp; // extended pointer on <internal> inode 182 vfs_inode_t * internal_inode_ptr; // local pointer on <internal> inode 163 183 char node_name[16]; 164 184 xptr_t chdev_xp; … … 168 188 vfs_inode_t * inode_ptr; 169 189 uint32_t channel; 170 xptr_t unused_xp; // required by add_child_in_parent()190 xptr_t unused_xp; // required by add_child_in_parent() 171 191 error_t error; 192 172 193 173 194 #if DEBUG_DEVFS_LOCAL_INIT … … 179 200 #endif 180 201 181 // create "internal"directory202 // create <internal> directory 182 203 snprintf( node_name , 16 , "internal_%x" , local_cxy ); 183 204 184 error = vfs_add_child_in_parent( local_cxy, 185 FS_TYPE_DEVFS, 186 devfs_dev_inode_xp, 187 node_name, 205 error = vfs_add_child_in_parent( local_cxy, // target cluster 206 FS_TYPE_DEVFS, // FS type 207 devfs_dev_inode_xp, // parent inode 208 node_name, // child name 188 209 &unused_xp, 189 devfs_internal_inode_xp );190 191 // set inode "type" field192 in ode_ptr = GET_PTR( *devfs_internal_inode_xp );193 in ode_ptr->type = INODE_TYPE_DEV;210 &internal_inode_xp ); // child inode 211 212 // set <internal> inode "type" field 213 internal_inode_ptr = GET_PTR( internal_inode_xp ); 214 internal_inode_ptr->type = INODE_TYPE_DEV; 194 215 195 216 // create dentries <.> and <..> in <internal> 196 error |= vfs_add_special_dentries( *devfs_internal_inode_xp,217 error |= vfs_add_special_dentries( internal_inode_xp, 197 218 devfs_dev_inode_xp ); 198 219 … … 226 247 error = vfs_add_child_in_parent( local_cxy, 227 248 FS_TYPE_DEVFS, 228 *devfs_internal_inode_xp,249 internal_inode_xp, 229 250 chdev_ptr->name, 230 251 &unused_xp, … … 270 291 error = vfs_add_child_in_parent( local_cxy, 271 292 FS_TYPE_DEVFS, 272 *devfs_internal_inode_xp,293 internal_inode_xp, 273 294 chdev_ptr->name, 274 295 &unused_xp,
Note: See TracChangeset
for help on using the changeset viewer.