Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSImplApplConfig
0007  *
0008  * @brief This header file evaluates configuration options related to the I/O
0009  *   library configuration.
0010  */
0011 
0012 /*
0013  * Copyright (C) 2020 embedded brains GmbH & Co. KG
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 #ifndef _RTEMS_CONFDEFS_LIBIO_H
0038 #define _RTEMS_CONFDEFS_LIBIO_H
0039 
0040 #ifndef __CONFIGURATION_TEMPLATE_h
0041 #error "Do not include this file directly, use <rtems/confdefs.h> instead"
0042 #endif
0043 
0044 #ifdef CONFIGURE_INIT
0045 
0046 #include <rtems/confdefs/bsp.h>
0047 #include <rtems/sysinit.h>
0048 
0049 #ifdef CONFIGURE_FILESYSTEM_ALL
0050   #define CONFIGURE_FILESYSTEM_DOSFS
0051   #define CONFIGURE_FILESYSTEM_FTPFS
0052   #define CONFIGURE_FILESYSTEM_IMFS
0053   #define CONFIGURE_FILESYSTEM_JFFS2
0054   /* #define CONFIGURE_FILESYSTEM_NFS         See #5118 */
0055   #define CONFIGURE_FILESYSTEM_RFS
0056   #define CONFIGURE_FILESYSTEM_TFTPFS
0057 #endif
0058 
0059 #ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
0060   #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
0061     #error "CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
0062   #endif
0063 
0064   #define CONFIGURE_IMFS_DISABLE_CHMOD
0065   #define CONFIGURE_IMFS_DISABLE_CHOWN
0066   #define CONFIGURE_IMFS_DISABLE_LINK
0067   #define CONFIGURE_IMFS_DISABLE_READLINK
0068   #define CONFIGURE_IMFS_DISABLE_RENAME
0069   #define CONFIGURE_IMFS_DISABLE_SYMLINK
0070   #define CONFIGURE_IMFS_DISABLE_UNMOUNT
0071   #define CONFIGURE_IMFS_DISABLE_UTIME
0072 #endif
0073 
0074 #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
0075   #define CONFIGURE_IMFS_DISABLE_CHMOD
0076   #define CONFIGURE_IMFS_DISABLE_CHOWN
0077   #define CONFIGURE_IMFS_DISABLE_LINK
0078   #define CONFIGURE_IMFS_DISABLE_MKNOD_FILE
0079   #define CONFIGURE_IMFS_DISABLE_MOUNT
0080   #define CONFIGURE_IMFS_DISABLE_READDIR
0081   #define CONFIGURE_IMFS_DISABLE_READLINK
0082   #define CONFIGURE_IMFS_DISABLE_RENAME
0083   #define CONFIGURE_IMFS_DISABLE_RMNOD
0084   #define CONFIGURE_IMFS_DISABLE_SYMLINK
0085   #define CONFIGURE_IMFS_DISABLE_UNMOUNT
0086   #define CONFIGURE_IMFS_DISABLE_UTIME
0087 #endif
0088 
0089 #ifndef CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
0090   #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 3
0091 #endif
0092 
0093 #if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) || \
0094   CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0
0095   #include <rtems/libio.h>
0096 #endif
0097 
0098 #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
0099   #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
0100     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
0101   #endif
0102 
0103   #ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
0104     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM"
0105   #endif
0106 
0107   #ifdef CONFIGURE_FILESYSTEM_DOSFS
0108     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_DOSFS"
0109   #endif
0110 
0111   #ifdef CONFIGURE_FILESYSTEM_FTPFS
0112     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_FTPFS"
0113   #endif
0114 
0115   #ifdef CONFIGURE_FILESYSTEM_IMFS
0116     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_IMFS"
0117   #endif
0118 
0119   #ifdef CONFIGURE_FILESYSTEM_JFFS2
0120     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_JFFS2"
0121   #endif
0122 
0123   #ifdef CONFIGURE_FILESYSTEM_NFS
0124     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_NFS"
0125   #endif
0126 
0127   #ifdef CONFIGURE_FILESYSTEM_RFS
0128     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_RFS"
0129   #endif
0130 
0131   #ifdef CONFIGURE_FILESYSTEM_TFTPFS
0132     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_TFTPFS"
0133   #endif
0134 #else
0135   #include <rtems/imfs.h>
0136 #endif
0137 
0138 #ifdef CONFIGURE_FILESYSTEM_DOSFS
0139 #include <rtems/dosfs.h>
0140 #endif
0141 
0142 #ifdef CONFIGURE_FILESYSTEM_FTPFS
0143 #include <rtems/ftpfs.h>
0144 #endif
0145 
0146 #ifdef CONFIGURE_FILESYSTEM_JFFS2
0147 #include <rtems/jffs2.h>
0148 
0149 #ifndef CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY
0150   #define CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY \
0151     RTEMS_JFFS2_DELAYED_WRITE_TASK_PRIORITY_DEFAULT
0152 #endif
0153 
0154 const rtems_jffs2_config jffs2_config = {
0155   CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY,
0156 };
0157 
0158 #endif
0159 
0160 #ifdef CONFIGURE_FILESYSTEM_NFS
0161 #include <librtemsNfs.h>
0162 #endif
0163 
0164 #ifdef CONFIGURE_FILESYSTEM_RFS
0165 #include <rtems/rtems-rfs.h>
0166 #endif
0167 
0168 #ifdef CONFIGURE_FILESYSTEM_TFTPFS
0169 #include <rtems/tftp.h>
0170 #endif
0171 
0172 #ifdef __cplusplus
0173 extern "C" {
0174 #endif
0175 
0176 #ifndef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
0177 
0178 #ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
0179   #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \
0180     IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK
0181 #endif
0182 
0183 #if CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 16 && \
0184   CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 32 && \
0185   CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 64 && \
0186   CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 128 && \
0187   CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 256 && \
0188   CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 512
0189   #error "CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK must be a power of two between 16 and 512"
0190 #endif
0191 
0192 const int imfs_memfile_bytes_per_block = CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK;
0193 
0194 static IMFS_fs_info_t IMFS_root_fs_info;
0195 
0196 static const rtems_filesystem_operations_table IMFS_root_ops = {
0197   rtems_filesystem_default_lock,
0198   rtems_filesystem_default_unlock,
0199   #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
0200     IMFS_eval_path_devfs,
0201   #else
0202     IMFS_eval_path,
0203   #endif
0204   #ifdef CONFIGURE_IMFS_DISABLE_LINK
0205     rtems_filesystem_default_link,
0206   #else
0207     IMFS_link,
0208   #endif
0209   rtems_filesystem_default_are_nodes_equal,
0210   #ifdef CONFIGURE_IMFS_DISABLE_MKNOD
0211     rtems_filesystem_default_mknod,
0212   #else
0213     IMFS_mknod,
0214   #endif
0215   #ifdef CONFIGURE_IMFS_DISABLE_RMNOD
0216     rtems_filesystem_default_rmnod,
0217   #else
0218     IMFS_rmnod,
0219   #endif
0220   #ifdef CONFIGURE_IMFS_DISABLE_CHMOD
0221     rtems_filesystem_default_fchmod,
0222   #else
0223     IMFS_fchmod,
0224   #endif
0225   #ifdef CONFIGURE_IMFS_DISABLE_CHOWN
0226     rtems_filesystem_default_chown,
0227   #else
0228     IMFS_chown,
0229   #endif
0230   IMFS_node_clone,
0231   IMFS_node_free,
0232   #ifdef CONFIGURE_IMFS_DISABLE_MOUNT
0233     rtems_filesystem_default_mount,
0234   #else
0235     IMFS_mount,
0236   #endif
0237   #ifdef CONFIGURE_IMFS_DISABLE_UNMOUNT
0238     rtems_filesystem_default_unmount,
0239   #else
0240     IMFS_unmount,
0241   #endif
0242   rtems_filesystem_default_fsunmount,
0243   #ifdef CONFIGURE_IMFS_DISABLE_UTIME
0244     rtems_filesystem_default_utimens,
0245   #else
0246     IMFS_utimens,
0247   #endif
0248   #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK
0249     rtems_filesystem_default_symlink,
0250   #else
0251     IMFS_symlink,
0252   #endif
0253   #ifdef CONFIGURE_IMFS_DISABLE_READLINK
0254     rtems_filesystem_default_readlink,
0255   #else
0256     IMFS_readlink,
0257   #endif
0258   #ifdef CONFIGURE_IMFS_DISABLE_RENAME
0259     rtems_filesystem_default_rename,
0260   #else
0261     IMFS_rename,
0262   #endif
0263   rtems_filesystem_default_statvfs
0264 };
0265 
0266 static const IMFS_mknod_controls IMFS_root_mknod_controls = {
0267   #ifdef CONFIGURE_IMFS_DISABLE_READDIR
0268     &IMFS_mknod_control_dir_minimal,
0269   #else
0270     &IMFS_mknod_control_dir_default,
0271   #endif
0272   #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_DEVICE
0273     &IMFS_mknod_control_enosys,
0274   #else
0275     &IMFS_mknod_control_device,
0276   #endif
0277   #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_FILE
0278     &IMFS_mknod_control_enosys,
0279   #else
0280     &IMFS_mknod_control_memfile,
0281   #endif
0282   #ifdef CONFIGURE_IMFS_ENABLE_MKFIFO
0283     &IMFS_mknod_control_fifo
0284   #else
0285     &IMFS_mknod_control_enosys
0286   #endif
0287 };
0288 
0289 static const IMFS_mount_data IMFS_root_mount_data = {
0290   &IMFS_root_fs_info,
0291   &IMFS_root_ops,
0292   &IMFS_root_mknod_controls
0293 };
0294 
0295 const rtems_filesystem_table_t rtems_filesystem_table[] = {
0296   { "/", IMFS_initialize_support },
0297   #ifdef CONFIGURE_FILESYSTEM_DOSFS
0298     { RTEMS_FILESYSTEM_TYPE_DOSFS, rtems_dosfs_initialize },
0299   #endif
0300   #ifdef CONFIGURE_FILESYSTEM_FTPFS
0301     { RTEMS_FILESYSTEM_TYPE_FTPFS, rtems_ftpfs_initialize },
0302   #endif
0303   #ifdef CONFIGURE_FILESYSTEM_IMFS
0304     { RTEMS_FILESYSTEM_TYPE_IMFS, IMFS_initialize },
0305   #endif
0306   #ifdef CONFIGURE_FILESYSTEM_JFFS2
0307     { RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize },
0308   #endif
0309   #ifdef CONFIGURE_FILESYSTEM_NFS
0310     { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfs_initialize },
0311   #endif
0312   #ifdef CONFIGURE_FILESYSTEM_RFS
0313     { RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise },
0314   #endif
0315   #ifdef CONFIGURE_FILESYSTEM_TFTPFS
0316     { RTEMS_FILESYSTEM_TYPE_TFTPFS, rtems_tftpfs_initialize },
0317   #endif
0318   { NULL, NULL }
0319 };
0320 
0321 const rtems_filesystem_mount_configuration
0322 rtems_filesystem_root_configuration = {
0323   NULL,
0324   NULL,
0325   "/",
0326   RTEMS_FILESYSTEM_READ_WRITE,
0327   &IMFS_root_mount_data
0328 };
0329 
0330 RTEMS_SYSINIT_ITEM(
0331   rtems_filesystem_initialize,
0332   RTEMS_SYSINIT_ROOT_FILESYSTEM,
0333   RTEMS_SYSINIT_ORDER_MIDDLE
0334 );
0335 
0336 #endif /* !CONFIGURE_APPLICATION_DISABLE_FILESYSTEM */
0337 
0338 #if CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0
0339   rtems_libio_t rtems_libio_iops[ CONFIGURE_MAXIMUM_FILE_DESCRIPTORS ];
0340 
0341   const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE( rtems_libio_iops );
0342 #endif
0343 
0344 #ifdef __cplusplus
0345 }
0346 #endif
0347 
0348 #endif /* CONFIGURE_INIT */
0349 
0350 #endif /* _RTEMS_CONFDEFS_LIBIO_H */