Changeset b87f418 in mainline for generic/src/mm/frame.c


Ignore:
Timestamp:
2005-12-07T23:00:30Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f62355a
Parents:
4acac843
Message:

Send in some improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/mm/frame.c

    r4acac843 rb87f418  
    11/*
    2  * Copyright (C) 2001-2004 Jakub Jermar
     2 * Copyright (C) 2001-2005 Jakub Jermar
     3 * Copyright (C) 2005 Sergey Bondari
    34 * All rights reserved.
    45 *
     
    226227
    227228        /* Force base to the nearest lower address frame boundary. */
    228         base &= ~(FRAME_SIZE - 1);
     229        base = ALIGN_DOWN(base, FRAME_SIZE);
    229230        /* 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);
    233234        zone_blacklist[index].base = base;
    234235        zone_blacklist[index].size = size;
     
    285286
    286287        if (!z) {
    287                 panic("Cannot allocate zone (%dB).\n", size);
     288                panic("Cannot allocate zone (base=%P, size=%d).\n", base, size);
    288289        }
    289290       
     
    394395        frame_t * frame;
    395396        zone_t * zone;
    396         count_t index;
     397        index_t index;
    397398        bool is_left, is_right;
    398399
     
    400401        zone = (zone_t *) b->data;
    401402       
     403        ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX(zone, frame), frame->buddy_order));
     404       
    402405        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       
    408410        if (is_left) {
    409411                index = (FRAME_INDEX(zone, frame)) + (1 << frame->buddy_order);
     
    431433link_t * zone_buddy_bisect(buddy_system_t *b, link_t * block) {
    432434        frame_t * frame_l, * frame_r;
     435
    433436        frame_l = list_get_instance(block, frame_t, buddy_link);
    434437        frame_r = (frame_l + (1 << (frame_l->buddy_order - 1)));
     438       
    435439        return &frame_r->buddy_link;
    436440}
     
    446450link_t * zone_buddy_coalesce(buddy_system_t *b, link_t * block_1, link_t * block_2) {
    447451        frame_t * frame1, * frame2;
     452       
    448453        frame1 = list_get_instance(block_1, frame_t, buddy_link);
    449454        frame2 = list_get_instance(block_2, frame_t, buddy_link);
     455       
    450456        return frame1 < frame2 ? block_1 : block_2;
    451457}
Note: See TracChangeset for help on using the changeset viewer.