-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72f27ce
commit b9f23ba
Showing
4 changed files
with
1,085 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
storage/blockdevice/COMPONENT_SPINAND/include/SPINAND/bch.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2022 Macronix International Co., Ltd. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef _BCH_H | ||
#define _BCH_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
#include <stdint.h> | ||
|
||
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) | ||
|
||
struct bch_code { | ||
unsigned int m; | ||
unsigned int n; | ||
unsigned int t; | ||
unsigned int ecc_bits; | ||
unsigned int ecc_words; | ||
unsigned int len; | ||
unsigned int *a_pow; | ||
unsigned int *a_log; | ||
unsigned int *mod_tab; | ||
unsigned int *ecc; | ||
unsigned int *syn; | ||
unsigned int *elp; | ||
unsigned int *buf; | ||
unsigned int *buf2; | ||
unsigned char *input_data; | ||
unsigned int endian; | ||
}; | ||
|
||
struct bch_code *bch_init(unsigned int m, unsigned int t); | ||
void bch_free(struct bch_code *bch); | ||
void bch_encode(struct bch_code *bch, unsigned char *data, unsigned int *ecc); | ||
int bch_decode(struct bch_code *bch, unsigned char *data, unsigned int *ecc); | ||
int fls(int x); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
Oops, something went wrong.