2 * Simple test program -- demonstrating use of IMFS
12 #include <rtems/libio.h>
13 #include <yaffs/rtems_yaffs.h>
15 #include "yaffs-rtems-flashsim.h"
17 #define YPATH "/yaffs_mount_pt"
20 void yaffs_bug_fn(const char *file_name, int line_no)
22 printf("Yaffs bug at %s:%d\n", file_name, line_no);
25 int filesystem_init(const char *mount_target)
27 struct yaffs_dev *device;
28 rtems_yaffs_default_os_context *os_context;
29 rtems_yaffs_mount_data mount_args;
32 rtems_filesystem_register(RTEMS_FILESYSTEM_TYPE_YAFFS,
33 rtems_yaffs_mount_handler);
35 // We mount the filesystem by passing an appropriate
36 // rtems_yaffs_mount_data as the last argument to mount(). mount_data is
37 // used to pass a yaffs_dev pointer by-value.
40 device = yaffs_rtems_flashsim_setup();
42 // Initialize callback storage for RTEMS's VFS inside the yaffs_dev.
43 os_context = malloc(sizeof(rtems_yaffs_default_os_context));
44 rtems_yaffs_initialize_default_os_context(os_context);
46 device->os_context = os_context;
48 mount_args.dev = device;
50 if (mount_and_make_target_path(NULL,
52 RTEMS_FILESYSTEM_TYPE_YAFFS,
53 RTEMS_FILESYSTEM_READ_WRITE,
55 perror("mount_and_make");
58 chmod(mount_target, 0777); /* Make partition rw/modifiable */
63 extern int run_the_test(void);
66 rtems_task_argument ignored
73 err = filesystem_init(YPATH);
75 printf("filesystem_init(\"%s\") returned %d\n", YPATH, err);
79 yaffs_rtems_flashsim_dump_status();
88 So basically, we are registering our NAND-specific callbacks with YAFFS
89 and registering the RTEMS-YAFFS filesystem callbacks with RTEMS.
90 The rtems_filesystem_register() associates the mount() system call with
91 a callback function to handle that system call, in this case
92 rtems_yaffs_mount_handler(). rtems_yaffs_mount_handler() and
93 RTEMS_FILESYSTEM_TYPE_YAFFS (just a string) are provided
94 by the rtems-yaffs fork.
96 mount_and_make_target_path() is provided by RTEMS: it combines a
97 mkdir -p` with mount(), passing the mount_args to the
98 previously-registered handler.
102 /* configuration information */
104 /* NOTICE: the clock driver is explicitly disabled */
105 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
106 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
108 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
109 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 32
111 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
112 #define CONFIGURE_MAXIMUM_TASKS 1
114 #define CONFIGURE_MAXIMUM_SEMAPHORES 20
116 #define CONFIGURE_INIT
118 #include <rtems/confdefs.h>