Ignore:
Timestamp:
Dec 6, 2019, 12:07:51 PM (4 years ago)
Author:
alain
Message:

Fix several bugs in the FATFS and in the VFS,
related to the creation of big files requiring
more than 4 Kbytes (one cluster) on device.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/grdxt.c

    r635 r656  
    315315                else                   
    316316                {
    317                     *found_key = (ix1 << (w2+w3)) | (ix2 << w1) | ix3;
     317                    *found_key = (ix1 << (w2+w3)) | (ix2 << w3) | ix3;
    318318                    return ptr3[ix3];
    319319                }
     
    343343    grdxt_t * rt_ptr = GET_PTR( rt_xp );
    344344
     345#if DEBUG_GRDXT_INSERT
     346uint32_t cycle = (uint32_t)hal_get_cycles();
     347if(DEBUG_GRDXT_INSERT < cycle)
     348printk("\n[%s] enter / rt_xp (%x,%x) / key %x / value %x\n",
     349__FUNCTION__, rt_cxy, rt_ptr, key, (intptr_t)value );
     350#endif
     351
    345352    // get widths
    346353    uint32_t        w1 = hal_remote_l32( XPTR( rt_cxy , &rt_ptr->ix1_width ) );
     
    348355    uint32_t        w3 = hal_remote_l32( XPTR( rt_cxy , &rt_ptr->ix3_width ) );
    349356
     357#if DEBUG_GRDXT_INSERT
     358if(DEBUG_GRDXT_INSERT < cycle)
     359printk("\n[%s] get widths : w1 %d / w2 %d / w3 %d\n",
     360__FUNCTION__, w1, w2, w3 );
     361#endif
     362
    350363// Check key value
    351364assert( ((key >> (w1 + w2 + w3)) == 0 ), "illegal key value %x\n", key );
     
    356369        uint32_t        ix3 = key & ((1 << w3) - 1);         // index in level 3 array
    357370
     371#if DEBUG_GRDXT_INSERT
     372if(DEBUG_GRDXT_INSERT < cycle)
     373printk("\n[%s] compute indexes : ix1 %d / ix2 %d / ix3 %d\n",
     374__FUNCTION__, ix1, ix2, ix3 );
     375#endif
     376
    358377    // get ptr1
    359378    void ** ptr1 = hal_remote_lpt( XPTR( rt_cxy , &rt_ptr->root ) );
     
    361380    if( ptr1 == NULL ) return -1;
    362381
     382#if DEBUG_GRDXT_INSERT
     383if(DEBUG_GRDXT_INSERT < cycle)
     384printk("\n[%s] compute ptr1 = %x\n",
     385__FUNCTION__, (intptr_t)ptr1 );
     386#endif
     387
    363388    // get ptr2
    364389    void ** ptr2 = hal_remote_lpt( XPTR( rt_cxy , &ptr1[ix1] ) );
     390
     391#if DEBUG_GRDXT_INSERT
     392if(DEBUG_GRDXT_INSERT < cycle)
     393printk("\n[%s] get current ptr2 = %x\n",
     394__FUNCTION__, (intptr_t)ptr2 );
     395#endif
    365396
    366397    // allocate memory for the missing level_2 array if required
     
    374405
    375406        if( ptr2 == NULL ) return -1;
    376 
     407       
    377408        // update level_1 entry
    378409        hal_remote_spt( XPTR( rt_cxy , &ptr1[ix1] ) , ptr2 );
     410
     411#if DEBUG_GRDXT_INSERT
     412if(DEBUG_GRDXT_INSERT < cycle)
     413printk("\n[%s] update ptr1[%d] : &ptr1[%d] = %x / ptr2 = %x\n",
     414__FUNCTION__, ix1, ix1, &ptr1[ix1], ptr2 );
     415#endif
     416
    379417    }
    380418
    381419    // get ptr3
    382420    void ** ptr3 = hal_remote_lpt( XPTR( rt_cxy , &ptr2[ix2] ) );
     421
     422#if DEBUG_GRDXT_INSERT
     423if(DEBUG_GRDXT_INSERT < cycle)
     424printk("\n[%s] get current ptr3 = %x\n",
     425__FUNCTION__, (intptr_t)ptr3 );
     426#endif
    383427
    384428    // allocate memory for the missing level_3 array if required
     
    395439        // update level_2 entry
    396440        hal_remote_spt( XPTR( rt_cxy , &ptr2[ix2] ) , ptr3 );
     441
     442#if DEBUG_GRDXT_INSERT
     443if(DEBUG_GRDXT_INSERT < cycle)
     444printk("\n[%s] update  ptr2[%d] : &ptr2[%d] %x / ptr3 %x\n",
     445__FUNCTION__, ix2, ix2, &ptr2[ix2], ptr3 );
     446#endif
     447
    397448    }
    398449
    399450    // register value in level_3 array
    400451    hal_remote_spt( XPTR( rt_cxy , &ptr3[ix3] ) , value );
     452
     453#if DEBUG_GRDXT_INSERT
     454if(DEBUG_GRDXT_INSERT < cycle)
     455printk("\n[%s] update  ptr3[%d] : &ptr3[%d] %x / value %x\n",
     456__FUNCTION__, ix3, ix3, &ptr3[ix3], value );
     457#endif
    401458
    402459    hal_fence();
     
    498555        uint32_t       ix3;
    499556
     557    void        ** ptr1;
     558    void        ** ptr2;
     559    void        ** ptr3;
     560
    500561// check rt_xp
    501562assert( (rt_xp != XPTR_NULL) , "pointer on radix tree is NULL\n" );
     
    510571    uint32_t       w3 = hal_remote_l32( XPTR( rt_cxy , &rt_ptr->ix3_width ) );
    511572
    512     void ** ptr1 = hal_remote_lpt( XPTR( rt_cxy , &rt_ptr->root ) );
     573    ptr1 = hal_remote_lpt( XPTR( rt_cxy , &rt_ptr->root ) );
    513574
    514575        printk("\n***** Generic Radix Tree for <%s>\n", name );
     
    516577        for( ix1=0 ; ix1 < (uint32_t)(1<<w1) ; ix1++ )
    517578        {
    518             void ** ptr2 = hal_remote_lpt( XPTR( rt_cxy , &ptr1[ix1] ) );
     579            ptr2 = hal_remote_lpt( XPTR( rt_cxy , &ptr1[ix1] ) );
    519580        if( ptr2 == NULL )  continue;
    520581   
    521582        for( ix2=0 ; ix2 < (uint32_t)(1<<w2) ; ix2++ )
    522583        {
    523                 void ** ptr3 = hal_remote_lpt( XPTR( rt_cxy , &ptr2[ix2] ) );
     584                ptr3 = hal_remote_lpt( XPTR( rt_cxy , &ptr2[ix2] ) );
    524585            if( ptr3 == NULL ) continue;
    525586
     
    530591
    531592                uint32_t key = (ix1<<(w2+w3)) + (ix2<<w3) + ix3;
    532                 printk(" - key = %x / value = %x\n", key , (intptr_t)value );
     593                printk(" - key = %x / value = %x / ptr1 = %x / ptr2 = %x / ptr3 = %x\n",
     594                key, (intptr_t)value, (intptr_t)ptr1, (intptr_t)ptr2, (intptr_t)ptr3 );
    533595            }
    534596        }
Note: See TracChangeset for help on using the changeset viewer.