3.1   Introduction

The purpose of this chapter is to provide you with a description of the interface between your flash memory hardware, TrueFFS for Tornado, and VxWorks. Thus, this chapter describes all the standard functions and structures essential to a socket component driver and an MTD. The two structures that are your main concern are the FLFlash structure and the FLSocket structure.

Internally, TrueFFS for Tornado allocates an array containing five FLFlash structures, one for each possible flash device. TrueFFS uses the FLFlash structure to store the data and function pointers it needs to manage the flash device. For example, it is the FLFlash structure that contains the MTD function pointers that TrueFFS uses to handle the low-level details of reading and writing the flash medium. These function pointers are installed by running an MTD identify routine.

The FLFlash structure also contains a pointer to an FLSocket structure. TrueFFS uses this FLSocket structure to store the data and function pointers it uses to handle the hardware (socket) interface to the flash device. These functions are installed by calls from your sysTffsInit( ) to the xxxRegister( ) routines.


*   

NOTE: TrueFFS for Tornado ships with a set of MTDs that supports a wide variety of flash devices. Thus, it is likely that you do not need to write your own MTD, although you are always free to do so. For a list of the flash devices currently supported, see 3.5 MTD-Supported Flash Devices.
Registering Your Socket Component Driver with TrueFFS

Including TrueFFS in VxWorks configures usrRoot( ) to call tffsDrv( ). This starts the chain of function calls shown in Figure 3-1. One of the goals of these function calls is to register the functions of your socket component driver with TrueFFS.

For the most part, the bulk of the work takes place in xxxRegister( ), a function defined in sysTffs.c. The xxxRegister( )function updates the FLSocket structure that TrueFFS has assigned to a drive number (volume) with references to the socket services available in the socket component driver. TrueFFS calls the functions referenced in the FLSocket structure to handle the hardware interface to the flash device.

Identifying an MTD for the Flash Technology

To create a TrueFFS block device, you must call tffsDevCreate( ). Internally, the call to tffsDevCreate( ) gives rise to the chain of function calls shown in Figure 3-2. One of the goals of these function calls is the identification of the MTD appropriate to the flash technology. This identification takes place in flIdentifyFlash( ). This function steps through a table of xxxIdentify( ) routines, executing each routine until one succeeds. 1

Upon success, the identify routine updates the FLFlash structure with data and pointers to the MTDs routines for reading, writing, erasing, and mapping the flash media. Identification also completes the initialization of the FLSocket structure referenced within this FLFlash structure.


*   

NOTE: Included with TrueFFS for Tornado are sources for several MTDs and socket component drivers. The MTDs are in target/src/drv/tffs. The socket component drivers are defined in the sysTffs.c files provided in the target/config/bspname directory for each BSP that supports TrueFFS.

1:  The same MTD could be simultaneously active on multiple flash volumes.