- Timestamp:
- 2005-12-07T23:00:30Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f62355a
- Parents:
- 4acac843
- Location:
- generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/include/align.h
r4acac843 rb87f418 30 30 #define __ALIGN_H__ 31 31 32 #define ALIGN(s, a) ((s) % (a) ? (((s) / (a)) + 1) * (a) : (s)) 32 /** Align to the nearest higher address. 33 * 34 * @param s Address or size to be aligned. 35 * @param a Size of alignment. 36 */ 37 #define ALIGN_UP(s, a) ((s) % (a) ? (((s) / (a)) + 1) * (a) : (s)) 38 39 /** Align to the nearest lower address. 40 * 41 * @param s Address or size to be aligned. 42 * @param a Size of alignment. 43 */ 44 #define ALIGN_DOWN(s, a) ((s) & ~((a)-1)) 33 45 34 46 #endif -
generic/include/mm/frame.h
r4acac843 rb87f418 46 46 #define FRAME_INDEX(zone, frame) ((index_t)((frame) - (zone)->frames)) 47 47 #define FRAME_INDEX_VALID(zone, index) (((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count))) 48 #define IS_BUDDY_LEFT_BLOCK(zone, frame) ((FRAME_INDEX((zone), (frame)) & ~(((__native) -1)<<((frame)->buddy_order + 1))) == 0) 48 #define IS_BUDDY_ORDER_OK(index, order) ((~(((__native) -1) << (order)) & (index)) == 0) 49 #define IS_BUDDY_LEFT_BLOCK(zone, frame) (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0) 50 #define IS_BUDDY_RIGHT_BLOCK(zone, frame) (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1) 49 51 50 52 #define ZONE_BLACKLIST_SIZE 3 -
generic/src/main/main.c
r4acac843 rb87f418 142 142 143 143 heap_size = CONFIG_HEAP_SIZE + (config.memory_size/FRAME_SIZE)*sizeof(frame_t); 144 kernel_size = ALIGN (hardcoded_ktext_size + hardcoded_kdata_size + heap_size, PAGE_SIZE);144 kernel_size = ALIGN_UP(hardcoded_ktext_size + hardcoded_kdata_size + heap_size, PAGE_SIZE); 145 145 heap_delta = kernel_size - (hardcoded_ktext_size + hardcoded_kdata_size + heap_size); 146 146 -
generic/src/mm/frame.c
r4acac843 rb87f418 1 1 /* 2 * Copyright (C) 2001-2004 Jakub Jermar 2 * Copyright (C) 2001-2005 Jakub Jermar 3 * Copyright (C) 2005 Sergey Bondari 3 4 * All rights reserved. 4 5 * … … 226 227 227 228 /* Force base to the nearest lower address frame boundary. */ 228 base &= ~(FRAME_SIZE - 1);229 base = ALIGN_DOWN(base, FRAME_SIZE); 229 230 /* Align size to frame boundary. */ 230 size = ALIGN (size, FRAME_SIZE);231 232 ASSERT( zone_blacklist_count <=ZONE_BLACKLIST_SIZE);231 size = ALIGN_UP(size, FRAME_SIZE); 232 233 ASSERT(index < ZONE_BLACKLIST_SIZE); 233 234 zone_blacklist[index].base = base; 234 235 zone_blacklist[index].size = size; … … 285 286 286 287 if (!z) { 287 panic("Cannot allocate zone ( %dB).\n", size);288 panic("Cannot allocate zone (base=%P, size=%d).\n", base, size); 288 289 } 289 290 … … 394 395 frame_t * frame; 395 396 zone_t * zone; 396 count_t index;397 index_t index; 397 398 bool is_left, is_right; 398 399 … … 400 401 zone = (zone_t *) b->data; 401 402 403 ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX(zone, frame), frame->buddy_order)); 404 402 405 is_left = IS_BUDDY_LEFT_BLOCK(zone, frame); 403 is_right = !is_left; 404 405 /* 406 * test left buddy 407 */ 406 is_right = IS_BUDDY_RIGHT_BLOCK(zone, frame); 407 408 ASSERT(is_left ^ is_right); 409 408 410 if (is_left) { 409 411 index = (FRAME_INDEX(zone, frame)) + (1 << frame->buddy_order); … … 431 433 link_t * zone_buddy_bisect(buddy_system_t *b, link_t * block) { 432 434 frame_t * frame_l, * frame_r; 435 433 436 frame_l = list_get_instance(block, frame_t, buddy_link); 434 437 frame_r = (frame_l + (1 << (frame_l->buddy_order - 1))); 438 435 439 return &frame_r->buddy_link; 436 440 } … … 446 450 link_t * zone_buddy_coalesce(buddy_system_t *b, link_t * block_1, link_t * block_2) { 447 451 frame_t * frame1, * frame2; 452 448 453 frame1 = list_get_instance(block_1, frame_t, buddy_link); 449 454 frame2 = list_get_instance(block_2, frame_t, buddy_link); 455 450 456 return frame1 < frame2 ? block_1 : block_2; 451 457 }
Note:
See TracChangeset
for help on using the changeset viewer.