fix mutex issue in semaphore.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1927 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong@gmail.com
2012-01-29 08:23:14 +00:00
parent 2f9cd34325
commit fcf01d1d3d
12 changed files with 333 additions and 60 deletions
+37 -44
View File
@@ -94,54 +94,41 @@ filesystems/uffs/flash/nand_ids.c
'''
jffs2 = Split('''
jffs2/dfs_jffs2.c
jffs2/porting.c
jffs2/cyg/compress/src/adler32.c
jffs2/cyg/compress/src/compress.c
jffs2/cyg/compress/src/deflate.c
jffs2/cyg/compress/src/infback.c
jffs2/cyg/compress/src/infblock.c
jffs2/cyg/compress/src/inffast.c
jffs2/cyg/compress/src/inflate.c
jffs2/cyg/compress/src/inftrees.c
jffs2/cyg/compress/src/maketree.c
jffs2/cyg/compress/src/trees.c
jffs2/cyg/compress/src/uncompr.c
jffs2/cyg/compress/src/zutil.c
jffs2/cyg/crc/crc16.c
jffs2/cyg/crc/crc32.c
jffs2/cyg/crc/posix_crc.c
jffs2/kernel/rbtree.c
jffs2/src/build.c
jffs2/src/compr.c
jffs2/src/compr_rtime.c
jffs2/src/compr_rubin.c
jffs2/src/compr_zlib.c
jffs2/src/debug.c
jffs2/src/dir-ecos.c
jffs2/src/erase.c
jffs2/src/flashio.c
jffs2/src/fs-ecos.c
jffs2/src/gc.c
jffs2/src/gcthread.c
jffs2/src/malloc-ecos.c
jffs2/src/nodelist.c
jffs2/src/nodemgmt.c
jffs2/src/read.c
jffs2/src/readinode.c
jffs2/src/scan.c
jffs2/src/write.c
filesystems/jffs2/dfs_jffs2.c
filesystems/jffs2/porting.c
filesystems/jffs2/cyg/crc/crc16.c
filesystems/jffs2/cyg/crc/crc32.c
filesystems/jffs2/cyg/crc/posix_crc.c
filesystems/jffs2/kernel/rbtree.c
filesystems/jffs2/src/build.c
filesystems/jffs2/src/compr.c
filesystems/jffs2/src/compr_rtime.c
filesystems/jffs2/src/compr_rubin.c
filesystems/jffs2/src/debug.c
filesystems/jffs2/src/dir-ecos.c
filesystems/jffs2/src/erase.c
filesystems/jffs2/src/flashio.c
filesystems/jffs2/src/fs-ecos.c
filesystems/jffs2/src/gc.c
filesystems/jffs2/src/malloc-ecos.c
filesystems/jffs2/src/nodelist.c
filesystems/jffs2/src/nodemgmt.c
filesystems/jffs2/src/read.c
filesystems/jffs2/src/readinode.c
filesystems/jffs2/src/scan.c
filesystems/jffs2/src/write.c
''')
src_local = dfs
CPPDEFINES = []
# The set of source files associated with this SConscript file.
path = [RTT_ROOT + '/components/dfs', RTT_ROOT + '/components/dfs/include']
if GetDepend('RT_USING_DFS_YAFFS2'):
src_local = src_local + yaffs2_main + yaffs2_comm
path = path + [RTT_ROOT + '/components/dfs/filesystems/yaffs2', RTT_ROOT + '/components/dfs/filesystems/yaffs2/direct']
path = path + [RTT_ROOT + '/components/dfs/filesystems/yaffs2', \
RTT_ROOT + '/components/dfs/filesystems/yaffs2/direct']
if GetDepend('RT_USING_DFS_ELMFAT'):
if GetDepend('RT_DFS_ELM_USE_LFN'):
@@ -162,12 +149,18 @@ if GetDepend('RT_USING_DFS_DEVFS'):
if GetDepend('RT_USING_DFS_UFFS'):
src_local = src_local + uffs
path = path + [RTT_ROOT + '/components/dfs/filesystems/uffs/src/inc', RTT_ROOT + '/components/dfs/filesystems/uffs', RTT_ROOT + '/components/dfs/filesystems/uffs/flash']
path = path + [RTT_ROOT + '/components/dfs/filesystems/uffs/src/inc', \
RTT_ROOT + '/components/dfs/filesystems/uffs', \
RTT_ROOT + '/components/dfs/filesystems/uffs/flash']
if GetDepend('RT_USING_DFS_JFFS2'):
src_local = src_local + jffs2
path = path + [RTT_ROOT + '/components/dfs/filesystems/jffs2/src', RTT_ROOT + '/components/dfs/filesystems/jffs2/kernel', RTT_ROOT + '/components/dfs/filesystems/jffs2/include', RTT_ROOT + '/components/dfs/filesystems/jffs2', RTT_ROOT + '/components/dfs/filesystems/jffs2/cyg/compress']
group = DefineGroup('Filesystem', src_local, depend = ['RT_USING_DFS'], CPPPATH = path)
path = path + [RTT_ROOT + '/components/dfs/filesystems/jffs2/src', \
RTT_ROOT + '/components/dfs/filesystems/jffs2/kernel', \
RTT_ROOT + '/components/dfs/filesystems/jffs2/include', \
RTT_ROOT + '/components/dfs/filesystems/jffs2']
CPPDEFINES = CPPDEFINES + ['__ECOS']
group = DefineGroup('Filesystem', src_local, depend = ['RT_USING_DFS'], CPPPATH = path, CPPDEFINES = CPPDEFINES)
Return('group')
+2 -2
View File
@@ -21,7 +21,7 @@
#include <dfs_fs.h>
#include <dfs_def.h>
#include <dfs_jffs2.h>
#include "dfs_jffs2.h"
#include "porting.h"
#define FILE_PATH_MAX 256 /* the longest file path */
@@ -165,7 +165,7 @@ static int dfs_jffs2_mount(struct dfs_filesystem* fs,
* s_dev in struct super_block, and mte->data will be
* filled with jffs2_sb(see the source of jffs2_mount.
*/
mte->data = fs->dev_id;
mte->data = (CYG_ADDRWORD)fs->dev_id;
device_partition[index].dev = fs->dev_id;
/* after jffs2_mount, mte->data will not be dev_id any more */
@@ -0,0 +1,6 @@
#ifndef __DFS_JFFS2_H__
#define __DFS_JFFS2_H__
int dfs_jffs2_init(void);
#endif
@@ -40,7 +40,7 @@ struct jffs2_inode_info {
uint16_t flags;
uint8_t usercompr;
#if !defined (__ECOS)
#if !defined (__ECOS) && !defined(RT_THREAD)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2)
struct inode vfs_inode;
#endif
@@ -26,13 +26,13 @@ struct semaphore {
#define DECLARE_MUTEX(x) struct semaphore x = { { .value = 0, } };
#define DECLARE_MUTEX_LOCKED(x) struct semaphore x = { { .vlalue = 1 } };
#define init_MUTEX(sem) rt_mutex_init((rt_mutex_t *)sem, "mutex", RT_IPC_FLAG_FIFO)
#define init_MUTEX(sem) rt_mutex_init((rt_mutex_t)sem, "mutex", RT_IPC_FLAG_FIFO)
#define init_MUTEX_LOCKED(sem) do { \
rt_mutex_init((rt_mutex_t *)sem, "mutex", RT_IPC_FLAG_FIFO);\
rt_mutex_take((rt_mutex_t *)sem, RT_WAITING_FOREVER);} \
rt_mutex_init((rt_mutex_t)sem, "mutex", RT_IPC_FLAG_FIFO);\
rt_mutex_take((rt_mutex_t)sem, RT_WAITING_FOREVER);} \
while(0)
#define down(sem) rt_mutex_take((rt_mutex_t *)sem, RT_WAITING_FOREVER)
#define down_interruptible(sem) ({rt_mutex_take((rt_mutex_t *)sem, RT_WAITING_FOREVER), 0; })
#define down(sem) rt_mutex_take((rt_mutex_t)sem, RT_WAITING_FOREVER)
#define down_interruptible(sem) ({rt_mutex_take((rt_mutex_t)sem, RT_WAITING_FOREVER), 0; })
/*
Attempt to lock the mutex pointed to by the mutex argument without waiting.
If the mutex is already locked by some other thread then this function
@@ -41,6 +41,6 @@ TRUE is returned.
void cyg_drv_mutex_unlock( cyg_drv_mutex *mutex )
*/
#define down_trylock(sem) rt_mutex_take((rt_mutex_t *)sem, RT_WAITING_NO)
#define up(sem) rt_mutex_release((rt_mutex_t *)sem)
#define down_trylock(sem) rt_mutex_take((rt_mutex_t)sem, RT_WAITING_NO)
#define up(sem) rt_mutex_release((rt_mutex_t)sem)
#endif /* __ASM_SEMAPHORE_H__ */
@@ -1,5 +1,13 @@
#ifndef __LINUX_CONFIG_H__
#define __LINUX_CONFIG_H__
#define __LINUX_CONFIG_H__
#define CONFIG_JFFS2_FS_DEBUG 0
#define GFP_KERNEL 0
/* #define CONFIG_JFFS2_FS_WRITEBUFFER 0 */
/* #define CONFIG_JFFS2_PROC */
/* #define CONFIG_JFFS2_RTIME */
/* #define CONFIG_JFFS2_RUBIN */
/* #define CONFIG_JFFS2_ZLIB */
#endif /* __LINUX_CONFIG_H__ */
@@ -1,5 +1,6 @@
#ifndef __LINUX_VERSION_H__
#define __LINUX_VERSION_H__
#include <rtthread.h>
#endif /* __LINUX_VERSION_H__ */
+1 -1
View File
@@ -21,4 +21,4 @@ void jffs2_get_info_from_sb(void * data, struct jffs2_fs_info * info)
info->sector_size = c->sector_size;
info->nr_blocks = c->nr_blocks;
info->free_size = c->free_size; //fixme need test!
}
}
+1 -1
View File
@@ -35,4 +35,4 @@ struct jffs2_dirent
// should be used with caution.
char d_name[NAME_MAX+1];
};
#endif
#endif
@@ -22,7 +22,9 @@
#include <linux/jffs2_fs_i.h>
#ifdef __ECOS
#include "os-ecos.h"
#include "os-ecos.h"
#elif defined(RT_THREAD)
#include "os-rtthread.h"
#else
#include <linux/mtd/compatmac.h> /* For compatibility with older kernels */
#include "os-linux.h"
@@ -15,8 +15,6 @@
#define __JFFS2_OS_ECOS_H__
#include <rtthread.h>
#define malloc rt_malloc
#define free rt_free
#define printf rt_kprintf
//#include <pkgconf/fs_jffs2.h>
File diff suppressed because it is too large Load Diff