1 | /* |
---|
2 | * devfs.h - DEVFS File System API definition |
---|
3 | * |
---|
4 | * Authors Mohamed Lamine Karaoui (2014,2015) |
---|
5 | * Alain Greiner (2016,2017) |
---|
6 | * |
---|
7 | * Copyright (c) 2011,2012 UPMC Sorbonne Universites |
---|
8 | * |
---|
9 | * This file is part of ALMOS-MKH. |
---|
10 | * |
---|
11 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
12 | * under the terms of the GNU General Public License as published by |
---|
13 | * the Free Software Foundation; version 2.0 of the License. |
---|
14 | * |
---|
15 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | * General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU General Public License |
---|
21 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
22 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef _DEVFS_H_ |
---|
26 | #define _DEVFS_H_ |
---|
27 | |
---|
28 | ////////////////////////////////////////////////////////////////////////////////////////// |
---|
29 | // The DEVFS File System contains inodes and dentries associated to all chdev descriptors |
---|
30 | // availables in the architecture. |
---|
31 | // |
---|
32 | // It is structured as a three levels tree structure : |
---|
33 | // - The "dev" directory inode is stored in cluster_IO. It is the root of the DEVFS |
---|
34 | // file system. The parent inode is the "/" VFS root. |
---|
35 | // - There is one "internal_cxy" directory inode per cluster, that is the parent of |
---|
36 | // the local children inodes associated to the local, internal chdev descriptors. |
---|
37 | // The parent dentry is stored in cluster_IO. |
---|
38 | // - The I/O cluster contains one "external" directory inode, that is the parent of |
---|
39 | // the remote children inodes associated to the remote external chdev descriptors. |
---|
40 | // The parent dentry is stored in cluster_IO. |
---|
41 | // |
---|
42 | // The DEVFS extensions to the generic VFS are the following: |
---|
43 | // 1) The vfs_ctx_t "extend" field is a void* pointing on the devfs_ctx_t structure. |
---|
44 | // This structure contains two extended pointers on the DEVFS "dev" directory inode, |
---|
45 | // and on the "external" directory inode. |
---|
46 | // 2) The vfs_inode_t "extend" field is a void*, pointing on the associated |
---|
47 | // chdev descriptor. |
---|
48 | ////////////////////////////////////////////////////////////////////////////////////////// |
---|
49 | |
---|
50 | /***************************************************************************************** |
---|
51 | * This structure defines the DEVFS context extension. |
---|
52 | ****************************************************************************************/ |
---|
53 | |
---|
54 | typedef struct devfs_ctx_s |
---|
55 | { |
---|
56 | xptr_t dev_inode_xp; /*! extended pointer on DEVFS root inode */ |
---|
57 | xptr_t external_inode_xp; /*! extended pointer on DEVFS external inode */ |
---|
58 | } |
---|
59 | devfs_ctx_t; |
---|
60 | |
---|
61 | |
---|
62 | /***************************************************************************************** |
---|
63 | * This fuction allocates memory from local cluster for a DEVFS context descriptor. |
---|
64 | ***************************************************************************************** |
---|
65 | * @ return a pointer on the created context / return NULL if failure. |
---|
66 | ****************************************************************************************/ |
---|
67 | devfs_ctx_t * devfs_ctx_alloc(); |
---|
68 | |
---|
69 | /***************************************************************************************** |
---|
70 | * This function initialises the DEVFS context from arguments values, and link it |
---|
71 | * to the relevant VFS context in the local cluster. |
---|
72 | ***************************************************************************************** |
---|
73 | * @ devfs_ctx : local pointer on DEVFS context. |
---|
74 | * @ devfs_dev_inode_xp : [out] extended pointer on <dev> inode. |
---|
75 | * @ devfs_external_inode_xp : [out] extended pointer on <external> inode. |
---|
76 | ****************************************************************************************/ |
---|
77 | void devfs_ctx_init( devfs_ctx_t * devfs_ctx, |
---|
78 | xptr_t devfs_dev_inode_xp, |
---|
79 | xptr_t devfs_external_inode_xp ); |
---|
80 | |
---|
81 | /***************************************************************************************** |
---|
82 | * This function releases memory dynamically allocated for the DEVFS context. |
---|
83 | ***************************************************************************************** |
---|
84 | * @ devfs_ctx : local pointer on DEVFS context. |
---|
85 | ****************************************************************************************/ |
---|
86 | void devfs_ctx_destroy( devfs_ctx_t * devfs_ctx ); |
---|
87 | |
---|
88 | /***************************************************************************************** |
---|
89 | * This function start to create the DEVFS subtree. |
---|
90 | * This function should be called once in the cluster containing the VFS parent inode. |
---|
91 | * More precisely, it creates in cluster IO the "dev" and "external" DEVFS directories. |
---|
92 | * For each one, it creates the inode and link the associated dentry to parent inode. |
---|
93 | * The DEVFS root inode is linked to the VFS parent inode identified by <parent_inode_xp>. |
---|
94 | ***************************************************************************************** |
---|
95 | * @ parent_inode_xp : extended pointer on the parent VFS inode. |
---|
96 | * @ devfs_dev_inode_xp : [out] extended pointer on created <dev> inode. |
---|
97 | * @ devfs_external_inode_xp : [out] extended pointer on created <external> inode. |
---|
98 | ****************************************************************************************/ |
---|
99 | void devfs_global_init( xptr_t parent_inode_xp, |
---|
100 | xptr_t * devfs_dev_inode_xp, |
---|
101 | xptr_t * devfs_external_inode_xp ); |
---|
102 | |
---|
103 | /***************************************************************************************** |
---|
104 | * This function completes the initialisation of the DEVFS subtree. |
---|
105 | * It should be called once in each cluster. |
---|
106 | * 1. In each cluster (i), it creates the "internal" directory, |
---|
107 | * linked to the DEVFS "dev" parent directory. |
---|
108 | * 2. In each cluster (i), it creates - for each external chdev in cluster (i) - |
---|
109 | * a pseudo-file, linked to the DEVFS "external" parent directory. |
---|
110 | * 3. In each cluster (i), it creates - for each internal chdev in cluster (i) - |
---|
111 | * a pseudo-file, linked to the DEVFS "internal" parent directory. |
---|
112 | ***************************************************************************************** |
---|
113 | * @ devfs_dev_inode_xp : extended pointer on DEVFS root inode. |
---|
114 | * @ devfs_external_inode_xp : extended pointer on DEVFS external inode. |
---|
115 | * @ devfs_internal_inode_xp : [out] extended pointer on created <internal> inode. |
---|
116 | ****************************************************************************************/ |
---|
117 | void devfs_local_init( xptr_t devfs_dev_inode_xp, |
---|
118 | xptr_t devfs_external_inode_xp, |
---|
119 | xptr_t * devfs_internal_inode_xp ); |
---|
120 | |
---|
121 | #endif /* _DEVFS_H_ */ |
---|