Changeset 50 for trunk/kernel/vfs
- Timestamp:
- Jun 26, 2017, 3:15:11 PM (7 years ago)
- Location:
- trunk/kernel/vfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/devfs.c
r23 r50 139 139 xptr_t new_inode_xp; 140 140 141 printk("\n @@@ devfs_chdev : 0 / name = %s\n", name );142 141 devfs_dmsg("\n[INFO] %s : create dentry for %s\n", __FUNCTION__ , name ); 142 143 143 // create vfs_dentry in local cluster 144 144 error = vfs_dentry_create( FS_TYPE_DEVFS, … … 146 146 parent, 147 147 &new_dentry_xp ); 148 149 printk("\n @@@ devfs_chdev : 1 / name = %s\n", name );150 151 148 if ( error ) 152 149 { … … 156 153 } 157 154 158 printk("\n @@@ devfs_chdev : 2 / name = %s\n", name );159 155 devfs_dmsg("\n[INFO] %s : create inode for %s\n", __FUNCTION__ , name ); 156 160 157 // create vfs_inode in local cluster 161 158 uint32_t attr = 0; … … 171 168 gid, 172 169 &new_inode_xp ); 173 174 printk("\n @@@ devfs_chdev : 3 / name = %s\n", name );175 176 170 if( error ) 177 171 { … … 229 223 ///// step 1 : all clusters initialize local DEVFS context ///// 230 224 231 printk("\n @@@ devfs_mount : 0 / name = %s\n", devfs_root_name );232 233 225 devfs_ctx_init( vfs_ctx , parent_inode_xp ); 234 226 235 227 ///// step 2 : cluster_0 creates DEVFS root ///// 236 237 printk("\n @@@ devfs_mount : 1 / name = %s\n", devfs_root_name );238 228 239 229 if( local_cxy == 0 ) … … 242 232 parent_inode_xp, 243 233 &root_inode_xp ); 244 printk("\n @@@ devfs_mount : 2\n");245 246 234 } 247 235 … … 251 239 ///// step 3 : all clusters create "internal" directory and chdevs ///// 252 240 253 printk("\n @@@ devfs_mount : 3 / name = %s\n", devfs_root_name ); 241 // TODO check device existence : (chdev_xp != XPTR_NULL) in chdev_dir 254 242 255 243 snprintf( node_name , 16 , "internal_%x" , local_cxy ); 256 257 printk("\n @@@ devfs_mount : 4 / name = %s\n", devfs_root_name );258 244 259 245 devfs_create_directory( node_name, 260 246 root_inode_xp, 261 247 &internal_inode_xp ); 262 263 printk("\n @@@ devfs_mount : 5 / name = %s\n", devfs_root_name );264 248 265 249 // create ICU chdev inode … … 270 254 &chdev_inode_xp ); 271 255 272 printk("\n @@@ devfs_mount : 6 / name = %s\n", devfs_root_name );273 274 256 // create MMC chdev inode 275 257 chdev_ptr = (chdev_t *)GET_PTR( chdev_dir.mmc[local_cxy] ); … … 279 261 &chdev_inode_xp ); 280 262 281 printk("\n @@@ devfs_mount : 7 / name = %s\n", devfs_root_name );282 283 263 // create DMA chdev inodes (one DMA channel per core) 284 264 for( channel = 0 ; channel < cluster->cores_nr ; channel++ ) … … 290 270 (vfs_inode_t *)GET_PTR( internal_inode_xp ), 291 271 &chdev_inode_xp ); 292 293 printk("\n @@@ devfs_mount : 8 / name = %s\n", devfs_root_name );294 295 272 } 296 273 297 274 ///// step 4 : cluster_io creates "external" directory and chdevs ///// 275 276 // TODO check device existence : (chdev_xp != XPTR_NULL) in chdev_dir 298 277 299 278 if( local_cxy == cluster->io_cxy ) … … 302 281 root_inode_xp, 303 282 &external_inode_xp ); 304 305 printk("\n @@@ devfs_mount : 9 / name = %s\n", devfs_root_name );306 283 307 284 // create IOB chdev inode … … 312 289 &chdev_inode_xp ); 313 290 314 printk("\n @@@ devfs_mount : 10 / name = %s\n", devfs_root_name );315 316 291 // create PIC chdev inode 317 292 chdev_ptr = (chdev_t *)GET_PTR( chdev_dir.pic ); … … 374 349 (vfs_inode_t *)GET_PTR( external_inode_xp ), 375 350 &chdev_inode_xp ); 376 printk("\n @@@ devfs_mount : 11 / name = %s\n", devfs_root_name );377 378 351 } 379 352 } … … 676 649 677 650 678 const struct vfs_file_op_s devfs_f_op =679 {680 .open = devfs_open,681 .read = devfs_read,682 .write = devfs_write,683 .lseek = devfs_lseek,684 .mmap = devfs_mmap,685 .munmap = devfs_munmap,686 .readdir = devfs_readdir,687 .close = devfs_close,688 .release = devfs_release689 };690 691 651 */ 692 652 -
trunk/kernel/vfs/fatfs.c
r23 r50 36 36 #include <fatfs.h> 37 37 38 38 39 ////////////////////////////////////////////////////////////////////////////////////////// 39 40 // Extern variables 40 41 ////////////////////////////////////////////////////////////////////////////////////////// 41 42 42 extern vfs_ctx_t fs_context[FS_TYPES_NR]; // allocated in vfs.c file43 44 extern remote_barrier_t global_barrier; // allocated danskernel_init.c43 extern vfs_ctx_t fs_context[FS_TYPES_NR]; // allocated in vfs.c file 44 45 extern remote_barrier_t global_barrier; // allocated in kernel_init.c 45 46 46 47 ////////////////////////////////////////////////////////////////////////////////////////// … … 297 298 xptr_t root_inode_xp ) 298 299 { 299 error_t error; 300 uint8_t buffer[512]; // buffer for boot record 301 302 // make a synchronous access to IOC device to read the boot record from device 300 error_t error; 301 uint8_t * buffer; 302 kmem_req_t req; 303 304 // allocate a 512 bytes buffer to store the boot record 305 req.type = KMEM_512_BYTES; 306 req.flags = AF_KERNEL | AF_ZERO; 307 buffer = (uint8_t *)kmem_alloc( &req ); 308 309 fatfs_dmsg("\n[INFO] %s : enters with buffer = %x\n", 310 __FUNCTION__ , (intptr_t)buffer ); 311 312 // load the boot record from device 313 // using a synchronous access to IOC device 303 314 error = dev_ioc_sync_read( buffer , 0 , 1 ); 304 assert( (error == 0) , __FUNCTION__ , "cannot access FAT boot record" ); 315 316 assert( (error == 0) , __FUNCTION__ , "cannot access boot record" ); 317 318 #if CONFIG_FAT_DEBUG 319 uint32_t line; 320 uint32_t byte = 0; 321 printk("\n*** boot record at cycle %d ***\n", hal_time_stamp() ); 322 for ( line = 0 ; line < 32 ; line++ ) 323 { 324 printk(" %X | %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x |\n", 325 byte, 326 buffer[byte+ 0],buffer[byte+ 1],buffer[byte+ 2],buffer[byte+ 3], 327 buffer[byte+ 4],buffer[byte+ 5],buffer[byte+ 6],buffer[byte+ 7], 328 buffer[byte+ 8],buffer[byte+ 9],buffer[byte+10],buffer[byte+11], 329 buffer[byte+12],buffer[byte+13],buffer[byte+14],buffer[byte+15] ); 330 331 byte += 16; 332 } 333 #endif 305 334 306 335 // check sector size from boot record 307 336 uint32_t sector_size = get_record_from_buffer( BPB_BYTSPERSEC , buffer , 1 ); 337 308 338 assert( (sector_size == 512) , __FUNCTION__ , "sector size must be 512 bytes" ); 309 339 310 340 // check cluster size from boot record 311 341 uint32_t nb_sectors = get_record_from_buffer( BPB_SECPERCLUS , buffer , 1 ); 342 312 343 assert( (nb_sectors == 8) , __FUNCTION__ , "cluster size must be 8 sectors" ); 313 344 314 345 // check number of FAT copies from boot record 315 346 uint32_t nb_fats = get_record_from_buffer( BPB_NUMFATS , buffer , 1 ); 347 316 348 assert( (nb_fats == 1) , __FUNCTION__ , "number of FAT copies must be 1" ); 317 349 318 350 // get & check number of sectors in FAT from boot record 319 351 uint32_t fat_sectors = get_record_from_buffer( BPB_FAT32_FATSZ32 , buffer , 1 ); 352 320 353 assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ , "FAT not multiple of 16 sectors"); 321 354 322 355 // get and check root cluster from boot record 323 356 uint32_t root_cluster = get_record_from_buffer( BPB_FAT32_ROOTCLUS , buffer , 1 ); 357 324 358 assert( (root_cluster == 2) , __FUNCTION__ , "Root cluster index must be 2"); 325 359 326 360 // get FAT lba from boot record 327 361 uint32_t fat_lba = get_record_from_buffer( BPB_RSVDSECCNT , buffer , 1 ); 328 362 363 // release the 512 bytes buffer 364 req.type = KMEM_512_BYTES; 365 req.ptr = buffer; 366 kmem_free( &req ); 367 329 368 // allocate a mapper for the FAT itself 330 369 mapper_t * fat_mapper = mapper_create(); 370 331 371 assert( (fat_mapper != NULL) , __FUNCTION__ , "no memory for FAT mapper" ); 332 372 … … 342 382 fatfs_ctx->fat_mapper_xp = XPTR( local_cxy , fat_mapper ); 343 383 384 fatfs_dmsg("\n*** FAT context ***\n" 385 "- fat_sectors = %d\n" 386 "- sector size = %d\n" 387 "- cluster size = %d\n" 388 "- fat_first_lba = %d\n" 389 "- data_first_lba = %d\n" 390 "- mapper = %l\n", 391 fatfs_ctx->fat_sectors_count, 392 fatfs_ctx->bytes_per_sector, 393 fatfs_ctx->bytes_per_cluster, 394 fatfs_ctx->fat_begin_lba, 395 fatfs_ctx->cluster_begin_lba, 396 fatfs_ctx->fat_mapper_xp ); 397 344 398 // initialize the VFS context 345 399 vfs_ctx->type = FS_TYPE_FATFS; -
trunk/kernel/vfs/vfs.c
r23 r50 49 49 50 50 ////////////////////////////////////////////////////////////////////////////////////////// 51 // Global variables 52 ////////////////////////////////////////////////////////////////////////////////////////// 53 54 // array of supported FS contexts 55 vfs_ctx_t fs_context[FS_TYPES_NR]; 56 51 // Extern variables 52 ////////////////////////////////////////////////////////////////////////////////////////// 53 54 extern vfs_ctx_t fs_context[FS_TYPES_NR]; // allocate in kernel_init.c 55 57 56 ////////////////////////////////////////////////////////////////////////////////////////// 58 57 // Context related functions … … 297 296 kmem_req_t req; // request to kernel memory allocator 298 297 299 printk("\n @@@ dentry_create : 0 / name = %s\n", name );300 301 298 // check type and get pointer on context 302 299 if ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS]; … … 319 316 } 320 317 321 printk("\n @@@ dentry_create : 1 / name = %s\n", name );322 323 318 // allocate memory for dentry descriptor 324 319 req.type = KMEM_VFS_DENTRY; … … 340 335 strcpy( dentry->name , name ); 341 336 342 printk("\n @@@ dentry_create : 2 / name = %s\n", name );343 344 337 // register dentry in hash table rooted in parent inode 345 338 xhtab_insert( XPTR( local_cxy , &parent->children ), 346 339 name, 347 340 XPTR( local_cxy , &dentry->xlist ) ); 348 349 printk("\n @@@ dentry_create : 3 / name = %s\n", name );350 341 351 342 // return extended pointer on dentry
Note: See TracChangeset
for help on using the changeset viewer.