1edd4a866SHeiko Carstens // SPDX-License-Identifier: GPL-2.0 2edd4a866SHeiko Carstens /* 3edd4a866SHeiko Carstens * Definitions and wrapper functions for kernel decompressor 4edd4a866SHeiko Carstens * 5edd4a866SHeiko Carstens * Copyright IBM Corp. 2010 6edd4a866SHeiko Carstens * 7edd4a866SHeiko Carstens * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 8edd4a866SHeiko Carstens */ 9edd4a866SHeiko Carstens 10edd4a866SHeiko Carstens #include <linux/kernel.h> 11edd4a866SHeiko Carstens #include <linux/string.h> 12edd4a866SHeiko Carstens #include <asm/page.h> 13edd4a866SHeiko Carstens #include "decompressor.h" 149c3205b2SAlexander Gordeev #include "boot.h" 15edd4a866SHeiko Carstens 16edd4a866SHeiko Carstens /* 17edd4a866SHeiko Carstens * gzip declarations 18edd4a866SHeiko Carstens */ 19edd4a866SHeiko Carstens #define STATIC static 20edd4a866SHeiko Carstens 21edd4a866SHeiko Carstens #undef memset 22edd4a866SHeiko Carstens #undef memcpy 23edd4a866SHeiko Carstens #undef memmove 24edd4a866SHeiko Carstens #define memmove memmove 25edd4a866SHeiko Carstens #define memzero(s, n) memset((s), 0, (n)) 26edd4a866SHeiko Carstens 27f993d24aSMasahiro Yamada #if defined(CONFIG_KERNEL_BZIP2) 28edd4a866SHeiko Carstens #define BOOT_HEAP_SIZE 0x400000 29f993d24aSMasahiro Yamada #elif defined(CONFIG_KERNEL_ZSTD) 30edd4a866SHeiko Carstens #define BOOT_HEAP_SIZE 0x30000 31edd4a866SHeiko Carstens #else 32edd4a866SHeiko Carstens #define BOOT_HEAP_SIZE 0x10000 33edd4a866SHeiko Carstens #endif 34edd4a866SHeiko Carstens 35edd4a866SHeiko Carstens static unsigned long free_mem_ptr = (unsigned long) _end; 36edd4a866SHeiko Carstens static unsigned long free_mem_end_ptr = (unsigned long) _end + BOOT_HEAP_SIZE; 37edd4a866SHeiko Carstens 38edd4a866SHeiko Carstens #ifdef CONFIG_KERNEL_GZIP 39edd4a866SHeiko Carstens #include "../../../../lib/decompress_inflate.c" 40edd4a866SHeiko Carstens #endif 41edd4a866SHeiko Carstens 42edd4a866SHeiko Carstens #ifdef CONFIG_KERNEL_BZIP2 43edd4a866SHeiko Carstens #include "../../../../lib/decompress_bunzip2.c" 44edd4a866SHeiko Carstens #endif 45edd4a866SHeiko Carstens 46edd4a866SHeiko Carstens #ifdef CONFIG_KERNEL_LZ4 47edd4a866SHeiko Carstens #include "../../../../lib/decompress_unlz4.c" 48edd4a866SHeiko Carstens #endif 49edd4a866SHeiko Carstens 50edd4a866SHeiko Carstens #ifdef CONFIG_KERNEL_LZMA 51edd4a866SHeiko Carstens #include "../../../../lib/decompress_unlzma.c" 52edd4a866SHeiko Carstens #endif 53edd4a866SHeiko Carstens 54edd4a866SHeiko Carstens #ifdef CONFIG_KERNEL_LZO 55edd4a866SHeiko Carstens #include "../../../../lib/decompress_unlzo.c" 56edd4a866SHeiko Carstens #endif 57edd4a866SHeiko Carstens 58edd4a866SHeiko Carstens #ifdef CONFIG_KERNEL_XZ 59edd4a866SHeiko Carstens #include "../../../../lib/decompress_unxz.c" 60edd4a866SHeiko Carstens #endif 61edd4a866SHeiko Carstens 62edd4a866SHeiko Carstens #ifdef CONFIG_KERNEL_ZSTD 63edd4a866SHeiko Carstens #include "../../../../lib/decompress_unzstd.c" 64edd4a866SHeiko Carstens #endif 65edd4a866SHeiko Carstens 66edd4a866SHeiko Carstens unsigned long mem_safe_offset(void) 67edd4a866SHeiko Carstens { 68*56b1069cSAlexander Gordeev return ALIGN(free_mem_end_ptr, PAGE_SIZE); 69edd4a866SHeiko Carstens } 70edd4a866SHeiko Carstens 71*56b1069cSAlexander Gordeev void deploy_kernel(void *output) 72edd4a866SHeiko Carstens { 73edd4a866SHeiko Carstens __decompress(_compressed_start, _compressed_end - _compressed_start, 747ab41c2cSVasily Gorbik NULL, NULL, output, vmlinux.image_size, NULL, error); 75edd4a866SHeiko Carstens } 76