⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bch_hm.h

📁 M-System DOC(Disk on a Chip) Flash芯片映像读写工具, 可以进行二片Flash芯片的内容互相拷贝, 提高烧录程序的效率.
💻 H
字号:
/***********************************************************************************/
/*                        M-Systems Confidential                                   */
/*           Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2003            */
/*                         All Rights Reserved                                     */
/***********************************************************************************/
/*                            NOTICE OF M-SYSTEMS OEM                              */
/*                           SOFTWARE LICENSE AGREEMENT                            */
/*                                                                                 */
/*      THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE                 */
/*      AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT           */
/*      FOR THE SPECIFIC TERMS AND CONDITIONS OF USE,                              */
/*      OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE:                               */
/*      E-MAIL = info@m-sys.com                                                    */
/***********************************************************************************/

/*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/general storage/TrueFFS/src/mtd/bch_hm.h-arc  $
 * 
 *    Rev 1.2   Jun 12 2003 21:43:16   oris
 * Added extern prefix
 * 
 *    Rev 1.1   Jun 12 2003 15:29:16   roneng
 * Add prototype for Hamming syndrom calculation
 * 
 *    Rev 1.0   Apr 09 2003 12:15:54   OriS
 * Initial revision.
 * 
 */

/*****************************************************************************/
/* Header file for ECC software                                              */
/*                                                                           */ 
/* Algorithms and programming were written by :                              */
/*                                                                           */
/*      Itai Dror                                                            */
/*                                                                           */
/*      Fortress Security Division, Omer                                     */
/*      M - Systems, Flash Disk Pioneers                                     */ 
/*                                                                           */
/*      email: itaid@m-sys.com                                               */
/*      version 1.0, Feb. 2, 2002                                            */
/*                                                                           */
/*      version 1.02, Dec 10, 2002                                           */
/*      (Disk On Chip naming convention compliance)                          */                  
/*                                                                           */
/*****************************************************************************/

#ifndef __ECCFunctions_h

#define __ECCFunctions_h

/* Enable to test ECC without the translation layer software */

#include "flbase.h" 



/* ***************************************************************************/
/* !!!!!!!!!!!!!!!!!!!!!!!   Warning !!!!         !!!!!!!!!!!!!!!!!!!!!!!    */
/* This optimization feature is valid only for at least 32 bits compilers    */
/*                                                                           */
/* Acceleration of the finite field multiplication routine assumes int is    */
/* at least 32 bits                                                          */
/*                                                                           */
/*   #define FL_ASSUME_NATIVE_IS_32BITS                                      */  
/*                                                                           */
/* ***************************************************************************/

/*  ECC Macros */
#define   Px            0x3088
#define   PAdd(a,b)     ((a)^(b))
#define   Polinome      0x6111
#define   Alpha1Mull(a) (((a)&1)?(PAdd((a),Polinome)>>1):((a)>>1))
#define   Alpha2Mull(a) (((a)>>2)^wAlpha2Table[(a)&3])
#define   Alpha4Mull(a) (((a)>>4)^wAlpha4Table[(a)&0xF])


#define   MAXERRORS            4   /* Maximum number of errors */
/* BCH_FindLocator can deal with more then 4 errors but not the whole        */
/* Software                                                                  */

