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); }
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; }
STATUS usrCFConfig ( int drive, /* drive number of hard disk (0 or 1) */ char * fileName /* mount point */ ) { BLK_DEV *pBlkDev; char bootDir [BOOT_FILE_LEN]; char buffer [1024]; int offset = 0; DATAFLASH_RAW cfRaw; char *pSys; DOS_PART_TBL *pPart; if ((UINT)drive >= DATAFLASH_MAX_DRIVES) { printErr ("drive is out of range (0-%d).\n", DATAFLASH_MAX_DRIVES - 1); return (ERROR); } /* split off boot device from boot file */ devSplit (fileName, bootDir); strcpy(mountpoint,bootDir); /* read the boot sector */ cfRaw.cylinder = 0; cfRaw.head = 0; cfRaw.sector = 1; cfRaw.pBuf = buffer; cfRaw.nSecs = 1; cfRaw.direction = 0; cfcRawio (drive, &cfRaw); /* get an offset if it is formated by MSDOS */ pSys = &buffer[DOS_BOOT_SYS_ID]; pPart = (DOS_PART_TBL *)&buffer[DOS_BOOT_PART_TBL]; if ((strncmp(pSys, VXDOS, strlen(VXDOS)) != 0) && (strncmp(pSys, VXEXT, strlen(VXEXT)) != 0)) { offset = usrCFPartition (drive, pPart); } if ((pBlkDev = cfcDevCreate(drive, 0, offset)) == (BLK_DEV *)NULL) { printErr ("Error during cfDevCreate: %x\n", errno); return (ERROR); } /* Make DOS file system */ #if 0 if (dosFsDevInit(bootDir, pBlkDev, NULL) == (DOS_VOL_DESC *)NULL) { printErr ("Error during dosFsDevInit: %x\n", errno); return (ERROR); } #endif if (dosFsDevCreate(bootDir, pBlkDev, 20,0) == (DOS_VOL_DESC *)NULL) { printErr ("Error during dosFsDevInit: %x\n", errno); return (ERROR); } return (OK); }