xref: /illumos-gate/usr/src/uts/common/io/cxgbe/t4nex/fastlz.h (revision 99ea293e719ac006d413e4fde6ac0d5cd4dd6c59)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source. A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13    FastLZ - lightning-fast lossless compression library
14 
15    Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
16    Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
17    Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
18 
19    Permission is hereby granted, free of charge, to any person obtaining a copy
20    of this software and associated documentation files (the "Software"), to deal
21    in the Software without restriction, including without limitation the rights
22    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23    copies of the Software, and to permit persons to whom the Software is
24    furnished to do so, subject to the following conditions:
25 
26    The above copyright notice and this permission notice shall be included in
27    all copies or substantial portions of the Software.
28 
29    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35    THE SOFTWARE.
36 
37    $FreeBSD$
38    */
39 #ifndef FASTLZ_H
40 #define FASTLZ_H
41 
42 #define FASTLZ_VERSION 0x000100
43 
44 #define FASTLZ_VERSION_MAJOR	 0
45 #define FASTLZ_VERSION_MINOR	 0
46 #define FASTLZ_VERSION_REVISION  0
47 
48 #define FASTLZ_VERSION_STRING "0.1.0"
49 
50 struct cudbg_buffer;
51 
52 int fastlz_compress(const void *input, int length, void *output);
53 int fastlz_compress_level(int level, const void *input, int length,
54 			  void *output);
55 int fastlz_decompress(const void *input, int length, void *output, int maxout);
56 
57 /* prototypes */
58 
59 int write_magic(struct cudbg_buffer *);
60 int detect_magic(struct cudbg_buffer *);
61 
62 int write_to_buf(void *, u32, u32 *, void *, u32);
63 int read_from_buf(void *, u32, u32 *, void *,  u32);
64 
65 int write_chunk_header(struct cudbg_buffer *, int, int, unsigned long,
66 		       unsigned long, unsigned long);
67 
68 int read_chunk_header(struct cudbg_buffer *, int* , int*, unsigned long*,
69 		      unsigned long*, unsigned long*);
70 
71 unsigned long block_compress(const unsigned char *, unsigned long length,
72 			     unsigned char *);
73 #endif /* FASTLZ_H */
74