Rev 852 | Rev 1037 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 852 | Rev 946 | ||
---|---|---|---|
Line 308... | Line 308... | ||
308 | index = (frame_index(zone, frame)) + (1 << frame->buddy_order); |
308 | index = (frame_index(zone, frame)) + (1 << frame->buddy_order); |
309 | } else { // if (is_right) |
309 | } else { // if (is_right) |
310 | index = (frame_index(zone, frame)) - (1 << frame->buddy_order); |
310 | index = (frame_index(zone, frame)) - (1 << frame->buddy_order); |
311 | } |
311 | } |
312 | 312 | ||
313 | - | ||
314 | if (frame_index_valid(zone, index)) { |
313 | if (frame_index_valid(zone, index)) { |
315 | if (zone->frames[index].buddy_order == frame->buddy_order && |
314 | if (zone->frames[index].buddy_order == frame->buddy_order && |
316 | zone->frames[index].refcount == 0) { |
315 | zone->frames[index].refcount == 0) { |
317 | return &zone->frames[index].buddy_link; |
316 | return &zone->frames[index].buddy_link; |
318 | } |
317 | } |
Line 467... | Line 466... | ||
467 | 466 | ||
468 | ASSERT(frame->refcount); |
467 | ASSERT(frame->refcount); |
469 | 468 | ||
470 | if (!--frame->refcount) { |
469 | if (!--frame->refcount) { |
471 | buddy_system_free(zone->buddy_system, &frame->buddy_link); |
470 | buddy_system_free(zone->buddy_system, &frame->buddy_link); |
472 | } |
- | |
473 | 471 | ||
474 | /* Update zone information. */ |
472 | /* Update zone information. */ |
475 | zone->free_count += (1 << order); |
473 | zone->free_count += (1 << order); |
476 | zone->busy_count -= (1 << order); |
474 | zone->busy_count -= (1 << order); |
477 | } |
475 | } |
- | 476 | } |
|
478 | 477 | ||
479 | /** Return frame from zone */ |
478 | /** Return frame from zone */ |
480 | static frame_t * zone_get_frame(zone_t *zone, index_t frame_idx) |
479 | static frame_t * zone_get_frame(zone_t *zone, index_t frame_idx) |
481 | { |
480 | { |
482 | ASSERT(frame_idx < zone->count); |
481 | ASSERT(frame_idx < zone->count); |
Line 599... | Line 598... | ||
599 | newzone->busy_count++; |
598 | newzone->busy_count++; |
600 | zone_frame_free(newzone, pfn+i-newzone->base); |
599 | zone_frame_free(newzone, pfn+i-newzone->base); |
601 | } |
600 | } |
602 | } |
601 | } |
603 | 602 | ||
604 | - | ||
605 | /** Reduce allocated block to count of order 0 frames |
603 | /** Reduce allocated block to count of order 0 frames |
606 | * |
604 | * |
607 | * The allocated block need 2^order frames of space. Reduce all frames |
605 | * The allocated block need 2^order frames of space. Reduce all frames |
608 | * in block to order 0 and free the unneded frames. This means, that |
606 | * in block to order 0 and free the unneded frames. This means, that |
609 | * when freeing the block, you have to free every frame from block. |
607 | * when freeing the block, you have to free every frame from block. |
Line 706... | Line 704... | ||
706 | errout: |
704 | errout: |
707 | spinlock_unlock(&zones.lock); |
705 | spinlock_unlock(&zones.lock); |
708 | interrupts_restore(ipl); |
706 | interrupts_restore(ipl); |
709 | } |
707 | } |
710 | 708 | ||
711 | - | ||
712 | /** |
709 | /** |
713 | * Merge all zones into one big zone |
710 | * Merge all zones into one big zone |
714 | * |
711 | * |
715 | * It is reasonable to do this on systems whose bios reports parts in chunks, |
712 | * It is reasonable to do this on systems whose bios reports parts in chunks, |
716 | * so that we could have 1 zone (it's faster). |
713 | * so that we could have 1 zone (it's faster). |
Line 770... | Line 767... | ||
770 | z->frames[i].refcount = 0; |
767 | z->frames[i].refcount = 0; |
771 | buddy_system_free(z->buddy_system, &z->frames[i].buddy_link); |
768 | buddy_system_free(z->buddy_system, &z->frames[i].buddy_link); |
772 | } |
769 | } |
773 | } |
770 | } |
774 | 771 | ||
775 | - | ||
776 | /** Compute configuration data size for zone */ |
772 | /** Compute configuration data size for zone */ |
777 | __address zone_conf_size(count_t count) |
773 | __address zone_conf_size(count_t count) |
778 | { |
774 | { |
779 | int size = sizeof(zone_t) + count*sizeof(frame_t); |
775 | int size = sizeof(zone_t) + count*sizeof(frame_t); |
780 | int max_order; |
776 | int max_order; |
Line 782... | Line 778... | ||
782 | max_order = fnzb(count); |
778 | max_order = fnzb(count); |
783 | size += buddy_conf_size(max_order); |
779 | size += buddy_conf_size(max_order); |
784 | return size; |
780 | return size; |
785 | } |
781 | } |
786 | 782 | ||
787 | - | ||
788 | /** Create and add zone to system |
783 | /** Create and add zone to system |
789 | * |
784 | * |
790 | * @param confframe Where configuration frame is supposed to be. |
785 | * @param confframe Where configuration frame is supposed to be. |
791 | * Always check, that we will not disturb the kernel and possibly init. |
786 | * Always check, that we will not disturb the kernel and possibly init. |
792 | * If confframe is given _outside_ this zone, it is expected, |
787 | * If confframe is given _outside_ this zone, it is expected, |