Changeset 5d2ab23 in mainline


Ignore:
Timestamp:
2006-01-17T20:52:33Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
64c44e8
Parents:
77147d6
Message:

Commit of the falloc_bad branch to trunk (719:723).

Files:
5 edited

Legend:

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

    r77147d6 r5d2ab23  
    5151        else
    5252                zone_create_in_region(KA2PA(KERNEL_LOAD_ADDRESS),
    53                                       config.memory_size & ~(FRAME_SIZE-1));
     53                                      (config.memory_size & ~(FRAME_SIZE-1)));
    5454}
  • generic/include/mm/frame.h

    r77147d6 r5d2ab23  
    5050#define ADDR2FRAME(zone, addr)                  (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
    5151#define FRAME_INDEX(zone, frame)                ((index_t)((frame) - (zone)->frames))
     52#define FRAME_INDEX_ABS(zone, frame)            (((index_t)((frame) - (zone)->frames)) + (zone)->base_index)
    5253#define FRAME_INDEX_VALID(zone, index)          (((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count)))
    5354#define IS_BUDDY_ORDER_OK(index, order)         ((~(((__native) -1) << (order)) & (index)) == 0)
    5455#define IS_BUDDY_LEFT_BLOCK(zone, frame)        (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
    5556#define IS_BUDDY_RIGHT_BLOCK(zone, frame)       (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
     57#define IS_BUDDY_LEFT_BLOCK_ABS(zone, frame)    (((FRAME_INDEX_ABS((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
     58#define IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame)   (((FRAME_INDEX_ABS((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
    5659
    5760#define ZONE_BLACKLIST_SIZE     4
     
    6265        SPINLOCK_DECLARE(lock); /**< this lock protects everything below */
    6366        __address base;         /**< physical address of the first frame in the frames array */
     67        index_t base_index;     /**< frame index offset of the zone base */
    6468        frame_t *frames;        /**< array of frame_t structures in this zone */
    6569        count_t free_count;     /**< number of free frame_t structures */
  • generic/src/main/main.c

    r77147d6 r5d2ab23  
    123123       
    124124        context_save(&ctx);
    125         context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + config.kernel_size, CONFIG_STACK_SIZE);
     125        context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + config.kernel_size - CONFIG_STACK_SIZE, CONFIG_STACK_SIZE);
    126126        context_restore(&ctx);
    127127        /* not reached */
  • generic/src/mm/frame.c

    r77147d6 r5d2ab23  
    134134        }
    135135               
    136 
    137136        /* Allocate frames from zone buddy system */
    138137        tmp = buddy_system_alloc(zone->buddy_system, order);
     
    161160                *status = FRAME_OK;
    162161        }
    163        
    164162        return v;
    165163}
     
    180178        zone_t *zone = NULL;
    181179        frame_t *frame;
     180        int order;
     181       
    182182        ASSERT(addr % FRAME_SIZE == 0);
    183183       
     
    210210       
    211211        frame = ADDR2FRAME(zone, addr);
     212       
     213        /* remember frame order */
     214        order = frame->buddy_order;
    212215
    213216        ASSERT(frame->refcount);
     
    218221
    219222        /* Update zone information. */
    220         zone->free_count += (1 << frame->buddy_order);
    221         zone->busy_count -= (1 << frame->buddy_order);
     223        zone->free_count += (1 << order);
     224        zone->busy_count -= (1 << order);
    222225       
    223226        spinlock_unlock(&zone->lock);
     
    322325       
    323326                z->base = start;
     327                z->base_index = start / FRAME_SIZE;
     328               
    324329                z->flags = flags;
    325330
     
    349354                        buddy_system_free(z->buddy_system, &z->frames[i].buddy_link);   
    350355                }
     356               
    351357        }
    352358        return z;
     
    401407        frame = list_get_instance(block, frame_t, buddy_link);
    402408        zone = (zone_t *) b->data;
    403        
    404         ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX(zone, frame), frame->buddy_order));
    405        
    406         is_left = IS_BUDDY_LEFT_BLOCK(zone, frame);
    407         is_right = IS_BUDDY_RIGHT_BLOCK(zone, frame);
     409        ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX_ABS(zone, frame), frame->buddy_order));
     410       
     411       
     412        is_left = IS_BUDDY_LEFT_BLOCK_ABS(zone, frame);
     413        is_right = IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame);
    408414       
    409415        ASSERT(is_left ^ is_right);
  • test/mm/falloc1/test.c

    r77147d6 r5d2ab23  
    3434#include <debug.h>
    3535
    36 #define MAX_FRAMES 1024
     36#define MAX_FRAMES 2048
    3737#define MAX_ORDER 8
    3838#define TEST_RUNS 4
     
    5353                        allocated = 0;
    5454                        for (i=0;i<MAX_FRAMES>>order;i++) {
    55                                 frames[allocated] = frame_alloc(FRAME_NON_BLOCKING,order, &status);
     55                                frames[allocated] = frame_alloc(FRAME_NON_BLOCKING, order, &status);
     56                               
     57                                if (frames[allocated] % (FRAME_SIZE << order) != 0) {
     58                                        panic("Test failed. Block at address %X (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
     59                                }
     60                               
    5661                                if (status == 0) {
    5762                                        allocated++;
Note: See TracChangeset for help on using the changeset viewer.