1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2; Copyright(c) 2011-2016 Intel Corporation All rights reserved. 3; 4; Redistribution and use in source and binary forms, with or without 5; modification, are permitted provided that the following conditions 6; are met: 7; * Redistributions of source code must retain the above copyright 8; notice, this list of conditions and the following disclaimer. 9; * Redistributions in binary form must reproduce the above copyright 10; notice, this list of conditions and the following disclaimer in 11; the documentation and/or other materials provided with the 12; distribution. 13; * Neither the name of Intel Corporation nor the names of its 14; contributors may be used to endorse or promote products derived 15; from this software without specific prior written permission. 16; 17; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 29 30;; START_FIELDS 31%macro START_FIELDS 0 32%assign _FIELD_OFFSET 0 33%assign _STRUCT_ALIGN 0 34%endm 35 36;; FIELD name size align 37%macro FIELD 3 38%define %%name %1 39%define %%size %2 40%define %%align %3 41 42%assign _FIELD_OFFSET (_FIELD_OFFSET + (%%align) - 1) & (~ ((%%align)-1)) 43%%name equ _FIELD_OFFSET 44%assign _FIELD_OFFSET _FIELD_OFFSET + (%%size) 45%if (%%align > _STRUCT_ALIGN) 46%assign _STRUCT_ALIGN %%align 47%endif 48%endm 49 50;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 51;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 53 54START_FIELDS ;; BitBuf2 55 56;; name size align 57FIELD _m_bits, 8, 8 58FIELD _m_bit_count, 4, 4 59FIELD _m_out_buf, 8, 8 60FIELD _m_out_end, 8, 8 61FIELD _m_out_start, 8, 8 62 63%assign _BitBuf2_size _FIELD_OFFSET 64%assign _BitBuf2_align _STRUCT_ALIGN 65 66;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 67;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 68;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 69%define HIST_ELEM_SIZE 4 70 71START_FIELDS ;; isal_mod_hist 72 73;; name size align 74FIELD _d_hist, 30*HIST_ELEM_SIZE, HIST_ELEM_SIZE 75FIELD _ll_hist, 513*HIST_ELEM_SIZE, HIST_ELEM_SIZE 76 77%assign _isal_mod_hist_size _FIELD_OFFSET 78%assign _isal_mod_hist_align _STRUCT_ALIGN 79 80;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 81;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 82;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 83 84%define HUFF_CODE_SIZE 4 85 86START_FIELDS ;; hufftables_icf 87 88;; name size align 89FIELD _dist_table, 31 * HUFF_CODE_SIZE, HUFF_CODE_SIZE 90FIELD _lit_len_table, 513 * HUFF_CODE_SIZE, HUFF_CODE_SIZE 91 92%assign _hufftables_icf_size _FIELD_OFFSET 93%assign _hufftables_icf_align _STRUCT_ALIGN 94 95;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 96;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 97;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 98 99START_FIELDS ;; hash8k_buf 100 101;; name size align 102FIELD _hash8k_table, 2 * IGZIP_HASH8K_HASH_SIZE, 2 103 104%assign _hash_buf1_size _FIELD_OFFSET 105%assign _hash_buf1_align _STRUCT_ALIGN 106 107;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 108;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 110 111START_FIELDS ;; hash_map_buf 112 113;; name size align 114FIELD _hash_table, 2 * IGZIP_HASH_MAP_HASH_SIZE, 2 115FIELD _matches_next, 8, 8 116FIELD _matches_end, 8, 8 117FIELD _matches, 4*4*1024, 4 118FIELD _overflow, 4*LA, 4 119 120%assign _hash_map_buf_size _FIELD_OFFSET 121%assign _hash_map_buf_align _STRUCT_ALIGN 122 123;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 124;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 125;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 126 127%define DEF_MAX_HDR_SIZE 328 128START_FIELDS ;; level_buf 129 130;; name size align 131FIELD _encode_tables, _hufftables_icf_size, _hufftables_icf_align 132FIELD _hist, _isal_mod_hist_size, _isal_mod_hist_align 133FIELD _deflate_hdr_count, 4, 4 134FIELD _deflate_hdr_extra_bits,4, 4 135FIELD _deflate_hdr, DEF_MAX_HDR_SIZE, 1 136FIELD _icf_buf_next, 8, 8 137FIELD _icf_buf_avail_out, 8, 8 138FIELD _icf_buf_start, 8, 8 139FIELD _lvl_extra, _hash_map_buf_size, _hash_map_buf_align 140 141%assign _level_buf_base_size _FIELD_OFFSET 142%assign _level_buf_base_align _STRUCT_ALIGN 143 144_hash8k_hash_table equ _lvl_extra + _hash8k_table 145_hash_map_hash_table equ _lvl_extra + _hash_table 146_hash_map_matches_next equ _lvl_extra + _matches_next 147_hash_map_matches_end equ _lvl_extra + _matches_end 148_hash_map_matches equ _lvl_extra + _matches 149_hist_lit_len equ _hist+_ll_hist 150_hist_dist equ _hist+_d_hist 151 152;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 153;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 154;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 155 156START_FIELDS ;; isal_zstate 157 158;; name size align 159FIELD _total_in_start,4, 4 160FIELD _block_next, 4, 4 161FIELD _block_end, 4, 4 162FIELD _dist_mask, 4, 4 163FIELD _hash_mask, 4, 4 164FIELD _state, 4, 4 165FIELD _bitbuf, _BitBuf2_size, _BitBuf2_align 166FIELD _crc, 4, 4 167FIELD _has_wrap_hdr, 1, 1 168FIELD _has_eob_hdr, 1, 1 169FIELD _has_eob, 1, 1 170FIELD _has_hist, 1, 1 171FIELD _has_level_buf_init, 2, 2 172FIELD _count, 4, 4 173FIELD _tmp_out_buff, 16, 1 174FIELD _tmp_out_start, 4, 4 175FIELD _tmp_out_end, 4, 4 176FIELD _b_bytes_valid, 4, 4 177FIELD _b_bytes_processed, 4, 4 178FIELD _buffer, BSIZE, 1 179FIELD _head, IGZIP_LVL0_HASH_SIZE*2, 2 180%assign _isal_zstate_size _FIELD_OFFSET 181%assign _isal_zstate_align _STRUCT_ALIGN 182 183_bitbuf_m_bits equ _bitbuf+_m_bits 184_bitbuf_m_bit_count equ _bitbuf+_m_bit_count 185_bitbuf_m_out_buf equ _bitbuf+_m_out_buf 186_bitbuf_m_out_end equ _bitbuf+_m_out_end 187_bitbuf_m_out_start equ _bitbuf+_m_out_start 188 189;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 190;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 191;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 192 193START_FIELDS ;; isal_zstream 194 195;; name size align 196FIELD _next_in, 8, 8 197FIELD _avail_in, 4, 4 198FIELD _total_in, 4, 4 199FIELD _next_out, 8, 8 200FIELD _avail_out, 4, 4 201FIELD _total_out, 4, 4 202FIELD _hufftables, 8, 8 203FIELD _level, 4, 4 204FIELD _level_buf_size, 4, 4 205FIELD _level_buf, 8, 8 206FIELD _end_of_stream, 2, 2 207FIELD _flush, 2, 2 208FIELD _gzip_flag, 2, 2 209FIELD _hist_bits, 2, 2 210FIELD _internal_state, _isal_zstate_size, _isal_zstate_align 211 212%assign _isal_zstream_size _FIELD_OFFSET 213%assign _isal_zstream_align _STRUCT_ALIGN 214 215_internal_state_total_in_start equ _internal_state+_total_in_start 216_internal_state_block_next equ _internal_state+_block_next 217_internal_state_block_end equ _internal_state+_block_end 218_internal_state_b_bytes_valid equ _internal_state+_b_bytes_valid 219_internal_state_b_bytes_processed equ _internal_state+_b_bytes_processed 220_internal_state_crc equ _internal_state+_crc 221_internal_state_dist_mask equ _internal_state+_dist_mask 222_internal_state_hash_mask equ _internal_state+_hash_mask 223_internal_state_bitbuf equ _internal_state+_bitbuf 224_internal_state_state equ _internal_state+_state 225_internal_state_count equ _internal_state+_count 226_internal_state_tmp_out_buff equ _internal_state+_tmp_out_buff 227_internal_state_tmp_out_start equ _internal_state+_tmp_out_start 228_internal_state_tmp_out_end equ _internal_state+_tmp_out_end 229_internal_state_has_wrap_hdr equ _internal_state+_has_wrap_hdr 230_internal_state_has_eob equ _internal_state+_has_eob 231_internal_state_has_eob_hdr equ _internal_state+_has_eob_hdr 232_internal_state_has_hist equ _internal_state+_has_hist 233_internal_state_has_level_buf_init equ _internal_state+_has_level_buf_init 234_internal_state_buffer equ _internal_state+_buffer 235_internal_state_head equ _internal_state+_head 236_internal_state_bitbuf_m_bits equ _internal_state+_bitbuf_m_bits 237_internal_state_bitbuf_m_bit_count equ _internal_state+_bitbuf_m_bit_count 238_internal_state_bitbuf_m_out_buf equ _internal_state+_bitbuf_m_out_buf 239_internal_state_bitbuf_m_out_end equ _internal_state+_bitbuf_m_out_end 240_internal_state_bitbuf_m_out_start equ _internal_state+_bitbuf_m_out_start 241 242;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 243;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 244;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 245;; Internal States 246ZSTATE_NEW_HDR equ 0 247ZSTATE_HDR equ (ZSTATE_NEW_HDR + 1) 248ZSTATE_CREATE_HDR equ (ZSTATE_HDR + 1) 249ZSTATE_BODY equ (ZSTATE_CREATE_HDR + 1) 250ZSTATE_FLUSH_READ_BUFFER equ (ZSTATE_BODY + 1) 251ZSTATE_FLUSH_ICF_BUFFER equ (ZSTATE_FLUSH_READ_BUFFER + 1) 252ZSTATE_TYPE0_HDR equ (ZSTATE_FLUSH_ICF_BUFFER + 1) 253ZSTATE_TYPE0_BODY equ (ZSTATE_TYPE0_HDR + 1) 254ZSTATE_SYNC_FLUSH equ (ZSTATE_TYPE0_BODY + 1) 255ZSTATE_FLUSH_WRITE_BUFFER equ (ZSTATE_SYNC_FLUSH + 1) 256ZSTATE_TRL equ (ZSTATE_FLUSH_WRITE_BUFFER + 1) 257 258;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 259;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 260;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 261_NO_FLUSH equ 0 262_SYNC_FLUSH equ 1 263_FULL_FLUSH equ 2 264_STORED_BLK equ 0 265%assign _STORED_BLK_END 65535 266;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 267;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 268;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 269IGZIP_NO_HIST equ 0 270IGZIP_HIST equ 1 271IGZIP_DICT_HIST equ 2 272 273;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 274;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 275;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 276