Rev 946 | Rev 1063 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 946 | Rev 1037 | ||
---|---|---|---|
Line 132... | Line 132... | ||
132 | zone_t *z; |
132 | zone_t *z; |
133 | 133 | ||
134 | ipl = interrupts_disable(); |
134 | ipl = interrupts_disable(); |
135 | spinlock_lock(&zones.lock); |
135 | spinlock_lock(&zones.lock); |
136 | /* Try to merge */ |
136 | /* Try to merge */ |
137 | if (zones.count+1 == ZONES_MAX) |
137 | if (zones.count + 1 == ZONES_MAX) |
138 | panic("Maximum zone(%d) count exceeded.", ZONES_MAX); |
138 | panic("Maximum zone(%d) count exceeded.", ZONES_MAX); |
139 | for (i=0; i < zones.count; i++) { |
139 | for (i = 0; i < zones.count; i++) { |
140 | /* Check for overflow */ |
140 | /* Check for overflow */ |
141 | z = zones.info[i]; |
141 | z = zones.info[i]; |
142 | if (overlaps(newzone->base,newzone->count, |
142 | if (overlaps(newzone->base,newzone->count, |
143 | z->base, z->count)) { |
143 | z->base, z->count)) { |
144 | printf("Zones overlap!\n"); |
144 | printf("Zones overlap!\n"); |
Line 146... | Line 146... | ||
146 | } |
146 | } |
147 | if (newzone->base < z->base) |
147 | if (newzone->base < z->base) |
148 | break; |
148 | break; |
149 | } |
149 | } |
150 | /* Move other zones up */ |
150 | /* Move other zones up */ |
151 | for (j=i;j < zones.count;j++) |
151 | for (j = i;j < zones.count; j++) |
152 | zones.info[j+1] = zones.info[j]; |
152 | zones.info[j + 1] = zones.info[j]; |
153 | zones.info[i] = newzone; |
153 | zones.info[i] = newzone; |
154 | zones.count++; |
154 | zones.count++; |
155 | spinlock_unlock(&zones.lock); |
155 | spinlock_unlock(&zones.lock); |
156 | interrupts_restore(ipl); |
156 | interrupts_restore(ipl); |
157 | 157 | ||
Line 687... | Line 687... | ||
687 | /* Subtract zone information from busy frames */ |
687 | /* Subtract zone information from busy frames */ |
688 | newzone->busy_count -= cframes; |
688 | newzone->busy_count -= cframes; |
689 | 689 | ||
690 | /* Replace existing zones in zoneinfo list */ |
690 | /* Replace existing zones in zoneinfo list */ |
691 | zones.info[z1] = newzone; |
691 | zones.info[z1] = newzone; |
692 | for (i=z2+1;i < zones.count;i++) |
692 | for (i = z2 + 1; i < zones.count; i++) |
693 | zones.info[i-1] = zones.info[i]; |
693 | zones.info[i - 1] = zones.info[i]; |
694 | zones.count--; |
694 | zones.count--; |
695 | 695 | ||
696 | /* Free old zone information */ |
696 | /* Free old zone information */ |
697 | return_config_frames(newzone, zone1); |
697 | return_config_frames(newzone, zone1); |
698 | return_config_frames(newzone, zone2); |
698 | return_config_frames(newzone, zone2); |
Line 806... | Line 806... | ||
806 | /* If conframe is supposed to be inside our zone, then make sure |
806 | /* If conframe is supposed to be inside our zone, then make sure |
807 | * it does not span kernel & init |
807 | * it does not span kernel & init |
808 | */ |
808 | */ |
809 | confcount = SIZE2FRAMES(zone_conf_size(count)); |
809 | confcount = SIZE2FRAMES(zone_conf_size(count)); |
810 | if (confframe >= start && confframe < start+count) { |
810 | if (confframe >= start && confframe < start+count) { |
811 | for (;confframe < start+count;confframe++) { |
811 | for (;confframe < start + count; confframe++) { |
812 | addr = PFN2ADDR(confframe); |
812 | addr = PFN2ADDR(confframe); |
813 | if (overlaps(addr, PFN2ADDR(confcount), |
- | |
814 | KA2PA(config.base),config.kernel_size)) |
813 | if (overlaps(addr, PFN2ADDR(confcount), KA2PA(config.base), config.kernel_size)) |
815 | continue; |
814 | continue; |
- | 815 | ||
- | 816 | bool overlap = false; |
|
- | 817 | count_t i; |
|
816 | if (config.init_addr) |
818 | for (i = 0; i < init.cnt; i++) |
817 | if (overlaps(addr,PFN2ADDR(confcount), |
819 | if (overlaps(addr, PFN2ADDR(confcount), KA2PA(init.tasks[i].addr), init.tasks[i].size)) { |
818 | KA2PA(config.init_addr), |
820 | overlap = true; |
- | 821 | break; |
|
- | 822 | } |
|
819 | config.init_size)) |
823 | if (overlap) |
820 | continue; |
824 | continue; |
- | 825 | ||
821 | break; |
826 | break; |
822 | } |
827 | } |
823 | if (confframe >= start+count) |
828 | if (confframe >= start + count) |
824 | panic("Cannot find configuration data for zone."); |
829 | panic("Cannot find configuration data for zone."); |
825 | } |
830 | } |
826 | 831 | ||
827 | z = (zone_t *)PA2KA(PFN2ADDR(confframe)); |
832 | z = (zone_t *)PA2KA(PFN2ADDR(confframe)); |
828 | zone_construct(start, count, z, flags); |
833 | zone_construct(start, count, z, flags); |
Line 987... | Line 992... | ||
987 | frame_arch_init(); |
992 | frame_arch_init(); |
988 | if (config.cpu_active == 1) { |
993 | if (config.cpu_active == 1) { |
989 | pfn_t firstframe = ADDR2PFN(KA2PA(config.base)); |
994 | pfn_t firstframe = ADDR2PFN(KA2PA(config.base)); |
990 | pfn_t lastframe = ADDR2PFN(KA2PA(config.base+config.kernel_size)); |
995 | pfn_t lastframe = ADDR2PFN(KA2PA(config.base+config.kernel_size)); |
991 | frame_mark_unavailable(firstframe,lastframe-firstframe+1); |
996 | frame_mark_unavailable(firstframe,lastframe-firstframe+1); |
- | 997 | ||
- | 998 | count_t i; |
|
992 | if (config.init_size > 0) |
999 | for (i = 0; i < init.cnt; i++) |
993 | frame_mark_unavailable(ADDR2PFN(KA2PA(config.init_addr)), |
1000 | frame_mark_unavailable(ADDR2PFN(KA2PA(init.tasks[i].addr)), SIZE2FRAMES(init.tasks[i].size)); |
994 | SIZE2FRAMES(config.init_size)); |
- | |
995 | } |
1001 | } |
996 | } |
1002 | } |
997 | 1003 | ||
998 | 1004 | ||
999 | 1005 | ||
Line 1007... | Line 1013... | ||
1007 | 1013 | ||
1008 | ipl = interrupts_disable(); |
1014 | ipl = interrupts_disable(); |
1009 | spinlock_lock(&zones.lock); |
1015 | spinlock_lock(&zones.lock); |
1010 | printf("# Base address\tFree Frames\tBusy Frames\n"); |
1016 | printf("# Base address\tFree Frames\tBusy Frames\n"); |
1011 | printf(" ------------\t-----------\t-----------\n"); |
1017 | printf(" ------------\t-----------\t-----------\n"); |
1012 | for (i=0;i<zones.count;i++) { |
1018 | for (i = 0; i < zones.count; i++) { |
1013 | zone = zones.info[i]; |
1019 | zone = zones.info[i]; |
1014 | spinlock_lock(&zone->lock); |
1020 | spinlock_lock(&zone->lock); |
1015 | printf("%d: %L\t%d\t\t%d\n",i,PFN2ADDR(zone->base), |
1021 | printf("%d: %L\t%d\t\t%d\n",i,PFN2ADDR(zone->base), |
1016 | zone->free_count, zone->busy_count); |
1022 | zone->free_count, zone->busy_count); |
1017 | spinlock_unlock(&zone->lock); |
1023 | spinlock_unlock(&zone->lock); |
Line 1030... | Line 1036... | ||
1030 | int i; |
1036 | int i; |
1031 | 1037 | ||
1032 | ipl = interrupts_disable(); |
1038 | ipl = interrupts_disable(); |
1033 | spinlock_lock(&zones.lock); |
1039 | spinlock_lock(&zones.lock); |
1034 | 1040 | ||
1035 | for (i=0;i < zones.count; i++) { |
1041 | for (i = 0; i < zones.count; i++) { |
1036 | if (i == num || PFN2ADDR(zones.info[i]->base) == num) { |
1042 | if (i == num || PFN2ADDR(zones.info[i]->base) == num) { |
1037 | zone = zones.info[i]; |
1043 | zone = zones.info[i]; |
1038 | break; |
1044 | break; |
1039 | } |
1045 | } |
1040 | } |
1046 | } |