Changeset 71eef11 in mainline
- Timestamp:
- 2008-02-06T14:24:13Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7208b6c
- Parents:
- 1b067315
- Location:
- kernel
- Files:
-
- 14 deleted
- 26 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/Makefile.inc
r1b067315 r71eef11 88 88 arch/$(ARCH)/src/fpu_context.c \ 89 89 arch/$(ARCH)/src/boot/boot.S \ 90 arch/$(ARCH)/src/boot/memmap.c \ 90 91 arch/$(ARCH)/src/pm.c \ 91 92 arch/$(ARCH)/src/context.S \ … … 104 105 arch/$(ARCH)/src/mm/tlb.c \ 105 106 arch/$(ARCH)/src/asm_utils.S \ 106 arch/$(ARCH)/src/mm/memory_init.c \107 107 arch/$(ARCH)/src/cpu/cpu.c \ 108 108 arch/$(ARCH)/src/proc/scheduler.c \ -
kernel/arch/amd64/src/amd64.c
r1b067315 r71eef11 51 51 52 52 #include <arch/bios/bios.h> 53 #include <arch/mm/memory_init.h>54 53 #include <arch/cpu.h> 55 54 #include <print.h> -
kernel/arch/amd64/src/boot/boot.S
r1b067315 r71eef11 183 183 184 184 xorl %ecx, %ecx # no memory size or map available 185 movl %ecx, e801memorysize186 185 movl %ecx, e820counter 187 186 … … 191 190 192 191 movl (%ebx), %eax # ebx = physical address of struct multiboot_info 193 194 bt $0, %eax # mbi->flags[0] (mem_lower, mem_upper valid)195 jc mem_valid196 197 xorl %ecx, %ecx198 jmp mem_invalid199 200 mem_valid:201 movl 4(%ebx), %ecx # mbi->mem_lower202 addl 8(%ebx), %ecx # mbi->mem_upper203 204 mem_invalid:205 movl %ecx, e801memorysize206 192 207 193 bt $3, %eax # mbi->flags[3] (mods_count, mods_addr valid) -
kernel/arch/amd64/src/boot/memmap.c
r1b067315 r71eef11 27 27 */ 28 28 29 /** @addtogroup ia32mm29 /** @addtogroup amd64mm 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup ia32mm, am64mm34 33 */ 35 34 36 #ifndef KERN_ia32_MEMORY_INIT_H_ 37 #define KERN_ia32_MEMORY_INIT_H_ 35 #include <arch/boot/memmap.h> 38 36 39 size_t get_memory_size(void); 40 41 #endif 37 uint8_t e820counter = 0xff; 38 e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS]; 42 39 43 40 /** @} -
kernel/arch/arm32/Makefile.inc
r1b067315 r71eef11 89 89 arch/$(ARCH)/src/mm/page.c \ 90 90 arch/$(ARCH)/src/mm/tlb.c \ 91 arch/$(ARCH)/src/mm/memory_init.c \92 91 arch/$(ARCH)/src/mm/page_fault.c 93 92 -
kernel/arch/arm32/src/mm/frame.c
r1b067315 r71eef11 36 36 #include <mm/frame.h> 37 37 #include <arch/mm/frame.h> 38 #include <arch/machine.h> 38 39 #include <config.h> 39 40 #include <arch/debug/print.h> … … 46 47 { 47 48 /* all memory as one zone */ 48 zone_create(0, ADDR2PFN( config.memory_size),49 zone_create(0, ADDR2PFN(machine_get_memory_size()), 49 50 BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0); 50 last_frame = config.memory_size;51 last_frame = machine_get_memory_size(); 51 52 52 53 /* blacklist boot page table */ -
kernel/arch/ia32/Makefile.inc
r1b067315 r71eef11 142 142 arch/$(ARCH)/src/mm/as.c \ 143 143 arch/$(ARCH)/src/mm/frame.c \ 144 arch/$(ARCH)/src/mm/memory_init.c \145 144 arch/$(ARCH)/src/mm/page.c \ 146 145 arch/$(ARCH)/src/mm/tlb.c \ … … 151 150 arch/$(ARCH)/src/drivers/vesa.c \ 152 151 arch/$(ARCH)/src/boot/boot.S \ 152 arch/$(ARCH)/src/boot/memmap.c \ 153 153 arch/$(ARCH)/src/fpu_context.c \ 154 154 arch/$(ARCH)/src/debugger.c -
kernel/arch/ia32/include/boot/memmap.h
r1b067315 r71eef11 66 66 extern e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS]; 67 67 extern uint8_t e820counter; 68 extern uint32_t e801memorysize; /**< Size of available memory in KB. */69 68 70 69 #endif -
kernel/arch/ia32/src/boot/boot.S
r1b067315 r71eef11 110 110 je valid_boot 111 111 112 xorl %ecx, %ecx # no memory size or map available 113 movl %ecx, e801memorysize 112 xorl %ecx, %ecx # no memory map available 114 113 movl %ecx, e820counter 115 114 … … 119 118 120 119 movl (%ebx), %eax # ebx = physical address of struct multiboot_info 121 122 bt $0, %eax # mbi->flags[0] (mem_lower, mem_upper valid)123 jc mem_valid124 125 xorl %ecx, %ecx126 jmp mem_invalid127 128 mem_valid:129 movl 4(%ebx), %ecx # mbi->mem_lower130 addl 8(%ebx), %ecx # mbi->mem_upper131 132 mem_invalid:133 movl %ecx, e801memorysize134 120 135 121 bt $3, %eax # mbi->flags[3] (mods_count, mods_addr valid) -
kernel/arch/ia32/src/boot/memmap.c
r1b067315 r71eef11 1 1 /* 2 * Copyright (c) 2005 Martin Decky2 * Copyright (c) 2005 Josef Cejka 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup ppc64mm29 /** @addtogroup ia32mm 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef KERN_ppc64_MEMORY_INIT_H_ 36 #define KERN_ppc64_MEMORY_INIT_H_ 35 #include <arch/boot/memmap.h> 37 36 38 size_t get_memory_size(void); 39 40 #endif 37 uint8_t e820counter = 0xff; 38 e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS]; 41 39 42 40 /** @} -
kernel/arch/ia32/src/ia32.c
r1b067315 r71eef11 55 55 #include <arch/bios/bios.h> 56 56 57 #include <arch/mm/memory_init.h>58 57 #include <interrupt.h> 59 58 #include <ddi/irq.h> -
kernel/arch/ia32xen/Makefile.inc
r1b067315 r71eef11 132 132 arch/$(ARCH)/src/mm/as.c \ 133 133 arch/$(ARCH)/src/mm/frame.c \ 134 arch/$(ARCH)/src/mm/memory_init.c \135 134 arch/$(ARCH)/src/mm/page.c \ 136 135 arch/$(ARCH)/src/mm/tlb.c \ -
kernel/arch/ia32xen/src/ia32xen.c
r1b067315 r71eef11 54 54 #include <arch/bios/bios.h> 55 55 56 #include <arch/mm/memory_init.h>57 56 #include <interrupt.h> 58 57 #include <arch/debugger.h> -
kernel/arch/ia64/src/mm/frame.c
r1b067315 r71eef11 42 42 * for real ia64 systems that provide memory map. 43 43 */ 44 #define MEMORY_SIZE (512 * 1024 * 1024) 44 45 #define ROM_BASE 0xa0000 45 #define ROM_SIZE (384 *1024)46 #define ROM_SIZE (384 * 1024) 46 47 47 48 void frame_arch_init(void) 48 49 { 49 zone_create(0, config.memory_size >> FRAME_WIDTH, 1, 0);50 zone_create(0, SIZE2FRAMES(MEMORY_SIZE), 1, 0); 50 51 51 52 /* 52 53 * Blacklist ROM regions. 53 54 */ 54 frame_mark_unavailable(ADDR2PFN(ROM_BASE), ROM_SIZE >> FRAME_WIDTH);55 frame_mark_unavailable(ADDR2PFN(ROM_BASE), SIZE2FRAMES(ROM_SIZE)); 55 56 } 56 57 -
kernel/arch/mips32/src/drivers/arc.c
r1b067315 r71eef11 221 221 } 222 222 } else 223 printf("%#10x %#10x free\n", 0, config.memory_size);223 printf("%#10x %#10x free\n", 0, CONFIG_MEMORY_SIZE); 224 224 } 225 225 … … 363 363 if (arc_enabled()) { 364 364 arc_memdescriptor_t *desc; 365 int total = 0;366 365 uintptr_t base; 367 366 size_t basesize; … … 380 379 basesize = ALIGN_DOWN(basesize, FRAME_SIZE); 381 380 382 total += basesize;383 384 381 zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize), 385 382 ADDR2PFN(base), 0); … … 388 385 } 389 386 390 config.memory_size = total;391 387 return true; 392 388 } -
kernel/arch/mips32/src/mm/frame.c
r1b067315 r71eef11 47 47 { 48 48 if (!arc_frame_init()) { 49 zone_create(0, ADDR2PFN( config.memory_size), 1, 0);49 zone_create(0, ADDR2PFN(CONFIG_MEMORY_SIZE), 1, 0); 50 50 /* 51 51 * Blacklist interrupt vector -
kernel/arch/ppc32/Makefile.inc
r1b067315 r71eef11 80 80 arch/$(ARCH)/src/mm/as.c \ 81 81 arch/$(ARCH)/src/mm/frame.c \ 82 arch/$(ARCH)/src/mm/memory_init.c \83 82 arch/$(ARCH)/src/mm/page.c \ 84 83 arch/$(ARCH)/src/mm/tlb.c \ -
kernel/arch/ppc32/src/mm/frame.c
r1b067315 r71eef11 35 35 #include <arch/boot/boot.h> 36 36 #include <arch/mm/frame.h> 37 #include <arch/mm/memory_init.h>38 37 #include <mm/frame.h> 39 38 #include <align.h> -
kernel/arch/ppc32/src/ppc32.c
r1b067315 r71eef11 37 37 #include <arch/boot/boot.h> 38 38 #include <arch/drivers/cuda.h> 39 #include <arch/mm/memory_init.h>40 39 #include <arch/interrupt.h> 41 40 #include <genarch/fb/fb.h> -
kernel/arch/ppc64/Makefile.inc
r1b067315 r71eef11 68 68 arch/$(ARCH)/src/mm/as.c \ 69 69 arch/$(ARCH)/src/mm/frame.c \ 70 arch/$(ARCH)/src/mm/memory_init.c \71 70 arch/$(ARCH)/src/mm/page.c \ 72 71 arch/$(ARCH)/src/mm/tlb.c \ -
kernel/arch/ppc64/src/mm/frame.c
r1b067315 r71eef11 35 35 #include <arch/boot/boot.h> 36 36 #include <arch/mm/frame.h> 37 #include <arch/mm/memory_init.h>38 37 #include <mm/frame.h> 39 38 #include <align.h> -
kernel/arch/ppc64/src/ppc64.c
r1b067315 r71eef11 35 35 #include <arch.h> 36 36 #include <arch/boot/boot.h> 37 #include <arch/mm/memory_init.h>38 37 #include <arch/interrupt.h> 39 38 #include <genarch/fb/fb.h> -
kernel/arch/sparc64/Makefile.inc
r1b067315 r71eef11 90 90 arch/$(ARCH)/src/mm/page.c \ 91 91 arch/$(ARCH)/src/mm/tlb.c \ 92 arch/$(ARCH)/src/mm/memory_init.c \93 92 arch/$(ARCH)/src/sparc64.c \ 94 93 arch/$(ARCH)/src/start.S \ -
kernel/generic/include/config.h
r1b067315 r71eef11 70 70 71 71 uintptr_t base; 72 size_t memory_size; /**< Size of detected memory in bytes. */73 72 size_t kernel_size; /**< Size of memory in bytes taken by kernel and stack */ 74 73 -
kernel/generic/include/macros.h
r1b067315 r71eef11 67 67 #define PA_overlaps(x, szx, y, szy) overlaps(KA2PA(x), szx, KA2PA(y), szy) 68 68 69 #define SIZE2KB(size) (size >> 10) 70 #define SIZE2MB(size) (size >> 20) 71 69 72 #define STRING(arg) STRING_ARG(arg) 70 73 #define STRING_ARG(arg) #arg -
kernel/generic/include/mm/frame.h
r1b067315 r71eef11 85 85 } 86 86 87 static inline size_t FRAMES2SIZE(count_t frames) 88 { 89 return (size_t) (frames << FRAME_WIDTH); 90 } 91 87 92 #define IS_BUDDY_ORDER_OK(index, order) \ 88 93 ((~(((unative_t) -1) << (order)) & (index)) == 0) … … 105 110 106 111 extern int zone_create(pfn_t start, count_t count, pfn_t confframe, int flags); 107 void *frame_get_parent(pfn_t frame, unsigned int hint); 108 void frame_set_parent(pfn_t frame, void *data, unsigned int hint); 109 void frame_mark_unavailable(pfn_t start, count_t count); 110 uintptr_t zone_conf_size(count_t count); 111 void zone_merge(unsigned int z1, unsigned int z2); 112 void zone_merge_all(void); 112 extern void *frame_get_parent(pfn_t frame, unsigned int hint); 113 extern void frame_set_parent(pfn_t frame, void *data, unsigned int hint); 114 extern void frame_mark_unavailable(pfn_t start, count_t count); 115 extern uintptr_t zone_conf_size(count_t count); 116 extern void zone_merge(unsigned int z1, unsigned int z2); 117 extern void zone_merge_all(void); 118 extern uint64_t zone_total_size(void); 113 119 114 120 /* … … 116 122 */ 117 123 extern void zone_print_list(void); 118 void zone_print_one(unsigned int znum);124 extern void zone_print_one(unsigned int znum); 119 125 120 126 #endif -
kernel/generic/src/main/main.c
r1b067315 r71eef11 64 64 #include <align.h> 65 65 #include <interrupt.h> 66 #include <arch/mm/memory_init.h>67 66 #include <mm/frame.h> 68 67 #include <mm/page.h> … … 144 143 145 144 config.base = hardcoded_load_address; 146 config.memory_size = get_memory_size();147 148 145 config.kernel_size = ALIGN_UP(hardcoded_ktext_size + 149 146 hardcoded_kdata_size, PAGE_SIZE); … … 220 217 ddi_init(); 221 218 arch_post_mm_init(); 222 219 223 220 version_print(); 224 printf("kernel: %.*p hardcoded_ktext_size=%zd K, "225 "hardcoded_kdata_size=%zd K\n", sizeof(uintptr_t) * 2,226 config.base, hardcoded_ktext_size >> 10,227 hardcoded_kdata_size >> 10);228 printf("stack: %.*p size=%zd K\n", sizeof(uintptr_t) * 2,229 config.stack_base, config.stack_size >> 10);230 221 printf("kernel: %.*p hardcoded_ktext_size=%zd KB, " 222 "hardcoded_kdata_size=%zd KB\n", sizeof(uintptr_t) * 2, 223 config.base, SIZE2KB(hardcoded_ktext_size), 224 SIZE2KB(hardcoded_kdata_size)); 225 printf("stack: %.*p size=%zd KB\n", sizeof(uintptr_t) * 2, 226 config.stack_base, SIZE2KB(config.stack_size)); 227 231 228 arch_pre_smp_init(); 232 229 smp_init(); 233 230 /* Slab must be initialized after we know the number of processors. */ 234 231 slab_enable_cpucache(); 235 236 printf(" config.memory_size=%zdM\n", config.memory_size >> 20);237 printf("config.cpu_count=%zd\n", config.cpu_count);232 233 printf("Detected %zu CPU(s), %llu MB free memory\n", 234 config.cpu_count, SIZE2MB(zone_total_size())); 238 235 cpu_init(); 239 236 -
kernel/generic/src/mm/frame.c
r1b067315 r71eef11 105 105 106 106 107 /******************** *************/107 /********************/ 108 108 /* Helper functions */ 109 /********************/ 110 109 111 static inline index_t frame_index(zone_t *zone, frame_t *frame) 110 112 { 111 return (index_t)(frame - zone->frames); 112 } 113 return (index_t) (frame - zone->frames); 114 } 115 113 116 static inline index_t frame_index_abs(zone_t *zone, frame_t *frame) 114 117 { 115 return (index_t)(frame - zone->frames) + zone->base; 116 } 118 return (index_t) (frame - zone->frames) + zone->base; 119 } 120 117 121 static inline int frame_index_valid(zone_t *zone, index_t index) 118 122 { 119 return index >= 0 && index < zone->count;123 return (index >= 0) && (index < zone->count); 120 124 } 121 125 … … 123 127 static index_t make_frame_index(zone_t *zone, frame_t *frame) 124 128 { 125 return frame - zone->frames;129 return (frame - zone->frames); 126 130 } 127 131 … … 138 142 } 139 143 140 /********************** ***************/144 /**********************/ 141 145 /* Zoneinfo functions */ 146 /**********************/ 142 147 143 148 /** … … 155 160 ipl = interrupts_disable(); 156 161 spinlock_lock(&zones.lock); 162 157 163 /* Try to merge */ 158 if (zones.count + 1 == ZONES_MAX) 159 panic("Maximum zone(%d) count exceeded.", ZONES_MAX); 164 if (zones.count + 1 == ZONES_MAX) { 165 printf("Maximum zone count %u exceeded!\n", ZONES_MAX); 166 spinlock_unlock(&zones.lock); 167 interrupts_restore(ipl); 168 return -1; 169 } 170 160 171 for (i = 0; i < zones.count; i++) { 161 172 /* Check for overflow */ 162 173 z = zones.info[i]; 163 if (overlaps(newzone->base,newzone->count, z->base, 164 z->count)) { 174 if (overlaps(newzone->base, newzone->count, z->base, z->count)) { 165 175 printf("Zones overlap!\n"); 166 176 return -1; … … 169 179 break; 170 180 } 181 171 182 /* Move other zones up */ 172 183 for (j = i; j < zones.count; j++) 173 184 zones.info[j + 1] = zones.info[j]; 185 174 186 zones.info[i] = newzone; 175 187 zones.count++; 188 176 189 spinlock_unlock(&zones.lock); 177 190 interrupts_restore(ipl); … … 182 195 /** 183 196 * Try to find a zone where can we find the frame 184 197 * 185 198 * Assume interrupts are disabled. 186 199 * 187 200 * @param frame Frame number contained in zone 188 201 * @param pzone If not null, it is used as zone hint. Zone index … … 901 914 } 902 915 903 z = (zone_t *) PA2KA(PFN2ADDR(confframe));916 z = (zone_t *) PA2KA(PFN2ADDR(confframe)); 904 917 zone_construct(start, count, z, flags); 905 918 znum = zones_add_zone(z); … … 1110 1123 1111 1124 1125 /** Return total size of all zones 1126 * 1127 */ 1128 uint64_t zone_total_size(void) { 1129 zone_t *zone = NULL; 1130 unsigned int i; 1131 ipl_t ipl; 1132 uint64_t total = 0; 1133 1134 ipl = interrupts_disable(); 1135 spinlock_lock(&zones.lock); 1136 1137 for (i = 0; i < zones.count; i++) { 1138 zone = zones.info[i]; 1139 spinlock_lock(&zone->lock); 1140 total += (uint64_t) FRAMES2SIZE(zone->count); 1141 spinlock_unlock(&zone->lock); 1142 } 1143 1144 spinlock_unlock(&zones.lock); 1145 interrupts_restore(ipl); 1146 1147 return total; 1148 } 1149 1150 1112 1151 1113 1152 /** Prints list of zones … … 1161 1200 1162 1201 for (i = 0; i < zones.count; i++) { 1163 if ( i == num || PFN2ADDR(zones.info[i]->base) == num) {1202 if ((i == num) || (PFN2ADDR(zones.info[i]->base) == num)) { 1164 1203 zone = zones.info[i]; 1165 1204 break; … … 1175 1214 printf("Zone base address: %#.*p\n", sizeof(uintptr_t) * 2, 1176 1215 PFN2ADDR(zone->base)); 1177 printf("Zone size: %zd frames (%zd K)\n", zone->count,1178 ((zone->count) * FRAME_SIZE) >> 10);1179 printf("Allocated space: %zd frames (%zd K)\n", zone->busy_count,1180 (zone->busy_count * FRAME_SIZE) >> 10);1181 printf("Available space: %zd frames (%zd K)\n", zone->free_count,1182 (zone->free_count * FRAME_SIZE) >> 10);1216 printf("Zone size: %zd frames (%zd KB)\n", zone->count, 1217 SIZE2KB(FRAMES2SIZE(zone->count))); 1218 printf("Allocated space: %zd frames (%zd KB)\n", zone->busy_count, 1219 SIZE2KB(FRAMES2SIZE(zone->busy_count))); 1220 printf("Available space: %zd frames (%zd KB)\n", zone->free_count, 1221 SIZE2KB(FRAMES2SIZE(zone->free_count))); 1183 1222 buddy_system_structure_print(zone->buddy_system, FRAME_SIZE); 1184 1185 1223 spinlock_unlock(&zone->lock); 1224 1186 1225 out: 1187 1226 spinlock_unlock(&zones.lock);
Note:
See TracChangeset
for help on using the changeset viewer.