From c43d68510e309b8e8d152c158ec46450f14d72a6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 26 Jan 2018 11:42:01 +0900 Subject: zlib: add gunzip() support This commit adds some more files to use zlib from TF. To use zlib, ->zalloc and ->zfree hooks are needed. The implementation depends on the system. For user-space, the libc provides malloc() and friends. Unfortunately, ARM Trusted Firmware does not provide malloc() or any concept of dynamic memory allocation. I implemented very simple calloc() and free() for this. Stupidly, zfree() never frees memory, but it works enough for this. The purpose of using zlib is to implement gunzip() - this function takes compressed data from in_buf, then dumps the decompressed data to oub_buf. The work_buf is used for memory allocation during the decompress. Upon exit, it updates in_buf and out_buf. If successful, in_buf points to the end of input data, out_buf to the end of the decompressed data. To use this feature, you need to do: - include lib/zlib/zlib.mk from your platform.mk - add $(ZLIB_SOURCES) to your BL*_SOURCES Signed-off-by: Masahiro Yamada --- include/lib/zlib/tf_gunzip.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 include/lib/zlib/tf_gunzip.h (limited to 'include/lib') diff --git a/include/lib/zlib/tf_gunzip.h b/include/lib/zlib/tf_gunzip.h new file mode 100644 index 00000000..46d20eb8 --- /dev/null +++ b/include/lib/zlib/tf_gunzip.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __TF_GUNZIP_H__ +#define __TF_GUNZIP_H__ + +#include +#include + +int gunzip(uintptr_t *in_buf, size_t in_len, uintptr_t *out_buf, + size_t out_len, uintptr_t work_buf, size_t work_len); + +#endif /* __TF_GUNZIP_H___ */ -- cgit v1.2.3