18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * lzodefs.h -- architecture, OS and compiler specific defines 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1996-2012 Markus F.X.J. Oberhumer <markus@oberhumer.com> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * The full LZO package can be found at: 88c2ecf20Sopenharmony_ci * http://www.oberhumer.com/opensource/lzo/ 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Changed for Linux kernel use by: 118c2ecf20Sopenharmony_ci * Nitin Gupta <nitingupta910@gmail.com> 128c2ecf20Sopenharmony_ci * Richard Purdie <rpurdie@openedhand.com> 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* Version 178c2ecf20Sopenharmony_ci * 0: original lzo version 188c2ecf20Sopenharmony_ci * 1: lzo with support for RLE 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci#define LZO_VERSION 1 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define COPY4(dst, src) \ 238c2ecf20Sopenharmony_ci put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst)) 248c2ecf20Sopenharmony_ci#if defined(CONFIG_X86_64) || defined(CONFIG_ARM64) 258c2ecf20Sopenharmony_ci#define COPY8(dst, src) \ 268c2ecf20Sopenharmony_ci put_unaligned(get_unaligned((const u64 *)(src)), (u64 *)(dst)) 278c2ecf20Sopenharmony_ci#else 288c2ecf20Sopenharmony_ci#define COPY8(dst, src) \ 298c2ecf20Sopenharmony_ci COPY4(dst, src); COPY4((dst) + 4, (src) + 4) 308c2ecf20Sopenharmony_ci#endif 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) 338c2ecf20Sopenharmony_ci#error "conflicting endian definitions" 348c2ecf20Sopenharmony_ci#elif defined(CONFIG_X86_64) || defined(CONFIG_ARM64) 358c2ecf20Sopenharmony_ci#define LZO_USE_CTZ64 1 368c2ecf20Sopenharmony_ci#define LZO_USE_CTZ32 1 378c2ecf20Sopenharmony_ci#define LZO_FAST_64BIT_MEMORY_ACCESS 388c2ecf20Sopenharmony_ci#elif defined(CONFIG_X86) || defined(CONFIG_PPC) 398c2ecf20Sopenharmony_ci#define LZO_USE_CTZ32 1 408c2ecf20Sopenharmony_ci#elif defined(CONFIG_ARM) && (__LINUX_ARM_ARCH__ >= 5) 418c2ecf20Sopenharmony_ci#define LZO_USE_CTZ32 1 428c2ecf20Sopenharmony_ci#endif 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define M1_MAX_OFFSET 0x0400 458c2ecf20Sopenharmony_ci#define M2_MAX_OFFSET 0x0800 468c2ecf20Sopenharmony_ci#define M3_MAX_OFFSET 0x4000 478c2ecf20Sopenharmony_ci#define M4_MAX_OFFSET_V0 0xbfff 488c2ecf20Sopenharmony_ci#define M4_MAX_OFFSET_V1 0xbffe 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define M1_MIN_LEN 2 518c2ecf20Sopenharmony_ci#define M1_MAX_LEN 2 528c2ecf20Sopenharmony_ci#define M2_MIN_LEN 3 538c2ecf20Sopenharmony_ci#define M2_MAX_LEN 8 548c2ecf20Sopenharmony_ci#define M3_MIN_LEN 3 558c2ecf20Sopenharmony_ci#define M3_MAX_LEN 33 568c2ecf20Sopenharmony_ci#define M4_MIN_LEN 3 578c2ecf20Sopenharmony_ci#define M4_MAX_LEN 9 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define M1_MARKER 0 608c2ecf20Sopenharmony_ci#define M2_MARKER 64 618c2ecf20Sopenharmony_ci#define M3_MARKER 32 628c2ecf20Sopenharmony_ci#define M4_MARKER 16 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define MIN_ZERO_RUN_LENGTH 4 658c2ecf20Sopenharmony_ci#define MAX_ZERO_RUN_LENGTH (2047 + MIN_ZERO_RUN_LENGTH) 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define lzo_dict_t unsigned short 688c2ecf20Sopenharmony_ci#define D_BITS 13 698c2ecf20Sopenharmony_ci#define D_SIZE (1u << D_BITS) 708c2ecf20Sopenharmony_ci#define D_MASK (D_SIZE - 1) 718c2ecf20Sopenharmony_ci#define D_HIGH ((D_MASK >> 1) + 1) 72