📄 systffs.c
字号:
/* sysTffs.c - Wind River SBC8260 system-dependent TrueFFS library *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01c,20mar02,kab T2.2 update01b,11may01,g_h cleaning01a,29dec00,jec ported from ADS860 driver.*//*DESCRIPTIONThis library provides board-specific hardware access routines for TrueFFS.In effect, these routines comprise the socket component driver (or drivers)for your flash device hardware. At socket registration time, TrueFFS storespointers to the functions of this socket component driver in an 'FLSocket'structure. When TrueFFS needs to access the flash device, it uses thesefunctions.Because this file is, for the most part, a device driver that exports itsfunctionality by registering function pointers with TrueFFS, very few of thefunctions defined here are externally callable. For the record, theseexternal functions are flFitInSocketWindow() and flDelayLoop(). You shouldnever have any need to call these functions.However, one of the most import functions defined in this file is neitherreferenced in an 'FLSocket' structure, nor is it externally callable. Thisfunction is sysTffsInit(). TrueFFS calls this function at initializationtime to register socket component drivers for all the flash devices attachedto your target. It is this call to sysTffs() that results in assigningdrive numbers to the flash devices on your target hardware. Drive numbersare assigned by the order in which the socket component drivers are registered.The first to be registered is drive 0, the second is drive 1, and so on up to4. As shipped, TrueFFS supports up to five flash drives.After registering socket component drivers for a flash device, you mayformat the flash medium even though there is not yet a block device driverassociated with the flash (see the reference entry for the tffsDevCreate()routine). To format the flash medium for use with TrueFFS,call tffsDevFormat() or, for some BSPs, sysTffsFormat().The sysTffsFormat() routine is an optional but BSP-specific externallycallable helper function. Internally, it calls tffsDevFormat() with apointer to a 'FormatParams' structure initialized to values that leave aspace on the flash device for a boot image. This space is outside theregion managed by TrueFFS. This special region is necessary for bootimages because the normal translation and wear-leveling services of TrueFFSare incompatible with the needs of the boot program and the boot image itrelies upon. To write a boot image (or any other data) into this area,use tffsBootImagePut().Finally, this file also contains define statements for symbolic constantsthat determine which MTDs, translation layer modules, and other utilitiesare ultimately included in TrueFFS. These defines are as follows:.IP "INCLUDE_TL_NFTL"To include the NAND-based translation layer module..IP "INCLUDE_TL_FTL"To include the NOR-based translation layer module..IP "INCLUDE_TL_SSFDC"To include the SSFDC-appropriate translation layer module..IP "INCLUDE_MTD_I28F016"For Intel 28f016 flash devices..IP "INCLUDE_MTD_I28F008"For Intel 28f008 flash devices..IP "INCLUDE_MTD_I28F008_BAJA"For Intel 28f008 flash devices on the Heurikon Baja 4700..IP "INCLUDE_MTD_AMD"For AMD, Fujitsu: 29F0{40,80,16} 8-bit flash devices..IP "INCLUDE_MTD_CDSN"For Toshiba, Samsung: NAND CDSN flash devices..IP "INCLUDE_MTD_DOC2"For Toshiba, Samsung: NAND DOC flash devices..IP "INCLUDE_MTD_CFISCS"For CFI/SCS flash devices..IP "INCLUDE_MTD_WAMD"For AMD, Fujitsu 29F0{40,80,16} 16-bit flash devices..IP "INCLUDE_TFFS_BOOT_IMAGE"To include tffsBootImagePut() in TrueFFS for Tornado..LPTo exclude any of the modules mentioned above, edit sysTffs.c and undefineits associated symbolic constant.The function sysTffsFormat() is provided so one might seasily format theFlash SIMM to have the TFFS file system in one half of it.INCLUDE FILES: flsocket.h, tffsDrv.h*//* includes */#include "vxWorks.h"#include "taskLib.h"#include "config.h"#include "tffs/flsocket.h"#include "tffs/tffsDrv.h"/* defines */#ifndef PRJ_BUILD#undef INCLUDE_MTD_I28F016 /* Intel: 28f016 */#undef INCLUDE_MTD_I28F008 /* Intel: 28f008 */#define INCLUDE_MTD_AMD /* AMD, Fujitsu: 29f0{40,80,16} 8bit */#undef INCLUDE_MTD_CDSN /* Toshiba, Samsung: NAND, CDSN */#undef INCLUDE_MTD_DOC2 /* Toshiba, Samsung: NAND, DOC */#undef INCLUDE_MTD_CFISCS /* CFI/SCS */#undef INCLUDE_MTD_WAMD /* AMD, Fujitsu: 29f0{40,80,16} 16bit */#undef INCLUDE_TL_NFTL /* NFTL translation layer */#define INCLUDE_TL_FTL /* FTL translation layer */#undef INCLUDE_TL_SSFDC /* SSFDC translation layer */#endif /* PRJ_BUILD */#define INCLUDE_SOCKET_SIMM /* SIMM socket interface */#undef INCLUDE_SOCKET_PCMCIA /* PCMCIA socket interface */#define INCLUDE_TFFS_BOOT_IMAGE /* include tffsBootImagePut() */#define FLASH_BASE_ADRS CS6_FLASH_ADRS /* Flash memory base address */#define FLASH_SIZE CS6_FLASH_SIZE /* Flash memory size */#undef HALF_FORMAT /* lower 0.5MB for bootimage, upper 1.5MB for TFFS */#define VCC_DELAY_MSEC 100 /* Millisecs to wait for Vcc ramp up */#define VPP_DELAY_MSEC 100 /* Millisecs to wait for Vpp ramp up */#define BCSR1_PCCVPP_12V 0x00200000#define KILL_TIME_FUNC ((iz * iz) / (iz + iz)) / ((iy + iz) / (iy * iz))/* locals */LOCAL UINT32 sysTffsMsecLoopCount = 0;/* forward declarations */#ifdef INCLUDE_SOCKET_SIMMLOCAL FLBoolean simmCardDetected (FLSocket vol);LOCAL void simmVccOn (FLSocket vol);LOCAL void simmVccOff (FLSocket vol);#ifdef SOCKET_12_VOLTSLOCAL FLStatus simmVppOn (FLSocket vol);LOCAL void simmVppOff (FLSocket vol);#endif /* SOCKET_12_VOLTS */LOCAL FLStatus simmInitSocket (FLSocket vol);LOCAL void simmSetWindow (FLSocket vol);LOCAL void simmSetMappingContext (FLSocket vol, unsigned page);LOCAL FLBoolean simmGetAndClearCardChangeIndicator (FLSocket vol);LOCAL FLBoolean simmWriteProtected (FLSocket vol);LOCAL void simmRegister (void);#endif /* INCLUDE_SOCKET_SIMM */#ifdef INCLUDE_SOCKET_PCMCIALOCAL FLBoolean pcCardDetected (FLSocket vol);LOCAL void pcVccOn (FLSocket vol);LOCAL void pcVccOff (FLSocket vol);#ifdef SOCKET_12_VOLTSLOCAL FLStatus pcVppOn (FLSocket vol);LOCAL void pcVppOff (FLSocket vol);#endif /* SOCKET_12_VOLTS */LOCAL FLStatus pcInitSocket (FLSocket vol);LOCAL void pcSetWindow (FLSocket vol);LOCAL void pcSetMappingContext (FLSocket vol, unsigned page);LOCAL FLBoolean pcGetAndClearCardChangeIndicator (FLSocket vol);LOCAL FLBoolean pcWriteProtected (FLSocket vol);LOCAL void pcRegister (void);#endif /* INCLUDE_SOCKET_PCMCIA */#ifndef DOC#include "tffs/tffsConfig.c"#endif /* DOC *//********************************************************************************* sysTffsInit - board level initialization for TFFS** This routine calls the socket registration routines for the socket component* drivers that will be used with this BSP. The order of registration signifies* the logical drive number given to the drive associated with the socket.** RETURNS: N/A*/LOCAL void sysTffsInit ( void ) { UINT32 ix = 0; UINT32 iy = 1; UINT32 iz = 2; int oldTick; /* we assume followings: * - no interrupts except timer is happening. * - the loop count that consumes 1 msec is in 32 bit. * it is done in the early stage of usrRoot() in tffsDrv(). */ oldTick = tickGet (); while (oldTick == tickGet ()) /* wait for next clock interrupt */ ; oldTick = tickGet (); while (oldTick == tickGet ()) /* loop one clock tick */ { iy = KILL_TIME_FUNC; /* consume time */ ix++; /* increment the counter */ } sysTffsMsecLoopCount = ix * sysClkRateGet () / 1000;#ifdef INCLUDE_SOCKET_SIMM simmRegister (); /* SIMM socket interface register */#endif /* INCLUDE_SOCKET_SIMM */#ifdef INCLUDE_SOCKET_PCMCIA pcRegister (); /* PCMCIA socket interface register */#endif /* INCLUDE_SOCKET_PCMCIA */ }#ifdef INCLUDE_SOCKET_SIMM/********************************************************************************* simmRegister - install routines for the Flash SIMM** This routine installs necessary functions for the Flash SIMM.** RETURNS: N/A*/LOCAL void simmRegister ( void ) { FLSocket vol = flSocketOf (noOfDrives);#if (CS6_FLASH_SIZE == FLASH_SIZE_4MB) tffsSocket[noOfDrives] = "SIMM";#else /* On Board FLASH */ tffsSocket[noOfDrives] = "OnBoard";#endif /* (CS6_FLASH_SIZE == FLASH_SIZE_4MB) */ vol.window.baseAddress = (unsigned int)(FLASH_BASE_ADRS >> 12); vol.cardDetected = simmCardDetected; vol.VccOn = simmVccOn; vol.VccOff = simmVccOff;#ifdef SOCKET_12_VOLTS vol.VppOn = simmVppOn; vol.VppOff = simmVppOff;#endif vol.initSocket = simmInitSocket; vol.setWindow = simmSetWindow; vol.setMappingContext = simmSetMappingContext; vol.getAndClearCardChangeIndicator = simmGetAndClearCardChangeIndicator; vol.writeProtected = simmWriteProtected; noOfDrives++; }/********************************************************************************* simmCardDetected - detect if a card is present (inserted)** This routine detects if a card is present (inserted).** RETURNS: TRUE, or FALSE if the card is not present.*/LOCAL FLBoolean simmCardDetected ( FLSocket vol /* pointer identifying drive */ ) { return (TRUE); }/********************************************************************************* simmVccOn - turn on Vcc (3.3/5 Volts)** This routine turns on Vcc (3.3/5 Volts). Vcc must be known to be good* on exit.** RETURNS: N/A*/LOCAL void simmVccOn ( FLSocket vol /* pointer identifying drive */ ) { }/********************************************************************************* simmVccOff - turn off Vcc (3.3/5 Volts)** This routine turns off Vcc (3.3/5 Volts).** RETURNS: N/A*/LOCAL void simmVccOff ( FLSocket vol /* pointer identifying drive */ ) { }#ifdef SOCKET_12_VOLTS/********************************************************************************* simmVppOn - turns on Vpp (12 Volts)** This routine turns on Vpp (12 Volts). Vpp must be known to be good on exit.** RETURNS: flOK always.*/LOCAL FLStatus simmVppOn ( FLSocket vol /* pointer identifying drive */ ) { return (flOK); }/********************************************************************************* simmVppOff - turns off Vpp (12 Volts)** This routine turns off Vpp (12 Volts).** RETURNS: N/A*/LOCAL void simmVppOff ( FLSocket vol /* pointer identifying drive */ ) { }#endif /* SOCKET_12_VOLTS *//********************************************************************************* simmInitSocket - perform all necessary initializations of the socket** This routine performs all necessary initializations of the socket.** RETURNS: flOK always.*/LOCAL FLStatus simmInitSocket ( FLSocket vol /* pointer identifying drive */ ) { return (flOK); }/********************************************************************************* simmSetWindow - set current window attributes, Base address, size, etc** This routine sets current window hardware attributes: Base address, size,* speed and bus width. The requested settings are given in the 'vol.window'* structure. If it is not possible to set the window size requested in* 'vol.window.size', the window size should be set to a larger value,* if possible. In any case, 'vol.window.size' should contain the* actual window size (in 4 KB units) on exit.** RETURNS: N/A*/LOCAL void simmSetWindow ( FLSocket vol /* pointer identifying drive */ ) { /* Physical base as a 4K page */ vol.window.baseAddress = (unsigned int)(FLASH_BASE_ADRS >> 12); flSetWindowSize (&vol, FLASH_SIZE >> 12); }/********************************************************************************* simmSetMappingContext - sets the window mapping register to a card address** This routine sets the window mapping register to a card address.* The window should be set to the value of 'vol.window.currentPage',* which is the card address divided by 4 KB. An address over 128MB,* (page over 32K) specifies an attribute-space address.** The page to map is guaranteed to be on a full window-size boundary.** RETURNS: N/A*/LOCAL void simmSetMappingContext ( FLSocket vol, /* pointer identifying drive */ unsigned page /* page to be mapped */ ) { }/********************************************************************************* simmGetAndClearCardChangeIndicator - return the hardware card-change indicator** This routine returns the hardware card-change indicator and clears it if set.** RETURNS: FALSE, or TRUE if the card has been changed*/LOCAL FLBoolean simmGetAndClearCardChangeIndicator ( FLSocket vol /* pointer identifying drive */ ) { return (FALSE); }/********************************************************************************* simmWriteProtected - return the write-protect state of the media** This routine returns the write-protect state of the media** RETURNS: FALSE, or TRUE if the card is write-protected*/LOCAL FLBoolean simmWriteProtected ( FLSocket vol /* pointer identifying drive */ ) { return (FALSE); }#endif /* INCLUDE_SOCKET_SIMM */#ifdef INCLUDE_SOCKET_PCMCIA/********************************************************************************* pcRegister - install routines for the PCMCIA Flash Card** This routine installs necessary functions for the PCMCIA Flash Card.** RETURNS: N/A*/LOCAL void pcRegister ( void ) { FLSocket vol = flSocketOf (noOfDrives); tffsSocket[noOfDrives] = "PCMCIA"; vol.window.baseAddress = (PC_BASE_ADRS_0) >> 12; vol.cardDetected = pcCardDetected; vol.VccOn = pcVccOn; vol.VccOff = pcVccOff;#ifdef SOCKET_12_VOLTS vol.VppOn = pcVppOn;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -