Changeset 656 for trunk/kernel/libk/grdxt.c
- Timestamp:
- Dec 6, 2019, 12:07:51 PM (5 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.