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