Changeset b87f418 in mainline


Ignore:
Timestamp:
2005-12-07T23:00:30Z (19 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.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/mm/frame.c

    r4acac843 rb87f418  
    5858                        if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
    5959                                zone_create_in_region(e820table[i].base_address, e820table[i].size & ~(FRAME_SIZE-1));
    60                                 if (last_frame < ALIGN(e820table[i].base_address + e820table[i].size, FRAME_SIZE))
    61                                         last_frame = ALIGN(e820table[i].base_address + e820table[i].size, FRAME_SIZE);
     60                                if (last_frame < ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE))
     61                                        last_frame = ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE);
    6262                        }                       
    6363                }
  • arch/ia64/include/context.h

    r4acac843 rb87f418  
    4141 * One item is put onto the stack to support get_stack_base().
    4242 */
    43 #define SP_DELTA        (0+ALIGN(STACK_ITEM_SIZE, STACK_ALIGNMENT))
     43#define SP_DELTA        (0+ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4444
    4545#define PFM_MASK        (~0x3fffffffff)
     
    5151#define context_set(c, _pc, stack, size)                                                                \
    5252        (c)->pc = (__address) _pc;                                                                      \
    53         (c)->bsp = ((__address) stack) + ALIGN(sizeof(the_t), REGISTER_STACK_ALIGNMENT);                \
     53        (c)->bsp = ((__address) stack) + ALIGN_UP(sizeof(the_t), REGISTER_STACK_ALIGNMENT);             \
    5454        (c)->ar_pfs &= PFM_MASK;                                                                        \
    55         (c)->sp = ((__address) stack) + ALIGN((size), STACK_ALIGNMENT) - SP_DELTA;
     55        (c)->sp = ((__address) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - SP_DELTA;
    5656
    5757/*
  • arch/sparc64/include/context.h

    r4acac843 rb87f418  
    3131
    3232#ifndef __sparc64_STACK_H__
    33 #include <arch/stack.h>
     33# include <arch/stack.h>
    3434#endif
    3535
     
    5050#define context_set(c, _pc, stack, size)                                                                \
    5151        (c)->pc = ((__address) _pc) - 8;                                                                \
    52         (c)->sp = ((__address) stack) + ALIGN((size), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA);       \
     52        (c)->sp = ((__address) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA);    \
    5353        (c)->fp = -STACK_BIAS
    5454       
  • generic/include/align.h

    r4acac843 rb87f418  
    3030#define __ALIGN_H__
    3131
    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))
    3345
    3446#endif
  • generic/include/mm/frame.h

    r4acac843 rb87f418  
    4646#define FRAME_INDEX(zone, frame)                ((index_t)((frame) - (zone)->frames))
    4747#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)
    4951
    5052#define ZONE_BLACKLIST_SIZE     3
  • generic/src/main/main.c

    r4acac843 rb87f418  
    142142
    143143        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);
    145145        heap_delta = kernel_size - (hardcoded_ktext_size + hardcoded_kdata_size + heap_size);
    146146       
  • 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.