Subversion Repositories HelenOS

Rev

Rev 689 | Rev 759 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 689 Rev 724
Line 47... Line 47...
47
#define FRAME_ERROR     2   /* frame_alloc return status */
47
#define FRAME_ERROR     2   /* frame_alloc return status */
48
 
48
 
49
#define FRAME2ADDR(zone, frame)         ((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
49
#define FRAME2ADDR(zone, frame)         ((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
50
#define ADDR2FRAME(zone, addr)          (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
50
#define ADDR2FRAME(zone, addr)          (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
51
#define FRAME_INDEX(zone, frame)        ((index_t)((frame) - (zone)->frames))
51
#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)
52
#define FRAME_INDEX_VALID(zone, index)      (((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count)))
53
#define FRAME_INDEX_VALID(zone, index)      (((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count)))
53
#define IS_BUDDY_ORDER_OK(index, order)     ((~(((__native) -1) << (order)) & (index)) == 0)
54
#define IS_BUDDY_ORDER_OK(index, order)     ((~(((__native) -1) << (order)) & (index)) == 0)
54
#define IS_BUDDY_LEFT_BLOCK(zone, frame)    (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
55
#define IS_BUDDY_LEFT_BLOCK(zone, frame)    (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
55
#define IS_BUDDY_RIGHT_BLOCK(zone, frame)   (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
56
#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)
56
 
59
 
57
#define ZONE_BLACKLIST_SIZE 4
60
#define ZONE_BLACKLIST_SIZE 4
58
 
61
 
59
struct zone {
62
struct zone {
60
    link_t link;        /**< link to previous and next zone */
63
    link_t link;        /**< link to previous and next zone */
61
 
64
 
62
    SPINLOCK_DECLARE(lock); /**< this lock protects everything below */
65
    SPINLOCK_DECLARE(lock); /**< this lock protects everything below */
63
    __address base;     /**< physical address of the first frame in the frames array */
66
    __address base;     /**< physical address of the first frame in the frames array */
-
 
67
    index_t base_index; /**< frame index offset of the zone base */
64
    frame_t *frames;    /**< array of frame_t structures in this zone */
68
    frame_t *frames;    /**< array of frame_t structures in this zone */
65
    count_t free_count; /**< number of free frame_t structures */
69
    count_t free_count; /**< number of free frame_t structures */
66
    count_t busy_count; /**< number of busy frame_t structures */
70
    count_t busy_count; /**< number of busy frame_t structures */
67
   
71
   
68
    buddy_system_t * buddy_system; /**< buddy system for the zone */
72
    buddy_system_t * buddy_system; /**< buddy system for the zone */