compr.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  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. #ifndef __JFFS2_COMPR_H__
  11. #define __JFFS2_COMPR_H__
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <stdint.h>
  15. #include "linux/jffs2.h"
  16. #define CONFIG_JFFS2_ZLIB
  17. #define CONFIG_JFFS2_RTIME
  18. #define CONFIG_JFFS2_LZO
  19. #define JFFS2_RUBINMIPS_PRIORITY 10
  20. #define JFFS2_DYNRUBIN_PRIORITY 20
  21. #define JFFS2_RTIME_PRIORITY 50
  22. #define JFFS2_ZLIB_PRIORITY 60
  23. #define JFFS2_LZO_PRIORITY 80
  24. #define JFFS2_COMPR_MODE_NONE 0
  25. #define JFFS2_COMPR_MODE_PRIORITY 1
  26. #define JFFS2_COMPR_MODE_SIZE 2
  27. #define JFFS2_COMPR_MODE_FAVOURLZO 3
  28. #define kmalloc(a,b) malloc(a)
  29. #define kfree(a) free(a)
  30. #ifndef GFP_KERNEL
  31. #define GFP_KERNEL 0
  32. #endif
  33. #define vmalloc(a) malloc(a)
  34. #define vfree(a) free(a)
  35. #define printk(...) fprintf(stderr,__VA_ARGS__)
  36. #define KERN_EMERG
  37. #define KERN_ALERT
  38. #define KERN_CRIT
  39. #define KERN_ERR
  40. #define KERN_WARNING
  41. #define KERN_NOTICE
  42. #define KERN_INFO
  43. #define KERN_DEBUG
  44. struct list_head {
  45. struct list_head *next, *prev;
  46. };
  47. void jffs2_set_compression_mode(int mode);
  48. int jffs2_get_compression_mode(void);
  49. int jffs2_set_compression_mode_name(const char *mode_name);
  50. int jffs2_enable_compressor_name(const char *name);
  51. int jffs2_disable_compressor_name(const char *name);
  52. int jffs2_set_compressor_priority(const char *name, int priority);
  53. struct jffs2_compressor {
  54. struct list_head list;
  55. int priority; /* used by prirority comr. mode */
  56. const char *name;
  57. char compr; /* JFFS2_COMPR_XXX */
  58. int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
  59. uint32_t *srclen, uint32_t *destlen);
  60. int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
  61. uint32_t cdatalen, uint32_t datalen);
  62. int usecount;
  63. int disabled; /* if seted the compressor won't compress */
  64. unsigned char *compr_buf; /* used by size compr. mode */
  65. uint32_t compr_buf_size; /* used by size compr. mode */
  66. uint32_t stat_compr_orig_size;
  67. uint32_t stat_compr_new_size;
  68. uint32_t stat_compr_blocks;
  69. uint32_t stat_decompr_blocks;
  70. };
  71. int jffs2_register_compressor(struct jffs2_compressor *comp);
  72. int jffs2_unregister_compressor(struct jffs2_compressor *comp);
  73. int jffs2_compressors_init(void);
  74. int jffs2_compressors_exit(void);
  75. uint16_t jffs2_compress(unsigned char *data_in, unsigned char **cpage_out,
  76. uint32_t *datalen, uint32_t *cdatalen);
  77. /* If it is setted, a decompress will be called after every compress */
  78. void jffs2_compression_check_set(int yesno);
  79. int jffs2_compression_check_get(void);
  80. int jffs2_compression_check_errorcnt_get(void);
  81. char *jffs2_list_compressors(void);
  82. char *jffs2_stats(void);
  83. /* Compressor modules */
  84. /* These functions will be called by jffs2_compressors_init/exit */
  85. #ifdef CONFIG_JFFS2_ZLIB
  86. int jffs2_zlib_init(void);
  87. void jffs2_zlib_exit(void);
  88. #endif
  89. #ifdef CONFIG_JFFS2_RTIME
  90. int jffs2_rtime_init(void);
  91. void jffs2_rtime_exit(void);
  92. #endif
  93. #ifdef CONFIG_JFFS2_LZO
  94. int jffs2_lzo_init(void);
  95. void jffs2_lzo_exit(void);
  96. #endif
  97. #endif /* __JFFS2_COMPR_H__ */