Rev 1269 | Rev 1599 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1269 | Rev 1568 | ||
|---|---|---|---|
| Line 132... | Line 132... | ||
| 132 | /* Zoneinfo functions */ |
132 | /* Zoneinfo functions */ |
| 133 | 133 | ||
| 134 | /** |
134 | /** |
| 135 | * Insert-sort zone into zones list |
135 | * Insert-sort zone into zones list |
| 136 | * |
136 | * |
| - | 137 | * @param newzone New zone to be inserted into zone list |
|
| 137 | * @return zone number on success, -1 on error |
138 | * @return zone number on success, -1 on error |
| 138 | */ |
139 | */ |
| 139 | static int zones_add_zone(zone_t *newzone) |
140 | static int zones_add_zone(zone_t *newzone) |
| 140 | { |
141 | { |
| 141 | int i,j; |
142 | int i,j; |
| Line 170... | Line 171... | ||
| 170 | } |
171 | } |
| 171 | 172 | ||
| 172 | /** |
173 | /** |
| 173 | * Try to find a zone where can we find the frame |
174 | * Try to find a zone where can we find the frame |
| 174 | * |
175 | * |
| 175 | * @param hint Start searching in zone 'hint' |
176 | * @param frame Frame number contained in zone |
| - | 177 | * @param pzone If not null, it is used as zone hint. Zone index |
|
| - | 178 | * is filled into the variable on success. |
|
| 176 | * @param lock Lock zone if true |
179 | * @return Pointer to LOCKED zone containing frame |
| 177 | * |
180 | * |
| 178 | * Assume interrupts disable |
181 | * Assume interrupts disable |
| 179 | */ |
182 | */ |
| 180 | static zone_t * find_zone_and_lock(pfn_t frame, int *pzone) |
183 | static zone_t * find_zone_and_lock(pfn_t frame, int *pzone) |
| 181 | { |
184 | { |
| Line 218... | Line 221... | ||
| 218 | /** |
221 | /** |
| 219 | * Find AND LOCK zone that can allocate order frames |
222 | * Find AND LOCK zone that can allocate order frames |
| 220 | * |
223 | * |
| 221 | * Assume interrupts are disabled!! |
224 | * Assume interrupts are disabled!! |
| 222 | * |
225 | * |
| - | 226 | * @param order Size (2^order) of free space we are trying to find |
|
| 223 | * @param pzone Pointer to preferred zone or NULL, on return contains zone number |
227 | * @param pzone Pointer to preferred zone or NULL, on return contains zone number |
| 224 | */ |
228 | */ |
| 225 | static zone_t * find_free_zone_lock(__u8 order, int *pzone) |
229 | static zone_t * find_free_zone_lock(__u8 order, int *pzone) |
| 226 | { |
230 | { |
| 227 | int i; |
231 | int i; |
| Line 466... | Line 470... | ||
| 466 | } |
470 | } |
| 467 | 471 | ||
| 468 | /** Free frame from zone |
472 | /** Free frame from zone |
| 469 | * |
473 | * |
| 470 | * Assume zone is locked |
474 | * Assume zone is locked |
| - | 475 | * |
|
| - | 476 | * @param zone Pointer to zone from which the frame is to be freed |
|
| - | 477 | * @param frame_idx Frame index relative to zone |
|
| 471 | */ |
478 | */ |
| 472 | static void zone_frame_free(zone_t *zone, index_t frame_idx) |
479 | static void zone_frame_free(zone_t *zone, index_t frame_idx) |
| 473 | { |
480 | { |
| 474 | frame_t *frame; |
481 | frame_t *frame; |
| 475 | __u8 order; |
482 | __u8 order; |
| Line 516... | Line 523... | ||
| 516 | * Join 2 zones |
523 | * Join 2 zones |
| 517 | * |
524 | * |
| 518 | * Expect zone_t *z to point to space at least zone_conf_size large |
525 | * Expect zone_t *z to point to space at least zone_conf_size large |
| 519 | * |
526 | * |
| 520 | * Assume z1 & z2 are locked |
527 | * Assume z1 & z2 are locked |
| - | 528 | * |
|
| - | 529 | * @param z Target zone structure pointer |
|
| - | 530 | * @param z1 Zone to merge |
|
| - | 531 | * @param z2 Zone to merge |
|
| 521 | */ |
532 | */ |
| 522 | 533 | ||
| 523 | static void _zone_merge(zone_t *z, zone_t *z1, zone_t *z2) |
534 | static void _zone_merge(zone_t *z, zone_t *z1, zone_t *z2) |
| 524 | { |
535 | { |
| 525 | __u8 max_order; |
536 | __u8 max_order; |
| Line 625... | Line 636... | ||
| 625 | } |
636 | } |
| 626 | 637 | ||
| 627 | /** Reduce allocated block to count of order 0 frames |
638 | /** Reduce allocated block to count of order 0 frames |
| 628 | * |
639 | * |
| 629 | * The allocated block need 2^order frames of space. Reduce all frames |
640 | * The allocated block need 2^order frames of space. Reduce all frames |
| 630 | * in block to order 0 and free the unneded frames. This means, that |
641 | * in block to order 0 and free the unneeded frames. This means, that |
| 631 | * when freeing the block, you have to free every frame from block. |
642 | * when freeing the previously allocated block starting with frame_idx, |
| - | 643 | * you have to free every frame. |
|
| 632 | * |
644 | * |
| 633 | * @param zone |
645 | * @param zone |
| 634 | * @param frame_idx Index to block |
646 | * @param frame_idx Index to block |
| 635 | * @param count Allocated space in block |
647 | * @param count Allocated space in block |
| 636 | */ |
648 | */ |
| Line 749... | Line 761... | ||
| 749 | /** Create frame zone |
761 | /** Create frame zone |
| 750 | * |
762 | * |
| 751 | * Create new frame zone. |
763 | * Create new frame zone. |
| 752 | * |
764 | * |
| 753 | * @param start Physical address of the first frame within the zone. |
765 | * @param start Physical address of the first frame within the zone. |
| 754 | * @param size Size of the zone. Must be a multiple of FRAME_SIZE. |
766 | * @param count Count of frames in zone |
| 755 | * @param conffram Address of configuration frame |
767 | * @param z Address of configuration information of zone |
| 756 | * @param flags Zone flags. |
768 | * @param flags Zone flags. |
| 757 | * |
769 | * |
| 758 | * @return Initialized zone. |
770 | * @return Initialized zone. |
| 759 | */ |
771 | */ |
| 760 | static void zone_construct(pfn_t start, count_t count, zone_t *z, int flags) |
772 | static void zone_construct(pfn_t start, count_t count, zone_t *z, int flags) |
| Line 791... | Line 803... | ||
| 791 | z->frames[i].refcount = 0; |
803 | z->frames[i].refcount = 0; |
| 792 | buddy_system_free(z->buddy_system, &z->frames[i].buddy_link); |
804 | buddy_system_free(z->buddy_system, &z->frames[i].buddy_link); |
| 793 | } |
805 | } |
| 794 | } |
806 | } |
| 795 | 807 | ||
| 796 | /** Compute configuration data size for zone */ |
808 | /** Compute configuration data size for zone |
| - | 809 | * |
|
| - | 810 | * @param count Size of zone in frames |
|
| - | 811 | * @return Size of zone configuration info (in bytes) |
|
| - | 812 | */ |
|
| 797 | __address zone_conf_size(count_t count) |
813 | __address zone_conf_size(count_t count) |
| 798 | { |
814 | { |
| 799 | int size = sizeof(zone_t) + count*sizeof(frame_t); |
815 | int size = sizeof(zone_t) + count*sizeof(frame_t); |
| 800 | int max_order; |
816 | int max_order; |
| 801 | 817 | ||
| Line 804... | Line 820... | ||
| 804 | return size; |
820 | return size; |
| 805 | } |
821 | } |
| 806 | 822 | ||
| 807 | /** Create and add zone to system |
823 | /** Create and add zone to system |
| 808 | * |
824 | * |
| - | 825 | * @param start First frame number (absolute) |
|
| - | 826 | * @param count Size of zone in frames |
|
| 809 | * @param confframe Where configuration frame is supposed to be. |
827 | * @param confframe Where configuration frames are supposed to be. |
| 810 | * Always check, that we will not disturb the kernel and possibly init. |
828 | * Automatically checks, that we will not disturb the |
| - | 829 | * kernel and possibly init. |
|
| 811 | * If confframe is given _outside_ this zone, it is expected, |
830 | * If confframe is given _outside_ this zone, it is expected, |
| 812 | * that the area is already marked BUSY and big enough |
831 | * that the area is already marked BUSY and big enough |
| 813 | * to contain zone_conf_size() amount of data |
832 | * to contain zone_conf_size() amount of data. |
| - | 833 | * If the confframe is inside the area, the zone free frame |
|
| - | 834 | * information is modified not to include it. |
|
| 814 | * |
835 | * |
| 815 | * @return Zone number or -1 on error |
836 | * @return Zone number or -1 on error |
| 816 | */ |
837 | */ |
| 817 | int zone_create(pfn_t start, count_t count, pfn_t confframe, int flags) |
838 | int zone_create(pfn_t start, count_t count, pfn_t confframe, int flags) |
| 818 | { |
839 | { |