blob: 68cc7010dbdfa57240e7b333f5e4661759901098 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
David Woodhousec00c3102007-04-25 14:16:47 +01004 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * University of Szeged, Hungary
6 *
David Woodhousec00c3102007-04-25 14:16:47 +01007 * For licensing information, see the file 'LICENCE' in this directory.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 */
10
11#ifndef __JFFS2_COMPR_H__
12#define __JFFS2_COMPR_H__
13
14#include <linux/kernel.h>
15#include <linux/vmalloc.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/fs.h>
22#include <linux/jffs2.h>
David Woodhousecbb9a562006-05-03 13:07:27 +010023#include "jffs2_fs_i.h"
24#include "jffs2_fs_sb.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include "nodelist.h"
26
27#define JFFS2_RUBINMIPS_PRIORITY 10
28#define JFFS2_DYNRUBIN_PRIORITY 20
29#define JFFS2_LZARI_PRIORITY 30
30#define JFFS2_LZO_PRIORITY 40
31#define JFFS2_RTIME_PRIORITY 50
32#define JFFS2_ZLIB_PRIORITY 60
33
34#define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
35#define JFFS2_DYNRUBIN_DISABLED /* for decompression */
36
37#define JFFS2_COMPR_MODE_NONE 0
38#define JFFS2_COMPR_MODE_PRIORITY 1
39#define JFFS2_COMPR_MODE_SIZE 2
40
41struct jffs2_compressor {
42 struct list_head list;
43 int priority; /* used by prirority comr. mode */
44 char *name;
45 char compr; /* JFFS2_COMPR_XXX */
46 int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
47 uint32_t *srclen, uint32_t *destlen, void *model);
48 int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
49 uint32_t cdatalen, uint32_t datalen, void *model);
50 int usecount;
51 int disabled; /* if seted the compressor won't compress */
52 unsigned char *compr_buf; /* used by size compr. mode */
53 uint32_t compr_buf_size; /* used by size compr. mode */
54 uint32_t stat_compr_orig_size;
55 uint32_t stat_compr_new_size;
56 uint32_t stat_compr_blocks;
57 uint32_t stat_decompr_blocks;
58};
59
60int jffs2_register_compressor(struct jffs2_compressor *comp);
61int jffs2_unregister_compressor(struct jffs2_compressor *comp);
62
63int jffs2_compressors_init(void);
64int jffs2_compressors_exit(void);
65
66uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
67 unsigned char *data_in, unsigned char **cpage_out,
68 uint32_t *datalen, uint32_t *cdatalen);
69
70int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
71 uint16_t comprtype, unsigned char *cdata_in,
72 unsigned char *data_out, uint32_t cdatalen, uint32_t datalen);
73
74void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig);
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076/* Compressor modules */
77/* These functions will be called by jffs2_compressors_init/exit */
78
79#ifdef CONFIG_JFFS2_RUBIN
80int jffs2_rubinmips_init(void);
81void jffs2_rubinmips_exit(void);
82int jffs2_dynrubin_init(void);
83void jffs2_dynrubin_exit(void);
84#endif
85#ifdef CONFIG_JFFS2_RTIME
86int jffs2_rtime_init(void);
87void jffs2_rtime_exit(void);
88#endif
89#ifdef CONFIG_JFFS2_ZLIB
90int jffs2_zlib_init(void);
91void jffs2_zlib_exit(void);
92#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94#endif /* __JFFS2_COMPR_H__ */