Changeset 610 for trunk/kernel/libk/xlist.h
- Timestamp:
- Dec 27, 2018, 7:38:58 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/xlist.h
r603 r610 5 5 * xlist.h - Double Circular Linked lists, using extended pointers. 6 6 * 7 * Author : Alain Greiner (2016 )7 * Author : Alain Greiner (2016,2017,2018) 8 8 * 9 9 * Copyright (c) UPMC Sorbonne Universites … … 31 31 #include <hal_kernel_types.h> 32 32 #include <hal_remote.h> 33 #include <printk.h> 33 34 34 35 /**** global variables ***/ … … 190 191 * double linked list. Four extended pointers must be modified. 191 192 * The lock protecting the list should have been previously taken. 192 * @ root : extended pointer on the root xlist_entry_t193 * @ entry : extended pointer on the xlist_entry_t to be inserted194 **************************************************************************/ 195 static inline void xlist_add_first( xptr_t root ,196 xptr_t entry )193 * @ root_xp : extended pointer on the root xlist_entry_t 194 * @ entry_xp : extended pointer on the xlist_entry_t to be inserted 195 **************************************************************************/ 196 static inline void xlist_add_first( xptr_t root_xp, 197 xptr_t entry_xp ) 197 198 { 198 199 // get the extended pointer on the first element in list 199 xptr_t first = (xptr_t)hal_remote_l64( root);200 201 // update root .next <= entry202 hal_remote_s64( root , (uint64_t)entry);203 204 // update entry .next <= first205 hal_remote_s64( entry , (uint64_t)first);206 207 // entry.pred <= root208 hal_remote_s64( entry + sizeof(xptr_t) , (uint64_t)root);200 xptr_t first_xp = hal_remote_l64( root_xp ); 201 202 // update root_xp->next <= entry_xp 203 hal_remote_s64( root_xp , entry_xp ); 204 205 // update entry_xp->next <= first_xp 206 hal_remote_s64( entry_xp , first_xp ); 207 208 // update entry_xp->pred <= root_xp 209 hal_remote_s64( entry_xp + sizeof(xptr_t) , root_xp ); 209 210 210 // first.pred <= new211 hal_remote_s64( first + sizeof(xptr_t) , (uint64_t)entry);211 // update first_xp->pred <= entry_xp 212 hal_remote_s64( first_xp + sizeof(xptr_t) , entry_xp ); 212 213 } 213 214 … … 216 217 * double linked list. Four extended pointers must be modified. 217 218 * The lock protecting the list should have been previously taken. 218 * @ root : extended pointer on the root xlist_entry_t219 * @ entry : extended pointer on the xlist_entry_t to be inserted220 **************************************************************************/ 221 static inline void xlist_add_last( xptr_t root ,222 xptr_t entry )219 * @ root_xp : extended pointer on the root xlist_entry_t 220 * @ entry_xp : extended pointer on the xlist_entry_t to be inserted 221 **************************************************************************/ 222 static inline void xlist_add_last( xptr_t root_xp, 223 xptr_t entry_xp ) 223 224 { 224 225 // get the extended pointer on the last element in list 225 xptr_t last = (xptr_t)hal_remote_l64( root+ sizeof(xptr_t) );226 227 // update root .pred <= entry228 hal_remote_s64( root + sizeof(xptr_t) , (uint64_t)entry);229 230 // update entry .pred <= last231 hal_remote_s64( entry + sizeof(xptr_t) , (uint64_t)last);232 233 // entry.next <= root234 hal_remote_s64( entry , (uint64_t)root);226 xptr_t last_xp = hal_remote_l64( root_xp + sizeof(xptr_t) ); 227 228 // update root_xp->pred <= entry_xp 229 hal_remote_s64( root_xp + sizeof(xptr_t) , entry_xp ); 230 231 // update entry_xp->pred <= last_xp 232 hal_remote_s64( entry_xp + sizeof(xptr_t) , last_xp ); 233 234 // update entry_xp->next <= root_xp 235 hal_remote_s64( entry_xp , root_xp ); 235 236 236 // last.next <= entry237 hal_remote_s64( last , (uint64_t)entry);237 // update last_xp->next <= entry_xp 238 hal_remote_s64( last_xp , entry_xp ); 238 239 } 239 240 … … 241 242 /*************************************************************************** 242 243 * This function returns true if the list is empty. 243 * @ root : extended pointer on the root xlist_entry_t244 **************************************************************************/ 245 static inline bool_t xlist_is_empty( xptr_t root )244 * @ root_xp : extended pointer on the root xlist_entry_t. 245 **************************************************************************/ 246 static inline bool_t xlist_is_empty( xptr_t root_xp ) 246 247 { 247 248 // get the extended pointer root.next value 248 xptr_t next = (xptr_t)hal_remote_l64( root );249 250 return ( root == next );249 xptr_t next = (xptr_t)hal_remote_l64( root_xp ); 250 251 return ( root_xp == next ); 251 252 } 252 253 … … 279 280 * Four extended pointers must be modified. 280 281 * The memory allocated to the removed entry is not released. 281 * @ old : extended pointer on the xlist_entry_t to be removed.282 * @ new : extended pointer on the xlist_entry_t to be inserted.282 * @ old : extended pointer on the xlist_entry_t to be removed. 283 * @ new : extended pointer on the xlist_entry_t to be inserted. 283 284 **************************************************************************/ 284 285 static inline void xlist_replace( xptr_t old, … … 307 308 } 308 309 310 /*************************************************************************** 311 * This debug function displays all entries of an xlist. 312 * @ root_xp : extended pointer on the root xlist_entry_t. 313 * @ string : list identifier displayed in header. 314 * @ max : max number of éléments to display. 315 **************************************************************************/ 316 static inline void xlist_display( xptr_t root_xp, 317 char * string, 318 uint32_t max ) 319 { 320 cxy_t root_cxy; 321 xlist_entry_t * root_ptr; 322 323 xptr_t iter_xp; 324 cxy_t iter_cxy; 325 xlist_entry_t * iter_ptr; 326 327 xptr_t next_xp; 328 cxy_t next_cxy; 329 xlist_entry_t * next_ptr; 330 331 xptr_t pred_xp; 332 cxy_t pred_cxy; 333 xlist_entry_t * pred_ptr; 334 335 uint32_t index; 336 337 root_cxy = GET_CXY( root_xp ); 338 root_ptr = GET_PTR( root_xp ); 339 340 next_xp = hal_remote_l64( XPTR( root_cxy , &root_ptr->next ) ); 341 next_cxy = GET_CXY( next_xp ); 342 next_ptr = GET_PTR( next_xp ); 343 344 pred_xp = hal_remote_l64( XPTR( root_cxy , &root_ptr->pred ) ); 345 pred_cxy = GET_CXY( pred_xp ); 346 pred_ptr = GET_PTR( pred_xp ); 347 348 printk("\n***** root (%x,%x) / next (%x,%x) / pred (%x,%x) / %s *****\n", 349 root_cxy, root_ptr, next_cxy, next_ptr, pred_cxy, pred_ptr, string ); 350 351 if( xlist_is_empty( root_xp ) == false ) 352 { 353 for( iter_xp = hal_remote_l64( XPTR( root_cxy , &root_ptr->next) ) , index = 0 ; 354 (iter_xp != root_xp) && (index < max) ; 355 iter_xp = next_xp , index++ ) 356 { 357 iter_cxy = GET_CXY( iter_xp ); 358 iter_ptr = GET_PTR( iter_xp ); 359 360 next_xp = hal_remote_l64( XPTR( iter_cxy , &iter_ptr->next ) ); 361 next_cxy = GET_CXY( next_xp ); 362 next_ptr = GET_PTR( next_xp ); 363 364 pred_xp = hal_remote_l64( XPTR( iter_cxy , &iter_ptr->pred ) ); 365 pred_cxy = GET_CXY( pred_xp ); 366 pred_ptr = GET_PTR( pred_xp ); 367 368 printk(" - %d : iter (%x,%x) / next (%x,%x) / pred (%x,%x)\n", 369 index, iter_cxy, iter_ptr, next_cxy, next_ptr, pred_cxy, pred_ptr ); 370 } 371 } 372 } // end xlist_display() 373 309 374 #endif /* _XLIST_H_ */
Note: See TracChangeset
for help on using the changeset viewer.