^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: Zlib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* dfltcc.c - SystemZ DEFLATE CONVERSION CALL support. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include "dfltcc_util.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "dfltcc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) char *oesc_msg(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) int oesc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) if (oesc == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) return NULL; /* Successful completion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifdef STATIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) return NULL; /* Ignore for pre-boot decompressor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) sprintf(buf, "Operation-Ending-Supplemental Code is 0x%.2X", oesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) return buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) void dfltcc_reset(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) z_streamp strm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) uInt size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct dfltcc_state *dfltcc_state =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) (struct dfltcc_state *)((char *)strm->state + size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct dfltcc_qaf_param *param =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) (struct dfltcc_qaf_param *)&dfltcc_state->param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* Initialize available functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) if (is_dfltcc_enabled()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) dfltcc(DFLTCC_QAF, param, NULL, NULL, NULL, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) memmove(&dfltcc_state->af, param, sizeof(dfltcc_state->af));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) memset(&dfltcc_state->af, 0, sizeof(dfltcc_state->af));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* Initialize parameter block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) memset(&dfltcc_state->param, 0, sizeof(dfltcc_state->param));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) dfltcc_state->param.nt = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Initialize tuning parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (zlib_dfltcc_support == ZLIB_DFLTCC_FULL_DEBUG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) dfltcc_state->level_mask = DFLTCC_LEVEL_MASK_DEBUG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) dfltcc_state->level_mask = DFLTCC_LEVEL_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) dfltcc_state->block_size = DFLTCC_BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) dfltcc_state->block_threshold = DFLTCC_FIRST_FHT_BLOCK_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) dfltcc_state->dht_threshold = DFLTCC_DHT_MIN_SAMPLE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) dfltcc_state->param.ribm = DFLTCC_RIBM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) EXPORT_SYMBOL(dfltcc_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) MODULE_LICENSE("GPL");