예제 #1
0
파일: usrFd.c 프로젝트: andy345/vxworks5
STATUS usrFdConfig
    (
    int     drive,	/* drive number of floppy disk (0 - 3) */
    int     type,	/* type of floppy disk */
    char *  fileName	/* mount point */
    )
    {
    BLK_DEV *pBootDev;
    CBIO_DEV_ID cbio ;
    char bootDir [BOOT_FILE_LEN];

    if( type == NONE)
	return OK;

    if ((UINT)drive >= FD_MAX_DRIVES)
	{
	printErr ("drive is out of range (0-%d).\n", FD_MAX_DRIVES - 1);
	return (ERROR);
	}

    /* create a block device spanning entire disk (non-distructive!) */

    if ((pBootDev = fdDevCreate (drive, type, 0, 0)) == NULL)
	{
        printErr ("fdDevCreate failed.\n");
        return (ERROR);
	}

    /* create a disk cache to speed up Floppy operation */
    cbio = dcacheDevCreate( (CBIO_DEV_ID) pBootDev, NULL, 
                           FD_CACHE_SIZE, bootDir );

    if( cbio == NULL )
	{
	/* insufficient memory, will avoid the cache */
	cbio = cbioWrapBlkDev (pBootDev);
	}

    /* split off boot device from boot file */

    devSplit (fileName, bootDir);

    /* initialize device as a dosFs device named <bootDir> */

    if (dosFsDevCreate (bootDir, cbio, 20, NONE) == ERROR)
	{
        printErr ("dosFsDevCreate failed.\n");
        return (ERROR);
	}

    return (OK);
    }
예제 #2
0
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;
}