Changeset 686 for trunk/hal/tsar_mips32/core/hal_context.c
- Timestamp:
- Jan 13, 2021, 12:47:53 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_context.c
r679 r686 2 2 * hal_context.c - implementation of Thread Context API for TSAR-MIPS32 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 121 121 { 122 122 123 assert( __FUNCTION__, (sizeof(hal_cpu_context_t) <= CONFIG_CPU_CTX_SIZE), "illegal CPU context size" ); 123 assert( __FUNCTION__, (sizeof(hal_cpu_context_t) <= CONFIG_CPU_CTX_SIZE), 124 "illegal CPU context size" ); 124 125 125 126 // allocate memory for cpu_context 126 kmem_req_t req; 127 req.type = KMEM_KCM; 128 req.order = bits_log2( sizeof(hal_cpu_context_t) ); 129 req.flags = AF_KERNEL | AF_ZERO; 130 131 hal_cpu_context_t * context = kmem_alloc( &req ); 132 127 hal_cpu_context_t * context = kmem_alloc( bits_log2( sizeof(hal_cpu_context_t) ), 128 AF_KERNEL | AF_ZERO); 133 129 if( context == NULL ) return -1; 134 130 … … 152 148 hal_cpu_context_t * context = (hal_cpu_context_t *)thread->cpu_context; 153 149 154 assert( __FUNCTION__, (context != NULL ), "CPU context not allocated" ); 150 assert( __FUNCTION__, (context != NULL ), 151 "CPU context not allocated" ); 155 152 156 153 // compute the PPN for the GPT PT1 … … 405 402 void hal_cpu_context_destroy( thread_t * thread ) 406 403 { 407 kmem_req_t req; 408 404 // get pointer on CPU context 409 405 hal_cpu_context_t * ctx = thread->cpu_context; 410 406 411 407 // release CPU context if required 412 if( ctx != NULL ) 413 { 414 req.type = KMEM_KCM; 415 req.ptr = ctx; 416 kmem_free( &req ); 417 } 408 if( ctx != NULL ) kmem_free( ctx , bits_log2( sizeof(hal_cpu_context_t)) ); 418 409 419 410 } // end hal_cpu_context_destroy() … … 434 425 435 426 // allocate memory for fpu_context 436 kmem_req_t req; 437 req.type = KMEM_KCM; 438 req.flags = AF_KERNEL | AF_ZERO; 439 req.order = bits_log2( sizeof(hal_fpu_context_t) ); 440 441 hal_fpu_context_t * context = kmem_alloc( &req ); 427 hal_fpu_context_t * context = kmem_alloc( bits_log2( sizeof(hal_fpu_context_t) ), 428 AF_KERNEL | AF_ZERO ); 442 429 443 430 if( context == NULL ) return -1; … … 454 441 hal_fpu_context_t * context = thread->fpu_context; 455 442 456 assert( __FUNCTION__, (context != NULL) , "fpu context not allocated" ); 443 assert( __FUNCTION__, (context != NULL) , 444 "fpu context not allocated" ); 457 445 458 446 memset( context , 0 , sizeof(hal_fpu_context_t) ); … … 478 466 void hal_fpu_context_destroy( thread_t * thread ) 479 467 { 480 kmem_req_t req; 481 482 hal_fpu_context_t * context = thread->fpu_context; 468 // get pointer on FPU context 469 hal_fpu_context_t * ctx = thread->fpu_context; 483 470 484 471 // release FPU context if required 485 if( context != NULL ) 486 { 487 req.type = KMEM_KCM; 488 req.ptr = context; 489 kmem_free( &req ); 490 } 472 if( ctx != NULL ) kmem_free( ctx , bits_log2( sizeof(hal_fpu_context_t)) ); 491 473 492 474 } // end hal_fpu_context_destroy()
Note: See TracChangeset
for help on using the changeset viewer.