Changeset 183 for trunk/kernel/mm/mapper.c
- Timestamp:
- Jul 11, 2017, 1:15:53 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/mapper.c
r53 r183 48 48 49 49 // allocate memory for associated mapper 50 51 50 req.type = KMEM_MAPPER; 51 req.size = sizeof(mapper_t); 52 52 req.flags = AF_KERNEL | AF_ZERO; 53 53 mapper = (mapper_t *)kmem_alloc( &req ); 54 54 55 55 if( mapper == NULL ) … … 60 60 61 61 // initialize refcount & inode 62 62 mapper->refcount = 0; 63 63 mapper->inode = NULL; 64 64 65 65 // initialize radix tree 66 66 error = grdxt_init( &mapper->radix, 67 67 CONFIG_VMM_GRDXT_W1, 68 68 CONFIG_VMM_GRDXT_W2, … … 72 72 { 73 73 printk("\n[ERROR] in %s : cannot initialize radix tree\n", __FUNCTION__ ); 74 74 req.type = KMEM_MAPPER; 75 75 req.ptr = mapper; 76 76 kmem_free( &req ); … … 79 79 80 80 // initialize mapper lock 81 81 rwlock_init( &mapper->lock ); 82 82 83 83 // initialize waiting threads xlist (empty) 84 84 xlist_root_init( XPTR( local_cxy , &mapper->wait_root ) ); 85 85 86 86 // initialize vsegs xlist (empty) 87 87 xlist_root_init( XPTR( local_cxy , &mapper->vsegs_root ) ); 88 88 89 89 return mapper; 90 91 } // end mapper_create() 90 } 92 91 93 92 /////////////////////////////////////////// … … 109 108 { 110 109 // remove page from mapper and release to PPM 111 110 error = mapper_release_page( mapper , page ); 112 111 113 112 if ( error ) return error; … … 128 127 129 128 return 0; 130 131 } // end mapper_destroy() 132 129 } 133 130 134 131 //////////////////////////////////////////// … … 136 133 uint32_t index ) 137 134 { 138 139 140 135 kmem_req_t req; 136 page_t * page; 137 error_t error; 141 138 142 139 thread_t * this = CURRENT_THREAD; … … 149 146 150 147 // test if page available in mapper 151 if( ( page == NULL) || page_is_flag( page , PG_INLOAD ) ) // page not available 148 if( ( page == NULL) || page_is_flag( page , PG_INLOAD ) ) // page not available 152 149 { 153 150 // release the lock in READ_MODE and take it in WRITE_MODE … … 252 249 return page; 253 250 } 254 } // end mapper_get_page()251 } 255 252 256 253 /////////////////////////////////////////////// … … 273 270 274 271 // remove physical page from radix tree 275 272 grdxt_remove( &mapper->radix , page->index ); 276 273 277 274 // release mapper lock from WRITE_MODE … … 279 276 280 277 // release page to PPM 281 282 278 kmem_req_t req; 279 req.type = KMEM_PAGE; 283 280 req.ptr = page; 284 281 kmem_free( &req ); 285 282 286 283 return 0; 287 288 } // end mapper_release_page() 284 } 289 285 290 286 ///////////////////////////////////////// … … 316 312 for( index = first ; index <= last ; index++ ) 317 313 { 318 // compute page_offset 314 // compute page_offset 319 315 if( index == first ) page_offset = min_byte & CONFIG_PPM_PAGE_MASK; 320 316 else page_offset = 0; 321 317 322 // compute page_count 318 // compute page_count 323 319 if ( first == last ) page_count = size; 324 320 else if ( index == first ) page_count = CONFIG_PPM_PAGE_SIZE - page_offset; … … 352 348 353 349 return 0; 354 355 } // end mapper_move() 356 357 358 350 } 351
Note: See TracChangeset
for help on using the changeset viewer.