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