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