| 1 | |
| 2 | #ifndef DFLTCC_H
|
| 3 | #define DFLTCC_H
|
| 4 |
|
| 5 | #include "../zlib_deflate/defutil.h"
|
| 6 | #include <asm/facility.h>
|
| 7 | #include <asm/setup.h>
|
| 8 |
|
| 9 | |
| 10 | * Tuning parameters.
|
| 11 |
|
| 12 | #define DFLTCC_LEVEL_MASK 0x2
|
| 13 | #define DFLTCC_LEVEL_MASK_DEBUG 0x3fe
|
| 14 | #define DFLTCC_BLOCK_SIZE 1048576
|
| 15 | #define DFLTCC_FIRST_FHT_BLOCK_SIZE 4096
|
| 16 | #define DFLTCC_DHT_MIN_SAMPLE_SIZE 4096
|
| 17 | #define DFLTCC_RIBM 0
|
| 18 |
|
| 19 | #define DFLTCC_FACILITY 151
|
| 20 |
|
| 21 | |
| 22 | * Parameter Block for Query Available Functions.
|
| 23 |
|
| 24 | struct dfltcc_qaf_param {
|
| 25 | char fns[16];
|
| 26 | char reserved1[8];
|
| 27 | char fmts[2];
|
| 28 | char reserved2[6];
|
| 29 | };
|
| 30 |
|
| 31 | static_assert(sizeof(struct dfltcc_qaf_param) == 32);
|
| 32 |
|
| 33 | #define DFLTCC_FMT0 0
|
| 34 |
|
| 35 | |
| 36 | * Parameter Block for Generate Dynamic-Huffman Table, Compress and Expand.
|
| 37 |
|
| 38 | struct dfltcc_param_v0 {
|
| 39 | uint16_t pbvn;
|
| 40 | uint8_t mvn;
|
| 41 | uint8_t ribm;
|
| 42 | unsigned reserved32 : 31;
|
| 43 | unsigned cf : 1;
|
| 44 | uint8_t reserved64[8];
|
| 45 | unsigned nt : 1;
|
| 46 | unsigned reserved129 : 1;
|
| 47 | unsigned cvt : 1;
|
| 48 | unsigned reserved131 : 1;
|
| 49 | unsigned htt : 1;
|
| 50 | unsigned bcf : 1;
|
| 51 | unsigned bcc : 1;
|
| 52 | unsigned bhf : 1;
|
| 53 | unsigned reserved136 : 1;
|
| 54 | unsigned reserved137 : 1;
|
| 55 | unsigned dhtgc : 1;
|
| 56 | unsigned reserved139 : 5;
|
| 57 | unsigned reserved144 : 5;
|
| 58 | unsigned sbb : 3;
|
| 59 | uint8_t oesc;
|
| 60 | unsigned reserved160 : 12;
|
| 61 | unsigned ifs : 4;
|
| 62 | uint16_t ifl;
|
| 63 | uint8_t reserved192[8];
|
| 64 | uint8_t reserved256[8];
|
| 65 | uint8_t reserved320[4];
|
| 66 | uint16_t hl;
|
| 67 | unsigned reserved368 : 1;
|
| 68 | uint16_t ho : 15;
|
| 69 | uint32_t cv;
|
| 70 | unsigned eobs : 15;
|
| 71 | unsigned reserved431: 1;
|
| 72 | uint8_t eobl : 4;
|
| 73 | unsigned reserved436 : 12;
|
| 74 | unsigned reserved448 : 4;
|
| 75 | uint16_t cdhtl : 12; |
| 76 | Length
|
| 77 | uint8_t reserved464[6];
|
| 78 | uint8_t cdht[288];
|
| 79 | uint8_t reserved[32];
|
| 80 | uint8_t csb[1152];
|
| 81 | };
|
| 82 |
|
| 83 | static_assert(offsetof(struct dfltcc_param_v0, csb) == 384);
|
| 84 | static_assert(sizeof(struct dfltcc_param_v0) == 1536);
|
| 85 |
|
| 86 | #define CVT_CRC32 0
|
| 87 | #define CVT_ADLER32 1
|
| 88 | #define HTT_FIXED 0
|
| 89 | #define HTT_DYNAMIC 1
|
| 90 |
|
| 91 | |
| 92 | * Extension of inflate_state and deflate_state for DFLTCC.
|
| 93 |
|
| 94 | struct dfltcc_state {
|
| 95 | struct dfltcc_param_v0 param;
|
| 96 | struct dfltcc_qaf_param af;
|
| 97 | char msg[64];
|
| 98 | };
|
| 99 |
|
| 100 | |
| 101 | * Extension of inflate_state and deflate_state for DFLTCC.
|
| 102 |
|
| 103 | struct dfltcc_deflate_state {
|
| 104 | struct dfltcc_state common;
|
| 105 | uLong level_mask;
|
| 106 | uLong block_size;
|
| 107 | uLong block_threshold;
|
| 108 | uLong dht_threshold;
|
| 109 | };
|
| 110 |
|
| 111 | #define ALIGN_UP(p, size) (__typeof__(p))(((uintptr_t)(p) + ((size) - 1)) & ~((size) - 1))
|
| 112 |
|
| 113 | #define GET_DFLTCC_STATE(state) ((struct dfltcc_state *)((char *)(state) + ALIGN_UP(sizeof(*state), 8)))
|
| 114 |
|
| 115 | void dfltcc_reset_state(struct dfltcc_state *dfltcc_state);
|
| 116 |
|
| 117 | static inline int is_dfltcc_enabled(void)
|
| 118 | {
|
| 119 | return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED &&
|
| 120 | test_facility(DFLTCC_FACILITY));
|
| 121 | }
|
| 122 |
|
| 123 | #define DEFLATE_DFLTCC_ENABLED() is_dfltcc_enabled()
|
| 124 |
|
| 125 | #endif
|