Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Richard Purdie | 64c70b1 | 2007-07-10 17:22:24 -0700 | [diff] [blame] | 2 | /* |
| 3 | * lzodefs.h -- architecture, OS and compiler specific defines |
| 4 | * |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 5 | * Copyright (C) 1996-2012 Markus F.X.J. Oberhumer <markus@oberhumer.com> |
Richard Purdie | 64c70b1 | 2007-07-10 17:22:24 -0700 | [diff] [blame] | 6 | * |
| 7 | * The full LZO package can be found at: |
| 8 | * http://www.oberhumer.com/opensource/lzo/ |
| 9 | * |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 10 | * Changed for Linux kernel use by: |
Richard Purdie | 64c70b1 | 2007-07-10 17:22:24 -0700 | [diff] [blame] | 11 | * Nitin Gupta <nitingupta910@gmail.com> |
| 12 | * Richard Purdie <rpurdie@openedhand.com> |
| 13 | */ |
| 14 | |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 15 | |
Dave Rodgman | 5ee4014 | 2019-03-07 16:30:40 -0800 | [diff] [blame] | 16 | /* Version |
| 17 | * 0: original lzo version |
| 18 | * 1: lzo with support for RLE |
| 19 | */ |
| 20 | #define LZO_VERSION 1 |
| 21 | |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 22 | #define COPY4(dst, src) \ |
| 23 | put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst)) |
Matt Sealey | 761b323 | 2019-03-07 16:30:36 -0800 | [diff] [blame] | 24 | #if defined(CONFIG_X86_64) || defined(CONFIG_ARM64) |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 25 | #define COPY8(dst, src) \ |
| 26 | put_unaligned(get_unaligned((const u64 *)(src)), (u64 *)(dst)) |
| 27 | #else |
| 28 | #define COPY8(dst, src) \ |
| 29 | COPY4(dst, src); COPY4((dst) + 4, (src) + 4) |
| 30 | #endif |
| 31 | |
| 32 | #if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) |
| 33 | #error "conflicting endian definitions" |
Matt Sealey | 433b3b3 | 2019-03-07 16:30:33 -0800 | [diff] [blame] | 34 | #elif defined(CONFIG_X86_64) || defined(CONFIG_ARM64) |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 35 | #define LZO_USE_CTZ64 1 |
| 36 | #define LZO_USE_CTZ32 1 |
Dave Rodgman | 5ee4014 | 2019-03-07 16:30:40 -0800 | [diff] [blame] | 37 | #define LZO_FAST_64BIT_MEMORY_ACCESS |
Dave Rodgman | 9577759 | 2019-03-07 16:30:29 -0800 | [diff] [blame] | 38 | #elif defined(CONFIG_X86) || defined(CONFIG_PPC) |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 39 | #define LZO_USE_CTZ32 1 |
Dave Rodgman | 9577759 | 2019-03-07 16:30:29 -0800 | [diff] [blame] | 40 | #elif defined(CONFIG_ARM) && (__LINUX_ARM_ARCH__ >= 5) |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 41 | #define LZO_USE_CTZ32 1 |
| 42 | #endif |
Richard Purdie | 64c70b1 | 2007-07-10 17:22:24 -0700 | [diff] [blame] | 43 | |
| 44 | #define M1_MAX_OFFSET 0x0400 |
| 45 | #define M2_MAX_OFFSET 0x0800 |
| 46 | #define M3_MAX_OFFSET 0x4000 |
Dave Rodgman | 45ec975 | 2019-03-07 16:30:44 -0800 | [diff] [blame] | 47 | #define M4_MAX_OFFSET_V0 0xbfff |
| 48 | #define M4_MAX_OFFSET_V1 0xbffe |
Richard Purdie | 64c70b1 | 2007-07-10 17:22:24 -0700 | [diff] [blame] | 49 | |
| 50 | #define M1_MIN_LEN 2 |
| 51 | #define M1_MAX_LEN 2 |
| 52 | #define M2_MIN_LEN 3 |
| 53 | #define M2_MAX_LEN 8 |
| 54 | #define M3_MIN_LEN 3 |
| 55 | #define M3_MAX_LEN 33 |
| 56 | #define M4_MIN_LEN 3 |
| 57 | #define M4_MAX_LEN 9 |
| 58 | |
| 59 | #define M1_MARKER 0 |
| 60 | #define M2_MARKER 64 |
| 61 | #define M3_MARKER 32 |
| 62 | #define M4_MARKER 16 |
| 63 | |
Dave Rodgman | 5ee4014 | 2019-03-07 16:30:40 -0800 | [diff] [blame] | 64 | #define MIN_ZERO_RUN_LENGTH 4 |
| 65 | #define MAX_ZERO_RUN_LENGTH (2047 + MIN_ZERO_RUN_LENGTH) |
| 66 | |
Markus F.X.J. Oberhumer | 8b975bd | 2012-08-13 17:25:44 +0200 | [diff] [blame] | 67 | #define lzo_dict_t unsigned short |
| 68 | #define D_BITS 13 |
| 69 | #define D_SIZE (1u << D_BITS) |
| 70 | #define D_MASK (D_SIZE - 1) |
Richard Purdie | 64c70b1 | 2007-07-10 17:22:24 -0700 | [diff] [blame] | 71 | #define D_HIGH ((D_MASK >> 1) + 1) |