Ignore:
Timestamp:
Oct 4, 2018, 11:16:13 PM (6 years ago)
Author:
alain
Message:

Complete restructuration of kernel spinlocks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/xlist.h

    r457 r563  
    11/*
     2    // check calling thread can yield
     3    thread_assert_can_yield( this , __FUNCTION__ );
     4
    25 * xlist.h - Double Circular Linked lists, using extended pointers.
    36 *
     
    7881 **************************************************************************/
    7982
    80 #define XLIST_FIRST_ELEMENT( root_xp , type , member ) \
    81     ({ xptr_t __first = hal_remote_lwd( root_xp );     \
     83#define XLIST_FIRST( root_xp , type , member ) \
     84    ({ xptr_t __first = hal_remote_l64( root_xp );     \
    8285           XLIST_ELEMENT( __first , type , member ); })
    8386
     
    9295 **************************************************************************/
    9396
    94 #define XLIST_LAST_ELEMENT( root_xp , type , member )  \
    95     ({ xptr_t __last = hal_remote_lwd( root_xp + 8 );  \
     97#define XLIST_LAST( root_xp , type , member )  \
     98    ({ xptr_t __last = hal_remote_l64( root_xp + 8 );  \
    9699           XLIST_ELEMENT( __last , type , member ); })
    97100
    98101/***************************************************************************
    99102 * This macro traverses an extended double linked list in forward order.
    100  * The iter variable should NOT be deleted during traversal.
     103 * WARNING : the iter variable should NOT be deleted during traversal.
    101104 * @ root_xp  : extended pointer on the root xlist_entry_t
    102105 * @ iter_xp  : current extended pointer on a xlist_entry_t
     
    104107
    105108#define XLIST_FOREACH( root_xp , iter_xp )    \
    106 for( (iter_xp) = hal_remote_lwd( root_xp ) ;  \
     109for( (iter_xp) = hal_remote_l64( root_xp ) ;  \
    107110     (iter_xp) != (root_xp) ;                 \
    108      (iter_xp) = hal_remote_lwd( iter_xp ) )
     111     (iter_xp) = hal_remote_l64( iter_xp ) )
    109112
    110113/***************************************************************************
    111114 * This macro traverses an extended double linked list in backward order.
    112  * The iter variable should NOT be deleted during traversal.
     115 * WARNING : the iter variable should NOT be deleted during traversal.
    113116 * @ root_xp  : extended pointer on the root xlist_entry_t
    114117 * @ iter_xp  : current extended pointer on a xlist_entry_t
     
    116119
    117120#define XLIST_FOREACH_BACKWARD( root_xp , iter_xp )  \
    118 for( (iter_xp) = hal_remote_lwd( (root_xp) + 8 ) ;   \
     121for( (iter_xp) = hal_remote_l64( (root_xp) + 8 ) ;   \
    119122     (iter_xp) != (root_xp) ;                        \
    120      (iter_xp) = hal_remote_lwd( (iter_xp) + 8 ) )
     123     (iter_xp) = hal_remote_l64( (iter_xp) + 8 ) )
    121124
    122125/***************************************************************************
     
    130133{
    131134    // get root->next
    132     xptr_t root_next = (xptr_t)hal_remote_lwd( root );
     135    xptr_t root_next = (xptr_t)hal_remote_l64( root );
    133136
    134137    // get ref->next
    135     xptr_t ref_next  = (xptr_t)hal_remote_lwd( ref );
     138    xptr_t ref_next  = (xptr_t)hal_remote_l64( ref );
    136139
    137140    // test if list is empty or ref is the last element 
     
    150153{
    151154    // get root->next
    152     xptr_t root_next = (xptr_t)hal_remote_lwd( root );
     155    xptr_t root_next = (xptr_t)hal_remote_l64( root );
    153156
    154157    // get ref->pred
    155     xptr_t ref_pred  = (xptr_t)hal_remote_lwd( ref + 8 );
     158    xptr_t ref_pred  = (xptr_t)hal_remote_l64( ref + 8 );
    156159
    157160    // test if list is empty or ref is the first element 
     
    165168 * The root can be located in any cluster.
    166169 * @ root_xp   :  extended pointer on the root xlist_entry_t
    167  **************************************************************************/
     170xixi **************************************************************************/
    168171static inline void xlist_root_init( xptr_t root_xp )
    169172{
    170     hal_remote_swd(  root_xp   , root_xp );
    171     hal_remote_swd(  root_xp+8 , root_xp );
     173    hal_remote_s64(  root_xp   , root_xp );
     174    hal_remote_s64(  root_xp+8 , root_xp );
    172175}
    173176
     
    179182static inline void xlist_entry_init( xptr_t entry_xp )
    180183{
    181     hal_remote_swd(  entry_xp   , 0 );
    182     hal_remote_swd(  entry_xp+8 , 0 );
     184    hal_remote_s64(  entry_xp   , 0 );
     185    hal_remote_s64(  entry_xp+8 , 0 );
    183186}
    184187
     
    194197{
    195198    // get the extended pointer on the first element in list
    196     xptr_t first = (xptr_t)hal_remote_lwd( root );
     199    xptr_t first = (xptr_t)hal_remote_l64( root );
    197200
    198201    // update root.next <= entry
    199     hal_remote_swd( root , (uint64_t)entry );
     202    hal_remote_s64( root , (uint64_t)entry );
    200203
    201204    // update entry.next <= first
    202     hal_remote_swd( entry , (uint64_t)first );
     205    hal_remote_s64( entry , (uint64_t)first );
    203206
    204207    // entry.pred <= root
    205     hal_remote_swd( entry + 8 , (uint64_t)root );
     208    hal_remote_s64( entry + 8 , (uint64_t)root );
    206209   
    207210    // first.pred <= new
    208     hal_remote_swd( first + 8 , (uint64_t)entry );
     211    hal_remote_s64( first + 8 , (uint64_t)entry );
    209212}
    210213
     
    220223{
    221224    // get the extended pointer on the last element in list
    222     xptr_t last = (xptr_t)hal_remote_lwd( root + 8 );
     225    xptr_t last = (xptr_t)hal_remote_l64( root + 8 );
    223226
    224227    // update root.pred <= entry
    225     hal_remote_swd( root + 8 , (uint64_t)entry );
     228    hal_remote_s64( root + 8 , (uint64_t)entry );
    226229
    227230    // update entry.pred <= last
    228     hal_remote_swd( entry + 8 , (uint64_t)last );
     231    hal_remote_s64( entry + 8 , (uint64_t)last );
    229232
    230233    // entry.next <= root
    231     hal_remote_swd( entry , (uint64_t)root );
     234    hal_remote_s64( entry , (uint64_t)root );
    232235   
    233236    // last.next <= entry
    234     hal_remote_swd( last , (uint64_t)entry );
     237    hal_remote_s64( last , (uint64_t)entry );
    235238}
    236239
     
    243246{
    244247    // get the extended pointer root.next value
    245     xptr_t next = (xptr_t)hal_remote_lwd( root );
     248    xptr_t next = (xptr_t)hal_remote_l64( root );
    246249
    247250    return ( root == next );
     
    266269
    267270    // update pred.next <= next
    268     hal_remote_swd( pred , (uint64_t)next );
     271    hal_remote_s64( pred , (uint64_t)next );
    269272
    270273    // update next.pred <= pred
    271     hal_remote_swd( next + 8 , (uint64_t)pred );
     274    hal_remote_s64( next + 8 , (uint64_t)pred );
    272275}
    273276
     
    292295
    293296        // update new.next <= next
    294     hal_remote_swd( new , (uint64_t)next );
     297    hal_remote_s64( new , (uint64_t)next );
    295298
    296299    // update new.pred <= pred
    297     hal_remote_swd( new + 8 , (uint64_t)pred );
     300    hal_remote_s64( new + 8 , (uint64_t)pred );
    298301
    299302        // update pred.next <= new
    300     hal_remote_swd( pred , (uint64_t)new );
     303    hal_remote_s64( pred , (uint64_t)new );
    301304
    302305    // update next.pred <= new
    303     hal_remote_swd( next + 8 , (uint64_t)new );
     306    hal_remote_s64( next + 8 , (uint64_t)new );
    304307}
    305308
Note: See TracChangeset for help on using the changeset viewer.