Ignore:
Timestamp:
Jul 17, 2017, 8:42:59 AM (7 years ago)
Author:
alain
Message:

Bug fix in kernel_init
-This line, and those below, will be ignored--

M params.mk
M kernel_config.h
M Makefile
M hdd/virt_hdd.dmg
M tools/bootloader_tsar/boot.c
M kernel/libk/bits.h
M kernel/libk/elf.c
M kernel/libk/xhtab.c
M kernel/libk/elf.h
M kernel/libk/xhtab.h
M kernel/devices/dev_pic.c
M kernel/mm/vmm.c
M kernel/mm/mapper.c
M kernel/mm/mapper.h
M kernel/vfs/devfs.h
M kernel/vfs/vfs.c
M kernel/vfs/vfs.h
M kernel/vfs/devfs.c
M kernel/kern/chdev.h
M kernel/kern/kernel_init.c
M kernel/kern/process.c
M kernel/kern/process.h
M hal/tsar_mips32/core/hal_remote.c
M hal/tsar_mips32/drivers/soclib_pic.c

File:
1 edited

Legend:

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

    r188 r204  
    7676// returns true if given name matches directory entry name.
    7777////////////////////////////////////////////////////////////////////////////////////////////
    78 static bool_t xhtab_dentry_item_match_key( xptr_t item_xp,
     78static bool_t xhtab_dentry_item_match_key( xptr_t    item_xp,
    7979                                           void    * key )
    8080{
    81     vfs_dentry_t * dentry_ptr;
    82     cxy_t          dentry_cxy;
    83 
    84     char           name[CONFIG_VFS_MAX_NAME_LENGTH];
     81    char name[CONFIG_VFS_MAX_NAME_LENGTH];
    8582
    8683    // get dentry cluster and local pointer
    87     dentry_cxy = GET_CXY( item_xp );
    88     dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );
     84    cxy_t          dentry_cxy = GET_CXY( item_xp );
     85    vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );
    8986
    9087    // make a local copy of directory entry name
     
    9491    return( strcmp( name , (char*)key ) == 0 );
    9592}
    96                        
     93
     94////////////////////////////////////////////////////////////////////////////////////////////
     95// This function print the item key, that is the name for a vfs_entry_t,
     96////////////////////////////////////////////////////////////////////////////////////////////
     97// @ item_xp   : extended pointer on item.
     98////////////////////////////////////////////////////////////////////////////////////////////
     99static void xhtab_dentry_item_print_key( xptr_t item_xp )
     100{
     101    char name[CONFIG_VFS_MAX_NAME_LENGTH];
     102
     103    // get dentry cluster and local pointer
     104    cxy_t          dentry_cxy = GET_CXY( item_xp );
     105    vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );
     106   
     107    // make a local copy of directory entry name
     108    hal_remote_strcpy( XPTR( local_cxy , name ) ,
     109                       XPTR( dentry_cxy , &dentry_ptr->name ) );
     110
     111    // print dentry name
     112    printk("%s , ", name );
     113}                       
     114
    97115////////////////////////////////////////////////////////////////////////////////////////
    98116//         Generic access functions
     
    108126    remote_rwlock_init( XPTR( local_cxy , &xhtab->lock) );
    109127
    110     xhtab->items  = 0;
     128    xhtab->items            = 0;
     129    xhtab->current_index    = 0;
     130    xhtab->current_xlist_xp = XPTR_NULL;
    111131
    112132    if( type == XHTAB_DENTRY_TYPE )
     
    115135        xhtab->index_from_key  = &xhtab_dentry_index_from_key;
    116136        xhtab->item_from_xlist = &xhtab_dentry_item_from_xlist;
     137        xhtab->item_print_key  = &xhtab_dentry_item_print_key;
    117138    }
    118139    else
     
    134155                   void    * key )
    135156{
    136     xptr_t    xlist_xp;                                 // xlist_entry_t (iterator)
    137     xptr_t    item_xp;                                  // associated item
    138     xhtab_t * xhtab_ptr;                                // hash table local pointer
    139     cxy_t     xhtab_cxy;                                // hash table cluster
     157    xptr_t              xlist_xp;           // xlist_entry_t (iterator)
     158    xptr_t              item_xp;            // associated item
     159    xhtab_t           * xhtab_ptr;          // hash table local pointer
     160    cxy_t               xhtab_cxy;          // hash table cluster
     161    item_from_xlist_t * item_from_xlist;    // function pointer
     162    item_match_key_t  * item_match_key;     // function pointer
    140163
    141164    // get hash table cluster and local pointer
    142165    xhtab_cxy = GET_CXY( xhtab_xp );
    143166    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
     167
     168    // get pointer on "item_from_xlist" function
     169    item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     170                                                           &xhtab_ptr->item_from_xlist ) );
     171    // get pointer on "item_match_key" function
     172    item_match_key = (item_match_key_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     173                                                         &xhtab_ptr->item_match_key ) );
    144174
    145175    // scan sub-list[index]
     
    147177    {
    148178        // get extended pointer on item containing the xlist entry
    149             item_xp = xhtab_ptr->item_from_xlist( xlist_xp );
     179            item_xp = item_from_xlist( xlist_xp );
    150180
    151181        // check matching
    152         if( xhtab_ptr->item_match_key( item_xp , key ) ) return item_xp;
     182        if( item_match_key( item_xp , key ) ) return item_xp;
    153183    }
    154184
    155185    // No matching item found
    156186    return XPTR_NULL;
    157 }
     187
     188}  // end xhtab_scan()
    158189
    159190///////////////////////////////////////
     
    162193                      xptr_t   xlist_xp )
    163194{
    164     // get xhtab cluster and local pointer
    165     cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
    166     xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
    167 
     195    xptr_t             item_xp;
     196    uint32_t           index;
     197    cxy_t              xhtab_cxy;
     198    xhtab_t          * xhtab_ptr;
     199    index_from_key_t * index_from_key;     // function pointer
     200   
     201    // get xhtab cluster and local pointer
     202    xhtab_cxy = GET_CXY( xhtab_xp );
     203    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
     204
     205    // get pointer on "index_from_key" function
     206    index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     207                                                         &xhtab_ptr->index_from_key ) );
    168208    // compute index from key
    169         uint32_t index = xhtab_ptr->index_from_key( key );
     209        index = index_from_key( key );
    170210
    171211    // take the lock protecting hash table
     
    173213
    174214    // search a matching item
    175     xptr_t item_xp = xhtab_scan( xhtab_xp , index , key );
     215    item_xp = xhtab_scan( xhtab_xp , index , key );
    176216
    177217    if( item_xp != XPTR_NULL )    // error if found
     
    202242                      xptr_t   xlist_entry_xp )
    203243{
    204     // get xhtab cluster and local pointer
    205     cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
    206     xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
    207 
     244    xptr_t             item_xp;
     245    uint32_t           index;
     246    cxy_t              xhtab_cxy;
     247    xhtab_t          * xhtab_ptr;
     248    index_from_key_t * index_from_key;     // function pointer
     249
     250    // get xhtab cluster and local pointer
     251    xhtab_cxy = GET_CXY( xhtab_xp );
     252    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
     253
     254    // get pointer on "index_from_key" function
     255    index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     256                                                         &xhtab_ptr->index_from_key ) );
    208257    // compute index from key
    209         uint32_t index = xhtab_ptr->index_from_key( key );
     258        index = index_from_key( key );
    210259
    211260    // take the lock protecting hash table
     
    213262
    214263    // get extended pointer on item to remove
    215     xptr_t item_xp = xhtab_scan( xhtab_xp , index , key );
     264    item_xp = xhtab_scan( xhtab_xp , index , key );
    216265
    217266    if( item_xp == XPTR_NULL )    // error if not found
     
    241290                      void    * key )
    242291{
    243     xptr_t  item_xp;
    244 
    245     // get xhtab cluster and local pointer
    246     cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
    247     xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
    248 
     292    xptr_t             item_xp;
     293    uint32_t           index;
     294    cxy_t              xhtab_cxy;
     295    xhtab_t          * xhtab_ptr;
     296    index_from_key_t * index_from_key;     // function pointer
     297
     298    // get xhtab cluster and local pointer
     299    xhtab_cxy = GET_CXY( xhtab_xp );
     300    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
     301
     302    // get pointer on "index_from_key" function
     303    index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     304                                                         &xhtab_ptr->index_from_key ) );
    249305    // compute index from key
    250         uint32_t index = xhtab_ptr->index_from_key( key );
     306        index = index_from_key( key );
    251307
    252308    // take the lock protecting hash table
     
    288344xptr_t xhtab_get_first( xptr_t xhtab_xp )
    289345{
    290     uint32_t index;
    291     xptr_t   xlist_xp;
    292     xptr_t   item_xp;
    293     xptr_t   root_xp;
    294 
    295     // get xhtab cluster and local pointer
    296     cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
    297     xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
    298 
     346    uint32_t            index;
     347    cxy_t               xhtab_cxy;
     348    xhtab_t           * xhtab_ptr;
     349    xptr_t              xlist_xp;
     350    xptr_t              item_xp;
     351    xptr_t              root_xp;
     352    item_from_xlist_t * item_from_xlist;   // function pointer
     353
     354    // get xhtab cluster and local pointer
     355    xhtab_cxy = GET_CXY( xhtab_xp );
     356    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
     357
     358    // get pointer on "item_from_xlist" function
     359    item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     360                                                           &xhtab_ptr->item_from_xlist ) );
    299361    //loop on subsets
    300362    for( index = 0 ; index < XHASHTAB_SIZE ; index++ )
     
    309371        {
    310372            // get extended pointer on item containing the xlist entry
    311                 item_xp = xhtab_ptr->item_from_xlist( xlist_xp );
     373                item_xp = item_from_xlist( xlist_xp );
    312374
    313375            // register item in hash table header
     
    327389xptr_t xhtab_get_next( xptr_t xhtab_xp )
    328390{
    329     uint32_t index;
    330     xptr_t   xlist_xp;
    331     xptr_t   item_xp;
    332     xptr_t   root_xp;
     391    uint32_t            index;
     392    cxy_t               xhtab_cxy;
     393    xhtab_t           * xhtab_ptr;
     394    xptr_t              xlist_xp;
     395    xptr_t              item_xp;
     396    xptr_t              root_xp;
     397    item_from_xlist_t * item_from_xlist;   // function pointer
    333398
    334399    uint32_t current_index;
     
    336401
    337402    // get xhtab cluster and local pointer
    338     cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
    339     xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
     403    xhtab_cxy = GET_CXY( xhtab_xp );
     404    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
    340405
    341406    // get current item pointers
     
    343408    current_xlist_xp = hal_remote_lwd( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) );
    344409
     410    // get pointer on "item_from_xlist" function
     411    item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     412                                                           &xhtab_ptr->item_from_xlist ) );
    345413    //loop on subsets
    346414    for( index = current_index ; index < XHASHTAB_SIZE ; index++ )
     
    350418
    351419        // get next item
    352         xlist_xp = xlist_next( root_xp , current_xlist_xp );
     420        if( index == current_index ) xlist_xp = xlist_next( root_xp , current_xlist_xp );
     421        else                         xlist_xp = xlist_next( root_xp , root_xp );
    353422
    354423        if( xlist_xp != XPTR_NULL )  // next item found
    355424        {
    356425            // get extended pointer on item containing the xlist entry
    357                 item_xp = xhtab_ptr->item_from_xlist( xlist_xp );
     426                item_xp = item_from_xlist( xlist_xp );
    358427
    359428            // register item in hash table header
     
    370439} // end xhtab_get_next()
    371440
    372 
     441/////////////////////////////////////
     442void xhtab_display( xptr_t xhtab_xp )
     443{
     444    uint32_t            index;
     445    cxy_t               xhtab_cxy;
     446    xhtab_t           * xhtab_ptr;
     447    xptr_t              root_xp;
     448    xptr_t              iter_xp;
     449    xptr_t              item_xp;
     450    item_from_xlist_t * item_from_xlist;   // function pointer
     451    item_print_key_t  * item_print_key;    // function pointer
     452
     453    // get xhtab cluster and local pointer
     454    xhtab_cxy = GET_CXY( xhtab_xp );
     455    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
     456
     457    // get pointer on "item_from_xlist" function
     458    item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     459                                                           &xhtab_ptr->item_from_xlist ) );
     460    // get pointer on "item_print_key" function
     461    item_print_key = (item_print_key_t *)hal_remote_lpt( XPTR( xhtab_cxy ,
     462                                                         &xhtab_ptr->item_print_key ) );
     463    //loop on subsets
     464    for( index = 0 ; index < XHASHTAB_SIZE ; index++ )
     465    {
     466        printk(" index = %d : ", index );
     467
     468        // get root of subset
     469        root_xp = XPTR( xhtab_cxy , &xhtab_ptr->roots[index] );
     470
     471        // loop on xlist
     472        XLIST_FOREACH( root_xp , iter_xp )
     473        {
     474            // get item from xlist
     475            item_xp = item_from_xlist( iter_xp );
     476           
     477            // print item identifier
     478            item_print_key( item_xp );
     479        }
     480
     481        printk("\n");
     482    }
     483}  // end xhtab_display()
Note: See TracChangeset for help on using the changeset viewer.