Subversion Repositories HelenOS-historic

Rev

Rev 1757 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1757 Rev 1780
Line 64... Line 64...
64
 * @param data Pointer to be used by implementation.
64
 * @param data Pointer to be used by implementation.
65
 *
65
 *
66
 * @return New buddy system.
66
 * @return New buddy system.
67
 */
67
 */
68
void buddy_system_create(buddy_system_t *b,
68
void buddy_system_create(buddy_system_t *b,
69
             __u8 max_order,
69
             uint8_t max_order,
70
             buddy_system_operations_t *op,
70
             buddy_system_operations_t *op,
71
             void *data)
71
             void *data)
72
{
72
{
73
    int i;
73
    int i;
74
 
74
 
Line 99... Line 99...
99
 * @param b Buddy system pointer
99
 * @param b Buddy system pointer
100
 * @param i Size of the block (2^i)
100
 * @param i Size of the block (2^i)
101
 *
101
 *
102
 * @return True if block can be allocated
102
 * @return True if block can be allocated
103
 */
103
 */
104
bool buddy_system_can_alloc(buddy_system_t *b, __u8 i) {
104
bool buddy_system_can_alloc(buddy_system_t *b, uint8_t i) {
105
    __u8 k;
105
    uint8_t k;
106
   
106
   
107
    /*
107
    /*
108
     * If requested block is greater then maximal block
108
     * If requested block is greater then maximal block
109
     * we know immediatly that we cannot satisfy the request.
109
     * we know immediatly that we cannot satisfy the request.
110
     */
110
     */
Line 128... Line 128...
128
 * @ return Block of data or NULL if no such block was found
128
 * @ return Block of data or NULL if no such block was found
129
 */
129
 */
130
link_t *buddy_system_alloc_block(buddy_system_t *b, link_t *block)
130
link_t *buddy_system_alloc_block(buddy_system_t *b, link_t *block)
131
{
131
{
132
    link_t *left,*right, *tmp;
132
    link_t *left,*right, *tmp;
133
    __u8 order;
133
    uint8_t order;
134
 
134
 
135
    left = b->op->find_block(b, block, BUDDY_SYSTEM_INNER_BLOCK);
135
    left = b->op->find_block(b, block, BUDDY_SYSTEM_INNER_BLOCK);
136
    ASSERT(left);
136
    ASSERT(left);
137
    list_remove(left);
137
    list_remove(left);
138
    while (1) {
138
    while (1) {
Line 165... Line 165...
165
 * @param b Buddy system pointer.
165
 * @param b Buddy system pointer.
166
 * @param i Returned block will be 2^i big.
166
 * @param i Returned block will be 2^i big.
167
 *
167
 *
168
 * @return Block of data represented by link_t.
168
 * @return Block of data represented by link_t.
169
 */
169
 */
170
link_t *buddy_system_alloc(buddy_system_t *b, __u8 i)
170
link_t *buddy_system_alloc(buddy_system_t *b, uint8_t i)
171
{
171
{
172
    link_t *res, *hlp;
172
    link_t *res, *hlp;
173
 
173
 
174
    ASSERT(i <= b->max_order);
174
    ASSERT(i <= b->max_order);
175
 
175
 
Line 228... Line 228...
228
 * @param block Block to return.
228
 * @param block Block to return.
229
 */
229
 */
230
void buddy_system_free(buddy_system_t *b, link_t *block)
230
void buddy_system_free(buddy_system_t *b, link_t *block)
231
{
231
{
232
    link_t *buddy, *hlp;
232
    link_t *buddy, *hlp;
233
    __u8 i;
233
    uint8_t i;
234
 
234
 
235
    /*
235
    /*
236
     * Determine block's order.
236
     * Determine block's order.
237
     */
237
     */
238
    i = b->op->get_order(b, block);
238
    i = b->op->get_order(b, block);