Ignore:
Timestamp:
Dec 3, 2018, 12:17:35 PM (3 years ago)
Author:
alain
Message:

Improve the FAT32 file system to support cat, rm, cp commands.

File:
1 edited

Legend:

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

    r563 r603  
    2525 */
    2626
    27 #ifndef _ALMOS_XLIST_H_
    28 #define _ALMOS_XLIST_H_
     27#ifndef _XLIST_H_
     28#define _XLIST_H_
    2929
    3030#include <kernel_config.h>
     
    8181 **************************************************************************/
    8282
    83 #define XLIST_FIRST( root_xp , type , member ) \
    84     ({ xptr_t __first = hal_remote_l64( root_xp );     \
     83#define XLIST_FIRST( root_xp , type , member )       \
     84    ({ xptr_t __first = hal_remote_l64( root_xp );   \
    8585           XLIST_ELEMENT( __first , type , member ); })
    8686
     
    9595 **************************************************************************/
    9696
    97 #define XLIST_LAST( root_xp , type , member )  \
    98     ({ xptr_t __last = hal_remote_l64( root_xp + 8 );  \
     97#define XLIST_LAST( root_xp , type , member )                       \
     98    ({ xptr_t __last = hal_remote_l64( root_xp + sizeof(xptr_t) );  \
    9999           XLIST_ELEMENT( __last , type , member ); })
    100100
     
    118118 **************************************************************************/
    119119
    120 #define XLIST_FOREACH_BACKWARD( root_xp , iter_xp )  \
    121 for( (iter_xp) = hal_remote_l64( (root_xp) + 8 ) ;   \
    122      (iter_xp) != (root_xp) ;                        \
    123      (iter_xp) = hal_remote_l64( (iter_xp) + 8 ) )
     120#define XLIST_FOREACH_BACKWARD( root_xp , iter_xp )              \
     121for( (iter_xp) = hal_remote_l64( (root_xp) + sizeof(xptr_t) ) ;  \
     122     (iter_xp) != (root_xp) ;                                    \
     123     (iter_xp) = hal_remote_l64( (iter_xp) + sizeof(xptr_t) ) )
    124124
    125125/***************************************************************************
     
    156156
    157157    // get ref->pred
    158     xptr_t ref_pred  = (xptr_t)hal_remote_l64( ref + 8 );
     158    xptr_t ref_pred  = (xptr_t)hal_remote_l64( ref + sizeof(xptr_t) );
    159159
    160160    // test if list is empty or ref is the first element 
     
    171171static inline void xlist_root_init( xptr_t root_xp )
    172172{
    173     hal_remote_s64(  root_xp   , root_xp );
    174     hal_remote_s64(  root_xp+8 , root_xp );
     173    hal_remote_s64( root_xp                  , root_xp );
     174    hal_remote_s64( root_xp + sizeof(xptr_t) , root_xp );
    175175}
    176176
     
    182182static inline void xlist_entry_init( xptr_t entry_xp )
    183183{
    184     hal_remote_s64(  entry_xp   , 0 );
    185     hal_remote_s64(  entry_xp+8 , 0 );
     184    hal_remote_s64( entry_xp                  , 0 );
     185    hal_remote_s64( entry_xp + sizeof(xptr_t) , 0 );
    186186}
    187187
     
    206206
    207207    // entry.pred <= root
    208     hal_remote_s64( entry + 8 , (uint64_t)root );
     208    hal_remote_s64( entry + sizeof(xptr_t) , (uint64_t)root );
    209209   
    210210    // first.pred <= new
    211     hal_remote_s64( first + 8 , (uint64_t)entry );
     211    hal_remote_s64( first + sizeof(xptr_t) , (uint64_t)entry );
    212212}
    213213
     
    223223{
    224224    // get the extended pointer on the last element in list
    225     xptr_t last = (xptr_t)hal_remote_l64( root + 8 );
     225    xptr_t last = (xptr_t)hal_remote_l64( root + sizeof(xptr_t) );
    226226
    227227    // update root.pred <= entry
    228     hal_remote_s64( root + 8 , (uint64_t)entry );
     228    hal_remote_s64( root + sizeof(xptr_t) , (uint64_t)entry );
    229229
    230230    // update entry.pred <= last
    231     hal_remote_s64( entry + 8 , (uint64_t)last );
     231    hal_remote_s64( entry + sizeof(xptr_t) , (uint64_t)last );
    232232
    233233    // entry.next <= root
     
    262262    xlist_entry_t entry;
    263263    hal_remote_memcpy( XPTR( local_cxy , &entry ) ,
    264                                   xp ,
    265                                   sizeof(xlist_entry_t) );
     264                       xp ,
     265                       sizeof(xlist_entry_t) );
    266266
    267267    xptr_t next = entry.next;
     
    272272
    273273    // update next.pred <= pred
    274     hal_remote_s64( next + 8 , (uint64_t)pred );
     274    hal_remote_s64( next + sizeof(xptr_t) , (uint64_t)pred );
    275275}
    276276
     
    298298
    299299    // update new.pred <= pred
    300     hal_remote_s64( new + 8 , (uint64_t)pred );
     300    hal_remote_s64( new + sizeof(xptr_t) , (uint64_t)pred );
    301301
    302302        // update pred.next <= new
     
    304304
    305305    // update next.pred <= new
    306     hal_remote_s64( next + 8 , (uint64_t)new );
    307 }
    308 
    309 #endif  /* _ALMOS_LIST_H_ */
     306    hal_remote_s64( next + sizeof(xptr_t) , (uint64_t)new );
     307}
     308
     309#endif  /* _XLIST_H_ */
Note: See TracChangeset for help on using the changeset viewer.