Changeset 401 for trunk/kernel/vfs/fatfs.c
- Timestamp:
- Aug 17, 2017, 3:02:18 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/fatfs.c
r367 r401 26 26 #include <hal_special.h> 27 27 #include <printk.h> 28 #include <thread.h> 28 29 #include <kmem.h> 29 30 #include <ppm.h> … … 462 463 bool_t to_mapper ) 463 464 { 464 error_t error; 465 error_t error; 466 vfs_inode_t * inode; 467 mapper_t * mapper; 468 uint32_t index; // page index in mapper 469 uint8_t * buffer; // page base address in mapper 470 uint32_t count; // number of sectors in a page 471 uint32_t lba; // block address on device 472 fatfs_ctx_t * fatfs_ctx; // pointer on local FATFS context 465 473 466 474 // get pointer on source mapper and page index from page descriptor 467 mapper _t * mapper= page->mapper;468 uint32_tindex = page->index;475 mapper = page->mapper; 476 index = page->index; 469 477 470 478 // get VFS inode pointer from mapper 471 vfs_inode_t *inode = mapper->inode;472 473 fatfs_dmsg("\n[INFO] %s : enter for inode %x / page_index= %d / mapper = %x\n",474 __FUNCTION__, inode , index , mapper );475 476 // get memory bufferbase address479 inode = mapper->inode; 480 481 fatfs_dmsg("\n[INFO] %s : core[%x,%d] enter for inode %x / page_id = %d / mapper = %x\n", 482 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , index , mapper ); 483 484 // get page to move base address 477 485 xptr_t base_xp = ppm_page2base( XPTR( local_cxy , page ) ); 478 uint8_t *buffer = (uint8_t *)GET_PTR( base_xp );486 buffer = (uint8_t *)GET_PTR( base_xp ); 479 487 480 // get number of sectors f rom FATFS context481 fatfs_ctx _t * fatfs_ctx= (fatfs_ctx_t *)fs_context[FS_TYPE_FATFS].extend;482 uint32_tcount = fatfs_ctx->sectors_per_cluster;483 484 // analyse the mapper type : FAT ornormal inode485 if( inode == NULL ) // it is the FAT mapper488 // get number of sectors for one page (from FATFS context) 489 fatfs_ctx = (fatfs_ctx_t *)fs_context[FS_TYPE_FATFS].extend; 490 count = fatfs_ctx->sectors_per_cluster; 491 492 // test FAT/normal inode 493 if( inode == NULL ) // it is the FAT mapper 486 494 { 487 495 // get lba from page index 488 uint32_tlba = fatfs_ctx->fat_begin_lba + (count * index);496 lba = fatfs_ctx->fat_begin_lba + (count * index); 489 497 490 fatfs_dmsg("\n[INFO] %s : for FAT/ lba = %d\n",491 __FUNCTION__, lba );498 fatfs_dmsg("\n[INFO] %s : core[%x,%d] access FAT on device / lba = %d\n", 499 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , lba ); 492 500 493 501 // access device … … 496 504 497 505 if( error ) return EIO; 498 499 fatfs_dmsg("\n[INFO] %s : exit for FAT / page_index = %d / mapper = %x\n", 500 __FUNCTION__ , index , mapper ); 501 } 502 else // it is a normal inode mapper 506 } 507 else // it is a normal inode mapper 503 508 { 504 509 uint32_t searched_cluster_id; … … 506 511 // get first_cluster_id from inode extension 507 512 uint32_t first_cluster_id = (uint32_t)(intptr_t)inode->extend; 508 509 fatfs_dmsg("\n[INFO] %s : for inode %x / first_cluster_id = %d\n",510 __FUNCTION__ , inode , first_cluster_id );511 513 512 514 // compute cluster_id … … 544 546 545 547 // get lba from cluster_id 546 uint32_tlba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster_id );547 548 fatfs_dmsg("\n[INFO] %s : for inode %x / page = %d / cluster_id = %d / lba = %x\n",549 __FUNCTION__ , inode , index , searched_cluster_id , lba);548 lba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster_id ); 549 550 fatfs_dmsg("\n[INFO] %s : core[%x,%d] access device for inode %x / cluster_id = %d\n", 551 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , first_cluster_id ); 550 552 551 553 // access device … … 554 556 555 557 if( error ) return EIO; 556 557 fatfs_dmsg("\n[INFO] %s : exit for inode %x / page_index = %d / mapper = %x\n", 558 __FUNCTION__ , inode , index , mapper );559 }558 } 559 560 fatfs_dmsg("\n[INFO] %s : core[%x,%d] exit for inode %x / page_id = %d / mapper = %x\n", 561 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , index , mapper ); 560 562 561 563 return 0;
Note: See TracChangeset
for help on using the changeset viewer.