Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The generic controller extension layer allows extending the generic controller through a number of hook functions that are used by the generic controller, when flexibility in handling a specific operation is desirable. A generic controller extension is defined through a structure of type FS_NAND_CTRLR_GEN_EXT, described in Listing 15-10- API structure type for generic controller extension. Note that all unused function pointers should be set to DEF_NULL.

Code Block
languagecpp
titleListing

...

-

...

API structure type for generic controller extension

...

linenumberstrue
typedef  struct  fs_nand_ctrlr_gen_ext {
    void              (*Init)        (FS_ERR                  *p_err);        (1)
 
    void             *(*Open)        (FS_NAND_CTRLR_GEN_DATA  *p_ctrlr_data,  (2)
                                      void                    *p_ext_cfg,
                                      FS_ERR                  *p_err);
 
    void              (*Close)       (void                    *p_ext_data);   (3)
 
    FS_NAND_PG_SIZE   (*Setup)       (FS_NAND_CTRLR_GEN_DATA  *p_ctrlr_data,  (4)
                                      void                    *p_ext_data,
                                      FS_ERR                  *p_err);
 
    void              (*RdStatusChk) (void                    *p_ext_data,    (5)
                                      FS_ERR                  *p_err);
 
    void              (*ECC_Calc)    (void                    *p_ext_data,    (6)
                                      void                    *p_sec_buf,
                                      void                    *p_oos_buf,
                                      FS_NAND_PG_SIZE          oos_size,
                                      FS_ERR                  *p_err);
 
    void              (*ECC_Verify)  (void                    *p_ext_data,    (7)
                                      void                    *p_sec_buf,
                                      void                    *p_oos_buf,
                                      FS_NAND_PG_SIZE          oos_size,
                                      FS_ERR                  *p_err);
} FS_NAND_CTLRR_GEN_EXT;


Panel

(1) The Init() funtion provides an opportunity to initialize an extension. This will be called only once, when the extension is registered with the generic controller (

...

during FSDev_Open()). If multiple generic controller instances are configured with the same extension,

...

the Init()

...

 function will still be called only once.

...

(2)

...

 The Open()

...

 function is called by the generic controller’s

...

own Open() function. This function will also receive the controller extension configuration pointer.

...

(3)

...

 The Close() function might be called by the generic controller’s own Close() function and allow the extension to release its resources. Close()

...

 will typically never be called.

...

(4)

...

 The Setup()

...

 function is called during the generic controller’s

...

own Setup() function and provides an opportunity to setup some internal parameters according to the generic controller’s operating conditions. The generic controller’s instance data is provided as an argument to this function. The function must return the amount of required OOS storage space, in octets (ECC data, for example).

...

(5)

...

 The RdStatusChk()

...

 function is called after a sector read operation, by the generic

...

controller’s SecRd()

...

 function. It should determine if a read error has occurred and return an error accordingly.

...

(6)

...

 The ECC_Calc()

...

 function is called before a sector is written to the NAND device by the generic

...

controller’s SecWr()

...

 function, and provides an opportunity to calculate the ECC data and to append it to the OOS metadata.

...

(7)

...

 The ECC_Verify() function is called after a sector is read from the NAND device by the generic controller’s SecRd() function. It should read the ECC data from the OOS metadata, verify the sector and OOS data integrity, and correct any errors found if possible. It should return an appropriate error code if ECC errors are found.