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

📄 ecc.h

📁 <B>SMSC USB2.0 Flash硬盘驱动源码</B>
💻 H
字号:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// ecc library
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

//+-----------------------------------------------------------------------------
// Name:
//   ecc_correct()
//
// Declaration:
//   int8 ecc_correct(uint8 *,uint8 *,uint8 *) reentrant ;
//
// Purpose:
//   use ecc correction on databuf using ecc values from redundant
//   data buffer.  the ecc values are then recomputed and returned in
//   in the 3 byte eccbuf.
//
// Arguments:
//  databuf   - 512 byte buffer to run through the ecc_correction
//  redtbuf   - redundant data buffer (to be fixed)
//  eccbuf    - 3 byte buffer to store corrected ecc data
//
// Return:
//   - k_success - if the buffer contained no ecc errors
//   - k_ecc_corrected_buf_err - if the buffer contained a single bit error,
//             and has already been corrected (buffer contains valid data)
//   - k_ecc_corrected_buf_err - if the buf_ecc lp_hi, lp_lo, or cp contained
//             an error.  the buf_ecc and ecc variables will have the ecc code
//             for the given buffer.
//   - k_ecc_uncorrectable_err - if the buffer contains too many errors to
//             correct.
//
// Notes:
//   This is a FUNCTION, not a DFA.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
#define k_ecc_success                 k_success
#define k_ecc_corrected_buf_err       0x80
#define k_ecc_corrected_ecc_code_err  0x81
#define k_ecc_uncorrectable_err       0x82

t_result ecc_sw_correct(uint8* buf, uint8* redtbuf, uint8* eccbuf ) reentrant ;


//+-----------------------------------------------------------------------------
// Name:
//   ecc_sw_calculate()
//
// Declaration:
//   int8 ecc_correct(uint8 *) reentrant ;
//
// Purpose:
//   calculates ecc lp and cp values from a given 512 byte buffer
//
// Arguments:
//  databuf   - 512 byte buffer to obtain ecc values
//
// Return:
//  none
//
// Notes:
//   This is a FUNCTION, not a DFA.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
void ecc_sw_calculate(uint8 *) reentrant ;

//+-----------------------------------------------------------------------------
// Name:
//   ecc_sw_calculate()
//
// Declaration:
//   int8 ecc_correct(uint8 *) reentrant ;
//
// Purpose:
//   calculates ecc lp and cp values from a given 512 byte buffer
//
// Arguments:
//  databuf   - 512 byte buffer to obtain ecc values
//
// Return:
//  none
//
// Notes:
//   This is a FUNCTION, not a DFA.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
t_result ecc_check_rd_error() reentrant ;


//+-----------------------------------------------------------------------------
// Name:
//   ecc_sw_calculate()
//
// Declaration:
//   int8 ecc_correct(uint8 *) reentrant ;
//
// Purpose:
//   calculates ecc lp and cp values from a given 512 byte buffer
//
// Arguments:
//  databuf   - 512 byte buffer to obtain ecc values
//
// Return:
//  none
//
// Notes:
//   This is a FUNCTION, not a DFA.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
// void ecc_load_from_hw(uint8 pg) reentrant ;

//+-----------------------------------------------------------------------------
// Name:
//   ecc_sw_calculate()
//
// Declaration:
//   int8 ecc_correct(uint8 *) reentrant ;
//
// Purpose:
//   calculates ecc lp and cp values from a given 512 byte buffer
//
// Arguments:
//  databuf   - 512 byte buffer to obtain ecc values
//
// Return:
//  none
//
// Notes:
//   This is a FUNCTION, not a DFA.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
// void ecc_load_from_redt_data(void) reentrant ;

//+-----------------------------------------------------------------------------
// Name:
//   ecc_sw_calculate()
//
// Declaration:
//   int8 ecc_correct(uint8 *) reentrant ;
//
// Purpose:
//   calculates ecc lp and cp values from a given 512 byte buffer
//
// Arguments:
//  databuf   - 512 byte buffer to obtain ecc values
//
// Return:
//  none
//
// Notes:
//   This is a FUNCTION, not a DFA.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
t_result ecc_check_and_correct(uint8 *sector) reentrant ;

// extern xdata uint8  smil_ecc1 ;     /* LP 15-8 */
// extern xdata uint8  smil_ecc2 ;     /* LP 7-0  */
// extern xdata uint8  smil_ecc3 ;     /* CP 5-0,"1","1" */

extern xdata uint8 x_eccbuf[6];

typedef union u_ecc
{
  uint8 ecc[3] ;
  struct
  {
    uint8 lp_lo;  // lsw msb
    uint8 lp_hi;  // msw lsb
    uint8 cp;     // lsw lsb
  } u8 ;
} t_ecc ;

extern xdata t_ecc ecc_pg_1 ;
extern xdata t_ecc ecc_pg_2 ;

extern xdata uint8 buf_ecc_lp_hi ;  // line parity hi-byte (LP 15-8)
extern xdata uint8 buf_ecc_lp_lo ;  // line parity lo-byte (LP 7-0)
extern xdata uint8 buf_ecc_cp ;     // column parity bits  (CP 5-0,"1","1")
extern xdata uint8 ecc_lp_hi ;  // line parity hi-byte (LP 15-8)
extern xdata uint8 ecc_lp_lo ;  // line parity lo-byte (LP 7-0)
extern xdata uint8 ecc_cp ;     // column parity bits  (CP 5-0,"1","1")

⌨️ 快捷键说明

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