Hi all,<br><br>I am trying to set up the filesystem capabilities under the OSAL layer over RTEMS. Basically implementing mount, unmount and mkfs routines.<br>I want to have capabilities to mount external RAM disk filesystems, mapped out from the kernel space, in an SDRAM memory placed from 0x60000000 on for instance.<br>
<br>The OSAL layer gets this volume table structure:<br><br>OS_VolumeInfo_t OS_VolumeTable [NUM_TABLE_ENTRIES] =<br>{<br>    /* Dev Name  Phys Dev  Vol Type        Volatile?  Free?     IsMounted? Volname  MountPt BlockSz */<br>
    {"unused",   "unused", FS_BASED,        TRUE,      TRUE,     FALSE,     " ",      " ",     0        },<br>    {"unused",   "unused", FS_BASED,        TRUE,      TRUE,     FALSE,     " ",      " ",     0        },<br>
    {"unused",   "unused", FS_BASED,        TRUE,      TRUE,     FALSE,     " ",      " ",     0        },<br>    {"unused",   "unused", FS_BASED,        TRUE,      TRUE,     FALSE,     " ",      " ",     0        }<br>
};<br><br><br>and I already performed a sort of translation to RTEMS declaring this structure hereafter:<br>fstab_t OS_MountTable[NUM_TABLE_ENTRIES] =<br>{<br>    {OS_VolumeTable[0].DeviceName, OS_VolumeTable[0].MountPoint, &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 0 },<br>
    {OS_VolumeTable[1].DeviceName, OS_VolumeTable[1].MountPoint, &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 0 },<br>    {OS_VolumeTable[2].DeviceName, OS_VolumeTable[2].MountPoint, &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 0 },<br>
    {OS_VolumeTable[3].DeviceName, OS_VolumeTable[3].MountPoint, &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE, FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED, 0 }<br>};<br><br><br>The other thing we need is the rtems_bdbuf_configure structure, is defined as:<br>
rtems_bdbuf_config rtems_bdbuf_configuration[] = {<br>    //  BlockSize BlockNum    Address<br>    {512,         1024,          NULL}<br>};<br><br>and the rtems_ramdisk_configuration structure, this is the funny one. Later I'll detail the definition of this structure. But I would to define it like:<br>
<br>rtems_ramdisk_config rtems_ramdisk_configuration[NUM_TABLE_ENTRIES] = {<br>    //  BlockSize BlockNum    Address<br>    {0,         0,          0x0},<br>
    {0,         0,          0x0},<br>    {0,         0,          0x0},<br>    {0,         0,          0x0},<br>};<br><br><br>The functions to perform the mkfs and mount actions are:<br><br>int32 OS_mkfs (char *address, char *devname,char * volname, uint32 blocksize,<br>
               uint32 numblocks)<br>{<br>    msdos_format_request_param_t rqdata;<br>    int i = 0;<br><br><br>    // find a FREE entry in the OS_VolumeTable structure<br>    for ( i = 0; i < NUM_TABLE_ENTRIES; i++)<br>
    {<br>        if ( OS_VolumeTable[i].FreeFlag == TRUE )<br>            break;<br>    }<br><br>    // There is no entry available in the OS_VolumeTable structure<br>    if ( i >= NUM_TABLE_ENTRIES )<br>        return OS_FS_ERROR;<br>
<br>    // Fill up the OS_VolumeTable entry<br>    strcpy(OS_VolumeTable[i].DeviceName, devname);<br>    strcpy(OS_VolumeTable[i].VolumeName, volname);<br>    strcpy(OS_VolumeTable[i].PhysDevName, "");<br>    rtems_ramdisk_configuration[i].block_size = blocksize;<br>
    rtems_ramdisk_configuration[i].block_num = numblocks;<br>    rtems_ramdisk_configuration[i].location = (void*)address;<br><br>    // We need to format the filesystem as well<br>    memset(&rqdata, 0, sizeof(rqdata));<br>
    rqdata.OEMName = "RTEMS";<br>    rqdata.VolLabel = volname;<br>    rqdata.fattype = MSDOS_FMT_FATANY;<br>    rqdata.quick_format = TRUE;<br>    if( msdos_format(OS_VolumeTable[i].DeviceName, &rqdata) < 0 )<br>
    {<br>        OS_MSG_DBG("Error formating the new filesystem %s(%d) at 0x%x", OS_VolumeTable[i].DeviceName, i, rtems_ramdisk_configuration[i].location);<br>        return OS_FS_ERROR;<br>    }<br><br>    // Modify the Free flag in order to avoid future problems<br>
    OS_VolumeTable[i].FreeFlag = FALSE;<br><br>    OS_MSG_DBG("New filesystem %s(%d) created at 0x%x", OS_VolumeTable[i].DeviceName, i, rtems_ramdisk_configuration[i].location);<br>    return OS_FS_SUCCESS;<br><br>
}<br><br>int32 OS_mount (const char *devname, char* mountpoint)<br>{<br>    rtems_status_code rtems_status;<br>    int i;<br><br>    for ( i = 0; i < NUM_TABLE_ENTRIES; ++i)<br>    {<br>        if ( (strcmp(devname, OS_VolumeTable[i].DeviceName) == 0) &&<br>
             (OS_VolumeTable[i].FreeFlag == FALSE) )<br>            break;<br>    }<br><br>    if ( i >= NUM_TABLE_ENTRIES )<br>        return OS_FS_ERROR;<br><br>    // Fill up the mount point<br>    strcpy(OS_VolumeTable[i].MountPoint, mountpoint);<br>
<br>    // now we need to create a mount point. The hook to the ramdis filesystem.<br>    rtems_status = (rtems_status_code)rtems_fsmount(OS_MountTable,<br>            sizeof(OS_MountTable)/sizeof(OS_MountTable[i]), NULL );<br>
<br>    if ( rtems_status == RTEMS_SUCCESSFUL )<br>        return OS_FS_SUCCESS;<br>    else<br>        return OS_FS_ERROR;<br>}<br><br>In the OS_mkfs function, everything is filled and set up correctly, just to leave the file-system ready to get mounted. The mount function, performs the mounting of the file-system.<br>
<br>The problem is that, if I define the rtems_ramdisk_configuration like is stated before (all the fields to 0 value), I got an error trying to format the filesystem (in the msdos_format function), but, if I define the rtems_ramdisk_configuration like this:<br>
<br>    //  BlockSize BlockNum    Address<br>    {512,       2048,       0x62000000},<br>    {0,         0,          0x0},<br>    {0,         0,          0x0},<br>    {0,         0,          0x0},<br><br>with the first entry already filled, everything goes perfect. For me looks like RTEMS assumes that this rtems_ramdisk_configuration structure is statically configured, and no dynamic modification can be performed. Am I doing something wrong, or it is true that it is not possible to modify the rtems_ramdisk_configuration structure at execution time.<br>
<br><br>I don't know whether my explanation was clear enough...<br><br>Thanks in advance,<br><br>cheers,<br><br>Aitor<br><br>