Subversion Repositories HelenOS

Rev

Rev 2048 | Rev 2071 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2048 Rev 2059
Line 81... Line 81...
81
 
81
 
82
    frame_t *frames;    /**< array of frame_t structures in this zone */
82
    frame_t *frames;    /**< array of frame_t structures in this zone */
83
    count_t free_count; /**< number of free frame_t structures */
83
    count_t free_count; /**< number of free frame_t structures */
84
    count_t busy_count; /**< number of busy frame_t structures */
84
    count_t busy_count; /**< number of busy frame_t structures */
85
   
85
   
86
    buddy_system_t * buddy_system; /**< buddy system for the zone */
86
    buddy_system_t *buddy_system; /**< buddy system for the zone */
87
    int flags;
87
    int flags;
88
} zone_t;
88
} zone_t;
89
 
89
 
90
/*
90
/*
91
 * The zoneinfo.lock must be locked when accessing zoneinfo structure.
91
 * The zoneinfo.lock must be locked when accessing zoneinfo structure.
Line 174... Line 174...
174
    return i;
174
    return i;
175
}
175
}
176
 
176
 
177
/**
177
/**
178
 * Try to find a zone where can we find the frame
178
 * Try to find a zone where can we find the frame
-
 
179
 
-
 
180
 * Assume interrupts are disabled.
179
 *
181
 
180
 * @param frame Frame number contained in zone
182
 * @param frame Frame number contained in zone
181
 * @param pzone If not null, it is used as zone hint. Zone index
183
 * @param pzone If not null, it is used as zone hint. Zone index
182
 *              is filled into the variable on success.
184
 *              is filled into the variable on success.
183
 * @return Pointer to LOCKED zone containing frame
185
 * @return Pointer to locked zone containing frame
184
 *
-
 
185
 * Assume interrupts disable
-
 
186
 */
186
 */
187
static zone_t * find_zone_and_lock(pfn_t frame, int *pzone)
187
static zone_t * find_zone_and_lock(pfn_t frame, int *pzone)
188
{
188
{
189
    int i;
189
    int i;
190
    int hint = pzone ? *pzone : 0;
190
    int hint = pzone ? *pzone : 0;
Line 220... Line 220...
220
static int zone_can_alloc(zone_t *z, uint8_t order)
220
static int zone_can_alloc(zone_t *z, uint8_t order)
221
{
221
{
222
    return buddy_system_can_alloc(z->buddy_system, order);
222
    return buddy_system_can_alloc(z->buddy_system, order);
223
}
223
}
224
 
224
 
225
/**
-
 
226
 * Find AND LOCK zone that can allocate order frames
225
/** Find and lock zone that can allocate order frames.
227
 *
226
 *
228
 * Assume interrupts are disabled!!
227
 * Assume interrupts are disabled.
229
 *
228
 *
230
 * @param order Size (2^order) of free space we are trying to find
229
 * @param order Size (2^order) of free space we are trying to find
231
 * @param pzone Pointer to preferred zone or NULL, on return contains zone number
230
 * @param pzone Pointer to preferred zone or NULL, on return contains zone number
232
 */
231
 */
233
static zone_t * find_free_zone_and_lock(uint8_t order, int *pzone)
232
static zone_t * find_free_zone_and_lock(uint8_t order, int *pzone)
Line 258... Line 257...
258
    } while(i != hint);
257
    } while(i != hint);
259
    spinlock_unlock(&zones.lock);
258
    spinlock_unlock(&zones.lock);
260
    return NULL;
259
    return NULL;
261
}
260
}
262
 
261
 
263
/********************************************/
262
/**************************/
264
/* Buddy system functions */
263
/* Buddy system functions */
-
 
264
/**************************/
265
 
265
 
266
/** Buddy system find_block implementation
266
/** Buddy system find_block implementation
267
 *
267
 *
268
 * Find block that is parent of current list.
268
 * Find block that is parent of current list.
269
 * That means go to lower addresses, until such block is found
269
 * That means go to lower addresses, until such block is found
Line 434... Line 434...
434
    .mark_available = zone_buddy_mark_available,
434
    .mark_available = zone_buddy_mark_available,
435
    .find_block = zone_buddy_find_block,
435
    .find_block = zone_buddy_find_block,
436
    .print_id = zone_buddy_print_id
436
    .print_id = zone_buddy_print_id
437
};
437
};
438
 
438
 
439
/*************************************/
439
/******************/
440
/* Zone functions */
440
/* Zone functions */
-
 
441
/******************/
441
 
442
 
442
/** Allocate frame in particular zone
443
/** Allocate frame in particular zone
443
 *
444
 *
444
 * Assume zone is locked
445
 * Assume zone is locked
445
 * Panics if allocation is impossible.
446
 * Panics if allocation is impossible.
Line 532... Line 533...
532
 *
533
 *
533
 * @param z Target zone structure pointer
534
 * @param z Target zone structure pointer
534
 * @param z1 Zone to merge
535
 * @param z1 Zone to merge
535
 * @param z2 Zone to merge
536
 * @param z2 Zone to merge
536
 */
537
 */
537
 
-
 
538
static void _zone_merge(zone_t *z, zone_t *z1, zone_t *z2)
538
static void _zone_merge(zone_t *z, zone_t *z1, zone_t *z2)
539
{
539
{
540
    uint8_t max_order;
540
    uint8_t max_order;
541
    int i, z2idx;
541
    int i, z2idx;
542
    pfn_t frame_idx;
542
    pfn_t frame_idx;