TrueFFS for Tornado is designed to handle a maximum of five TrueFFS block devices. Internally, TrueFFS allocates an FLFlash structure and an FLSocket structure for each of the five possible flash devices. The initialization of these structures starts with the registration of your socket component driver functions with TrueFFS.
For the most part, this registration updates the FLSocket structure referenced by the socket member of FLFlash. The initialization of the FLFlash structure is completed by running an MTD identify routine. Because this identify routine depends on functions referenced in the FLSocket structure, you must install your socket component driver before you can run an MTD identify routine.
Almost all members of the FLFlash structure are set by the MTD identify routine, which gets most of the data it needs by probing the flash hardware. The only exception is the socket member, which is set by functions internal to TrueFFS. The FLFlash structure is defined in h/tffs/flflash.h as follows:1
typedef struct tFlash FLFlash; /* forward definition */ struct tFlash { FlashType type; /* flash device type (JEDEC id) */ long int erasableBlockSize; /* smallest erasable area */ long int chipSize; /* chip size */ int noOfChips; /* no. of chips in array */ int interleaving; /* chip interleaving */ unsigned flags; /* special options */ void * mtdVars; /* MTD private area for socket */ FLSocket * socket; /* FLSocket for this drive */ /* MTD-supplied flash map function */ void FAR0 * (*map)(FLFlash *, CardAddress, int); /* MTD-supplied flash read function */ FLStatus (*read)(FLFlash *, CardAddress, void FAR1 *, int, int); /* MTD-supplied flash write function */ FLStatus (*write)(FLFlash *,CardAddress,const void FAR1 *,int,int) /* MTD-supplied flash erase function */ FLStatus (*erase)(FLFlash *, int, int); /* callback to execute after power up */ void (*setPowerOnCallback)(FLFlash *); };
As a writer of a socket component driver, your primary concern is the initialization of an FLSocket structure. This structure provides TrueFFS with pointers to the functions that you have written to handle the interface with the flash hardware. For the most part, the specifics of how you implement these functions are rather hardware specific.
When relevant, the member descriptions point out WRS-supplied BSPs that you can use as examples. However, your greatest asset in this situation is your intimate knowledge of your particular hardware. The FLSocket structure is defined in h/tffs/flsocket.h as follows:
typedef struct tSocket FLSocket; /* forward definition */ struct tSocket { unsigned volNo; /* volume no. of socket */ unsigned serialNo; /* serial no. of socket on controller */ FLBoolean cardChanged; /* need media change notification */ int VccUsers; /* no. of current VCC users */ int VppUsers; /* No. of current VPP users */ PowerState VccState; /* actual VCC state */ PowerState VppState; /* actual VPP state */ FLBoolean remapped; /* set to TRUE if the socket window is moved */ void (*powerOnCallback)(void *flash); /* notification routine for Vcc on */ void * flash; /* flash object for callback */ struct { /* window state */ unsigned int baseAddress; /* physical base as a 4K page */ unsigned int currentPage; /* our current window page mapping */ void FAR0 * base; /* pointer to window base */ long int size; /* window size (must by power of 2) */ unsigned speed; /* in nsec. */ unsigned busWidth; /* 8 or 16 bits */ } window; FLBoolean (*cardDetected)(FLSocket vol); void (*VccOn)(FLSocket vol); void (*VccOff)(FLSocket vol); #ifdef SOCKET_12_VOLTS FLStatus (*VppOn)(FLSocket vol); void (*VppOff)(FLSocket vol); #endif /* SOCKET_12_VOLTS */ FLStatus (*initSocket)(FLSocket vol); void (*setWindow)(FLSocket vol); void (*setMappingContext)(FLSocket vol, unsigned page); FLBoolean (*getAndClearCardChangeIndicator)(FLSocket vol); FLBoolean (*writeProtected)(FLSocket vol); #ifdef EXIT void (*freeSocket)(FLSocket vol); #endif };
|
NOTE: TrueFFS for Tornado always defines both SOCKET_12_VOLTS and EXIT. Thus, all the members shown above are always included in the TrueFFS for Tornado version of this structure. |
1: If you are not writing an MTD, you can ignore the member descriptions provided for the FLFlash structure and skip ahead to the description of the FLSocket structure.