⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systffs.c

📁 WINDRIVER SBC7410 BSP
💻 C
📖 第 1 页 / 共 2 页
字号:
        case 1:            vol.window.baseAddress = FLASH_BASE_ADRS1 >> 12;            flSetWindowSize (&vol, FLASH_SIZE1 >> 12);            break;        case 2:            vol.window.baseAddress = FLASH_BASE_ADRS2 >> 12;            flSetWindowSize (&vol, FLASH_SIZE2 >> 12);            break;        case 3:            vol.window.baseAddress = FLASH_BASE_ADRS3 >> 12;            flSetWindowSize (&vol, FLASH_SIZE3 >> 12);            break;        }    }/********************************************************************************* rfaSetMappingContext - 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. On entry to this * routine vol.window.currentPage is the page already mapped into the window.* (In otherwords the page that was mapped by the last call to this routine.)* The page to map is guaranteed to be on a full window-size boundary.* This is meaningful only in environments that use sliding window mechanism* to view flash memory, like in PCMCIA. Not common in RFA environments. ** RETURNS: N/A*/LOCAL void rfaSetMappingContext    (    FLSocket vol,       /* pointer identifying drive */    unsigned page       /* page to be mapped */    )    {    }/********************************************************************************* rfaGetAndClearCardChangeIndicator - return the hardware card-change indicator** This routine returns TRUE if the card has been changed and FALSE if not. It* also clears the "card-changed" indicator if it has been set.* Always return FALSE in RFA environments since device is not removable.** RETURNS: FALSE, or TRUE if the card has been changed*/LOCAL FLBoolean rfaGetAndClearCardChangeIndicator    (    FLSocket vol        /* pointer identifying drive */    )    {    return(FALSE);    }/********************************************************************************* rfaWriteProtected - 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 rfaWriteProtected    (    FLSocket vol        /* pointer identifying drive */    )    {    return(FALSE);    }/********************************************************************************* 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 the specified number of milliseconds.** RETURNS: N/A** NOMANUAL*/void flDelayMsecs    (    unsigned milliseconds       /* milliseconds to wait */    )    {    UINT32 ix;    UINT32 iy = 1;    UINT32 iz = 2;    /* it doesn't count time consumed in interrupt level */    for ( ix = 0; ix < milliseconds; ix++ )        for ( ix = 0; ix < sysTffsMsecLoopCount; ix++ )            {            tickGet ();         /* dummy */            iy = KILL_TIME_FUNC;    /* consume time */            }    }/********************************************************************************* flDelayLoop - consume the specified time** This routine delays for the specified time.** RETURNS: N/A*/void flDelayLoop     (    int  cycles    )    {    while ( --cycles )        ;    }#if TRUE/********************************************************************************* 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.*/    #if 0 /* ZZZZZZZZZZZZZZ */typedef struct     {    /* FTL formatting section */    long int   bootImageLen;    /* Space to reserve for a boot-image at the start of the       medium. The FLite volume will begin at the next higher       erase unit boundary */    unsigned   percentUse;    /* FTL performance depends on how full the Flash media is,       getting slower when the media is close to 100%. It is       possible to avoid the worst consequences of this effect by       formatting the media to less than 100% capacity, so       guaranteeing some free space at all times. This of course       sacrifices some capcity.       The standard value to use is 99 */    unsigned   noOfSpareUnits;    /* FTL needs at least one spare erase unit to function as a       read/write media (it is possible to specify 0 to achieve       WORM functionality). It is possible to specify more than       one spare unit, which costs more media space.       The advantage to doing this is in case one of the Flash       erase units becomes bad and unerasable in the future, one       of the spare units will need to replace it. A second spare       unit will then enable to continue read/write functionality       (in its absence, the media will go into read-only mode).       The standard value to use is 1 */    unsigned long vmAddressingLimit;    /* A part of the FTL Virtual Map always resides in RAM. The       RAM part is the one that is used to address the part of       the media below the VM addressing limit. Reading and       writing to this part is usually faster to some degree.       The downside is that the bigger the limit, the more RAM       size is required.       The minimum VM limit is 0.       The standard value to use is 0x10000 (first 64 KBytes) */    int     (*progressCallback)(int totalUnitsToFormat,                                int totalUnitsFormattedSoFar);    /* Progress callback routine, will be called if not NULL.       The callback routine is called after erasing each unit,       and its parameters are the total number of erase units       to format and the number erased so far.       The callback routine returns a Status value. A value of       OK (0) allows formatting to continue. Any other value       will abort the formatting with the returned status code. */    /* DOS formatting section */    char    volumeId[4];    /* Volume identification number */    char *  volumeLabel;    /* Volume label string. If NULL, no label */    unsigned   noOfFATcopies;    /* It is customary to format DOS media with 2 FAT copies.       The first copy is always used, but more copies make it       possible to recover if the FAT becomes corrupted (a       rare occurrence). On the other hand, this slows down       performance and uses media space.       The standard value to use is 2 */    unsigned   embeddedCISlength;    /* Length in bytes of CIS to embed after the unit header */    char *  embeddedCIS;    /* The unit header is structured as a beginning of a PCMCIA       'tuple' chain (a CIS). The unit header contains a       data-organization tuple, which points past the end of the       unit header to a location which usually just contains       hex FF's which mark an 'end-of-tuple-chain'. Optionally,       it is possible to embed an entire CIS chain at this       location. If so, 'embeddedCISlength' marks the length in       bytes */    } tffsFormatParams;/*---------------------------------------------------------------------------*//*            IOCTL FIODISKFORMAT structure definition                       *//*---------------------------------------------------------------------------*/typedef struct     {    tffsFormatParams  formatParams;    unsigned          formatFlags;    } tffsDevFormatParams;    #endif /* ZZZZZZZZZZZZZ */STATUS sysTffsFormat (void)    {    STATUS status;    /* No fallow area */    tffsDevFormatParams params = {{0L, 99, 1,  0x10000L, NULL, {0,0,0,0}, NULL, \            2, 0, NULL}, FTL_FORMAT_IF_NEEDED} ;    /* we assume that the drive number 0 is RFA */#ifdef INCLUDE_TFFS_VOL0    printf("Formatting volume 0...\n");    status = tffsDevFormat (0, (int)&params);    if ( status != OK )        {        return ERROR ;        }    printf("volume 0 OK.\n");#endif#ifdef INCLUDE_TFFS_VOL1    printf("Formatting volume 1...\n");    status = tffsDevFormat (1, (int)&params);    if ( status != OK )        {        return ERROR ;        }    printf("volume 1 OK.\n");#endif#ifdef INCLUDE_TFFS_VOL2    printf("Formatting volume 2...\n");    status = tffsDevFormat (2, (int)&params);    if ( status != OK )        {        return ERROR ;        }    printf("volume 2 OK.\n");#endif#ifdef INCLUDE_TFFS_VOL3    printf("Formatting volume 3...\n");    status = tffsDevFormat (3, (int)&params);    if ( status != OK )        {        return ERROR ;        }    printf("volume 3 OK.\n");#endif    return(OK);    }/********************************************************************************* sysTffsErase - erase the specified TFFS volume.*** RETURNS: OK, ERROR*/STATUS sysTffsErase    (    int volume    )    {    UINT8 * ptr ;    UINT32 temp ;    switch ( volume )        {        case 0:            temp = FLASH_BASE_ADRS0 ;            while ( temp < (FLASH_BASE_ADRS0+FLASH_SIZE0) )                {                ptr = (UINT8*)temp ;#ifdef TFFS_DEBUG                printf("Erasing sector @ 0x%x\n",temp);#endif                if ( sysFlashEraseStrataflash(ptr) != OK )                    {                    printf("Error erasing sector @ 0x%x\n", (unsigned)ptr);                    return ERROR ;                    }                temp+=INTEL28F640_SECTOR_SZ;                }             printf("Volume %d erased.\n",volume);            break;        case 1:            temp = FLASH_BASE_ADRS1 ;            while ( temp < (FLASH_BASE_ADRS1+FLASH_SIZE1) )                {                ptr = (UINT8*)temp ;#ifdef TFFS_DEBUG                printf("Erasing sector @ 0x%x\n",temp);#endif                if ( sysFlashEraseStrataflash(ptr) != OK )                    {                    printf("Error erasing sector @ 0x%x\n", (unsigned)ptr);                    return ERROR ;                    }                temp+=INTEL28F640_SECTOR_SZ;                }             printf("Volume %d erased.\n",volume);            break;        case 2:            temp = FLASH_BASE_ADRS2 ;            while ( temp < (FLASH_BASE_ADRS2+FLASH_SIZE2) )                {                ptr = (UINT8*)temp ;#ifdef TFFS_DEBUG                printf("Erasing sector @ 0x%x\n",temp);#endif                if ( sysFlashEraseStrataflash(ptr) != OK )                    {                    printf("Error erasing sector @ 0x%x\n", (unsigned)ptr);                    return ERROR ;                    }                temp+=INTEL28F640_SECTOR_SZ;                }             printf("Volume %d erased.\n",volume);            break;        case 3:            temp = FLASH_BASE_ADRS3 ;            while ( temp < (FLASH_BASE_ADRS3+FLASH_SIZE3) )                {                ptr = (UINT8*)temp ;#ifdef TFFS_DEBUG                printf("Erasing sector @ 0x%x\n",temp);#endif                if ( sysFlashEraseStrataflash(ptr) != OK )                    {                    printf("Error erasing sector @ 0x%x\n", (unsigned)ptr);                    return ERROR ;                    }                temp+=INTEL28F640_SECTOR_SZ;                }             printf("Volume %d erased.\n",volume);            break;        default:            printf("Illegal volume %d\n",volume);            return ERROR ;        }    return OK ;    }#endif 

⌨️ 快捷键说明

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