[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 | |
---|
| 28 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 29 | // The DEVFS File System contains inodes associated to all chdev descriptors availables |
---|
| 30 | // 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 devfs |
---|
| 32 | // file system. The parent inode is the "/" global root. |
---|
| 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. |
---|
| 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. |
---|
| 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 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 43 | |
---|
| 44 | /************** Forward declarations ************************************************/ |
---|
| 45 | |
---|
| 46 | struct chdev_s; |
---|
| 47 | |
---|
| 48 | /****************************************************************************************** |
---|
| 49 | * This structure defines the DEVFS inode descriptor extension. |
---|
| 50 | *****************************************************************************************/ |
---|
| 51 | |
---|
| 52 | typedef struct devfs_inode_ext_s |
---|
| 53 | { |
---|
| 54 | struct chdev_s * chdev; /* extended pointer on associated chdev */ |
---|
| 55 | } |
---|
| 56 | devfs_inode_t; |
---|
| 57 | |
---|
| 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 ); |
---|
| 95 | |
---|
| 96 | /***************************************************************************************** |
---|
| 97 | * This function initializes all fields of the VFS context. |
---|
| 98 | * No extra memory is allocated for a DEVFS context. |
---|
| 99 | ***************************************************************************************** |
---|
| 100 | * @ vfs_ctx : local pointer on VFS context for FATFS. |
---|
| 101 | * @ root_inode_xp : extended pointer on the VFS root inode. |
---|
| 102 | ****************************************************************************************/ |
---|
| 103 | error_t devfs_ctx_init( struct vfs_ctx_s * vfs_ctx, |
---|
| 104 | xptr_t root_inode_xp ); |
---|
| 105 | |
---|
| 106 | /***************************************************************************************** |
---|
| 107 | * This function does not exist for a DEVFS context, as there is no DEVFS context. |
---|
| 108 | ****************************************************************************************/ |
---|
| 109 | error_t devfs_ctx_destroy(); |
---|
| 110 | |
---|
| 111 | /***************************************************************************************** |
---|
| 112 | * This function allocates memory for a DEVFS inode, initialise it, |
---|
| 113 | * and link it to the VFS inode. |
---|
| 114 | ***************************************************************************************** |
---|
| 115 | * @ inode : local pointer on the VFS inode. |
---|
| 116 | * @ chdev : local pointer on the chdev to be inserted in DEVFS. |
---|
| 117 | ****************************************************************************************/ |
---|
| 118 | error_t devfs_inode_create( struct vfs_inode_s * inode, |
---|
| 119 | struct chdev_s * chdev ); |
---|
| 120 | |
---|
| 121 | /***************************************************************************************** |
---|
| 122 | * This function releases memory allocated for a DEVFS inode. |
---|
| 123 | ***************************************************************************************** |
---|
| 124 | * @ inode : local pointer on vfs_inode. |
---|
| 125 | ****************************************************************************************/ |
---|
| 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 | |
---|
| 140 | #endif /* _DEVFS_H_ */ |
---|