2 * Copyright (c) 2013, James S. Plank and Kevin Greenan
5 * Jerasure - A C/C++ Library for a Variety of Reed-Solomon and RAID-6 Erasure
8 * Revision 2.0: Galois Field backend now links to GF-Complete
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * - Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * - Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
22 * - Neither the name of the University of Tennessee nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
33 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
34 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
36 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
43 #include <gf_complete.h>
49 extern int galois_init_default_field(int w);
50 extern int galois_uninit_field(int w);
51 extern void galois_change_technique(gf_t *gf, int w);
53 extern int galois_single_multiply(int a, int b, int w);
54 extern int galois_single_divide(int a, int b, int w);
55 extern int galois_inverse(int x, int w);
57 void galois_region_xor( char *src, /* Source Region */
58 char *dest, /* Dest Region (holds result) */
59 int nbytes); /* Number of bytes in region */
61 /* These multiply regions in w=8, w=16 and w=32. They are much faster
62 than calling galois_single_multiply. The regions must be long word aligned. */
64 void galois_w08_region_multiply(char *region, /* Region to multiply */
65 int multby, /* Number to multiply by */
66 int nbytes, /* Number of bytes in region */
67 char *r2, /* If r2 != NULL, products go here.
68 Otherwise region is overwritten */
69 int add); /* If (r2 != NULL && add) the produce is XOR'd with r2 */
71 void galois_w16_region_multiply(char *region, /* Region to multiply */
72 int multby, /* Number to multiply by */
73 int nbytes, /* Number of bytes in region */
74 char *r2, /* If r2 != NULL, products go here.
75 Otherwise region is overwritten */
76 int add); /* If (r2 != NULL && add) the produce is XOR'd with r2 */
78 void galois_w32_region_multiply(char *region, /* Region to multiply */
79 int multby, /* Number to multiply by */
80 int nbytes, /* Number of bytes in region */
81 char *r2, /* If r2 != NULL, products go here.
82 Otherwise region is overwritten */
83 int add); /* If (r2 != NULL && add) the produce is XOR'd with r2 */
85 gf_t* galois_init_field(int w,
93 gf_t* galois_init_composite_field(int w,
99 gf_t * galois_get_field_ptr(int w);