summaryrefslogtreecommitdiff
path: root/lib/zlib_dfltcc/dfltcc.c
blob: 7f77e5bb01c6573b4a38fd113946150f1977ac86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: Zlib
/* dfltcc.c - SystemZ DEFLATE CONVERSION CALL support. */

#include <linux/zutil.h>
#include "dfltcc_util.h"
#include "dfltcc.h"

char *oesc_msg(
    char *buf,
    int oesc
)
{
    if (oesc == 0x00)
        return NULL; /* Successful completion */
    else {
#ifdef STATIC
        return NULL; /* Ignore for pre-boot decompressor */
#else
        sprintf(buf, "Operation-Ending-Supplemental Code is 0x%.2X", oesc);
        return buf;
#endif
    }
}

void dfltcc_reset(
    z_streamp strm,
    uInt size
)
{
    struct dfltcc_state *dfltcc_state =
        (struct dfltcc_state *)((char *)strm->state + size);
    struct dfltcc_qaf_param *param =
        (struct dfltcc_qaf_param *)&dfltcc_state->param;

    /* Initialize available functions */
    if (is_dfltcc_enabled()) {
        dfltcc(DFLTCC_QAF, param, NULL, NULL, NULL, NULL, NULL);
        memmove(&dfltcc_state->af, param, sizeof(dfltcc_state->af));
    } else
        memset(&dfltcc_state->af, 0, sizeof(dfltcc_state->af));

    /* Initialize parameter block */
    memset(&dfltcc_state->param, 0, sizeof(dfltcc_state->param));
    dfltcc_state->param.nt = 1;

    /* Initialize tuning parameters */
    dfltcc_state->level_mask = DFLTCC_LEVEL_MASK;
    dfltcc_state->block_size = DFLTCC_BLOCK_SIZE;
    dfltcc_state->block_threshold = DFLTCC_FIRST_FHT_BLOCK_SIZE;
    dfltcc_state->dht_threshold = DFLTCC_DHT_MIN_SAMPLE_SIZE;
    dfltcc_state->param.ribm = DFLTCC_RIBM;
}