Changeset 2936eef in mainline
- Timestamp:
- 2007-02-05T15:40:45Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3c771149
- Parents:
- 55b4437
- Location:
- kernel/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/mm/frame.h
r55b4437 r2936eef 98 98 99 99 extern void frame_init(void); 100 extern void *frame_alloc_generic(uint8_t order, int flags, int *pzone);100 extern void *frame_alloc_generic(uint8_t order, int flags, unsigned int *pzone); 101 101 extern void frame_free(uintptr_t frame); 102 102 extern void frame_reference_add(pfn_t pfn); 103 103 104 104 extern int zone_create(pfn_t start, count_t count, pfn_t confframe, int flags); 105 void *frame_get_parent(pfn_t frame, int hint);106 void frame_set_parent(pfn_t frame, void *data, int hint);105 void *frame_get_parent(pfn_t frame, unsigned int hint); 106 void frame_set_parent(pfn_t frame, void *data, unsigned int hint); 107 107 void frame_mark_unavailable(pfn_t start, count_t count); 108 108 uintptr_t zone_conf_size(count_t count); 109 void zone_merge( int z1,int z2);109 void zone_merge(unsigned int z1, unsigned int z2); 110 110 void zone_merge_all(void); 111 111 … … 114 114 */ 115 115 extern void zone_print_list(void); 116 void zone_print_one( int znum);116 void zone_print_one(unsigned int znum); 117 117 118 118 #endif -
kernel/generic/src/mm/frame.c
r55b4437 r2936eef 94 94 typedef struct { 95 95 SPINLOCK_DECLARE(lock); 96 int count;96 unsigned int count; 97 97 zone_t *info[ZONES_MAX]; 98 98 } zones_t; … … 145 145 static int zones_add_zone(zone_t *newzone) 146 146 { 147 int i,j;147 unsigned int i, j; 148 148 ipl_t ipl; 149 149 zone_t *z; … … 186 186 * @return Pointer to locked zone containing frame 187 187 */ 188 static zone_t * find_zone_and_lock(pfn_t frame, int *pzone)189 { 190 int i;191 int hint = pzone ? *pzone : 0;188 static zone_t * find_zone_and_lock(pfn_t frame, unsigned int *pzone) 189 { 190 unsigned int i; 191 unsigned int hint = pzone ? *pzone : 0; 192 192 zone_t *z; 193 193 … … 233 233 static zone_t * find_free_zone_and_lock(uint8_t order, int *pzone) 234 234 { 235 int i;235 unsigned int i; 236 236 zone_t *z; 237 int hint = pzone ? *pzone : 0;237 unsigned int hint = pzone ? *pzone : 0; 238 238 239 239 spinlock_lock(&zones.lock); … … 540 540 { 541 541 uint8_t max_order; 542 int i, z2idx; 542 unsigned int i; 543 int z2idx; 543 544 pfn_t frame_idx; 544 545 frame_t *frame; … … 562 563 (void *) z); 563 564 564 z->frames = (frame_t *)(( void *)z->buddy_system+buddy_conf_size(max_order));565 z->frames = (frame_t *)((uint8_t *) z->buddy_system + buddy_conf_size(max_order)); 565 566 for (i = 0; i < z->count; i++) { 566 567 /* This marks all frames busy */ … … 574 575 * problems with allocation/free. 575 576 */ 576 for (i =0; i<z1->count; i++)577 for (i = 0; i < z1->count; i++) 577 578 z->frames[i] = z1->frames[i]; 578 for (i =0; i < z2->count; i++) {579 for (i = 0; i < z2->count; i++) { 579 580 z2idx = i + (z2->base - z1->base); 580 581 z->frames[z2idx] = z2->frames[i]; … … 624 625 frame_t *frame; 625 626 count_t cframes; 626 int i;627 unsigned int i; 627 628 628 629 pfn = ADDR2PFN((uintptr_t)KA2PA(oldzone)); … … 635 636 ASSERT(!frame->buddy_order); 636 637 637 for (i =0; i < cframes; i++) {638 for (i = 0; i < cframes; i++) { 638 639 newzone->busy_count++; 639 640 zone_frame_free(newzone, pfn+i-newzone->base); … … 658 659 frame_t *frame; 659 660 660 ASSERT(frame_idx +count < zone->count);661 ASSERT(frame_idx + count < zone->count); 661 662 662 663 order = zone->frames[frame_idx].buddy_order; 663 ASSERT(( 1 << order) >= count);664 ASSERT((count_t) (1 << order) >= count); 664 665 665 666 /* Reduce all blocks to order 0 */ 666 for (i =0; i <(1 << order); i++) {667 for (i = 0; i < (count_t) (1 << order); i++) { 667 668 frame = &zone->frames[i + frame_idx]; 668 669 frame->buddy_order = 0; … … 672 673 } 673 674 /* Free unneeded frames */ 674 for (i =count; i <(1 << order); i++) {675 for (i = count; i < (count_t) (1 << order); i++) { 675 676 zone_frame_free(zone, i + frame_idx); 676 677 } … … 686 687 * possible, merged configuration data occupies more space :-/ 687 688 */ 688 void zone_merge( int z1,int z2)689 void zone_merge(unsigned int z1, unsigned int z2) 689 690 { 690 691 ipl_t ipl; 691 692 zone_t *zone1, *zone2, *newzone; 692 int cframes;693 unsigned int cframes; 693 694 uint8_t order; 694 int i;695 unsigned int i; 695 696 pfn_t pfn; 696 697 … … 723 724 goto errout2; 724 725 725 newzone = (zone_t *) PA2KA(PFN2ADDR(pfn));726 newzone = (zone_t *) PA2KA(PFN2ADDR(pfn)); 726 727 727 728 _zone_merge(newzone, zone1, zone2); … … 780 781 static void zone_construct(pfn_t start, count_t count, zone_t *z, int flags) 781 782 { 782 int i;783 unsigned int i; 783 784 uint8_t max_order; 784 785 … … 802 803 /* Allocate frames _after_ the conframe */ 803 804 /* Check sizes */ 804 z->frames = (frame_t *)(( void *)z->buddy_system+buddy_conf_size(max_order));805 for (i = 0; i <count; i++) {805 z->frames = (frame_t *)((uint8_t *) z->buddy_system + buddy_conf_size(max_order)); 806 for (i = 0; i < count; i++) { 806 807 frame_initialize(&z->frames[i]); 807 808 } … … 849 850 uintptr_t addr; 850 851 count_t confcount; 851 int i;852 unsigned int i; 852 853 int znum; 853 854 … … 893 894 894 895 /* If confdata in zone, mark as unavailable */ 895 if (confframe >= start && confframe < start +count)896 for (i =confframe; i<confframe+confcount; i++) {896 if (confframe >= start && confframe < start + count) 897 for (i = confframe; i < confframe + confcount; i++) { 897 898 zone_mark_unavailable(z, i - z->base); 898 899 } … … 904 905 905 906 /** Set parent of frame */ 906 void frame_set_parent(pfn_t pfn, void *data, int hint)907 void frame_set_parent(pfn_t pfn, void *data, unsigned int hint) 907 908 { 908 909 zone_t *zone = find_zone_and_lock(pfn, &hint); … … 914 915 } 915 916 916 void * frame_get_parent(pfn_t pfn, int hint)917 void * frame_get_parent(pfn_t pfn, unsigned int hint) 917 918 { 918 919 zone_t *zone = find_zone_and_lock(pfn, &hint); … … 1045 1046 void frame_mark_unavailable(pfn_t start, count_t count) 1046 1047 { 1047 int i;1048 unsigned int i; 1048 1049 zone_t *zone; 1049 int prefzone = 0;1050 1051 for (i =0; i < count; i++) {1050 unsigned int prefzone = 0; 1051 1052 for (i = 0; i < count; i++) { 1052 1053 zone = find_zone_and_lock(start + i, &prefzone); 1053 1054 if (!zone) /* PFN not found */ … … 1095 1096 void zone_print_list(void) { 1096 1097 zone_t *zone = NULL; 1097 int i;1098 unsigned int i; 1098 1099 ipl_t ipl; 1099 1100 … … 1116 1117 * @param num Zone base address or zone number. 1117 1118 */ 1118 void zone_print_one( int num) {1119 void zone_print_one(unsigned int num) { 1119 1120 zone_t *zone = NULL; 1120 1121 ipl_t ipl; 1121 int i;1122 unsigned int i; 1122 1123 1123 1124 ipl = interrupts_disable();
Note:
See TracChangeset
for help on using the changeset viewer.