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