From 98b2ee0abdecbfefb399b352dd299e50de52c9b5 Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Fri, 7 Feb 2020 11:20:32 +1300 Subject: [PATCH] rtems-yaffs: Modes to freshen to latest Yaffs and build in yaffs2/rtems Makefile uses symlinks to files outside yaffs2/rtems aso that rtems can be built without modifying the directory structure and deleting files. Various tweaks needed to support changes in function prototypes. Signed-off-by: Charles Manning --- Makefile.rtems | 76 ------------------ direct/optional_sort/qsort.c | 4 +- direct/yportenv.h | 19 ++++- rtems/Makefile.rtems | 147 +++++++++++++++++++++++++++++++++++ rtems/rtems_yaffs.c | 14 ++-- 5 files changed, 174 insertions(+), 86 deletions(-) delete mode 100644 Makefile.rtems create mode 100644 rtems/Makefile.rtems diff --git a/Makefile.rtems b/Makefile.rtems deleted file mode 100644 index 6c8e140..0000000 --- a/Makefile.rtems +++ /dev/null @@ -1,76 +0,0 @@ -include $(RTEMS_MAKEFILE_PATH)/Makefile.inc -include $(RTEMS_MAKEFILE_PATH)/make/target.cfg - -INSTALL_BASE = $(RTEMS_MAKEFILE_PATH)/lib - -BUILDDIR = build-$(RTEMS_BSP) - -CPPFLAGS += -I. -Idirect -Idirect/rtems - -DEPFLAGS = -MT $@ -MD -MP -MF $(basename $@).d - -GCCFLAGS = -g -I . -B $(INSTALL_BASE) -specs bsp_specs -qrtems - -CFLAGS += $(DEPFLAGS) $(GCCFLAGS) - -INCLUDES = rtems/rtems_yaffs.h \ - direct/yportenv.h \ - direct/ydirectenv.h \ - direct/yaffs_osglue.h \ - direct/yaffs_hweight.h \ - direct/yaffscfg.h \ - direct/yaffs_list.h \ - direct/yaffsfs.h \ - yaffs_guts.h \ - yaffs_packedtags2.h \ - yaffs_ecc.h - -LIB = $(BUILDDIR)/libyaffs2.a -LIB_PIECES = yaffs_ecc \ - yaffs_guts \ - yaffs_packedtags1 \ - yaffs_tagscompat \ - yaffs_packedtags2 \ - yaffs_nand \ - yaffs_checkptrw \ - direct/yaffs_qsort \ - yaffs_nameval \ - yaffs_attribs \ - yaffs_allocator \ - yaffs_bitmap \ - yaffs_yaffs1 \ - yaffs_yaffs2 \ - yaffs_verify \ - yaffs_summary \ - direct/yaffs_hweight \ - rtems/rtems_yaffs \ - rtems/rtems_yaffs_os_context \ - rtems/rtems_yaffs_os_glue -LIB_OBJS = $(LIB_PIECES:%=$(BUILDDIR)/%.o) -LIB_DEPS = $(LIB_PIECES:%=$(BUILDDIR)/%.d) - -all: $(BUILDDIR) $(LIB) - -$(BUILDDIR): - mkdir $(BUILDDIR) - mkdir $(BUILDDIR)/direct - mkdir $(BUILDDIR)/rtems - -$(LIB): $(LIB_OBJS) - $(AR) rcu $@ $^ - $(RANLIB) $@ - -$(BUILDDIR)/%.o: %.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ - -clean: - rm -rf $(BUILDDIR) - -install: all - mkdir -p $(INSTALL_BASE)/include/yaffs - install -m 644 $(LIB) $(INSTALL_BASE) - install -m 644 $(INCLUDES) $(INSTALL_BASE)/include/yaffs - -.PHONY: clean install - --include $(LIB_DEPS) diff --git a/direct/optional_sort/qsort.c b/direct/optional_sort/qsort.c index 9c77899..b66f930 100644 --- a/direct/optional_sort/qsort.c +++ b/direct/optional_sort/qsort.c @@ -151,7 +151,7 @@ loop: SWAPINIT(a, es); vecswap(pb, pn - r, r); r = pb - pa; if (r > es) - yaffs_qsort(a, r / es, es, cmp); + qsort(a, r / es, es, cmp); r = pd - pc; if (r > es) { /* Iterate rather than recurse to save stack space */ @@ -159,5 +159,5 @@ loop: SWAPINIT(a, es); n = r / es; goto loop; } -/* yaffs_qsort(pn - r, r / es, es, cmp);*/ +/* qsort(pn - r, r / es, es, cmp);*/ } diff --git a/direct/yportenv.h b/direct/yportenv.h index d931f81..ee27f73 100644 --- a/direct/yportenv.h +++ b/direct/yportenv.h @@ -17,6 +17,24 @@ #define __YPORTENV_H__ +#ifdef __rtems__ + +#include +#include +#include +#include + +#define CONFIG_YAFFS_DIRECT 1 +#define CONFIG_YAFFS_SHORT_NAMES_IN_RAM 1 +#define CONFIG_YAFFS_YAFFS2 1 +#define CONFIG_YAFFS_PROVIDE_DEFS 1 +#define CONFIG_YAFFSFS_PROVIDE_VALUES 1 +#define CONFIG_YAFFS_DEFINES_TYPES 1 +#define NO_Y_INLINE 1 +#define loff_t off_t + +#endif /* __rtems__ */ + /* Definition of types */ #ifdef CONFIG_YAFFS_DEFINES_TYPES typedef unsigned char u8; @@ -26,7 +44,6 @@ typedef unsigned long long u64; typedef signed int s32; #endif - #ifdef CONFIG_YAFFS_PROVIDE_DEFS /* File types */ diff --git a/rtems/Makefile.rtems b/rtems/Makefile.rtems new file mode 100644 index 0000000..ea685e2 --- /dev/null +++ b/rtems/Makefile.rtems @@ -0,0 +1,147 @@ +# +# This file was originally written to work from the yaffs2 base directory +# which required deleting some of the Linux files. +# +# This is now modified to run from the yaffs2/rtems directory and copies in +# all files as symbolic links. +# + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_MAKEFILE_PATH)/make/target.cfg + +INSTALL_BASE = $(RTEMS_MAKEFILE_PATH)/lib + +BUILDDIR = build-$(RTEMS_BSP) + +CPPFLAGS += -I. + +DEPFLAGS = -MT $@ -MD -MP -MF $(basename $@).d + +GCCFLAGS = -g -I . -B $(INSTALL_BASE) -specs bsp_specs -qrtems + +CFLAGS += $(DEPFLAGS) $(GCCFLAGS) + +# Files to be made into local symlinks +YCORE_SYMLINKS = \ + yaffs_ecc.c \ + yaffs_guts.c \ + yaffs_packedtags1.c \ + yaffs_tagscompat.c \ + yaffs_packedtags2.c \ + yaffs_nand.c \ + yaffs_checkptrw.c \ + yaffs_nameval.c \ + yaffs_allocator.c \ + yaffs_bitmap.c \ + yaffs_yaffs1.c \ + yaffs_yaffs2.c \ + yaffs_verify.c \ + yaffs_summary.c \ + yaffs_ecc.h \ + yaffs_guts.h \ + yaffs_packedtags1.h \ + yaffs_tagscompat.h \ + yaffs_packedtags2.h \ + yaffs_nand.h \ + yaffs_checkptrw.h \ + yaffs_nameval.h \ + yaffs_attribs.h \ + yaffs_allocator.h \ + yaffs_bitmap.h \ + yaffs_yaffs1.h \ + yaffs_yaffs2.h \ + yaffs_verify.h \ + yaffs_summary.h \ + yaffs_trace.h \ + yaffs_endian.h \ + yaffs_getblockinfo.h \ + yaffs_tagsmarshall.h + + +DIRECT_SYMLINKS = \ + yaffs_attribs.c \ + yaffs_hweight.c \ + yaffs_hweight.h \ + yportenv.h \ + ydirectenv.h \ + yaffscfg.h \ + yaffs_osglue.h \ + yaffs_list.h \ + yaffsfs.h + +DIRECT_QSORT_SYMLINKS = \ + qsort.c + +ALL_SYMLINKS = $(YCORE_SYMLINKS) $(DIRECT_SYMLINKS) $(DIRECT_QSORT_SYMLINKS) + + +INCLUDES = rtems_yaffs.h \ + yportenv.h \ + ydirectenv.h \ + yaffs_osglue.h \ + yaffs_hweight.h \ + yaffscfg.h \ + yaffs_list.h \ + yaffsfs.h \ + yaffs_guts.h \ + yaffs_packedtags2.h \ + yaffs_ecc.h + +LIB = $(BUILDDIR)/libyaffs2.a +LIB_PIECES = yaffs_ecc \ + yaffs_guts \ + yaffs_packedtags1 \ + yaffs_tagscompat \ + yaffs_packedtags2 \ + yaffs_nand \ + yaffs_checkptrw \ + qsort \ + yaffs_nameval \ + yaffs_attribs \ + yaffs_allocator \ + yaffs_bitmap \ + yaffs_yaffs1 \ + yaffs_yaffs2 \ + yaffs_verify \ + yaffs_summary \ + yaffs_hweight \ + rtems_yaffs \ + rtems_yaffs_os_context \ + rtems_yaffs_os_glue +LIB_OBJS = $(LIB_PIECES:%=$(BUILDDIR)/%.o) +LIB_DEPS = $(LIB_PIECES:%=$(BUILDDIR)/%.d) + +all: $(BUILDDIR) $(ALL_SYMLINKS) $(LIB) + +symlinks:$(ALL_SYMLINKS) + +$(YCORE_SYMLINKS): + ln -s ../$@ $@ + +$(DIRECT_SYMLINKS): + ln -s ../direct/$@ $@ + +$(DIRECT_QSORT_SYMLINKS): + ln -s ../direct/optional_sort/$@ $@ + +$(BUILDDIR): + mkdir $(BUILDDIR) + +$(LIB): $(LIB_OBJS) + $(AR) rcu $@ $^ + $(RANLIB) $@ + +$(BUILDDIR)/%.o: %.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + +clean: + rm -rf $(BUILDDIR) $(ALL_SYMLINKS) + +install: all + mkdir -p $(INSTALL_BASE)/include/yaffs + install -m 644 $(LIB) $(INSTALL_BASE) + install -m 644 $(INCLUDES) $(INSTALL_BASE)/include/yaffs + +.PHONY: clean install + +-include $(LIB_DEPS) diff --git a/rtems/rtems_yaffs.c b/rtems/rtems_yaffs.c index b067f53..43986f2 100644 --- a/rtems/rtems_yaffs.c +++ b/rtems/rtems_yaffs.c @@ -407,7 +407,7 @@ static int ryfs_fchmod(const rtems_filesystem_location_info_t *loc, mode_t mode) if (obj != NULL) { obj->yst_mode = mode; obj->dirty = 1; - yc = yaffs_flush_file(obj, 0, 0); + yc = yaffs_flush_file(obj, 0, 0,0); } else { yc = YAFFS_FAIL; } @@ -435,7 +435,7 @@ static int ryfs_chown( obj->yst_uid = owner; obj->yst_gid = group; obj->dirty = 1; - yc = yaffs_flush_file(obj, 0, 0); + yc = yaffs_flush_file(obj, 0, 0, 0); } else { yc = YAFFS_FAIL; } @@ -456,9 +456,9 @@ static int ryfs_fsync_or_fdatasync(rtems_libio_t *iop) int yc; ylock(dev); - yc = yaffs_flush_file(obj, 0, 1); + yc = yaffs_flush_file(obj, 0, 1, 0); if (rtems_filesystem_location_is_instance_root(&iop->pathinfo)) { - yaffs_flush_whole_cache(dev); + yaffs_flush_whole_cache(dev, 0); } yunlock(dev); @@ -509,7 +509,7 @@ static int ryfs_file_close(rtems_libio_t *iop) struct yaffs_dev *dev = obj->my_dev; ylock(dev); - yaffs_flush_file(obj, 1, 0); + yaffs_flush_file(obj, 1, 0, 1); yunlock(dev); return 0; @@ -623,7 +623,7 @@ int rtems_yaffs_mount_handler(rtems_filesystem_mount_table_entry_t *mt_entry, co mt_entry->mt_fs_root->location.node_access = dev->root_dir; mt_entry->mt_fs_root->location.handlers = &yaffs_directory_handlers; - yaffs_flush_whole_cache(dev); + yaffs_flush_whole_cache(dev, 0); yunlock(dev); return 0; @@ -634,7 +634,7 @@ static void ryfs_fsunmount(rtems_filesystem_mount_table_entry_t *mt_entry) struct yaffs_dev *dev = ryfs_get_device_by_mt_entry(mt_entry); ylock(dev); - yaffs_flush_whole_cache(dev); + yaffs_flush_whole_cache(dev, 1); yaffs_deinitialise(dev); yunlock(dev); rtems_yaffs_os_unmount(dev); -- 2.30.2