Beispiel #1
0
STATUS usrRamDiskInit ()
{
	BLK_DEV *pBlkDev;
	DOS_VOL_DESC *pVolDesc;
	/* create a ram disk */
	pBlkDev=ramDevCreate(0, 512, 400, 200000, 0);
	if(pBlkDev==NULL){
		printf("ran disk create error!!\n");
		printErrno();
		return ERROR;
	}
	/* Create Ram Disk Device */
	/*if(dosFsDevCreate("/ram0", pBlkDev, 4, NULL)==NULL){
		printf("create ramdisk error!!!\n");
		printErrno();
		return ERROR;
	}*/
	/* Format dosFs */
	/*if(dosFsVolFormat(pBlkDev, DOS_OPT_BLANK | DOS_OPT_QUIET | DOS_OPT_FAT32, NULL)==NULL){
		printf("Format dosFs error!!!\n");
		printErrno();
		return ERROR;
	}*/
	pVolDesc=dosFsMkfs("/ram0",pBlkDev);
	
	return OK;
}
Beispiel #2
0
STATUS myblkDrv_fn(void)
{
	/*pBlkDev = myBlkCreate();
    if(pBlkDev==NULL)
    	printf("Error\n");
    else
    	printf("\n GOOD\n");
	return OK;*/
	
    BLK_DEV *pBlkDev; 
    DOS_VOL_DESC *pVolDesc; 
    pBlkDev = ramDevCreate (0, 512, 400, 400, 0); 
    /*if (dosFsDevCreate ("DEV1:", pBlkDev, 20, NULL) == ERROR) 
    { 
        printErrno( ); 
    }; 
     
    /* if you want to format then do the following */ 
  /*  if (dosFsVolFormat ("DEV1:", 2, NULL) == ERROR) 
    { 
        printErrno( ); 
    }*/


}
Beispiel #3
0
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 */
Beispiel #4
0
/*---------------------------------------------------------------------------------------
    Name: OS_initfs

    Purpose: Re-initialize an existing file system. This is used primarily for 
             vxWorks where we need to re-attach to an existing file system on 
             either the RAM, EEPROM, or FLASH drives.
    
    Returns: OS_FS_ERR_INVALID_POINTER if devname is NULL
             OS_FS_ERR_DRIVE_NOT_CREATED if the OS calls to create the the drive failed
             OS_FS_ERR_PATH_TOO_LONG if the name is too long
             OS_FS_ERR_DEVICE_NOT_FREE if the volume table is full
             OS_FS_SUCCESS on creating the disk

    Note: if address == 0, then a malloc will be called to create the disk
---------------------------------------------------------------------------------------*/
int32 OS_initfs (char *address, char *devname, char *volname, uint32 blocksize, 
               uint32 numblocks)
{
    int         i;
    char        local_volname[OS_MAX_PATH_LEN];
    uint32      ReturnCode;
    BLK_DEV     *ramDev;
    device_t    xbd;

#ifdef USE_VXWORKS_ATA_DRIVER
    BLK_DEV    *ataBlkDev;  
    int32       status;
#endif
    
    if ( devname == NULL || volname == NULL )
    {
        return OS_FS_ERR_INVALID_POINTER;
    }

    if(strlen(devname) > 32 || strlen(volname) > 30) /* 32 - 2 for ':0' in vxworks6 port */
    {
        return OS_FS_ERR_PATH_TOO_LONG;
    }


    /* 
    ** 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 yet 
    */
    strcpy(local_volname,volname);

    if (OS_VolumeTable[i].VolumeType == RAM_DISK)
    {
        printf("OSAL: Re-mounting 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 = xbdBlkDevCreateSync(ramDev,local_volname);
        if (xbd == NULLDEV)
        {
            ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED;
        }
        else
        {
           /*
           ** 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/OS_TranslatePath
           */
           strcat(local_volname,":0");
           strncpy(OS_VolumeTable[i].PhysDevName, local_volname, 32 );

           /*
           ** Nothing else has to be done here, because the 
           ** XBD call should automatically detect and init the existing DOS file system
           */
           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    
    /*
    ** Initialize 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: Re-mounting an ATA/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 = xbdBlkDevCreateSync(ataBlkDev,local_volname);
           if (xbd == NULLDEV)
           {
               printf("OSAL: Error Creating XBD device on ATA/FLASH disk.\n");
               ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED;
           }
           else
           {
              /*
              ** 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/OS_TranslatePath
              */
              status = OS_GetPhysDeviceName(OS_VolumeTable[i].PhysDevName, local_volname);
              if ( status == OS_FS_ERROR )
              {
                  ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED;
              }
              else
              {
                 /*
                 ** Nothing else needs to be done here, the XBD layer should 
                 ** re-init the DOS volume.
                 */
                 ReturnCode = OS_FS_SUCCESS;
              }
           }
        }    
    }/* if ATA_DISK */
#endif
    else
    {
        /* 
        ** VolumeType is something else that is not supported right now 
        */
        ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED;
    }
    return ReturnCode;

} /* end OS_initfs */