?? doc2k-systffs.c
字號:
/* sysTffs.c - PC 386/486 system-dependent TrueFFS library *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/* FAT-FTL Lite Software Development Kit * Copyright (C) M-Systems Ltd. 1995-1997 *//*modification history--------------------01d,31may99,yp Added comments suggested in SPR #2531901c,05feb99,yp fixed SPR #22515. Bad preprocessor define01b,03jun98,yp made scan addresses BSP specific01a,02jun98,yp derived from pc386-sysTffs.c*//*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 stores pointers to the functions of this socket component driver in an 'FLSocket' structure. When TrueFFS needs to access the flash device, it uses these functions. Because this file is, for the most part, a device driver that exports its functionality by registering function pointers with TrueFFS, very few of the functions defined here are externally callable. For the record, these external functions are flFitInSocketWindow() and flDelayLoop(). You should never 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 initialization time to register socket component drivers for all the flash devices attached to your target. It is this call to sysTffs() that results in assigning drive numbers to the flash devices on your target hardware. Drive numbers are 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 to 4. As shipped, TrueFFS supports up to five flash drives. After registering socket component drivers for a flash device, you may format 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 externally callable helper function. Internally, it calls tffsDevFormat() with a pointer to a 'FormatParams' structure initialized to values that leave a space on the flash device for a boot image. This space is outside the region managed by TrueFFS. This special region is necessary for boot images because the normal translation and wear-leveling services of TrueFFS are incompatible with the needs of the boot program and the boot image it relies upon. To write a boot image (or any other data) into this area, use tffsBootImagePut(). Finally, this file also contains define statements for symbolic constants that determine which MTDs, translation layer modules, and other utilities are 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.INCLUDE FILES: flsocket.hSEE ALSO : tffsDevFormat tffsRawio*//* includes */#include "vxWorks.h"#include "config.h"#include "tffs/flsocket.h"#include "tffs/pcic.h"/* defines */#define INCLUDE_MTD_DOC2 /* Toshiba, Samsung: NAND, DOC */#define INCLUDE_TL_NFTL /* NFTL translation layer */#define INCLUDE_SOCKET_DOC /* DOC socket interface */#define INCLUDE_TFFS_BOOT_IMAGE /* include tffsBootImagePut() */#define WINDOW_ID 0 /* PCIC window used (0-4) */#define VPP_DELAY_MSEC 100 /* Millisecs to wait for Vpp ramp up */#ifdef MBX860_BD_SIZE /* only way to know if bsp is MBX860 */#define DOC2_SCAN_ADRS_0 (CPU_PCI_ISA_MEM_BA + 0xc8000) /* start */#define DOC2_SCAN_ADRS_1 (CPU_PCI_ISA_MEM_BA + 0xf0000) /* end */#else /* ! MBX860 */#define DOC2_SCAN_ADRS_0 (0xc8000) /* start */#define DOC2_SCAN_ADRS_1 (0xf0000) /* end */#endif /* MBX 860 */#define KILL_TIME_FUNC ((iz * iz) / (iz + iz)) / ((iy + iz) / (iy * iz))#define PC_WINDOW 1 /* PCIC window no. used by TFFS */#define PC_EXTRAWS 1 /* PCIC wait state used by TFFS */#define PC_SOCKET_NAME_DOC "DOC" /* DOC socket name for DOC *//* externs */IMPORT unsigned windowBaseAddress (unsigned driveNo, unsigned long startAddr, unsigned long endAddr); /* nfdc2148.c *//* globals */char pcDriveNo[2] = {NONE, NONE}; /* drive number of the sockets *//* locals */LOCAL UINT32 sysTffsMsecLoopCount = 0; /* loop count to consume milli sec *//* forward declarations */#ifdef INCLUDE_SOCKET_DOCLOCAL FLStatus docRegister (void);LOCAL unsigned docWindowBaseAddress (unsigned driveNo);LOCAL FLBoolean docCardDetected (FLSocket vol);LOCAL void docVccOn (FLSocket vol);LOCAL void docVccOff (FLSocket vol);#ifdef SOCKET_12_VOLTSLOCAL FLStatus docVppOn (FLSocket vol);LOCAL void docVppOff (FLSocket vol);#endif /* SOCKET_12_VOLTS */LOCAL FLStatus docInitSocket (FLSocket vol);LOCAL void docSetWindow (FLSocket vol);LOCAL void docSetMappingContext (FLSocket vol, unsigned page);LOCAL FLBoolean docGetAndClearCardChangeIndicator (FLSocket vol);LOCAL FLBoolean docWriteProtected (FLSocket vol);#ifdef EXITLOCAL void docFreeSocket (FLSocket vol);#endif /* EXIT */#endif /* INCLUDE_SOCKET_DOC */#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 should be 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; (void) docRegister (); /* Disk On Chip */ }#ifdef INCLUDE_SOCKET_DOC/********************************************************************************* docRegister - registration routine for M-Systems Disk On Chip (DOC) * socket component driver** This routine populates the 'vol' structure for a logical drive with the* socket component driver routines for the M-System DOC. All socket routines* are referanced through the 'vol' structure and never from here directly** RETURNS: flOK, or flTooManyComponents if there're too many drives,* or flAdapterNotFound if there's no controller.*/LOCAL FLStatus docRegister (void) { FLSocket vol; if (noOfDrives >= DRIVES) return (flTooManyComponents); pVol = flSocketOf (noOfDrives); vol.window.baseAddress = docWindowBaseAddress (vol.volNo); if (vol.window.baseAddress == 0) return (flAdapterNotFound); vol.cardDetected = docCardDetected; vol.VccOn = docVccOn; vol.VccOff = docVccOff;#ifdef SOCKET_12_VOLTS vol.VppOn = docVppOn; vol.VppOff = docVppOff;#endif vol.initSocket = docInitSocket; vol.setWindow = docSetWindow; vol.setMappingContext = docSetMappingContext; vol.getAndClearCardChangeIndicator = docGetAndClearCardChangeIndicator; vol.writeProtected = docWriteProtected;#ifdef EXIT vol.freeSocket = docFreeSocket;#endif tffsSocket[noOfDrives] = PC_SOCKET_NAME_DOC; noOfDrives++; return (flOK); } /********************************************************************************* docWindowBaseAddress - Return the host base address of the DOC2 window** This routine Return the host base address of the window.* It scans the host address range from DOC2_SCAN_ADRS_0 to DOC2_SCAN_ADRS_1* (inclusive) attempting to identify DiskOnChip 2000 memory window.** RETURNS: Host physical address of window divided by 4 KB*/LOCAL unsigned docWindowBaseAddress ( unsigned driveNo /* drive number */ ) { return (windowBaseAddress (driveNo, DOC2_SCAN_ADRS_0, DOC2_SCAN_ADRS_1)); }/********************************************************************************* docCardDetected - 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 docCardDetected ( FLSocket vol /* pointer identifying drive */ ) { return (TRUE); }/********************************************************************************* docVccOn - 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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -