Ignore:
Timestamp:
Dec 3, 2018, 12:15:01 PM (6 years ago)
Author:
alain
Message:

Improve the FAT32 file system to support cat, rm, cp commands.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/kernel_init.c

    r583 r601  
    159159
    160160    "CLUSTER_PREFTBL",       // 21
     161
    161162    "PPM_DIRTY",             // 22
    162 
    163163    "CLUSTER_LOCALS",        // 23
    164164    "CLUSTER_COPIES",        // 24
     
    166166    "PROCESS_USERSYNC",      // 26
    167167    "PROCESS_FDARRAY",       // 27
    168 
    169     "MAPPER_STATE",          // 28
     168    "FATFS_FREE",            // 28
     169
    170170    "PROCESS_THTBL",         // 29
    171171
    172     "PROCESS_CWD",           // 30
    173     "VFS_INODE",             // 31
    174     "VFS_FILE",              // 32
    175     "VMM_VSL",               // 33
    176     "VMM_GPT",               // 34
     172    "MAPPER_STATE",          // 30
     173    "PROCESS_CWD",           // 31
     174    "VFS_INODE",             // 32
     175    "VFS_FILE",              // 33
     176    "VMM_VSL",               // 34
     177    "VMM_GPT",               // 35
    177178};       
    178179
    179 // these debug variables are used to analyse the sys_read() and sys_write() syscalls timing
     180// debug variables to analyse the sys_read() and sys_write() syscalls timing
    180181
    181182#if DEBUG_SYS_READ
     
    417418#if( DEBUG_KERNEL_INIT & 0x1 )
    418419if( hal_time_stamp() > DEBUG_KERNEL_INIT )
    419 printk("\n[DBG] %s : created MMC in cluster %x / chdev = %x\n",
     420printk("\n[%s] : created MMC in cluster %x / chdev = %x\n",
    420421__FUNCTION__ , local_cxy , chdev_ptr );
    421422#endif
     
    451452#if( DEBUG_KERNEL_INIT & 0x1 )
    452453if( hal_time_stamp() > DEBUG_KERNEL_INIT )
    453 printk("\n[DBG] %s : created DMA[%d] in cluster %x / chdev = %x\n",
     454printk("\n[%s] : created DMA[%d] in cluster %x / chdev = %x\n",
    454455__FUNCTION__ , channel , local_cxy , chdev_ptr );
    455456#endif
     
    611612#if( DEBUG_KERNEL_INIT & 0x1 )
    612613if( hal_time_stamp() > DEBUG_KERNEL_INIT )
    613 printk("\n[DBG] %s : create chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",
     614printk("\n[%s] : create chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",
    614615__FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy , chdev );
    615616#endif
     
    779780
    780781#if( DEBUG_KERNEL_INIT & 0x1 )
    781 if( hal_tim_stamp() > DEBUG_KERNEL_INIT )
     782if( hal_time_stamp() > DEBUG_KERNEL_INIT )
    782783{
    783     printk("\n[DBG] %s created PIC chdev in cluster %x at cycle %d\n",
     784    printk("\n[%s] created PIC chdev in cluster %x at cycle %d\n",
    784785    __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() );
    785786    dev_pic_inputs_display();
     
    969970#if DEBUG_KERNEL_INIT
    970971if( (core_lid ==  0) & (local_cxy == 0) )
    971 printk("\n[DBG] %s : exit barrier 0 : TXT0 initialized / sr %x / cycle %d\n",
     972printk("\n[%s] : exit barrier 0 : TXT0 initialized / sr %x / cycle %d\n",
    972973__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    973974#endif
     
    10111012#if DEBUG_KERNEL_INIT
    10121013if( (core_lid ==  0) & (local_cxy == 0) )
    1013 printk("\n[DBG] %s : exit barrier 1 : clusters initialised / sr %x / cycle %d\n",
     1014printk("\n[%s] : exit barrier 1 : clusters initialised / sr %x / cycle %d\n",
    10141015__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    10151016#endif
     
    10381039#if DEBUG_KERNEL_INIT
    10391040if( (core_lid ==  0) & (local_cxy == 0) )
    1040 printk("\n[DBG] %s : exit barrier 2 : PIC initialised / sr %x / cycle %d\n",
     1041printk("\n[%s] : exit barrier 2 : PIC initialised / sr %x / cycle %d\n",
    10411042__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    10421043#endif
     
    10711072#if DEBUG_KERNEL_INIT
    10721073if( (core_lid ==  0) & (local_cxy == 0) )
    1073 printk("\n[DBG] %s : exit barrier 3 : all chdev initialised / sr %x / cycle %d\n",
     1074printk("\n[%s] : exit barrier 3 : all chdevs initialised / sr %x / cycle %d\n",
    10741075__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    10751076#endif
     
    11151116        if( CONFIG_VFS_ROOT_IS_FATFS )
    11161117        {
    1117             // 1. allocate memory for FATFS context in cluster 0
     1118            // 1. allocate memory for FATFS context extension in cluster 0
    11181119            fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc();
    11191120
     
    11341135            uint32_t total_clusters   = fatfs_ctx->fat_sectors_count << 7;
    11351136 
    1136             // 4. initialize the FATFS entry in the vfs_context[] array
    1137             vfs_ctx_init( FS_TYPE_FATFS,                               // fs type
    1138                           0,                                           // attributes: unused
    1139                               total_clusters,               
    1140                               cluster_size,
    1141                               vfs_root_inode_xp,                           // VFS root
    1142                           fatfs_ctx );                                 // extend
    1143 
    1144             // 5. create VFS root inode in cluster 0
     1137            // 4. create VFS root inode in cluster 0
    11451138            error = vfs_inode_create( XPTR_NULL,                           // dentry_xp
    11461139                                      FS_TYPE_FATFS,                       // fs_type
    11471140                                      INODE_TYPE_DIR,                      // inode_type
    1148                                       (void *)(intptr_t)root_dir_cluster,  // extend
    11491141                                      0,                                   // attr
    11501142                                      0,                                   // rights
     
    11591151            }
    11601152
    1161             // 6. update the FATFS entry in vfs_context[] array
    1162             fs_context[FS_TYPE_FATFS].vfs_root_xp = vfs_root_inode_xp;
    1163 
    1164             // 7. check FATFS initialization
    1165             vfs_ctx_t   * vfs_ctx = &fs_context[FS_TYPE_FATFS];
    1166 
    1167             if( ((fatfs_ctx_t *)vfs_ctx->extend)->sectors_per_cluster != 8 )
    1168             {
    1169                 printk("\n[PANIC] in %s : illegal FATFS context in cluster 0\n",
    1170                 __FUNCTION__ );
    1171                 hal_core_sleep();
    1172             }
    1173                
     1153            // 5. update FATFS root inode extension 
     1154            cxy_t         vfs_root_cxy = GET_CXY( vfs_root_inode_xp );
     1155            vfs_inode_t * vfs_root_ptr = GET_PTR( vfs_root_inode_xp );
     1156            hal_remote_spt( XPTR( vfs_root_cxy , &vfs_root_ptr->extend ),
     1157                            (void*)(intptr_t)root_dir_cluster );
     1158
     1159            // 6. initialize the generic VFS context for FATFS
     1160            vfs_ctx_init( FS_TYPE_FATFS,                               // fs type
     1161                          0,                                           // attributes: unused
     1162                              total_clusters,                              // number of clusters
     1163                              cluster_size,                                // bytes
     1164                              vfs_root_inode_xp,                           // VFS root
     1165                          fatfs_ctx );                                 // extend
    11741166        }
    11751167        else
     
    11931185#if DEBUG_KERNEL_INIT
    11941186if( (core_lid ==  0) & (local_cxy == 0) )
    1195 printk("\n[DBG] %s : exit barrier 4 : VFS root initialized in cluster 0 / sr %x / cycle %d\n",
     1187printk("\n[%s] : exit barrier 4 : VFS root initialized in cluster 0 / sr %x / cycle %d\n",
    11961188__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    11971189#endif
     
    12621254#if DEBUG_KERNEL_INIT
    12631255if( (core_lid ==  0) & (local_cxy == 1) )
    1264 printk("\n[DBG] %s : exit barrier 5 : VFS root initialized in cluster 1 / sr %x / cycle %d\n",
     1256printk("\n[%s] : exit barrier 5 : VFS root initialized in cluster 1 / sr %x / cycle %d\n",
    12651257__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    12661258#endif
     
    13111303#if DEBUG_KERNEL_INIT
    13121304if( (core_lid ==  0) & (local_cxy == 0) )
    1313 printk("\n[DBG] %s : exit barrier 6 : DEVFS root initialized in cluster 0 / sr %x / cycle %d\n",
     1305printk("\n[%s] : exit barrier 6 : DEVFS root initialized in cluster 0 / sr %x / cycle %d\n",
    13141306__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    13151307#endif
     
    13481340#if DEBUG_KERNEL_INIT
    13491341if( (core_lid ==  0) & (local_cxy == 0) )
    1350 printk("\n[DBG] %s : exit barrier 7 : DEV initialized in cluster 0 / sr %x / cycle %d\n",
     1342printk("\n[%s] : exit barrier 7 : DEV initialized in cluster 0 / sr %x / cycle %d\n",
    13511343__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    13521344#endif
     
    13741366#if DEBUG_KERNEL_INIT
    13751367if( (core_lid ==  0) & (local_cxy == 0) )
    1376 printk("\n[DBG] %s : exit barrier 8 : process init created / sr %x / cycle %d\n",
     1368printk("\n[%s] : exit barrier 8 : process init created / sr %x / cycle %d\n",
    13771369__FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
    13781370#endif
     
    14451437
    14461438#if DEBUG_KERNEL_INIT
    1447 printk("\n[DBG] %s : thread %x on core[%x,%d] jumps to thread_idle_func() / cycle %d\n",
     1439printk("\n[%s] : thread %x on core[%x,%d] jumps to thread_idle_func() / cycle %d\n",
    14481440__FUNCTION__ , CURRENT_THREAD , local_cxy , core_lid , (uint32_t)hal_get_cycles() );
    14491441#endif
Note: See TracChangeset for help on using the changeset viewer.