Changeset 683 for trunk/kernel/libk/grdxt.c
- Timestamp:
- Jan 13, 2021, 12:36:17 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/grdxt.c
r671 r683 40 40 uint32_t ix3_width ) 41 41 { 42 43 assert( __FUNCTION__, (rt != NULL), 44 "pointer on radix tree is NULL\n" ); 45 42 46 void ** root; 43 kmem_req_t req;44 47 45 48 rt->ix1_width = ix1_width; … … 48 51 49 52 // allocates first level array 50 req.type = KMEM_KCM; 51 req.order = ix1_width + ( (sizeof(void*) == 4) ? 2 : 3 ); 52 req.flags = AF_KERNEL | AF_ZERO; 53 root = kmem_alloc( &req ); 53 uint32_t order = ix1_width + ( (sizeof(void*) == 4) ? 2 : 3 ); 54 root = kmem_alloc( order , AF_ZERO ); 54 55 55 56 if( root == NULL ) … … 68 69 void grdxt_destroy( grdxt_t * rt ) 69 70 { 70 kmem_req_t req; 71 72 assert( __FUNCTION__, (rt != NULL), 73 "pointer on radix tree is NULL\n" ); 74 75 uint32_t order; 71 76 72 77 uint32_t w1 = rt->ix1_width; … … 81 86 uint32_t ix2; 82 87 uint32_t ix3; 83 84 assert( __FUNCTION__, (rt != NULL) , "pointer on radix tree is NULL\n" );85 88 86 89 for( ix1=0 ; ix1 < (uint32_t)(1 << w1) ; ix1++ ) … … 106 109 107 110 // release level 3 array 108 req.type = KMEM_KCM; 109 req.ptr = ptr3; 110 kmem_free( &req ); 111 order = w3 + ( (sizeof(void*) == 4) ? 2 : 3 ); 112 kmem_free( ptr3 , order ); 111 113 } 112 114 113 115 // release level 2 array 114 req.type = KMEM_KCM; 115 req.ptr = ptr2; 116 kmem_free( &req ); 116 order = w2 + ( (sizeof(void*) == 4) ? 2 : 3 ); 117 kmem_free( ptr2 , order ); 117 118 } 118 119 119 120 // release level 1 array 120 req.type = KMEM_KCM; 121 req.ptr = ptr1; 122 kmem_free( &req ); 121 order = w1 + ( (sizeof(void*) == 4) ? 2 : 3 ); 122 kmem_free( ptr1 , order ); 123 123 124 124 } // end grdxt_destroy() … … 129 129 void * value ) 130 130 { 131 kmem_req_t req;131 uint32_t order; 132 132 133 133 uint32_t w1 = rt->ix1_width; … … 136 136 137 137 // Check key value 138 assert( __FUNCTION__, ((key >> (w1 + w2 + w3)) == 0 ), "illegal key value %x\n", key ); 138 assert( __FUNCTION__, ((key >> (w1 + w2 + w3)) == 0 ), 139 "illegal key value %x\n", key ); 139 140 140 141 // compute indexes … … 155 156 { 156 157 // allocate memory for level 2 array 157 req.type = KMEM_KCM; 158 req.order = w2 + ( (sizeof(void*) == 4) ? 2 : 3 ); 159 req.flags = AF_KERNEL | AF_ZERO; 160 ptr2 = kmem_alloc( &req ); 158 order = w2 + ( (sizeof(void*) == 4) ? 2 : 3 ); 159 ptr2 = kmem_alloc( order , AF_ZERO ); 161 160 162 161 if( ptr2 == NULL) return -1; … … 173 172 { 174 173 // allocate memory for level 3 array 175 req.type = KMEM_KCM; 176 req.order = w3 + ( (sizeof(void*) == 4) ? 2 : 3 ); 177 req.flags = AF_KERNEL | AF_ZERO; 178 ptr3 = kmem_alloc( &req ); 174 order = w3 + ( (sizeof(void*) == 4) ? 2 : 3 ); 175 ptr3 = kmem_alloc( order , AF_ZERO ); 179 176 180 177 if( ptr3 == NULL) return -1; … … 202 199 203 200 // Check key value 204 assert( __FUNCTION__, ((key >> (w1 + w2 + w3)) == 0 ), "illegal key value %x\n", key ); 201 assert( __FUNCTION__, ((key >> (w1 + w2 + w3)) == 0 ), 202 "illegal key value %x\n", key ); 205 203 206 204 // compute indexes … … 244 242 245 243 // Check key value 246 assert( __FUNCTION__, ((key >> (w1 + w2 + w3)) == 0 ), "illegal key value %x\n", key ); 244 assert( __FUNCTION__, ((key >> (w1 + w2 + w3)) == 0 ), 245 "illegal key value %x\n", key ); 247 246 248 247 void ** ptr1 = rt->root; … … 284 283 285 284 // Check key value 286 assert( __FUNCTION__, ((start_key >> (w1 + w2 + w3)) == 0 ), "illegal key value %x\n", start_key ); 285 assert( __FUNCTION__, ((start_key >> (w1 + w2 + w3)) == 0 ), 286 "illegal key value %x\n", start_key ); 287 287 288 288 // compute max indexes … … 338 338 uint32_t ix3_width ) 339 339 { 340 341 assert( __FUNCTION__, (rt_xp != XPTR_NULL), 342 "extended pointer on radix tree is NULL\n" ); 343 340 344 void ** root; 341 kmem_req_t req;342 345 343 346 // get cluster and local pointer … … 351 354 352 355 // allocates first level array 353 req.type = KMEM_KCM; 354 req.order = ix1_width + ( (sizeof(void*) == 4) ? 2 : 3 ); 355 req.flags = AF_KERNEL | AF_ZERO; 356 root = kmem_remote_alloc( rt_cxy , &req ); 356 uint32_t order = ix1_width + ( (sizeof(void*) == 4) ? 2 : 3 ); 357 root = kmem_remote_alloc( rt_cxy , order , AF_ZERO ); 357 358 358 359 if( root == NULL ) … … 372 373 void grdxt_remote_destroy( xptr_t rt_xp ) 373 374 { 374 kmem_req_t req; 375 376 assert( __FUNCTION__, (rt_xp != XPTR_NULL), 377 "extended pointer on radix tree is NULL\n" ); 378 379 uint32_t order; 375 380 376 381 uint32_t w1; … … 422 427 423 428 // release level 3 array 424 req.type = KMEM_KCM; 425 req.ptr = ptr3; 426 kmem_remote_free( rt_cxy , &req ); 429 order = w3 + ((sizeof(void*) == 4) ? 2 : 3 ); 430 kmem_remote_free( rt_cxy , ptr3 , order ); 427 431 } 428 432 429 433 // release level 2 array 430 req.type = KMEM_KCM; 431 req.ptr = ptr2; 432 kmem_remote_free( rt_cxy , &req ); 434 order = w2 + ((sizeof(void*) == 4) ? 2 : 3 ); 435 kmem_remote_free( rt_cxy , ptr2 , order ); 433 436 } 434 437 435 438 // release level 1 array 436 req.type = KMEM_KCM; 437 req.ptr = ptr1; 438 kmem_remote_free( rt_cxy , &req ); 439 order = w1 + ((sizeof(void*) == 4) ? 2 : 3 ); 440 kmem_remote_free( rt_cxy , ptr1 , order ); 439 441 440 442 } // end grdxt_remote_destroy() … … 445 447 void * value ) 446 448 { 447 kmem_req_t req;449 uint32_t order; 448 450 449 451 // get cluster and local pointer on remote rt descriptor … … 507 509 { 508 510 // allocate memory in remote cluster 509 req.type = KMEM_KCM; 510 req.order = w2 + ((sizeof(void*) == 4) ? 2 : 3 ); 511 req.flags = AF_ZERO | AF_KERNEL; 512 ptr2 = kmem_remote_alloc( rt_cxy , &req ); 511 order = w2 + ((sizeof(void*) == 4) ? 2 : 3 ); 512 ptr2 = kmem_remote_alloc( rt_cxy , order , AF_ZERO ); 513 513 514 514 if( ptr2 == NULL ) return -1; … … 538 538 { 539 539 // allocate memory in remote cluster 540 req.type = KMEM_KCM; 541 req.order = w3 + ((sizeof(void*) == 4) ? 2 : 3 ); 542 req.flags = AF_ZERO | AF_KERNEL; 543 ptr3 = kmem_remote_alloc( rt_cxy , &req ); 540 order = w3 + ((sizeof(void*) == 4) ? 2 : 3 ); 541 ptr3 = kmem_remote_alloc( rt_cxy , order , AF_ZERO ); 544 542 545 543 if( ptr3 == NULL ) return -1;
Note: See TracChangeset
for help on using the changeset viewer.