Changeset 30187eb in mainline for generic/include


Ignore:
Timestamp:
2005-11-12T20:30:45Z (20 years ago)
Author:
Sergey Bondari <bondari@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a4be38d
Parents:
6e8b3c8
Message:

Buddy system allocator implementation. Not checked. For review only.

Location:
generic/include/mm
Files:
2 edited

Legend:

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

    r6e8b3c8 r30187eb  
    3636
    3737struct buddy_system_operations {
    38         link_t *(* find_buddy)(link_t *);               /**< Return pointer to left-side or right-side buddy for block passed as argument. */
    39         link_t *(* bisect)(link_t *);                   /**< Bisect the block passed as argument and return pointer to the new right-side buddy. */
    40         link_t *(* coalesce)(link_t *, link_t *);       /**< Coalesce to buddies into a bigger block. */
    41         void (*set_order)(link_t *, __u8);              /**< Set order of block passed as argument. */
    42         __u8 (*get_order)(link_t *);                    /**< Return order of block passed as argument. */
     38        link_t *(* find_buddy)(link_t *);                               /**< Return pointer to left-side or right-side buddy for block passed as argument. */
     39        link_t *(* bisect)(link_t *);                                   /**< Bisect the block passed as argument and return pointer to the new right-side buddy. */
     40        link_t *(* coalesce)(link_t *, link_t *);                       /**< Coalesce to buddies into a bigger block. */
     41        void (*set_order)(link_t *, __u8);                              /**< Set order of block passed as argument. */
     42        __u8 (*get_order)(link_t *);                                    /**< Return order of block passed as argument. */
    4343};
    4444
  • generic/include/mm/frame.h

    r6e8b3c8 r30187eb  
    11/*
    22 * Copyright (C) 2005 Jakub Jermar
     3 * Copyright (C) 2005 Sergey Bondari
    34 * All rights reserved.
    45 *
     
    3940#define FRAME_PANIC     2       /* panic on failure */
    4041
    41 #define FRAME2ADDR(zone, frame)         ((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
    42 #define ADDR2FRAME(zone, addr)          (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
     42#define FRAME2ADDR(zone, frame)                 ((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
     43#define ADDR2FRAME(zone, addr)                  (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
     44#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))
     47
     48
    4349
    4450struct zone {
     
    5258        count_t busy_count;     /**< number of frame_t structures not in free list */
    5359       
    54         buddy_system_t * buddy_system; /**< buddy system allocator for the zone */
     60        buddy_system_t * buddy_system; /**< buddy system for the zone */
    5561        int flags;
    5662};
     
    5965        count_t refcount;       /**< when == 0, the frame is in free list */
    6066        link_t link;            /**< link to zone free list when refcount == 0 */
    61         __u8 order;             /**< buddy system block order */
     67        __u8 buddy_order;       /**< buddy system block order */
    6268        link_t buddy_link;      /**< link to the next free block inside one order*/
    6369};
     
    7682extern void frame_not_free(__address addr);
    7783extern void frame_region_not_free(__address start, __address stop);
     84zone_t * get_zone_by_frame(frame_t * frame);
    7885
    7986/*
Note: See TracChangeset for help on using the changeset viewer.