Ignore:
Timestamp:
Aug 17, 2017, 3:02:18 PM (5 years ago)
Author:
alain
Message:

Few bugs in VMM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/vfs/fatfs.c

    r367 r401  
    2626#include <hal_special.h>
    2727#include <printk.h>
     28#include <thread.h>
    2829#include <kmem.h>
    2930#include <ppm.h>
     
    462463                                bool_t   to_mapper )
    463464{
    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
    465473
    466474    // get pointer on source mapper and page index from page descriptor
    467     mapper_t * mapper = page->mapper;
    468     uint32_t   index  = page->index;
     475    mapper = page->mapper;
     476    index  = page->index;
    469477
    470478    // 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 buffer base address
     479    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
    477485    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 );
    479487 
    480     // get number of sectors from FATFS context
    481     fatfs_ctx_t * fatfs_ctx = (fatfs_ctx_t *)fs_context[FS_TYPE_FATFS].extend;
    482     uint32_t count = fatfs_ctx->sectors_per_cluster;
    483 
    484     // analyse the mapper type : FAT or normal inode
    485     if( inode == NULL )  // it is the FAT mapper
     488    // 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
    486494    {
    487495        // get lba from page index
    488         uint32_t lba = fatfs_ctx->fat_begin_lba + (count * index);
     496        lba = fatfs_ctx->fat_begin_lba + (count * index);
    489497 
    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 );
    492500
    493501        // access device
     
    496504
    497505        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
    503508    {
    504509        uint32_t  searched_cluster_id;
     
    506511        // get first_cluster_id from inode extension
    507512        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 );
    511513
    512514        // compute cluster_id
     
    544546
    545547        // get lba from cluster_id
    546         uint32_t lba = 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 );
    550552
    551553        // access device
     
    554556
    555557        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 );
    560562
    561563    return 0;
Note: See TracChangeset for help on using the changeset viewer.