/* ------------------------------------------------------------------------- */
/* Routines that locate the error bits for BCH and Hamming codes             */
/* These routines convert the syndromes into bit locations of errors         */      
/* The zero bit location is the LS bit of the LS byte                        */
/* The highest bit location refers to the MS bit of the MS byte              */
/*                                                                           */
/* Algorithms and programming were written by :                              */
/*                                                                           */
/*      Itai Dror                                                            */
/*                                                                           */ 
/*      Fortress Security Division, Omer                                     */ 
/*      M - Systems, Flash Disk Pioneers                                     */
/*      email: itaid@m-sys.com                                               */ 
/*                                                                           */
/*      version 1.0, Feb. 2, 2002                                            */                     
/*                                                                           */
/*                                                                           */
/* ------------------------------------------------------------------------- */
/*                                                                           */
/* function:                                                                 */
/*                                                                           */
/*   FLSNative Hamming_FindErrorBit(FLByte Syndrome, FLSNative *errorbit)    */ 
/*                                                                           */
/* description:                                                              */
/*                                                                           */
/*   Hamming decoding 1 error correction / 2 errors detection routine.       */
/*   Find location of error or detects 2 errors.                             */ 
/*   Routine has 1 error correction and 2 errors detection capability.       */
/*   Routine convert 1 byte of syndrome that is calculated by the ECC        */ 
/*   hardware or by a software routine that simulates the ECC hardware       */
/*   into error bit location   in case of Hamming error correction           */
/*   ( 1 error ) or return 0 in case of 2 bits error detection.              */
/*                                                                           */
/* Input:                                                                    */
/*                                                                           */
/*      bSyndrome   -      1 byte ( 8 bits of extended Hamming syndrome )    */
/*      nspageinfosize -      Number of data bytes in pafeinfo               */
/*                     1 <= pageinfosize <= 14                               */
/*                                                                           */
/*      Warnning:   syndrome should not be zero                              */
/*                                                                           */
/* Output:                                                                   */
/*                                                                           */
/*      nserrorbit   -      Bit position of error in case of 1 error         */
/*                                                                           */
/* returned value -                                                          */
/*                                                                           */
/*      1   - Hamming Code can correct the error ( 1 error )                 */
/*      0   - Hamming Code can not correct the errors ( 2 errors or more )   */
/*                                                                           */ 
extern FLSNative Hamming_FindErrorBit(FLByte bSyndrome, 
                 FLSNative nspageinfosize, FLSNative *nserrorbit);
/* ------------------------------------------------------------------------- */
/*                                                                           */
/* function:                                                                 */
/*                                                                           */
/*   FLSNative BCH_FindErrorBits(FLByte bSyndrome[], FLSNative numbytes,     */
/*                                         FLSNative errorbits[])            */
/*                                                                           */
/* description:                                                              */
/*                                                                           */ 
/*   BCH decoding routine. BCH ECC code can correct up to 4 errors           */
/*   or detect more then 4 errors. BCH decoder finds the locations of bits   */
/*  errors. BCH decoder can   correct up to 4 errors. If number of errors is */
/*  greater then 4 then BCH decoder return a value of 5 and cannot correct   */
/*   the errors.   Probability of undetection is 1/800.                      */
/*                                                                           */
/* Input:                                                                    */
/*                                                                           */
/*      bSyndrome[]   -      7 bytes of BCH syndrome                         */
/*      nsnumbytes    -      Number of information bytes                     */
/*                     1 <= numbytes <= 2040                                 */
/*                                                                           */
/*      Warnning:   syndrome should not be zero                              */
/*                                                                           */
/* Output:                                                                   */
/*                                                                           */ 
/*      nserrorbits[]         -      Error locations                         */
/*                                                                           */
/* returned value -                                                          */ 
/*                                                                           */
/*      1,2,3,4   - Number of corrected errors                               */
/*      5      - BCH code detect 5 or more errors                            */
/*                                                                           */
extern FLSNative BCH_FindErrorBits(FLByte bSyndrome[], FLSNative nsnumbytes,       
                     FLSNative nserrorbits[]) ;

/* ------------------------------------------------------------------------- */
/*                                                                           */
/* function: unsigned char Hamming_Syndrome(unsigned char V[],int numbytes)  */ 
/*                                                                           */ 
/* discription:	                                                             */
/*                                                                           */
/* Calculate Hamming syndrome bits for 1 error correction, 2 errors detection*/
/*			                                                                 */
/*                                                                           */ 
/* Perfomance in accelerated using multiplication tables of Hamming g(X)     */
/*                                                                           */
/* Input:                                                                    */
/*		V[]			-		PageInfo bytes + paritybyte                      */
/*		numbytes	-		Number of bytes                                  */
/*                          1 <= numbytes <= 14                              */
/*                                                                           */ 
/* Returned value:                                                           */
/*		1 byte of syndrome                                                   */
/*                                                                           */
/*                                                                           */ 
/* ------------------------------------------------------------------------- */
extern FLByte Hamming_Syndrome(FLByte V[],FLSNative numbytes);
#endif /* __ECCFunctions_h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -