📄 systffs.c
字号:
/* sysTffs.c - ARM integrator TrueFFS Socket Component Driver *//* * Copyright (c) 2000, 2001, 2005, 2007 Wind River Systems, Inc. * * The right to copy, distribute or otherwise make use of this software * may be licensed only pursuant to the terms of an applicable Wind River * license agreement. No license to Wind River intellectual property rights * is granted herein. All rights not licensed by Wind River are reserved * by Wind River. *//*modification history--------------------01g,26sep07,mdo Clear out apigen errors/warnings01f,02may05,mdo SPR#10727201e,09feb05,rec fix manual autogenerate format problems01d,13nov01,nrv made use of PRJ_BUILD01c,09nov01,nrv merging in T3 version with some cleanup01b,14dec00,yp Documentation cleanup01a,29nov00,yp derived from ads860 sysTffs.c 01j.*//*This stub file provides the user with the means to create a TrueFFS compliantsocket component driver for use with any BSP. This is sample code and it isexpected, even required, to be modified after it is added to a BSP by theproject facility when the component INCLUDE_TFFS is added to a kernel project.Look for #error and TODO statements in the sample code.This stub does not provides code, just some procedural macros that thegeneric driver code will use.DESCRIPTIONThis library must provide board-specific hardware access routines for TrueFFS.In effect, these routines comprise the socket component driver (or drivers)for your flash device. At socket registration time, TrueFFS storesthe functions provided by 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, the onlyexternal functions are flFitInSocketWindow() and flDelayLoop(), and you shouldnever have to call them.However, one of the most important functions defined in this file is neitherreferenced in an 'FLSocket' structure, nor is it externally callable. Thisfunction is sysTffsInit() and it should only be called by TrueFFS. TrueFFScalls this function at initialization time to register socket componentdrivers for all the flash devices attached to your target. It is this callto sysTffs() that results in assigning drive numbers to the flash devices onyour target hardware. Drive numbers are assigned by the order in which thesocket component drivers are registered. The first to be registered is drive0, the second is drive 1, and so on up to 4. As shipped, TrueFFS supports upto 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,BSP-specific helper routine thatcan be called externally. Internally, sysTffsFormat() calls tffsDevFormat()with a pointer to a 'FormatParams' structure that is initialized to valuesthat leave a space on the flash device for a boot image. This space is outsidethe region 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().The function sysTffsFormat() is only provided when a Flash SIMM has to havethe TrueFFS file system in some desired fraction of it. It is provided onlyfor the purpose of simplifying the process of formatting a Flash part that should be subdivided.The Flash SIMM might also be referred to as RFA (Resident Flash Array) in thefollowing text.Example implementations of sysTffs.c can be found in the directory $(WIND_BASE)/target/src/drv/tffs/socketsThe files sds860-sysTffs.c and pc386-sysTffs.c have support for single and dualsocketed PCMCIA devices as well if that might be useful to you. They bothsupport multiple sockets.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:\is\i INCLUDE_TL_FTLTo include the NOR-based translation layer module.\i INCLUDE_TL_SSFDCTo include the SSFDC-appropriate translation layer module.\i INCLUDE_MTD_I28F016For Intel 28f016 flash devices.\i INCLUDE_MTD_I28F008For Intel 28f008 flash devices.\i INCLUDE_MTD_I28F008_BAJAFor Intel 28f008 flash devices on the Heurikon Baja 4700.\i INCLUDE_MTD_AMDFor AMD, Fujitsu: 29F0{40,80,16} 8-bit flash devices.\i INCLUDE_MTD_CFISCSFor CFI/SCS flash devices.\i INCLUDE_MTD_WAMDFor AMD, Fujitsu 29F0{40,80,16} 16-bit flash devices.\i INCLUDE_TFFS_BOOT_IMAGETo include tffsBootImagePut() in TrueFFS for Tornado.\ieTo exclude any of the modules mentioned above, edit sysTffs.c and undefineits associated symbolic constant.INCLUDE FILES: flsocket.h, tffsDrv.h*//**#error "sysTffs : Verify system macros and function before first use"**//* 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 */#undef INCLUDE_MTD_AMD /* AMD, Fujitsu: 29f0{40,80,16} 8bit */#define INCLUDE_MTD_CFISCS /* CFI/SCS */#undef INCLUDE_MTD_WAMD /* AMD, Fujitsu: 29f0{40,80,16} 16bit */#define INCLUDE_TL_FTL /* FTL translation layer */#undef INCLUDE_TL_SSFDC /* SSFDC translation layer */#undef INCLUDE_SOCKET_SIMM /* SIMM socket interface */#undef INCLUDE_SOCKET_PCMCIA /* PCMCIA socket interface */#endif /* PRJ_BUILD */#define INCLUDE_TFFS_BOOT_IMAGE /* include tffsBootImagePut() */#define FLASH_BASE_ADRS FLASH_BASE /* Flash memory base address */#undef FLASH_SIZE#define FLASH_SIZE 0x01000000 /* Flash memory size */#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 KILL_TIME_FUNC ((iz * iz) / (iz + iz)) / ((iy + iz) / (iy * iz))/* locals */LOCAL UINT32 sysTffsMsecLoopCount = 0;/* forward declarations */LOCAL FLBoolean rfaCardDetected (FLSocket vol);LOCAL void rfaVccOn (FLSocket vol);LOCAL void rfaVccOff (FLSocket vol);#ifdef SOCKET_12_VOLTSLOCAL FLStatus rfaVppOn (FLSocket vol);LOCAL void rfaVppOff (FLSocket vol);#endif /* SOCKET_12_VOLTS */LOCAL FLStatus rfaInitSocket (FLSocket vol);LOCAL void rfaSetWindow (FLSocket vol);LOCAL void rfaSetMappingContext (FLSocket vol, unsigned page);LOCAL FLBoolean rfaGetAndClearCardChangeIndicator (FLSocket vol);LOCAL FLBoolean rfaWriteProtected (FLSocket vol);LOCAL void rfaRegister (void);void sysFlashWriteEnable (void);#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 assigned 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; /* by default you can not write to flash so we enable writing now */ sysFlashWriteEnable(); /* we assume the following: * - 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; /* TODO: * Call each sockets register routine here */ rfaRegister (); /* RFA socket interface register */ }/********************************************************************************* rfaRegister - install routines for the Flash RFA** This routine installs necessary functions for the Resident Flash Array(RFA).** RETURNS: N/A*/LOCAL void rfaRegister (void) { FLSocket vol = flSocketOf (noOfDrives); tffsSocket[noOfDrives] = "RFA"; vol.window.baseAddress = FLASH_BASE_ADRS >> 12; vol.cardDetected = rfaCardDetected; vol.VccOn = rfaVccOn; vol.VccOff = rfaVccOff;#ifdef SOCKET_12_VOLTS vol.VppOn = rfaVppOn; vol.VppOff = rfaVppOff;#endif vol.initSocket = rfaInitSocket; vol.setWindow = rfaSetWindow; vol.setMappingContext = rfaSetMappingContext; vol.getAndClearCardChangeIndicator = rfaGetAndClearCardChangeIndicator; vol.writeProtected = rfaWriteProtected; noOfDrives++; }/********************************************************************************* rfaCardDetected - detect if a card is present (inserted)** This routine detects if a card is present (inserted).* Always return TRUE in RFA environments since device is not removable.** RETURNS: TRUE, always*/LOCAL FLBoolean rfaCardDetected ( FLSocket vol /* pointer identifying drive */ ) { return (TRUE); }/********************************************************************************* rfaVccOn - 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. Assumed to be ON constantly in RFA environment.** RETURNS: N/A*/LOCAL void rfaVccOn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -