Changeset 683 for trunk/kernel/libk/remote_buf.c
- Timestamp:
- Jan 13, 2021, 12:36:17 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/remote_buf.c
r671 r683 34 34 remote_buf_t * remote_buf_alloc( cxy_t cxy ) 35 35 { 36 kmem_req_t req; 37 38 req.type = KMEM_KCM; 39 req.order = bits_log2( sizeof(remote_buf_t) ); 40 req.flags = AF_ZERO; 41 return kmem_remote_alloc( cxy , &req ); 36 return kmem_remote_alloc( cxy, 37 bits_log2(sizeof(remote_buf_t)), 38 AF_ZERO ); 42 39 } 43 40 … … 50 47 assert( __FUNCTION__ , (order < 32) , "order cannot be larger than 31" ); 51 48 52 kmem_req_t req;53 49 uint8_t * data; 54 50 … … 57 53 58 54 // allocate the data buffer 59 if( order >= CONFIG_PPM_PAGE_SHIFT ) // use KMEM_PPM 60 { 61 req.type = KMEM_PPM; 62 req.order = order - CONFIG_PPM_PAGE_SHIFT; 63 req.flags = AF_NONE; 64 data = kmem_remote_alloc( buf_cxy , &req ); 65 66 if( data == NULL ) return -1; 67 } 68 else // use KMEM_KCM 69 { 70 req.type = KMEM_KCM; 71 req.order = order; 72 req.flags = AF_NONE; 73 data = kmem_remote_alloc( buf_cxy , &req ); 74 75 if( data == NULL ) return -1; 76 } 55 data = kmem_remote_alloc( buf_cxy , order , AF_NONE ); 56 57 if( data == NULL ) return -1; 77 58 78 59 // initialize buffer descriptor … … 90 71 void remote_buf_release_data( xptr_t buf_xp ) 91 72 { 92 kmem_req_t req;93 73 94 74 assert( __FUNCTION__ , (buf_xp != XPTR_NULL) , "buf_xp cannot be NULL" ); … … 102 82 103 83 // release memory allocated for data buffer if required 104 if( data_ptr != NULL ) 105 { 106 if( order >= CONFIG_PPM_PAGE_SHIFT ) // use KMEM_PPM 107 { 108 req.type = KMEM_PPM; 109 req.ptr = data_ptr; 110 kmem_remote_free( buf_cxy , &req ); 111 } 112 else // use KMEM_KCM 113 { 114 req.type = KMEM_KCM; 115 req.ptr = data_ptr; 116 kmem_remote_free( buf_cxy , &req ); 117 } 118 } 84 if( data_ptr != NULL ) kmem_remote_free( buf_cxy , data_ptr , order ); 85 119 86 } // end remote_buf_release_data() 120 87 … … 125 92 assert( __FUNCTION__ , (buf_xp != XPTR_NULL) , "buf_xp cannot be NULL" ); 126 93 127 kmem_req_t req;128 129 94 remote_buf_t * buf_ptr = GET_PTR( buf_xp ); 130 95 cxy_t buf_cxy = GET_CXY( buf_xp ); … … 134 99 135 100 // release remote_buf descriptor 136 req.type = KMEM_KCM; 137 req.ptr = buf_ptr; 138 kmem_remote_free( buf_cxy , &req ); 101 kmem_remote_free( buf_cxy , buf_ptr , bits_log2(sizeof(remote_buf_t)) ); 139 102 140 103 } // end remote_buf_destroy() … … 404 367 } // end remote_buf_status() 405 368 406 369 /////////////////////////////////////////////// 370 void remote_buf_display( const char * func_str, 371 xptr_t buf_xp, 372 uint32_t nbytes, 373 uint32_t offset ) 374 { 375 if( nbytes > 256 ) 376 { 377 printk("\n[WARNING] in %s : no more than 256 bytes\n", __FUNCTION__ ); 378 nbytes = 256; 379 } 380 381 uint8_t string[128]; // for header 382 uint8_t local_data[256]; // local data buffer 383 384 cxy_t cxy = GET_CXY( buf_xp ); 385 remote_buf_t * ptr = GET_PTR( buf_xp ); 386 387 uint32_t order = hal_remote_l32( XPTR( cxy , &ptr->order )); 388 uint32_t rid = hal_remote_l32( XPTR( cxy , &ptr->rid )); 389 uint32_t wid = hal_remote_l32( XPTR( cxy , &ptr->wid )); 390 uint32_t sts = hal_remote_l32( XPTR( cxy , &ptr->sts )); 391 uint8_t * data = hal_remote_lpt( XPTR( cxy , &ptr->data )); 392 393 // make a local copy of data buffer 394 hal_remote_memcpy( XPTR( local_cxy , local_data ), 395 XPTR( cxy , data + offset ), 396 nbytes ); 397 398 // build header 399 snprintk( (char*)string , 128 , 400 "in %s remote buffer [%x,%x] : size %d / rid %d / wid %d / sts %d ", 401 func_str , cxy , ptr , 1<<order , rid , wid , sts ); 402 403 // display buffer on TXT0 404 putb( (char*)string , local_data , nbytes ); 405 406 } // end remote_buf_display()
Note: See TracChangeset
for help on using the changeset viewer.