Changeset 656 for trunk/kernel/libk
- Timestamp:
- Dec 6, 2019, 12:07:51 PM (5 years ago)
- Location:
- trunk/kernel/libk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/grdxt.c
r635 r656 315 315 else 316 316 { 317 *found_key = (ix1 << (w2+w3)) | (ix2 << w 1) | ix3;317 *found_key = (ix1 << (w2+w3)) | (ix2 << w3) | ix3; 318 318 return ptr3[ix3]; 319 319 } … … 343 343 grdxt_t * rt_ptr = GET_PTR( rt_xp ); 344 344 345 #if DEBUG_GRDXT_INSERT 346 uint32_t cycle = (uint32_t)hal_get_cycles(); 347 if(DEBUG_GRDXT_INSERT < cycle) 348 printk("\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 345 352 // get widths 346 353 uint32_t w1 = hal_remote_l32( XPTR( rt_cxy , &rt_ptr->ix1_width ) ); … … 348 355 uint32_t w3 = hal_remote_l32( XPTR( rt_cxy , &rt_ptr->ix3_width ) ); 349 356 357 #if DEBUG_GRDXT_INSERT 358 if(DEBUG_GRDXT_INSERT < cycle) 359 printk("\n[%s] get widths : w1 %d / w2 %d / w3 %d\n", 360 __FUNCTION__, w1, w2, w3 ); 361 #endif 362 350 363 // Check key value 351 364 assert( ((key >> (w1 + w2 + w3)) == 0 ), "illegal key value %x\n", key ); … … 356 369 uint32_t ix3 = key & ((1 << w3) - 1); // index in level 3 array 357 370 371 #if DEBUG_GRDXT_INSERT 372 if(DEBUG_GRDXT_INSERT < cycle) 373 printk("\n[%s] compute indexes : ix1 %d / ix2 %d / ix3 %d\n", 374 __FUNCTION__, ix1, ix2, ix3 ); 375 #endif 376 358 377 // get ptr1 359 378 void ** ptr1 = hal_remote_lpt( XPTR( rt_cxy , &rt_ptr->root ) ); … … 361 380 if( ptr1 == NULL ) return -1; 362 381 382 #if DEBUG_GRDXT_INSERT 383 if(DEBUG_GRDXT_INSERT < cycle) 384 printk("\n[%s] compute ptr1 = %x\n", 385 __FUNCTION__, (intptr_t)ptr1 ); 386 #endif 387 363 388 // get ptr2 364 389 void ** ptr2 = hal_remote_lpt( XPTR( rt_cxy , &ptr1[ix1] ) ); 390 391 #if DEBUG_GRDXT_INSERT 392 if(DEBUG_GRDXT_INSERT < cycle) 393 printk("\n[%s] get current ptr2 = %x\n", 394 __FUNCTION__, (intptr_t)ptr2 ); 395 #endif 365 396 366 397 // allocate memory for the missing level_2 array if required … … 374 405 375 406 if( ptr2 == NULL ) return -1; 376 407 377 408 // update level_1 entry 378 409 hal_remote_spt( XPTR( rt_cxy , &ptr1[ix1] ) , ptr2 ); 410 411 #if DEBUG_GRDXT_INSERT 412 if(DEBUG_GRDXT_INSERT < cycle) 413 printk("\n[%s] update ptr1[%d] : &ptr1[%d] = %x / ptr2 = %x\n", 414 __FUNCTION__, ix1, ix1, &ptr1[ix1], ptr2 ); 415 #endif 416 379 417 } 380 418 381 419 // get ptr3 382 420 void ** ptr3 = hal_remote_lpt( XPTR( rt_cxy , &ptr2[ix2] ) ); 421 422 #if DEBUG_GRDXT_INSERT 423 if(DEBUG_GRDXT_INSERT < cycle) 424 printk("\n[%s] get current ptr3 = %x\n", 425 __FUNCTION__, (intptr_t)ptr3 ); 426 #endif 383 427 384 428 // allocate memory for the missing level_3 array if required … … 395 439 // update level_2 entry 396 440 hal_remote_spt( XPTR( rt_cxy , &ptr2[ix2] ) , ptr3 ); 441 442 #if DEBUG_GRDXT_INSERT 443 if(DEBUG_GRDXT_INSERT < cycle) 444 printk("\n[%s] update ptr2[%d] : &ptr2[%d] %x / ptr3 %x\n", 445 __FUNCTION__, ix2, ix2, &ptr2[ix2], ptr3 ); 446 #endif 447 397 448 } 398 449 399 450 // register value in level_3 array 400 451 hal_remote_spt( XPTR( rt_cxy , &ptr3[ix3] ) , value ); 452 453 #if DEBUG_GRDXT_INSERT 454 if(DEBUG_GRDXT_INSERT < cycle) 455 printk("\n[%s] update ptr3[%d] : &ptr3[%d] %x / value %x\n", 456 __FUNCTION__, ix3, ix3, &ptr3[ix3], value ); 457 #endif 401 458 402 459 hal_fence(); … … 498 555 uint32_t ix3; 499 556 557 void ** ptr1; 558 void ** ptr2; 559 void ** ptr3; 560 500 561 // check rt_xp 501 562 assert( (rt_xp != XPTR_NULL) , "pointer on radix tree is NULL\n" ); … … 510 571 uint32_t w3 = hal_remote_l32( XPTR( rt_cxy , &rt_ptr->ix3_width ) ); 511 572 512 void **ptr1 = hal_remote_lpt( XPTR( rt_cxy , &rt_ptr->root ) );573 ptr1 = hal_remote_lpt( XPTR( rt_cxy , &rt_ptr->root ) ); 513 574 514 575 printk("\n***** Generic Radix Tree for <%s>\n", name ); … … 516 577 for( ix1=0 ; ix1 < (uint32_t)(1<<w1) ; ix1++ ) 517 578 { 518 void **ptr2 = hal_remote_lpt( XPTR( rt_cxy , &ptr1[ix1] ) );579 ptr2 = hal_remote_lpt( XPTR( rt_cxy , &ptr1[ix1] ) ); 519 580 if( ptr2 == NULL ) continue; 520 581 521 582 for( ix2=0 ; ix2 < (uint32_t)(1<<w2) ; ix2++ ) 522 583 { 523 void **ptr3 = hal_remote_lpt( XPTR( rt_cxy , &ptr2[ix2] ) );584 ptr3 = hal_remote_lpt( XPTR( rt_cxy , &ptr2[ix2] ) ); 524 585 if( ptr3 == NULL ) continue; 525 586 … … 530 591 531 592 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 ); 533 595 } 534 596 } -
trunk/kernel/libk/grdxt.h
r635 r656 61 61 /******************************************************************************************* 62 62 * This function initialises the radix-tree descriptor, 63 * and allocates memory for the first level array of pointers. 63 64 * It must be called by a local thread. 64 * and allocates memory for the first level array of pointers.65 65 ******************************************************************************************* 66 66 * @ rt : pointer on the radix-tree descriptor. … … 77 77 /******************************************************************************************* 78 78 * This function releases all memory allocated to the radix-tree infrastructure. 79 * A warning message is printed on the kernel TXT0 if the radix tree is not empty. 79 80 * It must be called by a local thread. 80 * A warning message is printed on the kernel TXT0 if the radix tree is not empty.81 81 ******************************************************************************************* 82 82 * @ rt : pointer on the radix-tree descriptor. … … 86 86 /******************************************************************************************* 87 87 * This function insert a new item in the radix-tree. 88 * It dynamically allocates memory for new second and third level arrays if required. 88 89 * It must be called by a local thread. 89 * It dynamically allocates memory for new second and third level arrays if required.90 90 ******************************************************************************************* 91 91 * @ rt : pointer on the radix-tree descriptor. … … 100 100 /******************************************************************************************* 101 101 * This function removes an item identified by its key from the radix tree, 102 * and returns a pointer on the removed item. No memory is released. 102 103 * It must be called by a local thread. 103 * and returns a pointer on the removed item. No memory is released.104 104 ******************************************************************************************* 105 105 * @ rt : pointer on the radix-tree descriptor. … … 124 124 /******************************************************************************************* 125 125 * This function scan all radix-tree entries in increasing key order, starting from 126 * the value defined by the <start_key> argument, and return a pointer on the first valid 127 * registered item, and the found item key value. 126 128 * It must be called by a local thread. 127 * the value defined by the <key> argument, and return a pointer on the first valid128 * registered item, and the found item key value.129 129 ******************************************************************************************* 130 130 * @ rt : pointer on the radix-tree descriptor. 131 131 * @ start_key : key starting value for the scan. 132 132 * @ found_key : [out] buffer for found key value. 133 * @ return pointer on first valid item if found / return NULL if no tfound.133 * @ return pointer on first valid item if found / return NULL if no item found. 134 134 ******************************************************************************************/ 135 135 void * grdxt_get_first( grdxt_t * rt, -
trunk/kernel/libk/list.h
r651 r656 1 1 /* 2 * list.h - Double circular linked list2 * list.h - Local double circular linked list, using local pointers. 3 3 * 4 4 * Authors Ghassan Almaless (2008,2009,2010,2011,2012) … … 91 91 92 92 /*************************************************************************** 93 * This macro returns tpointer on the first element of a list.93 * This macro returns a pointer on the first element of a list. 94 94 *************************************************************************** 95 95 * @ root : pointer on the list root … … 171 171 list_entry_t * entry ) 172 172 { 173 list_entry_t * next = root->next;174 175 entry->next = next;173 list_entry_t * first = root->next; 174 175 entry->next = first; 176 176 entry->pred = root; 177 177 178 root->next = entry;179 next->pred = entry;178 root->next = entry; 179 first->pred = entry; 180 180 } 181 181 … … 190 190 list_entry_t * entry ) 191 191 { 192 list_entry_t * pred= root->pred;192 list_entry_t * last = root->pred; 193 193 194 194 entry->next = root; 195 entry->pred = pred;195 entry->pred = last; 196 196 197 197 root->pred = entry; 198 pred->next = entry;198 last->next = entry; 199 199 } 200 200 … … 366 366 list_entry_t * entry ) 367 367 { 368 list_entry_t * next = hal_remote_lpt( XPTR( cxy , &root->next ) );368 list_entry_t * first = hal_remote_lpt( XPTR( cxy , &root->next ) ); 369 369 370 hal_remote_spt( XPTR( cxy , &entry->next ) , next );370 hal_remote_spt( XPTR( cxy , &entry->next ) , first ); 371 371 hal_remote_spt( XPTR( cxy , &entry->pred ) , root ); 372 372 373 hal_remote_spt( XPTR( cxy , &root->next ) , entry );374 hal_remote_spt( XPTR( cxy , & next->pred ) , entry );373 hal_remote_spt( XPTR( cxy , &root->next ) , entry ); 374 hal_remote_spt( XPTR( cxy , &first->pred ) , entry ); 375 375 } 376 376 … … 387 387 list_entry_t * entry ) 388 388 { 389 list_entry_t * pred= hal_remote_lpt( XPTR( cxy , &root->pred ) );389 list_entry_t * last = hal_remote_lpt( XPTR( cxy , &root->pred ) ); 390 390 391 391 hal_remote_spt( XPTR( cxy , &entry->next ) , root ); 392 hal_remote_spt( XPTR( cxy , &entry->pred ) , pred);392 hal_remote_spt( XPTR( cxy , &entry->pred ) , last ); 393 393 394 394 hal_remote_spt( XPTR( cxy , &root->pred ) , entry ); 395 hal_remote_spt( XPTR( cxy , & pred->next ) , entry );395 hal_remote_spt( XPTR( cxy , &last->next ) , entry ); 396 396 } 397 397 … … 401 401 *************************************************************************** 402 402 * @ cxy : remote list cluster identifier 403 * @ entry : pointer on the entry to be removed.403 * @ entry : local pointer on the remote entry to be removed. 404 404 **************************************************************************/ 405 405 static inline void list_remote_unlink( cxy_t cxy, -
trunk/kernel/libk/xlist.h
r636 r656 1 1 /* 2 * xlist.h - Double Circular Linked lists, using extended pointers.2 * xlist.h - Trans-cluster double circular linked list, using extended pointers. 3 3 * 4 4 * Author : Alain Greiner (2016,2017,2018,2019)
Note: See TracChangeset
for help on using the changeset viewer.