int mount( int argc, char **argv ) { /* show a little bit of information */ printf( "trying to initalize device %s\n", devname ); /* init the ATA Device (Bus 0, Device 0 => Primary Master) */ ata_device= ataDevCreate( 0, 0, 0, 63 ); /* dosFsMkfsOptionsSet(DOS_OPT_LONGNAMES); hd_volume= dosFsMkfs( devname, ata_device ); */ /* init the Dos FS on the newly created device */ hd_volume= dosFsDevInit( devname, ata_device, NULL ); /* display the configuration data of the newly createtd device on stdio */ dosFsShow( devname, 0 ); return 0; }
STATUS flashFsLibInit(void) { int bootSize; /* * We are considered initialized once flashDosVolDesc is non-NULL. */ if (flashDosVolDesc) { return OK; } if (flashDrvLibInit() == ERROR) { printf("flashFsLibInit(): flashDrvLibInit() failed\n"); return (ERROR); } /* * Determine where our file system starts */ if (flashFsFindBootPartition(&bootSize) == OK) { flashBootSize = bootSize; } printf("Flash boot partition size = %d KB\n", flashBootSize / 1024); /* * 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..."); } if (!flashDosFormat) { #define DOS_OPT_DYNAMIC (DOS_OPT_CHANGENOWARN | DOS_OPT_AUTOSYNC) if (dosFsDevInitOptionsSet (DOS_OPT_DYNAMIC) != OK) { printf("flashFsLibInit: dosFsDevInitOptionsSet failed\n"); return (ERROR); } flashDosVolDesc = dosFsDevInit(FLASH_FS_NAME, &flashBlkDev, NULL); } if (flashDosVolDesc == NULL) { if (flashFsVerbose) { printf("\nflashFsLibInit: first time initialization...\n"); } if (dosFsMkfsOptionsSet(DOS_OPT_LONGNAMES) == ERROR) { printf("flashFsLibInit: dosFsMkfsOptionsSet failed\n"); } flashDosVolDesc = dosFsMkfs(FLASH_FS_NAME, &flashBlkDev); if (flashDosVolDesc == NULL) { printf("flashFsLibInit (first init): dosFsMkfs failed!"); printf("(0x%x)\n", errno); return ERROR; } else { if (flashFsVerbose) { printf("done\n"); } } } 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); }
STATUS sysScsiConfig (void) { #if FALSE /* EXAMPLE CODE IS NOT COMPILED */ UINT which; int scsiId; char modeData [4]; /* array for floppy MODE SELECT data */ SCSI_OPTIONS options; /* * NOTE: Either of the following global variables may be set or reset * from the VxWorks shell. Under 5.0, they should NOT both be set at the * same time, or output will be interleaved and hard to read!! They are * intended as an aid to trouble-shooting SCSI problems. */ scsiDebug = FALSE; /* enable SCSI debugging output */ scsiIntsDebug = FALSE; /* enable SCSI interrupt debugging output */ /* * The following section of code provides sample configurations within * VxWorks of SCSI peripheral devices and VxWorks file systems. It * should however be noted that the actual parameters provided to * scsiPhysDevCreate(), scsiBlkDevCreate(), dosFsDevInit() etc., are * highly dependent upon the user environment and should therefore be * modified accordingly. */ /* * HARD DRIVE CONFIGURATION * * In order to configure a hard disk and initialise both dosFs and rt11Fs * file systems, the following initialisation code will serve as an * example. */ /* configure a SCSI hard disk at busId = 2, LUN = 0 */ if ((pSpd20 = scsiPhysDevCreate (pSysScsiCtrl, 2, 0, 0, NONE, 0, 0, 0)) == (SCSI_PHYS_DEV *) NULL) { printErr ("usrScsiConfig: scsiPhysDevCreate failed.\n", 0, 0, 0, 0, 0, 0); } else { /* create block devices */ if (((pSbd0 = scsiBlkDevCreate (pSpd20, 0x10000, 0)) == NULL) || ((pSbd1 = scsiBlkDevCreate (pSpd20, 0x10000, 0x10000)) == NULL) || ((pSbd2 = scsiBlkDevCreate (pSpd20, 0, 0x20000)) == NULL)) { return (ERROR); } if ((dosFsDevInit ("/sd0/", pSbd0, NULL) == NULL) ) { return (ERROR); } #ifdef INCLUDE_RT11FS if ((rt11FsDevInit ("/sd1/", pSbd1, 0, 256, TRUE) == NULL) || (rt11FsDevInit ("/sd2/", pSbd2, 0, 256, TRUE) == NULL)) { return (ERROR); } #endif } /* * FLOPPY DRIVE CONFIGURATION * * In order to configure a removable media floppy drive with a * dosFs file system, the following device specific code will serve * as an example. Note that some arguments like mode parameters are * highly devcie and vendor specific. Thus, the appropriate peripheral * hardware manual should be consulted. */ /* configure floppy at busId = 3, LUN = 1 */ if ((pSpd31 = scsiPhysDevCreate (pSysScsiCtrl, 3, 1, 0, NONE, 0, 0, 0)) == (SCSI_PHYS_DEV *) NULL) { printErr ("usrScsiConfig: scsiPhysDevCreate failed.\n"); return (ERROR); } /* * Zero modeData array, then set byte 1 to "medium code" (0x1b). NOTE: * MODE SELECT data is highly device-specific. If your device requires * configuration via MODE SELECT, please consult the device's Programmer's * Reference for the relevant data format. */ bzero (modeData, sizeof (modeData)); modeData [1] = 0x1b; /* * issue the MODE SELECT command to correctly configure * floppy controller */ scsiModeSelect (pSpd31, 1, 0, modeData, sizeof (modeData)); /* * delete and re-create the SCSI_PHYS_DEV so that INQUIRY will return the * new device parameters, i.e., correct number of blocks */ scsiPhysDevDelete (pSpd31); if ((pSpd31 = scsiPhysDevCreate (pSysScsiCtrl, 3, 1, 0, NONE, 0, 0, 0)) == (SCSI_PHYS_DEV *) NULL) { printErr ("usrScsiConfig: scsiPhysDevCreate failed.\n"); return (ERROR); } if ((pSbdFloppy = scsiBlkDevCreate (pSpd31, 0, 0)) == NULL) { printErr ("usrScsiConfig: scsiBlkDevCreate failed.\n"); return (ERROR); } /* * Fill in the <blksPerTrack> (blocks (or sectors) per track) and <nHeads> * (number of heads) BLK_DEV fields, since it is impossible to ascertain * this information from the SCSI adapter card. This is important for * PC compatibility, primarily. */ scsiBlkDevInit ((SCSI_BLK_DEV *) pSbdFloppy, 15, 2); /* Initialize as a dosFs device */ /* * NOTE: pSbdFloppy is declared globally in case the following call * fails, in which case dosFsMkfs or dosFsDevInit can be * called (from the shell) with pSbdFloppy as an argument * (assuming pSbdFloppy != NULL) */ if (dosFsDevInit ("/fd0/", pSbdFloppy, NULL) == NULL) { printErr ("usrScsiConfig: dosFsDevInit failed.\n"); return (ERROR); } /* * CD-ROM DRIVE CONFIGURATION * * In order to configure a CD-ROM drive with cdromFs file system, * the following device specific code serves as an example. */ /* configure a SCSI CDROM at busId 6, LUN = 0 */ if ((pSpd60 = scsiPhysDevCreate (pSysScsiCtrl, 6, 0, 0, NONE, 0, 0, 0)) == (SCSI_PHYS_DEV *) NULL) { SCSI_DEBUG_MSG ("sysScsiConfig: scsiPhysDevCreate failed for CDROM.\n", 0, 0, 0, 0, 0, 0); } else if( (pSbdCd = scsiBlkDevCreate (pSpd60, 0, 0))== NULL ) { SCSI_DEBUG_MSG ("sysScsiConfig: scsiBlkDevCreate failed for CDROM.\n", 0, 0, 0, 0, 0, 0); } /* * Create an instance of a CDROM device in the I/O system. A block device * should have been created. The "cdromFsDevCreate" calls "iosDrvInstall" * which enters the appropriate driver routines in the I/O driver table. */ if ((cdVolDesc = cdromFsDevCreate ("cdrom:", (BLK_DEV *) pBlkDev)) == NULL) { printErr (ERROR); } /* * TAPE DRIVE CONFIGURATION * * In order to configure a sequential access tape device and a tapeFs * file system, the following code will serve as an example. Note that * sequential access and tapeFs support are only available via SCSI-2. * To make sure that SCSI-2 is being used, check for the INCLUDE_SCSI2 * macro definition in the BSP. * * The tape device does not support synchronous data transfers * or wide data transfers. Therefore, turn off the automatic configuration * of these features within VxWorks. */ scsiId = 4; which = SCSI_SET_OPT_XFER_PARAMS | SCSI_SET_OPT_WIDE_PARAMS; options.maxOffset = SCSI_SYNC_XFER_ASYNC_OFFSET; options.minPeriod = SCSI_SYNC_XFER_ASYNC_PERIOD; options.xferWidth = SCSI_WIDE_XFER_SIZE_NARROW; if (scsiTargetOptionsSet (pSysScsiCtrl, scsiId, &options, which) == ERROR) { printf ("Could not set target option parameters\n"); return (ERROR); } /* create SCSI physical device and sequential device */ if ((pSpd40 = scsiPhysDevCreate (pSysScsiCtrl, scsiId, 0,0,NONE,0,0,0)) == NULL) { printErr ("scsiPhysDevCreate failed.\n"); return (ERROR); } if ((pSd0 = scsiSeqDevCreate (pSpd40)) == NULL) { printErr ("scsiSeqDevCreate failed.\n"); return (ERROR); } /* configure a fixed block and rewind, tape file system */ pTapeConfig = (TAPE_CONFIG *) calloc (sizeof(TAPE_CONFIG),1); pTapeConfig->rewind = TRUE; /* rewind device */ pTapeConfig->blkSize = 512; /* fixed 512 byte block */ if (tapeFsDevInit ("/tape1", pSd0, pTapeConfig) == NULL) { printErr ("tapeFsDevInit failed.\n"); return (ERROR); } #endif /*FALSE, END OF EXAMPLE CODE */ return (OK); }