compr.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #ifndef __JFFS2_COMPR_H__
  12. #define __JFFS2_COMPR_H__
  13. #include <linux/kernel.h>
  14. #include <linux/vmalloc.h>
  15. #include <linux/list.h>
  16. #include <linux/types.h>
  17. #include <linux/string.h>
  18. #include <linux/slab.h>
  19. #include <linux/errno.h>
  20. #include <linux/fs.h>
  21. #include <linux/jffs2.h>
  22. #include "jffs2_fs_i.h"
  23. #include "jffs2_fs_sb.h"
  24. #include "nodelist.h"
  25. #define JFFS2_RUBINMIPS_PRIORITY 10
  26. #define JFFS2_DYNRUBIN_PRIORITY 20
  27. #define JFFS2_LZARI_PRIORITY 30
  28. #define JFFS2_RTIME_PRIORITY 50
  29. #define JFFS2_ZLIB_PRIORITY 60
  30. #define JFFS2_LZO_PRIORITY 80
  31. #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
  32. #define JFFS2_DYNRUBIN_DISABLED /* for decompression */
  33. #define JFFS2_COMPR_MODE_NONE 0
  34. #define JFFS2_COMPR_MODE_PRIORITY 1
  35. #define JFFS2_COMPR_MODE_SIZE 2
  36. #define JFFS2_COMPR_MODE_FAVOURLZO 3
  37. #define JFFS2_COMPR_MODE_FORCELZO 4
  38. #define JFFS2_COMPR_MODE_FORCEZLIB 5
  39. #define FAVOUR_LZO_PERCENT 80
  40. struct jffs2_compressor {
  41. struct list_head list;
  42. int priority; /* used by prirority comr. mode */
  43. char *name;
  44. char compr; /* JFFS2_COMPR_XXX */
  45. int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
  46. uint32_t *srclen, uint32_t *destlen);
  47. int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
  48. uint32_t cdatalen, uint32_t datalen);
  49. int usecount;
  50. int disabled; /* if set the compressor won't compress */
  51. unsigned char *compr_buf; /* used by size compr. mode */
  52. uint32_t compr_buf_size; /* used by size compr. mode */
  53. uint32_t stat_compr_orig_size;
  54. uint32_t stat_compr_new_size;
  55. uint32_t stat_compr_blocks;
  56. uint32_t stat_decompr_blocks;
  57. };
  58. int jffs2_register_compressor(struct jffs2_compressor *comp);
  59. int jffs2_unregister_compressor(struct jffs2_compressor *comp);
  60. int jffs2_compressors_init(void);
  61. int jffs2_compressors_exit(void);
  62. uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
  63. unsigned char *data_in, unsigned char **cpage_out,
  64. uint32_t *datalen, uint32_t *cdatalen);
  65. int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
  66. uint16_t comprtype, unsigned char *cdata_in,
  67. unsigned char *data_out, uint32_t cdatalen, uint32_t datalen);
  68. void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig);
  69. /* Compressor modules */
  70. /* These functions will be called by jffs2_compressors_init/exit */
  71. #ifdef CONFIG_JFFS2_RUBIN
  72. int jffs2_rubinmips_init(void);
  73. void jffs2_rubinmips_exit(void);
  74. int jffs2_dynrubin_init(void);
  75. void jffs2_dynrubin_exit(void);
  76. #endif
  77. #ifdef CONFIG_JFFS2_RTIME
  78. int jffs2_rtime_init(void);
  79. void jffs2_rtime_exit(void);
  80. #endif
  81. #ifdef CONFIG_JFFS2_ZLIB
  82. int jffs2_zlib_init(void);
  83. void jffs2_zlib_exit(void);
  84. #endif
  85. #ifdef CONFIG_JFFS2_LZO
  86. int jffs2_lzo_init(void);
  87. void jffs2_lzo_exit(void);
  88. #endif
  89. #endif /* __JFFS2_COMPR_H__ */