]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * JFFS2 -- Journalling Flash File System, Version 2. | |
3 | * | |
c00c310e | 4 | * Copyright © 2004 Ferenc Havasi <[email protected]>, |
ef53cb02 | 5 | * University of Szeged, Hungary |
6088c058 | 6 | * Copyright © 2004-2010 David Woodhouse <[email protected]> |
1da177e4 | 7 | * |
c00c310e | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
1da177e4 LT |
9 | * |
10 | */ | |
11 | ||
12 | #ifndef __JFFS2_COMPR_H__ | |
13 | #define __JFFS2_COMPR_H__ | |
14 | ||
15 | #include <linux/kernel.h> | |
16 | #include <linux/vmalloc.h> | |
17 | #include <linux/list.h> | |
18 | #include <linux/types.h> | |
19 | #include <linux/string.h> | |
20 | #include <linux/slab.h> | |
21 | #include <linux/errno.h> | |
22 | #include <linux/fs.h> | |
23 | #include <linux/jffs2.h> | |
cbb9a561 DW |
24 | #include "jffs2_fs_i.h" |
25 | #include "jffs2_fs_sb.h" | |
1da177e4 LT |
26 | #include "nodelist.h" |
27 | ||
28 | #define JFFS2_RUBINMIPS_PRIORITY 10 | |
29 | #define JFFS2_DYNRUBIN_PRIORITY 20 | |
30 | #define JFFS2_LZARI_PRIORITY 30 | |
1da177e4 LT |
31 | #define JFFS2_RTIME_PRIORITY 50 |
32 | #define JFFS2_ZLIB_PRIORITY 60 | |
c799aca3 RP |
33 | #define JFFS2_LZO_PRIORITY 80 |
34 | ||
1da177e4 LT |
35 | |
36 | #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */ | |
ef53cb02 | 37 | #define JFFS2_DYNRUBIN_DISABLED /* for decompression */ |
1da177e4 LT |
38 | |
39 | #define JFFS2_COMPR_MODE_NONE 0 | |
40 | #define JFFS2_COMPR_MODE_PRIORITY 1 | |
41 | #define JFFS2_COMPR_MODE_SIZE 2 | |
3b23c1f5 RP |
42 | #define JFFS2_COMPR_MODE_FAVOURLZO 3 |
43 | ||
44 | #define FAVOUR_LZO_PERCENT 80 | |
1da177e4 LT |
45 | |
46 | struct jffs2_compressor { | |
ef53cb02 DW |
47 | struct list_head list; |
48 | int priority; /* used by prirority comr. mode */ | |
49 | char *name; | |
50 | char compr; /* JFFS2_COMPR_XXX */ | |
51 | int (*compress)(unsigned char *data_in, unsigned char *cpage_out, | |
52 | uint32_t *srclen, uint32_t *destlen, void *model); | |
53 | int (*decompress)(unsigned char *cdata_in, unsigned char *data_out, | |
54 | uint32_t cdatalen, uint32_t datalen, void *model); | |
55 | int usecount; | |
56 | int disabled; /* if set the compressor won't compress */ | |
57 | unsigned char *compr_buf; /* used by size compr. mode */ | |
58 | uint32_t compr_buf_size; /* used by size compr. mode */ | |
59 | uint32_t stat_compr_orig_size; | |
60 | uint32_t stat_compr_new_size; | |
61 | uint32_t stat_compr_blocks; | |
62 | uint32_t stat_decompr_blocks; | |
1da177e4 LT |
63 | }; |
64 | ||
65 | int jffs2_register_compressor(struct jffs2_compressor *comp); | |
66 | int jffs2_unregister_compressor(struct jffs2_compressor *comp); | |
67 | ||
68 | int jffs2_compressors_init(void); | |
69 | int jffs2_compressors_exit(void); | |
70 | ||
71 | uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |
ef53cb02 DW |
72 | unsigned char *data_in, unsigned char **cpage_out, |
73 | uint32_t *datalen, uint32_t *cdatalen); | |
1da177e4 LT |
74 | |
75 | int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |
ef53cb02 DW |
76 | uint16_t comprtype, unsigned char *cdata_in, |
77 | unsigned char *data_out, uint32_t cdatalen, uint32_t datalen); | |
1da177e4 LT |
78 | |
79 | void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig); | |
80 | ||
1da177e4 LT |
81 | /* Compressor modules */ |
82 | /* These functions will be called by jffs2_compressors_init/exit */ | |
83 | ||
84 | #ifdef CONFIG_JFFS2_RUBIN | |
85 | int jffs2_rubinmips_init(void); | |
86 | void jffs2_rubinmips_exit(void); | |
87 | int jffs2_dynrubin_init(void); | |
88 | void jffs2_dynrubin_exit(void); | |
89 | #endif | |
90 | #ifdef CONFIG_JFFS2_RTIME | |
91 | int jffs2_rtime_init(void); | |
92 | void jffs2_rtime_exit(void); | |
93 | #endif | |
94 | #ifdef CONFIG_JFFS2_ZLIB | |
95 | int jffs2_zlib_init(void); | |
96 | void jffs2_zlib_exit(void); | |
97 | #endif | |
0fc72b81 DW |
98 | #ifdef CONFIG_JFFS2_LZO |
99 | int jffs2_lzo_init(void); | |
100 | void jffs2_lzo_exit(void); | |
101 | #endif | |
1da177e4 LT |
102 | |
103 | #endif /* __JFFS2_COMPR_H__ */ |