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 the listing below. Note that all unused function pointers should be set to DEF_NULL
.
Listing 15-10 API structure type for generic controller extension
L15-10(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.
L15-10(2) The Open()
function is called by the generic controller’s own Open()
function. This function will also receive the controller extension configuration pointer.
L15-10(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.
L15-10(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).
L15-10(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.
L15-10(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.
L15-10(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.