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


Ignore:
Timestamp:
2005-12-05T17:02:40Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
61e6c39
Parents:
9ebc238
Message:

Buddy system cleanup and fixes.

  • missing use of KA2PA in frame_init
  • truncating black list addresses to frame boundaries
  • removal of left-over obsolete structures
  • fixing some comments
File:
1 edited

Legend:

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

    r9ebc238 r4457455  
    6464        if (config.cpu_active == 1) {
    6565                zone_init();
    66                 frame_region_not_free(config.base, config.kernel_size);
     66                frame_region_not_free(KA2PA(config.base), config.kernel_size);
    6767        }
    6868
     
    7070}
    7171
    72 /** Allocate a frame
    73  *
    74  * Allocate a frame of physical memory.
     72/** Allocate power-of-two frames of physical memory.
    7573 *
    7674 * @param flags Flags for host zone selection and address processing.
     75 * @param order Allocate exactly 2^order frames.
    7776 *
    7877 * @return Allocated frame.
     
    203202 * Mark frame region not free.
    204203 *
    205  * @param start First address.
    206  * @param stop Last address.
     204 * @param base Base address of non-available region.
     205 * @param size Size of non-available region.
    207206 */
    208207void frame_region_not_free(__address base, size_t size)
    209208{
    210         count_t index;
     209        index_t index;
    211210        index = zone_blacklist_count++;
    212         ASSERT(base % FRAME_SIZE == 0);
    213        
    214         if (size % FRAME_SIZE != 0) {
    215                 size = ALIGN(size, FRAME_SIZE);
    216         }
    217         ASSERT(size % FRAME_SIZE == 0);
     211
     212        /* Force base to the nearest lower address frame boundary. */
     213        base &= ~(FRAME_SIZE - 1);
     214        /* Align size to frame boundary. */
     215        size = ALIGN(size, FRAME_SIZE);
     216
    218217        ASSERT(zone_blacklist_count <= ZONE_BLACKLIST_SIZE);
    219218        zone_blacklist[index].base = base;
     
    236235        int i;
    237236        zone_t * z;
    238         __address s; size_t sz;
     237        __address s;
     238        size_t sz;
    239239       
    240240        ASSERT(base % FRAME_SIZE == 0);
    241241        ASSERT(size % FRAME_SIZE == 0);
    242242       
    243         if (!size) return;
    244        
     243        if (!size)
     244                return;
     245
    245246        for (i = 0; i < zone_blacklist_count; i++) {
    246247                if (zone_blacklist[i].base >= base && zone_blacklist[i].base < base + size) {
     
    304305
    305306                z->free_count = cnt;
    306                 list_initialize(&z->free_head);
    307 
    308307                z->busy_count = 0;
    309308               
     
    316315                for (i = 0; i<cnt; i++) {
    317316                        frame_initialize(&z->frames[i], z);
    318                         list_append(&z->frames[i].link, &z->free_head);
    319317                }
    320318               
     
    322320                 * Create buddy system for the zone
    323321                 */
    324                 for (max_order = 0; cnt >> max_order; max_order++);
     322                for (max_order = 0; cnt >> max_order; max_order++)
     323                        ;
    325324                z->buddy_system = buddy_system_create(max_order, &zone_buddy_system_operations, (void *) z);
    326325               
     
    364363        frame->refcount = 1;
    365364        frame->buddy_order = 0;
    366         link_initialize(&frame->link);
    367365}
    368366
Note: See TracChangeset for help on using the changeset viewer.