Inflate compressed data.
Data will not be written beyond the specified end of the output data buffer, but the offset within the output data buffer will be updated to reflect the amount that should have been written. The caller can use this to find the length of the decompressed data before allocating the output data buffer.
522 "compression method %d\n",
deflate,
cm );
526 DBGC (
deflate,
"DEFLATE %p unsupported ZLIB preset " 551 DBGC (
deflate,
"DEFLATE %p found %sblock type %#x\n",
552 deflate, ( bfinal ?
"final " :
"" ), btype );
561 DBGC (
deflate,
"DEFLATE %p unsupported block type " 585 DBGC2 (
deflate,
"DEFLATE %p literal block length %#04zx\n",
614 in_remaining = (
in->len -
in->offset );
616 if (
len > in_remaining )
642 pattern->
count ; pattern++ ) {
644 lengths += pattern->
count;
648 goto construct_alphabets;
677 DBGC2 (
deflate,
"DEFLATE %p dynamic block %d codelen, %d " 678 "litlen, %d distance\n",
deflate,
724 dynamic_litlen_distance: {
741 static const uint8_t dup_len[3] = { 3, 3, 11 };
742 static const uint8_t extra_bits[3] = { 2, 3, 7 };
751 dynamic_litlen_distance_extra: {
753 unsigned int dup_len;
774 goto dynamic_litlen_distance;
777 goto construct_alphabets;
780 construct_alphabets: {
819 distance_offset ) ) != 0 )
846 (
isprint (
byte ) ?
byte :
'.' ) );
870 goto lzhuf_litlen_extra;
875 lzhuf_litlen_extra: {
911 lzhuf_distance_extra: {
926 DBGCP (
deflate,
"DEFLATE %p duplicate length %zd distance " 927 "%zd\n",
deflate, dup_len, dup_distance );
930 if ( dup_distance >
out->offset ) {
931 DBGC (
deflate,
"DEFLATE %p bad distance %zd (max " 932 "%zd)\n",
deflate, dup_distance,
out->offset );
#define EINVAL
Invalid argument.
static void deflate_set_length(struct deflate *deflate, unsigned int index, unsigned int bits)
Set Huffman symbol length.
struct arbelprm_rc_send_wqe rc
unsigned int length_index
Current length index within a set of code lengths.
#define DEFLATE_DYNAMIC_HLIT_LSB
Dynamic header HLIT field LSB.
static uint16_t deflate_distance_base[32]
Distance base values.
static void deflate_copy(struct deflate_chunk *out, userptr_t start, size_t offset, size_t len)
Copy data to output buffer (if available)
#define DEFLATE_CODELEN_BITS
Dynamic header code length length (in bits)
struct deflate_alphabet distance_codelen
Distance and code length Huffman alphabet.
unsigned int length_target
Target length index within a set of code lengths.
uint8_t extra
Signature extra byte.
#define DEFLATE_DYNAMIC_HCLEN_MASK
Dynamic header HCLEN field mask.
unsigned int extra_bits
Number of extra bits required.
size_t dup_distance
Distance of a duplicated string.
#define DEFLATE_HEADER_BTYPE_STATIC
Block header type: static Huffman alphabet.
unsigned int header
Current block header.
enum deflate_format format
Format.
unsigned int length
Current length within a set of code lengths.
#define ZLIB_ADLER32_BITS
ZLIB ADLER32 length (in bits)
A Huffman-coded alphabet.
#define DEFLATE_LITLEN_END
Literal/length end of block code.
#define DEFLATE_DYNAMIC_HDIST_MASK
Dynamic header HDIST field mask.
uint8_t count
Repetition count.
static unsigned int code
Response code.
#define ENOTSUP
Operation not supported.
static int isprint(int character)
Check if character is printable.
#define DEFLATE_DYNAMIC_HCLEN_LSB
Dynamic header HCLEN field LSB.
#define DEFLATE_HEADER_BTYPE_LSB
Block header type LSB.
#define ZLIB_HEADER_BITS
ZLIB header length (in bits)
#define DEFLATE_LITERAL_LEN_BITS
Literal header LEN/NLEN field length (in bits)
size_t dup_len
Length of a duplicated string.
#define ZLIB_HEADER_CM_DEFLATE
ZLIB header compression method: DEFLATE.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void * resume
Resume point.
#define DEFLATE_DYNAMIC_HLIT_MASK
Dynamic header HLIT field mask.
#define DEFLATE_CODELEN_MAX_CODE
Maximum value of a code length code.
unsigned int distance_count
Number of symbols in the distance Huffman alphabet.
static uint8_t deflate_litlen_base[28]
Literal/length base values.
struct deflate_alphabet litlen
Literal/length Huffman alphabet.
static int deflate_accumulate(struct deflate *deflate, struct deflate_chunk *in, unsigned int target)
Attempt to accumulate bits from input stream.
static uint8_t deflate_codelen_map[19]
Code length map.
#define DEFLATE_DYNAMIC_BITS
Dynamic header length (in bits)
Raw DEFLATE data (no header or footer)
static volatile void * bits
A static Huffman alphabet length pattern.
#define DEFLATE_HEADER_BTYPE_LITERAL
Block header type: literal data.
struct ena_aq_header header
Header.
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
#define DEFLATE_HEADER_BITS
Block header length (in bits)
#define ZLIB_HEADER_CM_MASK
ZLIB header compression method mask.
static struct deflate_static_length_pattern deflate_static_length_patterns[]
Static Huffman alphabet length patterns.
unsigned int litlen_count
Number of symbols in the literal/length Huffman alphabet.
#define ZLIB_HEADER_CM_LSB
ZLIB header compression method LSB.
#define DEFLATE_HEADER_BFINAL_BIT
Block header final block flags bit.
uint8_t lengths[((DEFLATE_LITLEN_MAX_CODE+1)+(DEFLATE_DISTANCE_MAX_CODE+1)+1)/2]
Huffman code lengths.
static void deflate_discard_to_byte(struct deflate *deflate)
Discard bits up to the next byte boundary.
static int deflate_extract(struct deflate *deflate, struct deflate_chunk *in, unsigned int target)
Attempt to extract a fixed number of bits from input stream.
static int deflate_decode(struct deflate *deflate, struct deflate_chunk *in, struct deflate_alphabet *alphabet)
Attempt to decode a Huffman-coded symbol from input stream.
#define ZLIB_HEADER_FDICT_BIT
ZLIB header preset dictionary flag bit.
#define NULL
NULL pointer (VOID *)
#define DEFLATE_DYNAMIC_HDIST_LSB
Dynamic header HDIST field LSB.
size_t remaining
Remaining length of data (e.g.
void * memset(void *dest, int character, size_t len) __nonnull
#define DEFLATE_HEADER_BTYPE_DYNAMIC
Block header type: dynamic Huffman alphabet.