Subversion Repositories HelenOS-historic

Rev

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

Rev 488 Rev 489
Line 336... Line 336...
336
       
336
       
337
        /*
337
        /*
338
         * Create buddy system for the zone
338
         * Create buddy system for the zone
339
         */
339
         */
340
        for (max_order = 0; cnt >> max_order; max_order++);
340
        for (max_order = 0; cnt >> max_order; max_order++);
341
        z->buddy_system = buddy_system_create(max_order, &zone_buddy_system_operations);
341
        z->buddy_system = buddy_system_create(max_order, &zone_buddy_system_operations, (void *) z);
342
    }
342
    }
343
   
343
   
344
    return z;
344
    return z;
345
}
345
}
346
 
346
 
Line 541... Line 541...
541
 
541
 
542
 
542
 
543
}
543
}
544
 
544
 
545
/** Buddy system find_buddy implementation
545
/** Buddy system find_buddy implementation
-
 
546
 *
-
 
547
 * @param b Buddy system.
546
 * @param block Block for which buddy should be found
548
 * @param block Block for which buddy should be found
547
 *
549
 *
548
 * @return Buddy for given block if found
550
 * @return Buddy for given block if found
549
 */
551
 */
550
link_t * zone_buddy_find_buddy(link_t * block) {
552
link_t * zone_buddy_find_buddy(buddy_system_t *b, link_t * block) {
551
    frame_t * frame, * f;
553
    frame_t * frame, * f;
552
    zone_t * zone;
554
    zone_t * zone;
553
    link_t * cur;
555
    link_t * cur;
554
    bool is_left, is_right;
556
    bool is_left, is_right;
555
 
557
 
Line 593... Line 595...
593
   
595
   
594
}
596
}
595
 
597
 
596
/** Buddy system bisect implementation
598
/** Buddy system bisect implementation
597
 *
599
 *
-
 
600
 * @param b Buddy system.
598
 * @param block Block to bisect
601
 * @param block Block to bisect
599
 *
602
 *
600
 * @return right block
603
 * @return right block
601
 */
604
 */
602
link_t * zone_buddy_bisect(link_t * block) {
605
link_t * zone_buddy_bisect(buddy_system_t *b, link_t * block) {
603
    frame_t * frame_l, * frame_r;
606
    frame_t * frame_l, * frame_r;
604
   
607
   
605
    frame_l = list_get_instance(block, frame_t, buddy_link);
608
    frame_l = list_get_instance(block, frame_t, buddy_link);
606
 
609
 
607
    frame_r = (frame_t *) (&frame_l + (1>>frame_l->buddy_order-1));
610
    frame_r = (frame_t *) (&frame_l + (1>>frame_l->buddy_order-1));
Line 610... Line 613...
610
   
613
   
611
}
614
}
612
 
615
 
613
/** Buddy system coalesce implementation
616
/** Buddy system coalesce implementation
614
 *
617
 *
-
 
618
 * @param b Buddy system.
615
 * @param block_1 First block
619
 * @param block_1 First block
616
 * @param block_2 First block's buddy
620
 * @param block_2 First block's buddy
617
 *
621
 *
618
 * @return Coalesced block (actually block that represents lower address)
622
 * @return Coalesced block (actually block that represents lower address)
619
 */
623
 */
620
link_t * zone_buddy_coalesce(link_t * block_1, link_t * block_2) {
624
link_t * zone_buddy_coalesce(buddy_system_t *b, link_t * block_1, link_t * block_2) {
621
    frame_t * frame1, * frame2;
625
    frame_t * frame1, * frame2;
622
   
626
   
623
    frame1 = list_get_instance(block_1, frame_t, buddy_link);
627
    frame1 = list_get_instance(block_1, frame_t, buddy_link);
624
    frame2 = list_get_instance(block_2, frame_t, buddy_link);
628
    frame2 = list_get_instance(block_2, frame_t, buddy_link);
625
   
629
   
626
    return &frame1 < &frame2 ? block_1 : block_2;
630
    return &frame1 < &frame2 ? block_1 : block_2;
627
}
631
}
628
 
632
 
629
/** Buddy system set_order implementation
633
/** Buddy system set_order implementation
-
 
634
 *
-
 
635
 * @param b Buddy system.
630
 * @param block Buddy system block
636
 * @param block Buddy system block
631
 * @param order Order to set
637
 * @param order Order to set
632
 */
638
 */
633
void zone_buddy_set_order(link_t * block, __u8 order) {
639
void zone_buddy_set_order(buddy_system_t *b, link_t * block, __u8 order) {
634
    frame_t * frame;
640
    frame_t * frame;
635
    frame = list_get_instance(block, frame_t, buddy_link);
641
    frame = list_get_instance(block, frame_t, buddy_link);
636
    frame->buddy_order = order;
642
    frame->buddy_order = order;
637
}
643
}
638
 
644
 
639
/** Buddy system get_order implementation
645
/** Buddy system get_order implementation
-
 
646
 *
-
 
647
 * @param b Buddy system.
640
 * @param block Buddy system block
648
 * @param block Buddy system block
641
 *
649
 *
642
 * @return Order of block
650
 * @return Order of block
643
 */
651
 */
644
__u8 zone_buddy_get_order(link_t * block) {
652
__u8 zone_buddy_get_order(buddy_system_t *b, link_t * block) {
645
    frame_t * frame;
653
    frame_t * frame;
646
    frame = list_get_instance(block, frame_t, buddy_link);
654
    frame = list_get_instance(block, frame_t, buddy_link);
647
    return frame->buddy_order;
655
    return frame->buddy_order;
648
}
656
}