/* * Wrapper for decompressing LZ4-compressed kernel, initramfs, and initrd * * Copyright (C) 2013, LG Electronics, Kyungsik Lee * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifdef STATIC #define PREBOOT #include "lz4/lz4_decompress.c" #else #include #endif #include #include #include #include #include /* * Note: Uncompressed chunk size is used in the compressor side * (userspace side for compression). * It is hardcoded because there is not proper way to extract it * from the binary stream which is generated by the preliminary * version of LZ4 tool so far. */ #define LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE (8 << 20) #define ARCHIVE_MAGICNUMBER 0x184C2102 STATIC inline int INIT unlz4(u8 *input, long in_len, long (*fill)(void *, unsigned long), long (*flush)(void *, unsigned long), u8 *output, long *posp, void (*error) (char *x)) { int ret = -1; size_t chunksize = 0; size_t uncomp_chunksize = LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE; u8 *inp; u8 *inp_start; u8 *outp; long size = in_len; #ifdef PREBOOT size_t out_len = get_unaligned_le32(input + in_len); #endif size_t dest_len; if (output) { outp = output; } else if (!flush) { error("NULL output pointer and no flush function provided"); goto exit_0; } else { outp = large_malloc(uncomp_chunksize); if (!outp) { error("Could not allocate output buffer"); goto exit_0; } } if (input && fill) { error("Both input pointer and fill function provided,"); goto exit_1; } else if (input) { inp = input; } else if (!fill) { error("NULL input pointer and missing fill function"); goto exit_1; } else { inp = large_malloc(lz4_compressbound(uncomp_chunksize)); if (!inp) { error("Could not allocate input buffer"); goto exit_1; } } inp_start = inp; if (posp) *posp = 0; if (fill) { size = fill(inp, 4); if (size < 4) { error("data corrupted"); goto exit_2; } } chunksize = get_unaligned_le32(inp); if (chunksize == ARCHIVE_MAGICNUMBER) { if (!fill) { inp += 4; size -= 4; } } else { error("invalid header"); goto exit_2; } if (posp) *posp += 4; for (;;) { if (fill) { size = fill(inp, 4); if (size == 0) break; if (size < 4) { error("data corrupted"); goto exit_2; } } chunksize = get_unaligned_le32(inp); if (chunksize == ARCHIVE_MAGICNUMBER) { if (!fill) { inp += 4; size -= 4; } if (posp) *posp += 4; continue; } if (posp) *posp += 4; if (!fill) { inp += 4; size -= 4; } else { if (chunksize > lz4_compressbound(uncomp_chunksize)) { error("chunk length is longer than allocated"); goto exit_2; } size = fill(inp, chunksize); if (size < chunksize) { error("data corrupted"); goto exit_2; } } #ifdef PREBOOT if (out_len >= uncomp_chunksize) { dest_len = uncomp_chunksize; out_len -= dest_len; } else dest_len = out_len; ret = lz4_decompress(inp, &chunksize, outp, dest_len); #else dest_len = uncomp_chunksize; ret = lz4_decompress_unknownoutputsize(inp, chunksize, outp, &dest_len); #endif if (ret < 0) { error("Decoding failed"); goto exit_2; } ret = -1; if (flush && flush(outp, dest_len) != dest_len) goto exit_2; if (output) outp += dest_len; if (posp) *posp += chunksize; if (!fill) { size -= chunksize; if (size == 0) break; else if (size < 0) { error("data corrupted"); goto exit_2; } inp += chunksize; } } ret = 0; exit_2: if (!input) large_free(inp_start); exit_1: if (!output) large_free(outp); exit_0: return ret; } #ifdef PREBOOT STATIC int INIT __decompress(unsigned char *buf, long in_len, long (*fill)(void*, unsigned long), long (*flush)(void*, unsigned long), unsigned char *output, long out_len, long *posp, void (*error)(char *x) ) { return unlz4(buf, in_len - 4, fill, flush, output, posp, error); } #endif ude/drm/bridge?h=nds-private-remove&id=5b2ec6f2be512485cb9fde7eb1119279af524c28'>logplain -rw-r--r--drmP.h25758logplain -rw-r--r--drm_agpsupport.h3867logplain -rw-r--r--drm_atomic.h14443logplain -rw-r--r--drm_atomic_helper.h10607logplain -rw-r--r--drm_auth.h2260logplain -rw-r--r--drm_blend.h2700logplain -rw-r--r--drm_bridge.h7977logplain -rw-r--r--drm_cache.h1763logplain -rw-r--r--drm_color_mgmt.h2166logplain -rw-r--r--drm_connector.h28613logplain -rw-r--r--drm_crtc.h28999logplain -rw-r--r--drm_crtc_helper.h3301logplain -rw-r--r--drm_debugfs_crc.h2670logplain -rw-r--r--drm_displayid.h2850logplain -rw-r--r--drm_dp_dual_mode_helper.h4532logplain -rw-r--r--drm_dp_helper.h30638logplain -rw-r--r--drm_dp_mst_helper.h16260logplain -rw-r--r--drm_drv.h14861logplain -rw-r--r--drm_edid.h14335logplain -rw-r--r--drm_encoder.h8160logplain -rw-r--r--drm_encoder_slave.h6583logplain -rw-r--r--drm_fb_cma_helper.h1929logplain -rw-r--r--drm_fb_helper.h15125logplain -rw-r--r--drm_fixed.h4825logplain -rw-r--r--drm_flip_work.h3071logplain -rw-r--r--drm_fourcc.h2748logplain -rw-r--r--drm_framebuffer.h9623logplain -rw-r--r--drm_gem.h8052logplain -rw-r--r--drm_gem_cma_helper.h2286logplain -rw-r--r--drm_global.h2011logplain -rw-r--r--drm_hashtab.h3139logplain -rw-r--r--drm_irq.h6323logplain -rw-r--r--drm_legacy.h6933logplain -rw-r--r--drm_mem_util.h2468logplain -rw-r--r--drm_mipi_dsi.h10327logplain -rw-r--r--drm_mm.h11462logplain -rw-r--r--drm_mode_config.h23728logplain -rw-r--r--drm_mode_object.h4911logplain -rw-r--r--drm_modes.h17078logplain -rw-r--r--drm_modeset_helper.h1576logplain -rw-r--r--drm_modeset_helper_vtables.h41180logplain -rw-r--r--drm_modeset_lock.h4241logplain -rw-r--r--drm_of.h2034logplain -rw-r--r--drm_os_linux.h2230logplain -rw-r--r--drm_panel.h7079logplain -rw-r--r--drm_pciids.h68035logplain -rw-r--r--drm_plane.h19435logplain -rw-r--r--drm_plane_helper.h3186logplain -rw-r--r--drm_print.h3232logplain -rw-r--r--drm_property.h11460logplain -rw-r--r--drm_rect.h5103logplain -rw-r--r--drm_simple_kms_helper.h4090logplain -rw-r--r--drm_sysfs.h300logplain -rw-r--r--drm_vma_manager.h7840logplain -rw-r--r--gma_drm.h1033logplain d---------i2c109logplain