Changeset 328f2934 in mainline for generic/include/mm/frame.h


Ignore:
Timestamp:
2005-12-04T19:37:13Z (20 years ago)
Author:
Sergey Bondari <bondari@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cf585c9
Parents:
d7ac642
Message:

Buddy allocator for physical memory complete implementation.
Tested on IA32, AMD64, MIPS32. RWLock Test #5 is not passed.
NOTE: Other architectures could be broken (but should not be)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/include/mm/frame.h

    rd7ac642 r328f2934  
    4343#define ADDR2FRAME(zone, addr)                  (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
    4444#define FRAME_INDEX(zone, frame)                ((count_t)((frame) - (zone)->frames))
    45 #define IS_BUDDY_LEFT_BLOCK(zone, frame)        ((FRAME_INDEX((zone), (frame)) % (1 >> ((frame)->buddy_order + 1))) == 0)
    46 #define IS_BUDDY_RIGHT_BLOCK(zone, frame)       ((FRAME_INDEX((zone), (frame)) % (1 >> ((frame)->buddy_order + 1))) == (1 >> (frame)->buddy_order))
     45#define FRAME_INDEX_VALID(zone, index)          (((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count)))
     46#define IS_BUDDY_LEFT_BLOCK(zone, frame)        ((FRAME_INDEX((zone), (frame)) % (1 << ((frame)->buddy_order + 1))) == 0)
     47#define IS_BUDDY_RIGHT_BLOCK(zone, frame)       ((FRAME_INDEX((zone), (frame)) % (1 << ((frame)->buddy_order + 1))) == (1 << (frame)->buddy_order))
    4748
    48 
     49#define ZONE_BLACKLIST_SIZE     3
    4950
    5051struct zone {
     
    6970};
    7071
     72struct region {
     73        __address base;
     74        size_t size;
     75};
     76
     77extern region_t zone_blacklist[];
     78extern count_t zone_blacklist_count;
     79extern void frame_region_not_free(__address base, size_t size);
     80extern void zone_create_in_region(__address base, size_t size);
     81
    7182extern spinlock_t zone_head_lock;       /**< this lock protects zone_head list */
    7283extern link_t zone_head;                /**< list of all zones in the system */
     
    7889extern void frame_init(void);
    7990extern void frame_initialize(frame_t *frame, zone_t *zone);
    80 __address frame_alloc(int flags);
     91__address frame_alloc(int flags, __u8 order);
    8192extern void frame_free(__address addr);
    82 extern void frame_not_free(__address addr);
    83 extern void frame_region_not_free(__address start, __address stop);
    8493zone_t * get_zone_by_frame(frame_t * frame);
    8594
     
    92101void zone_buddy_set_order(buddy_system_t *b, link_t * block, __u8 order);
    93102__u8 zone_buddy_get_order(buddy_system_t *b, link_t * block);
    94 
    95 __address zone_buddy_frame_alloc(int flags, __u8 order);
    96 void zone_buddy_frame_free(__address addr);
     103void zone_buddy_mark_busy(buddy_system_t *b, link_t * block);
    97104
    98105/*
Note: See TracChangeset for help on using the changeset viewer.