Changes in kernel/generic/src/mm/frame.c [97bdb4a:74c5a1ca] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/frame.c
r97bdb4a r74c5a1ca 75 75 /********************/ 76 76 77 NO_TRACEstatic inline size_t frame_index(zone_t *zone, frame_t *frame)77 static inline size_t frame_index(zone_t *zone, frame_t *frame) 78 78 { 79 79 return (size_t) (frame - zone->frames); 80 80 } 81 81 82 NO_TRACEstatic inline size_t frame_index_abs(zone_t *zone, frame_t *frame)82 static inline size_t frame_index_abs(zone_t *zone, frame_t *frame) 83 83 { 84 84 return (size_t) (frame - zone->frames) + zone->base; 85 85 } 86 86 87 NO_TRACEstatic inline bool frame_index_valid(zone_t *zone, size_t index)87 static inline bool frame_index_valid(zone_t *zone, size_t index) 88 88 { 89 89 return (index < zone->count); 90 90 } 91 91 92 NO_TRACEstatic inline size_t make_frame_index(zone_t *zone, frame_t *frame)92 static inline size_t make_frame_index(zone_t *zone, frame_t *frame) 93 93 { 94 94 return (frame - zone->frames); … … 100 100 * 101 101 */ 102 NO_TRACEstatic void frame_initialize(frame_t *frame)102 static void frame_initialize(frame_t *frame) 103 103 { 104 104 frame->refcount = 1; … … 121 121 * 122 122 */ 123 NO_TRACEstatic size_t zones_insert_zone(pfn_t base, size_t count)123 static size_t zones_insert_zone(pfn_t base, size_t count) 124 124 { 125 125 if (zones.count + 1 == ZONES_MAX) { … … 133 133 if (overlaps(base, count, 134 134 zones.info[i].base, zones.info[i].count)) { 135 printf("Zone (%p, %p) overlaps with zone (%p, %p)!\n", 136 PFN2ADDR(base), PFN2ADDR(base + count), 137 PFN2ADDR(zones.info[i].base), 138 PFN2ADDR(zones.info[i].base + zones.info[i].count)); 135 printf("Zones overlap!\n"); 139 136 return (size_t) -1; 140 137 } … … 165 162 */ 166 163 #ifdef CONFIG_DEBUG 167 NO_TRACEstatic size_t total_frames_free(void)164 static size_t total_frames_free(void) 168 165 { 169 166 size_t total = 0; … … 188 185 * 189 186 */ 190 NO_TRACEsize_t find_zone(pfn_t frame, size_t count, size_t hint)187 size_t find_zone(pfn_t frame, size_t count, size_t hint) 191 188 { 192 189 if (hint >= zones.count) … … 209 206 210 207 /** @return True if zone can allocate specified order */ 211 NO_TRACEstatic bool zone_can_alloc(zone_t *zone, uint8_t order)208 static bool zone_can_alloc(zone_t *zone, uint8_t order) 212 209 { 213 210 return (zone_flags_available(zone->flags) … … 225 222 * 226 223 */ 227 NO_TRACE static size_t find_free_zone(uint8_t order, zone_flags_t flags, 228 size_t hint) 224 static size_t find_free_zone(uint8_t order, zone_flags_t flags, size_t hint) 229 225 { 230 226 if (hint >= zones.count) … … 266 262 * 267 263 */ 268 NO_TRACE static link_t *zone_buddy_find_block(buddy_system_t *buddy,269 link_t *child,uint8_t order)264 static link_t *zone_buddy_find_block(buddy_system_t *buddy, link_t *child, 265 uint8_t order) 270 266 { 271 267 frame_t *frame = list_get_instance(child, frame_t, buddy_link); … … 289 285 * 290 286 */ 291 NO_TRACE static link_t *zone_buddy_find_buddy(buddy_system_t *buddy, 292 link_t *block) 287 static link_t *zone_buddy_find_buddy(buddy_system_t *buddy, link_t *block) 293 288 { 294 289 frame_t *frame = list_get_instance(block, frame_t, buddy_link); … … 326 321 * 327 322 */ 328 NO_TRACEstatic link_t *zone_buddy_bisect(buddy_system_t *buddy, link_t *block)323 static link_t *zone_buddy_bisect(buddy_system_t *buddy, link_t *block) 329 324 { 330 325 frame_t *frame_l = list_get_instance(block, frame_t, buddy_link); … … 344 339 * 345 340 */ 346 NO_TRACE static link_t *zone_buddy_coalesce(buddy_system_t *buddy,347 link_t *block_ 1, link_t *block_2)341 static link_t *zone_buddy_coalesce(buddy_system_t *buddy, link_t *block_1, 342 link_t *block_2) 348 343 { 349 344 frame_t *frame1 = list_get_instance(block_1, frame_t, buddy_link); … … 360 355 * 361 356 */ 362 NO_TRACEstatic void zone_buddy_set_order(buddy_system_t *buddy, link_t *block,357 static void zone_buddy_set_order(buddy_system_t *buddy, link_t *block, 363 358 uint8_t order) 364 359 { … … 374 369 * 375 370 */ 376 NO_TRACE static uint8_t zone_buddy_get_order(buddy_system_t *buddy, 377 link_t *block) 371 static uint8_t zone_buddy_get_order(buddy_system_t *buddy, link_t *block) 378 372 { 379 373 return list_get_instance(block, frame_t, buddy_link)->buddy_order; … … 386 380 * 387 381 */ 388 NO_TRACE static void zone_buddy_mark_busy(buddy_system_t *buddy, link_t *block)382 static void zone_buddy_mark_busy(buddy_system_t *buddy, link_t * block) 389 383 { 390 384 list_get_instance(block, frame_t, buddy_link)->refcount = 1; … … 395 389 * @param buddy Buddy system. 396 390 * @param block Buddy system block. 397 * 398 */ 399 NO_TRACE static void zone_buddy_mark_available(buddy_system_t *buddy, 400 link_t *block) 391 */ 392 static void zone_buddy_mark_available(buddy_system_t *buddy, link_t *block) 401 393 { 402 394 list_get_instance(block, frame_t, buddy_link)->refcount = 0; … … 429 421 * 430 422 */ 431 NO_TRACEstatic pfn_t zone_frame_alloc(zone_t *zone, uint8_t order)423 static pfn_t zone_frame_alloc(zone_t *zone, uint8_t order) 432 424 { 433 425 ASSERT(zone_flags_available(zone->flags)); … … 457 449 * 458 450 */ 459 NO_TRACEstatic void zone_frame_free(zone_t *zone, size_t frame_idx)451 static void zone_frame_free(zone_t *zone, size_t frame_idx) 460 452 { 461 453 ASSERT(zone_flags_available(zone->flags)); … … 478 470 479 471 /** Return frame from zone. */ 480 NO_TRACEstatic frame_t *zone_get_frame(zone_t *zone, size_t frame_idx)472 static frame_t *zone_get_frame(zone_t *zone, size_t frame_idx) 481 473 { 482 474 ASSERT(frame_idx < zone->count); … … 485 477 486 478 /** Mark frame in zone unavailable to allocation. */ 487 NO_TRACEstatic void zone_mark_unavailable(zone_t *zone, size_t frame_idx)479 static void zone_mark_unavailable(zone_t *zone, size_t frame_idx) 488 480 { 489 481 ASSERT(zone_flags_available(zone->flags)); … … 514 506 * 515 507 */ 516 NO_TRACE static void zone_merge_internal(size_t z1, size_t z2, zone_t *old_z1, 517 buddy_system_t *buddy) 508 static void zone_merge_internal(size_t z1, size_t z2, zone_t *old_z1, buddy_system_t *buddy) 518 509 { 519 510 ASSERT(zone_flags_available(zones.info[z1].flags)); … … 611 602 * 612 603 */ 613 NO_TRACEstatic void return_config_frames(size_t znum, pfn_t pfn, size_t count)604 static void return_config_frames(size_t znum, pfn_t pfn, size_t count) 614 605 { 615 606 ASSERT(zone_flags_available(zones.info[znum].flags)); … … 646 637 * 647 638 */ 648 NO_TRACE static void zone_reduce_region(size_t znum, pfn_t frame_idx, 649 size_t count) 639 static void zone_reduce_region(size_t znum, pfn_t frame_idx, size_t count) 650 640 { 651 641 ASSERT(zone_flags_available(zones.info[znum].flags)); … … 787 777 * 788 778 */ 789 NO_TRACE static void zone_construct(zone_t *zone, buddy_system_t *buddy,790 pfn_t start,size_t count, zone_flags_t flags)779 static void zone_construct(zone_t *zone, buddy_system_t *buddy, pfn_t start, 780 size_t count, zone_flags_t flags) 791 781 { 792 782 zone->base = start; … … 831 821 * 832 822 */ 833 size_t zone_conf_size(size_t count)823 uintptr_t zone_conf_size(size_t count) 834 824 { 835 825 return (count * sizeof(frame_t) + buddy_conf_size(fnzb(count))); … … 1118 1108 * 1119 1109 */ 1120 NO_TRACEvoid frame_reference_add(pfn_t pfn)1110 void frame_reference_add(pfn_t pfn) 1121 1111 { 1122 1112 irq_spinlock_lock(&zones.lock, true); … … 1137 1127 * 1138 1128 */ 1139 NO_TRACEvoid frame_mark_unavailable(pfn_t start, size_t count)1129 void frame_mark_unavailable(pfn_t start, size_t count) 1140 1130 { 1141 1131 irq_spinlock_lock(&zones.lock, true);
Note:
See TracChangeset
for help on using the changeset viewer.