This makes the porting process a bit cleaner.
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
CFLAGS+= -Werror=redundant-decls -Werror=nested-externs -Winline
CFLAGS+= -Werror=undef
-COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o \
+ yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
yaffs_checkptrw.o yaffs_qsort.o\
yaffs_verify.c yaffs_verify.h
YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
- yaffsfs.h yaffs_malloc.h ydirectenv.h \
+ yaffsfs.h yaffs_osglue.h ydirectenv.h \
yaffs_flashif.c yaffscfg.h yaffs_list.h \
yaffs_qsort.c yportenv.h yaffs_attribs.c \
yaffs_nandif.c yaffs_nandif.h yaffs_nandemul2k.h
--- /dev/null
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ * for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+
+#include "yaffscfg.h"
+#include "yaffs_guts.h"
+#include "yaffsfs.h"
+#include "yaffs_fileem2k.h"
+#include "yaffs_nandemul2k.h"
+#include "yaffs_norif1.h"
+#include "yaffs_trace.h"
+
+
+#include <errno.h>
+
+
+static int yaffsfs_lastError;
+
+void yaffsfs_SetError(int err)
+{
+ //Do whatever to set error
+ yaffsfs_lastError = err;
+}
+
+int yaffsfs_GetLastError(void)
+{
+ return yaffsfs_lastError;
+}
+
+
+#ifdef CONFIG_YAFFS_USE_PTHREADS
+#include <pthreads.h>
+static pthread_mutex_t mutex1;
+
+
+void yaffsfs_Lock(void)
+{
+ pthread_mutex_lock( &mutex1 );
+}
+
+void yaffsfs_Unlock(void)
+{
+ pthread_mutex_unlock( &mutex1 );
+}
+
+void yaffsfs_LockInit(void)
+{
+ pthread_mutex_init( &mutex, NULL);
+}
+
+#else
+
+void yaffsfs_Lock(void)
+{
+}
+
+void yaffsfs_Unlock(void)
+{
+}
+
+void yaffsfs_LockInit(void)
+{
+}
+#endif
+
+u32 yaffsfs_CurrentTime(void)
+{
+ return 0;
+}
+
+
+static int yaffs_kill_alloc = 0;
+static size_t total_malloced = 0;
+static size_t malloc_limit = 0 & 6000000;
+
+void *yaffs_malloc(size_t size)
+{
+ void * this;
+ if(yaffs_kill_alloc)
+ return NULL;
+ if(malloc_limit && malloc_limit <(total_malloced + size) )
+ return NULL;
+
+ this = malloc(size);
+ if(this)
+ total_malloced += size;
+ return this;
+}
+
+void yaffs_free(void *ptr)
+{
+ free(ptr);
+}
+
+void yaffsfs_OSInitialisation(void)
+{
+ yaffsfs_LockInit();
+}
+
+
#include "yaffs_nandemul2k.h"
#include "yaffs_norif1.h"
#include "yaffs_trace.h"
+#include "yaffs_osglue.h"
#include <errno.h>
0;
-static int yaffsfs_lastError;
-
-void yaffsfs_SetError(int err)
-{
- //Do whatever to set error
- yaffsfs_lastError = err;
-}
-
-
-int yaffsfs_GetLastError(void)
-{
- return yaffsfs_lastError;
-}
-
-void yaffsfs_Lock(void)
-{
-}
-
-void yaffsfs_Unlock(void)
-{
-}
-
-u32 yaffsfs_CurrentTime(void)
-{
- return 0;
-}
-
-
-static int yaffs_kill_alloc = 0;
-static size_t total_malloced = 0;
-static size_t malloc_limit = 0 & 6000000;
-
-void *yaffs_malloc(size_t size)
-{
- void * this;
- if(yaffs_kill_alloc)
- return NULL;
- if(malloc_limit && malloc_limit <(total_malloced + size) )
- return NULL;
-
- this = malloc(size);
- if(this)
- total_malloced += size;
- return this;
-}
-
-void yaffs_free(void *ptr)
-{
- free(ptr);
-}
-
-void yaffsfs_LocalInitialisation(void)
-{
- // Define locking semaphore.
-}
// Configuration
{
// Stuff to configure YAFFS
// Stuff to initialise anything special (eg lock semaphore).
- yaffsfs_LocalInitialisation();
+ yaffsfs_OSInitialisation();
// Set up devices
// /ram1 ram, yaffs1
0;
-static int yaffsfs_lastError;
-
-void yaffsfs_SetError(int err)
-{
- //Do whatever to set error
- yaffsfs_lastError = err;
-}
-
-
-int yaffsfs_GetLastError(void)
-{
- return yaffsfs_lastError;
-}
-
-void yaffsfs_Lock(void)
-{
-}
-
-void yaffsfs_Unlock(void)
-{
-}
-
-u32 yaffsfs_CurrentTime(void)
-{
- return 0;
-}
-
-
-static int yaffs_kill_alloc = 0;
-static size_t total_malloced = 0;
-static size_t malloc_limit = 0 & 6000000;
-
-void *yaffs_malloc(size_t size)
-{
- void * this;
- if(yaffs_kill_alloc)
- return NULL;
- if(malloc_limit && malloc_limit <(total_malloced + size) )
- return NULL;
-
- this = malloc(size);
- if(this)
- total_malloced += size;
- return this;
-}
-
-void yaffs_free(void *ptr)
-{
- free(ptr);
-}
-
-void yaffsfs_LocalInitialisation(void)
-{
- // Define locking semaphore.
-}
// Configuration
{
// Stuff to configure YAFFS
// Stuff to initialise anything special (eg lock semaphore).
- yaffsfs_LocalInitialisation();
+ yaffsfs_OSInitialisation();
yramsim_CreateRamSim("yaffs2",1,1000,0,0);
yramsim_CreateRamSim("p0",0,0x400,1,0xff);
yramsim_CreateRamSim("p1",0,0x400,1,0);
#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
-COMMONTESTOBJS = yaffscfg2k.o yramsim.o yaffs_fileem2k.o\
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o \
+ yramsim.o yaffs_fileem2k.o\
yaffs_nandif.o yaffs_attribs.o \
yaffsfs.o yaffs_ecc.o yaffs_guts.o \
yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
yaffs_verify.c yaffs_verify.h
-YAFFSDIRECTSYMLINKS = yaffsfs.c yaffsfs.h yaffscfg.h yaffs_malloc.h ydirectenv.h \
+YAFFSDIRECTSYMLINKS = yaffsfs.c yaffsfs.h yaffscfg.h yaffs_osglue.h ydirectenv.h \
yaffs_flashif.c yaffs_flashif.h yaffs_flashif2.h yaffs_list.h \
yaffs_nandif.c yaffs_nandif.h yaffs_qsort.c yaffs_nandemul2k.h \
yportenv.h yaffs_attribs.c
yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
yaffs_ramdisk.c yaffs_ramdisk.h yaffs_ramem2k.c \
yaffsnewcfg.c yramsim.c yramsim.h \
- ynorsim.h ynorsim.c
+ ynorsim.h ynorsim.c yaffs_osglue.c
SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS)
#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
-COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o \
+ yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
yaffs_checkptrw.o yaffs_qsort.o\
ALLOBJS = $(sort $(YAFFSTESTOBJS))
YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
- yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h yaffs_nandemul2k.h \
+ yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \
yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \
yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
yaffs_nameval.c yaffs_nameval.h \
yaffs_verify.c yaffs_verify.h
YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
- yaffsfs.h yaffs_malloc.h ydirectenv.h \
+ yaffsfs.h yaffs_osglue.h ydirectenv.h \
yaffs_flashif.c yaffscfg.h yaffs_qsort.c \
yaffs_nandemul2k.h yaffs_list.h \
yaffs_attribs.c \
DIRECTEXTRASYMLINKS = yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
yaffs_ramdisk.c yaffs_ramdisk.h yaffs_ramem2k.c \
- ynorsim.h ynorsim.c
+ ynorsim.h ynorsim.c yaffs_osglue.c
SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS)
#all: directtest2k boottest
#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
-COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o \
+ yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
yaffs_checkptrw.o yaffs_qsort.o\
ALLOBJS = $(sort $(YAFFSTESTOBJS)) $(PYTHONOBJS)
YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
- yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h yaffs_nandemul2k.h \
+ yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \
yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \
yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
yaffs_nameval.c yaffs_nameval.h \
yaffs_verify.c yaffs_verify.h
YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
- yaffsfs.h yaffs_malloc.h ydirectenv.h \
+ yaffsfs.h ydirectenv.h \
yaffs_flashif.c yaffscfg.h yaffs_qsort.c \
yaffs_nandemul2k.h yaffs_list.h \
- yaffs_attribs.c \
+ yaffs_attribs.c yaffs_osglue.h \
yaffs_nandif.c yaffs_nandif.h yportenv.h
DIRECTEXTRASYMLINKS = yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
yaffs_ramdisk.c yaffs_ramdisk.h yaffs_ramem2k.c \
- ynorsim.h ynorsim.c
+ ynorsim.h ynorsim.c yaffs_osglue.c
SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS) $(PYTONOSYMLINKS)
#all: directtest2k boottest
*
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
-
-#ifndef __YAFFS_MALLOC_H__
-#define __YAFFS_MALLOC_H__
-#include <stdlib.h>
-
+/*
+ * Header file for using yaffs in an application via
+ * a direct interface.
+ */
+
+
+#ifndef __YAFFS_OSGLUE_H__
+#define __YAFFS_OSGLUE_H__
+
+
+#include "yportenv.h"
+
+void yaffsfs_Lock(void);
+void yaffsfs_Unlock(void);
+
+u32 yaffsfs_CurrentTime(void);
+
+void yaffsfs_SetError(int err);
+
void *yaffs_malloc(size_t size);
void yaffs_free(void *ptr);
+
+void yaffsfs_OSInitialisation(void);
+
#endif
} yaffsfs_DeviceConfiguration;
-void yaffsfs_Lock(void);
-void yaffsfs_Unlock(void);
-
-u32 yaffsfs_CurrentTime(void);
-
-void yaffsfs_SetError(int err);
-
#endif
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
-#include "yaffs_malloc.h"
+#include "yaffs_osglue.h"
#include "assert.h"
#define YBUG() assert(0)