![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * Generic binary BCH encoding/decoding library 0004 * 0005 * Copyright © 2011 Parrot S.A. 0006 * 0007 * Author: Ivan Djelic <ivan.djelic@parrot.com> 0008 * 0009 * Description: 0010 * 0011 * This library provides runtime configurable encoding/decoding of binary 0012 * Bose-Chaudhuri-Hocquenghem (BCH) codes. 0013 */ 0014 #ifndef _BCH_H 0015 #define _BCH_H 0016 0017 #include <linux/types.h> 0018 0019 /** 0020 * struct bch_control - BCH control structure 0021 * @m: Galois field order 0022 * @n: maximum codeword size in bits (= 2^m-1) 0023 * @t: error correction capability in bits 0024 * @ecc_bits: ecc exact size in bits, i.e. generator polynomial degree (<=m*t) 0025 * @ecc_bytes: ecc max size (m*t bits) in bytes 0026 * @a_pow_tab: Galois field GF(2^m) exponentiation lookup table 0027 * @a_log_tab: Galois field GF(2^m) log lookup table 0028 * @mod8_tab: remainder generator polynomial lookup tables 0029 * @ecc_buf: ecc parity words buffer 0030 * @ecc_buf2: ecc parity words buffer 0031 * @xi_tab: GF(2^m) base for solving degree 2 polynomial roots 0032 * @syn: syndrome buffer 0033 * @cache: log-based polynomial representation buffer 0034 * @elp: error locator polynomial 0035 * @poly_2t: temporary polynomials of degree 2t 0036 * @swap_bits: swap bits within data and syndrome bytes 0037 */ 0038 struct bch_control { 0039 unsigned int m; 0040 unsigned int n; 0041 unsigned int t; 0042 unsigned int ecc_bits; 0043 unsigned int ecc_bytes; 0044 /* private: */ 0045 uint16_t *a_pow_tab; 0046 uint16_t *a_log_tab; 0047 uint32_t *mod8_tab; 0048 uint32_t *ecc_buf; 0049 uint32_t *ecc_buf2; 0050 unsigned int *xi_tab; 0051 unsigned int *syn; 0052 int *cache; 0053 struct gf_poly *elp; 0054 struct gf_poly *poly_2t[4]; 0055 bool swap_bits; 0056 }; 0057 0058 struct bch_control *bch_init(int m, int t, unsigned int prim_poly, 0059 bool swap_bits); 0060 0061 void bch_free(struct bch_control *bch); 0062 0063 void bch_encode(struct bch_control *bch, const uint8_t *data, 0064 unsigned int len, uint8_t *ecc); 0065 0066 int bch_decode(struct bch_control *bch, const uint8_t *data, unsigned int len, 0067 const uint8_t *recv_ecc, const uint8_t *calc_ecc, 0068 const unsigned int *syn, unsigned int *errloc); 0069 0070 #endif /* _BCH_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |