systffs.c

来自「MPC5200 BSP 支持ATA,USB, I2C,扩展网口」· C语言 代码 · 共 507 行 · 第 1/2 页

C
507
字号
/********************************************************************************* FLASH32VccOff - turn off Vcc (3.3/5 Volts)** This routine turns off Vcc (3.3/5 Volts). ** RETURNS: N/A*/LOCAL void FLASH32VccOff ( FLSocket vol ){}#ifdef SOCKET_12_VOLTS/********************************************************************************* FLASH32VppOn - 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 FLASH32VppOn( FLSocket vol ){    return (flOK);}/********************************************************************************* FLASH32VppOff - turns off Vpp (12 Volts)** This routine turns off Vpp (12 Volts).** RETURNS: N/A*/LOCAL void FLASH32VppOff ( FLSocket vol ){}#endif	/* SOCKET_12_VOLTS *//********************************************************************************* FLASH32InitSocket - perform all necessary initializations of the socket** This routine performs all necessary initializations of the socket.** RETURNS: flOK always.*/LOCAL FLStatus FLASH32InitSocket ( FLSocket vol ){    vol.cardChanged = FALSE;    /* enable memory window and map it at address 0 */    FLASH32SetWindow (&vol);    return (flOK);}/********************************************************************************* FLASH32SetWindow - 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 FLASH32SetWindow ( FLSocket vol ){        vol.window.baseAddress = g_tffs_DataBase >> 12;/* Physical base as a 4K page */    vol.window.size     = g_tffs_DataSize ;        /* data area size */    vol.window.base =  (void *)g_tffs_DataBase;    vol.window.currentPage = UNDEFINED_MAPPING;	/* force remapping */        vol.window.busWidth = 8 ;  /* use 16-bits */    vol.window.speed    = 120;  /* 120 nsec. */}/********************************************************************************* FLASH32SetMappingContext - 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 FLASH32SetMappingContext (FLSocket vol, unsigned page )/* page to be mapped */{}/********************************************************************************* FLASH32GetAndClearCardChangeIndicator - 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 FLASH32GetAndClearCardChangeIndicator  ( FLSocket vol ){      return (FALSE);  }/********************************************************************************* FLASH32WriteProtected - 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 FLASH32WriteProtected ( FLSocket vol ){     return (FALSE); }#endif	/* INCLUDE_SOCKET_FLASH32 *//********************************************************************************* flFitInSocketWindow - check whether the flash array fits in the socket window** This routine checks whether the flash array fits in the socket window.** RETURNS: A chip size guaranteed to fit in the socket window.*/long int flFitInSocketWindow     (    long int chipSize,		/* size of single physical chip in bytes */    int      interleaving,	/* flash chip interleaving (1,2,4 etc) */    long int windowSize		/* socket window size in bytes */    ){    if (chipSize*interleaving >  windowSize) /* doesn't fit in socket window */        {        int  roundedSizeBits;        /* fit chip in the socket window */        chipSize = windowSize / interleaving;        /* round chip size at powers of 2 */        for (roundedSizeBits = 0; (0x1L << roundedSizeBits) <= chipSize;roundedSizeBits++)	    ;        chipSize = (0x1L << (roundedSizeBits - 1));        }    return (chipSize);}/********************************************************************************* flDelayMsecs - wait for specified number of milliseconds** This routine waits for specified number of milliseconds.** RETURNS: N/A** NOMANUAL*/void flDelayMsecs    (    unsigned milliseconds       /* milliseconds to wait */    )    {    UINT32 ix1;    UINT32 ix;    UINT32 iy = 1;    UINT32 iz = 2;    /* it doesn't count time consumed in interrupt level */    for (ix1 = 0; ix1 < milliseconds; ix1++)        for (ix = 0; ix < sysTffsMsecLoopCount; ix++)	    {	    tickGet ();			/* dummy */	    iy = KILL_TIME_FUNC;	/* consume time */	    }    }/********************************************************************************* flDelayLoop - consume the specified time** This routine consumes the specified time.** RETURNS: N/A*/void flDelayLoop     (    int  cycles    )    {    while (--cycles)	;    }/********************************************************************************* sysTffsFormat - format the flash memory above an offset** This routine formats the flash memory.  Because this function defines * the symbolic constant, HALF_FORMAT, the lower half of the specified flash * memory is left unformatted.  If the lower half of the flash memory was* previously formated by TrueFFS, and you are trying to format the upper half,* you need to erase the lower half of the flash memory before you format the* upper half.  To do this, you could use:* .CS* tffsRawio(0, 3, 0, 8)  * .CE* The first argument in the tffsRawio() command shown above is the TrueFFS * drive number, 0.  The second argument, 3, is the function number (also * known as TFFS_PHYSICAL_ERASE).  The third argument, 0, specifies the unit * number of the first erase unit you want to erase.  The fourth argument, 8,* specifies how many erase units you want to erase.  ** RETURNS: OK, or ERROR if it fails.*/STATUS sysTffsFormat(void) {    STATUS status;    tffsDevFormatParams params  =	{{0, 99, 1, 0x10000L, NULL, {0,0,0,0}, NULL, 2, 0, NULL},	  FTL_FORMAT_IF_NEEDED };    params.formatParams.vmAddressingLimit=g_tffs_BlkSize;    status = tffsDevFormat(0, (int)&params);    return (status);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?