source: trunk/kernel/fs/devfs.h @ 533

Last change on this file since 533 was 484, checked in by viala@…, 6 years ago

[fs] Add void type to function prototypes with no parameter

File size: 7.8 KB
RevLine 
[23]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
[188]28//////////////////////////////////////////////////////////////////////////////////////////
29// The DEVFS File System contains inodes and dentries associated to all chdev descriptors
[238]30// availables in the architecture.
31//
32// It is structured as a three levels tree structure :
[188]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.
[23]35// - There is one "internal_cxy" directory inode per cluster, that is the parent of
[188]36//   the local children inodes associated to the local, internal chdev descriptors.
37//   The parent dentry is stored in cluster_IO.
[23]38// - The I/O cluster contains one "external" directory inode, that is the parent of
[188]39//   the remote children inodes associated to the remote external chdev descriptors.
40//   The parent dentry is stored in cluster_IO.
[23]41//
[238]42// The DEVFS extensions to the generic VFS are the following:
[407]43// 1) The vfs_ctx_t "extend" void* field is pointing on the devfs_ctx_t structure.
[238]44//    This structure contains two extended pointers on the DEVFS "dev" directory inode,
45//    and on the "external" directory inode.
[407]46// 2) The vfs_inode_t "extend" void* field is pointing on the chdev descriptor.
[188]47//////////////////////////////////////////////////////////////////////////////////////////
[23]48
[188]49/*****************************************************************************************
50 * This structure defines the DEVFS context extension.
51 ****************************************************************************************/
[23]52
[188]53typedef struct devfs_ctx_s
[23]54{
[204]55    xptr_t   dev_inode_xp;               /*! extended pointer on DEVFS root inode       */ 
[188]56    xptr_t   external_inode_xp;          /*! extended pointer on DEVFS external inode   */ 
[23]57}
[188]58devfs_ctx_t;
[23]59
60
61/*****************************************************************************************
[188]62 * This fuction allocates memory from local cluster for a DEVFS context descriptor.
[23]63 *****************************************************************************************
[188]64 * @ return a pointer on the created context / return NULL if failure.
[23]65 ****************************************************************************************/
[484]66devfs_ctx_t * devfs_ctx_alloc( void );
[23]67
68/*****************************************************************************************
[188]69 * This function initialises the DEVFS context from arguments values, and link it
70 * to the relevant VFS context in the local cluster.
71 *****************************************************************************************
72 * @ devfs_ctx               : local pointer on DEVFS context.
[204]73 * @ devfs_dev_inode_xp      : [out] extended pointer on  <dev> inode.
74 * @ devfs_external_inode_xp : [out] extended pointer on  <external> inode.
[23]75 ****************************************************************************************/
[188]76void devfs_ctx_init( devfs_ctx_t * devfs_ctx,
[204]77                     xptr_t        devfs_dev_inode_xp,
[188]78                     xptr_t        devfs_external_inode_xp );
[23]79
80/*****************************************************************************************
[188]81 * This function releases memory dynamically allocated for the DEVFS context.
[23]82 *****************************************************************************************
[188]83 * @ devfs_ctx   : local pointer on DEVFS context.
[23]84 ****************************************************************************************/
[188]85void devfs_ctx_destroy( devfs_ctx_t * devfs_ctx );
[23]86
87/*****************************************************************************************
[188]88 * This function start to create the DEVFS subtree.
89 * This function should be called once in the cluster containing the VFS parent inode.
90 * More precisely, it creates in cluster IO the "dev" and "external" DEVFS directories.
91 * For each one, it creates the inode and link the associated dentry to parent inode.
92 * The DEVFS root inode is linked to the VFS parent inode identified by <parent_inode_xp>.
[23]93 *****************************************************************************************
[188]94 * @ parent_inode_xp         : extended pointer on the parent VFS inode.
[204]95 * @ devfs_dev_inode_xp      : [out] extended pointer on created <dev> inode.
[188]96 * @ devfs_external_inode_xp : [out] extended pointer on created <external> inode.
[23]97 ****************************************************************************************/
[188]98void devfs_global_init( xptr_t   parent_inode_xp,
[204]99                        xptr_t * devfs_dev_inode_xp,
[188]100                        xptr_t * devfs_external_inode_xp );
[23]101
102/*****************************************************************************************
[188]103 * This function completes the initialisation of the DEVFS subtree.
104 * It should be called once in each cluster.
105 * 1. In each cluster (i), it creates the "internal" directory,
106 *    linked to the DEVFS "dev" parent directory.
107 * 2. In each cluster (i), it creates - for each external chdev in cluster (i) -
108 *    a pseudo-file, linked to the DEVFS "external" parent directory.
109 * 3. In each cluster (i), it creates - for each internal chdev in cluster (i) -
110 *    a pseudo-file, linked to the DEVFS "internal" parent directory.
111 *****************************************************************************************
[204]112 * @ devfs_dev_inode_xp      : extended pointer on DEVFS root inode.
[188]113 * @ devfs_external_inode_xp : extended pointer on DEVFS external inode.
[204]114 * @ devfs_internal_inode_xp : [out] extended pointer on created <internal> inode.
[23]115 ****************************************************************************************/
[204]116void devfs_local_init( xptr_t   devfs_dev_inode_xp,
117                       xptr_t   devfs_external_inode_xp,
118                       xptr_t * devfs_internal_inode_xp );
[188]119                       
[407]120/******************************************************************************************
121 * This function moves <size> bytes between a device, and a - possibly distributed -
122 * user space <buffer>. It uses the <file_xp> and <to_buffer> arguments, to call the
123 * relevant device access function.
124 * It is called by the sys_read() and sys_write() functions.
125 * The <size> argument cannot be larger than the CONFIG_TXT_KBUF_SIZE configuration
126 * parameter, as this function makes a copy between the user space buffer, and a local
127 * kernel buffer allocated in the kernel stack.
128 ******************************************************************************************
129 * @ to_buffer : device -> buffer if true / buffer -> device if false.
130 * @ file_xp   : extended pointer on the remote file descriptor.
131 * @ u_buf     : user space buffer (virtual address).
132 * @ size      : requested number of bytes from offset.
133 * @ returns number of bytes actually moved if success / -1 if error.
134 *****************************************************************************************/
135int devfs_user_move( bool_t   to_buffer,
136                     xptr_t   file_xp, 
137                     void   * u_buf,
138                     uint32_t size );
139
140
[23]141#endif  /* _DEVFS_H_ */
Note: See TracBrowser for help on using the repository browser.