Changeset 619 for trunk/kernel/mm/kcm.c
- Timestamp:
- Feb 12, 2019, 1:15:47 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/kcm.c
r567 r619 3 3 * 4 4 * Author Ghassan Almaless (2008,2009,2010,2011,2012) 5 * Alain Greiner (2016,2017,2018 )5 * Alain Greiner (2016,2017,2018,2019) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 51 51 52 52 #if DEBUG_KCM 53 thread_t * this = CURRENT_THREAD; 53 54 uint32_t cycle = (uint32_t)hal_get_cycles(); 54 55 if( DEBUG_KCM < cycle ) 55 printk("\n[ DBG] %s : thread %xenters for %s / page %x / count %d / active %d\n",56 __FUNCTION__ , CURRENT_THREAD , kmem_type_str( kcm->type ),56 printk("\n[%s] thread[%x,%x] enters for %s / page %x / count %d / active %d\n", 57 __FUNCTION__, this->process->pid, this->trdid, kmem_type_str(kcm->type), 57 58 (intptr_t)kcm_page , kcm_page->count , kcm_page->active ); 58 59 #endif 59 60 60 61 assert( kcm_page->active , "kcm_page should be active" ); 61 62 62 63 // get first block available 63 64 int32_t index = bitmap_ffs( kcm_page->bitmap , kcm->blocks_nr ); 64 65 65 66 assert( (index != -1) , "kcm_page should not be full" ); 66 67 67 68 // allocate block … … 90 91 cycle = (uint32_t)hal_get_cycles(); 91 92 if( DEBUG_KCM < cycle ) 92 printk("\n[ DBG] %s : thread %x exit / type%s / ptr %x / page %x / count %d\n",93 __FUNCTION__ , CURRENT_THREAD , kmem_type_str( kcm->type ) , (intptr_t)ptr,94 (intptr_t) kcm_page, kcm_page->count );93 printk("\n[%s] thread[%x,%x] exit for %s / ptr %x / page %x / count %d\n", 94 __FUNCTION__, this->process->pid, this->trdid, kmem_type_str(kcm->type), 95 (intptr_t)ptr, (intptr_t)kcm_page, kcm_page->count ); 95 96 #endif 96 97 … … 115 116 index = ((uint8_t *)ptr - (uint8_t *)kcm_page - CONFIG_KCM_SLOT_SIZE) / kcm->block_size; 116 117 117 assert( !bitmap_state( kcm_page->bitmap , index ) , "page already freed" ); 118 assert( (kcm_page->count > 0) , "count already zero" ); 118 assert( !bitmap_state( kcm_page->bitmap , index ) , "page already freed" ); 119 120 assert( (kcm_page->count > 0) , "count already zero" ); 119 121 120 122 bitmap_set( kcm_page->bitmap , index ); … … 163 165 if( page == NULL ) 164 166 { 165 printk("\n[ERROR] in %s : failed to allocate page in cluster % d\n",166 167 printk("\n[ERROR] in %s : failed to allocate page in cluster %x\n", 168 __FUNCTION__ , local_cxy ); 167 169 return ENOMEM; 168 170 } … … 216 218 uint32_t type ) 217 219 { 218 // the kcm_page descriptor mut fit in the KCM slot 219 assert( (sizeof(kcm_page_t) <= CONFIG_KCM_SLOT_SIZE) , 220 "KCM slot too small\n" ); 220 221 // the kcm_page descriptor must fit in the KCM slot 222 assert( (sizeof(kcm_page_t) <= CONFIG_KCM_SLOT_SIZE) , "KCM slot too small\n" ); 223 224 // the allocated object must fit in one single page 225 assert( (kmem_type_size(type) <= (CONFIG_PPM_PAGE_SIZE - CONFIG_KCM_SLOT_SIZE)), 226 "allocated object requires more than one single page\n" ); 221 227 222 228 // initialize lock … … 241 247 uint32_t blocks_nr = (CONFIG_PPM_PAGE_SIZE - CONFIG_KCM_SLOT_SIZE) / block_size; 242 248 kcm->blocks_nr = blocks_nr; 249 250 #if DEBUG_KCM 251 thread_t * this = CURRENT_THREAD; 252 uint32_t cycle = (uint32_t)hal_get_cycles(); 253 if( DEBUG_KCM < cycle ) 254 printk("\n[%s] thread[%x,%x] initialised KCM %s : block_size %d / blocks_nr %d\n", 255 __FUNCTION__, this->process->pid, this->trdid, 256 kmem_type_str( kcm->type ), block_size, blocks_nr ); 257 #endif 258 243 259 } 244 260 … … 331 347 kcm_t * kcm; 332 348 333 assert( (ptr != NULL) , "pointer cannot be NULL" ); 349 // check argument 350 assert( (ptr != NULL) , "pointer cannot be NULL" ); 334 351 335 352 kcm_page = (kcm_page_t *)((intptr_t)ptr & ~CONFIG_PPM_PAGE_MASK);
Note: See TracChangeset
for help on using the changeset viewer.