static int jag_format_flash(int format, unsigned int flags) { int rv = 0; #if !defined(DOC_IS_FLASH) if (format) { # ifdef DOS_OPT_DEFAULT if (dosFsVolFormat(FLASH_FS_NAME, DOS_OPT_DEFAULT, 0)) { rv |= -1; } # else if (diskInit(FLASH_FS_NAME)) { rv |= -1; } # endif flashFsSync(); } #else if (format) { extern STATUS tffsBCM47xxFormat(void); tffsBCM47xxFormat(); } #endif /* DOC_IS_FLASH */ return(rv); }
static int bcm53000_format_flash(int format, unsigned int flags) { int rv = 0; if (format) { # ifdef DOS_OPT_DEFAULT if (dosFsVolFormat(FLASH_FS_NAME, DOS_OPT_DEFAULT, 0)) { rv |= -1; } # else if (diskInit(FLASH_FS_NAME)) { rv |= -1; } # endif flashFsSync(); } return(rv); }
static int gto_format_flash(int format, unsigned int flags) { int rv = 0; if (format) { # ifdef DOS_OPT_DEFAULT if (dosFsVolFormat(FLASH_FS_NAME, DOS_OPT_DEFAULT, 0)) { rv |= -1; } # else if (diskInit(FLASH_FS_NAME)) { rv |= -1; } # endif printf("GTO Flash Formatted .\n"); flashFsSync(); } return(rv); }
STATUS flashFsLibInit(void) { #ifndef BUILD_VXBOOT CBIO_DEV_ID pCbio; int dosFsCacheSizeDefault = 128 * 1024 ; #endif int bootSize, bootOffset; /* * We are considered initialized once flashDosVolDesc is non-NULL. */ if (flashDosVolDesc) { return OK; } if (flashDrvLibInit() == ERROR) { printf("flashFsLibInit(): flashDrvLibInit() failed\n"); return (ERROR); } #ifndef BUILD_VXBOOT /* All Keystone platform are the same */ flsh_boot_size = 1024; #endif /* Find boot partition */ flashFsFindBootPartition(&bootSize, &bootOffset); /* Find vxworks filesystem partition */ flashFsFindVxworksPartition(&bootSize, &bootOffset); /* * Set up BLK DEV structure */ flashBlkDev.bd_blkRd = flashFsBlkRead; flashBlkDev.bd_blkWrt = flashFsBlkWrite; flashBlkDev.bd_ioctl = flashFsIoctl; flashBlkDev.bd_reset = NULL; flashBlkDev.bd_statusChk = NULL; flashBlkDev.bd_removable = FALSE; flashBlkDev.bd_nBlocks = FLASH_FS_SIZE_BLOCKS; flashBlkDev.bd_bytesPerBlk = FLASH_FS_BLOCK_SIZE; flashBlkDev.bd_blksPerTrack = 1; flashBlkDev.bd_nHeads = 1; flashBlkDev.bd_retry = 1; flashBlkDev.bd_mode = O_RDWR; flashBlkDev.bd_readyChanged = FALSE; if (flashFsVerbose) { printf("flashFsLibInit: Initializing\n"); } #if !defined(BUILD_VXBOOT) if (!flashDosFormat) { if ( (pCbio = dcacheDevCreate( (CBIO_DEV_ID) &flashBlkDev, NULL, dosFsCacheSizeDefault, FLASH_FS_NAME)) == NULL ) return (ERROR); if (dosFsDevCreate(FLASH_FS_NAME, pCbio, NUM_DOSFS_FILES, NONE)) { printf("Failed to create DOS file device \n"); return (ERROR); } flashDosVolDesc = dosFsVolDescGet(FLASH_FS_NAME, NULL); if (flashDosVolDesc == NULL) { if (flashFsVerbose) { printf("\nflashFsLibInit: first time initialization...\n"); } dosFsVolFormat(FLASH_FS_NAME, DOS_OPT_DEFAULT, NULL); flashDosVolDesc = dosFsVolDescGet(FLASH_FS_NAME, NULL); if (flashDosVolDesc == NULL) { printf("Failed to Format DOS file device \n"); return (ERROR); } } if (flashFsVerbose) { dosFsShow(FLASH_FS_NAME, DOS_CHK_VERB_2); } } #endif if (flashFsVerbose) { printf("done\n"); } flashFsSync(); return OK; }
int32 OS_mkfs (char *address, char *devname, char *volname, uint32 blocksize, uint32 numblocks) { int i; int status; char local_volname[OS_MAX_PATH_LEN]; uint32 ReturnCode; BLK_DEV *ramDev; device_t xbd; #ifdef USE_VXWORKS_ATA_DRIVER BLK_DEV *ataBlkDev; #endif if ( devname == NULL || volname == NULL ) return OS_FS_ERR_INVALID_POINTER; /* ** Find an open entry in the Volume Table */ for (i = 0; i < NUM_TABLE_ENTRIES; i++) { if (OS_VolumeTable[i].FreeFlag == TRUE && OS_VolumeTable[i].IsMounted == FALSE && strcmp(OS_VolumeTable[i].DeviceName, devname) == 0) break; } if (i >= NUM_TABLE_ENTRIES) return OS_FS_ERR_DEVICE_NOT_FREE; /* ** Now enter the info in the table */ OS_VolumeTable[i].FreeFlag = FALSE; strcpy(OS_VolumeTable[i].VolumeName, volname); OS_VolumeTable[i].BlockSize = blocksize; /* ** Note we don't know the mount point/physical device name yet */ strcpy(local_volname,volname); if (OS_VolumeTable[i].VolumeType == RAM_DISK) { printf("OSAL: Making a RAM disk at: 0x%08X\n",(unsigned long)address ); /* ** Create the ram disk device ** The 32 is the number of blocks per track. ** Other values dont seem to work here */ ramDev = ramDevCreate (address, blocksize , 32 , numblocks, 0); if (ramDev == NULL) { ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED; } /* ** Connect the ram drive to the xbd block device */ xbd = xbdBlkDevCreate(ramDev,local_volname); if (xbd == NULLDEV) { ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED; } else { /* ** Delay to allow the XBD operation to complete */ (void) taskDelay(100); /* ** Determine the vxWorks device name and store it ** in the Physical Device field of the volume table. ** It will be used for determining the path in OS_NameChange */ strcat(local_volname,":0"); strncpy(OS_VolumeTable[i].PhysDevName, local_volname, 32 ); /* ** Call the dos format routine */ status = dosFsVolFormat(OS_VolumeTable[i].PhysDevName, DOS_OPT_BLANK, NULL); if ( status == -1 ) { printf("OSAL: dosFsVolFormat failed. Errno = %d\n",errnoGet()); ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED; } else { ReturnCode = OS_FS_SUCCESS; } } } else if (OS_VolumeTable[i].VolumeType == FS_BASED) { /* ** FS_BASED will map the cFE to an already mounted filesystem */ /* ** now enter the info in the table */ OS_VolumeTable[i].FreeFlag = FALSE; strcpy(OS_VolumeTable[i].VolumeName, volname); OS_VolumeTable[i].BlockSize = blocksize; ReturnCode = OS_FS_SUCCESS; } #ifdef USE_VXWORKS_ATA_DRIVER /* ** Format an ATA disk ** This code requires an ATA driver in the BSP, so it must be ** left out of the compilation BSPs without. */ /* --------------------------------------------- */ else if (OS_VolumeTable[i].VolumeType == ATA_DISK) { printf("OSAL: Formatting a FLASH DISK\n"); /* ** Create the Flash disk device */ if( (ataBlkDev = ataDevCreate( 0, 0, 0, 0)) == NULL) { printf("OSAL: Error Creating flash disk device.\n"); ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED; } else { printf("OSAL: FLASH device initialized.\n"); /* ** Attach to the XBD layer */ xbd = xbdBlkDevCreate(ataBlkDev,local_volname); if (xbd == NULLDEV) { printf("OSAL: Error Creating XBD device on FLASH disk.\n"); ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED; } else { /* ** Delay to allow the XBD operation to complete */ (void) taskDelay(100); /* ** Determine the vxWorks device name and store it ** in the Physical Device field of the volume table. ** It will be used for determining the path in OS_NameChange */ status = OS_GetPhysDeviceName(OS_VolumeTable[i].PhysDevName, local_volname); if ( status == OS_FS_ERROR ) { ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED; } else { /* ** Format the Device with the DOS file system */ if ( dosFsVolFormat(OS_VolumeTable[i].PhysDevName,DOS_OPT_BLANK,NULL) == ERROR ) { printf("OSAL: DOS format error on flash disk.\n"); ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED; } else { ReturnCode = OS_FS_SUCCESS; } } } } }/* if ATA_DISK */ #endif else { /* ** VolumeType is something else that is not supported right now */ ReturnCode = OS_FS_ERROR; } return ReturnCode; } /* end OS_mkfs */