Changes in kernel/arch/ia32/src/mm/frame.c [ba4a63b8:142084b2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/mm/frame.c
rba4a63b8 r142084b2 47 47 #include <print.h> 48 48 49 #define PHYSMEM_LIMIT32 0x07c000000ull 50 #define PHYSMEM_LIMIT64 0x200000000ull 51 49 52 size_t hardcoded_unmapped_ktext_size = 0; 50 53 size_t hardcoded_unmapped_kdata_size = 0; … … 55 58 { 56 59 unsigned int i; 57 60 58 61 for (i = 0; i < e820counter; i++) { 59 62 uint64_t base = e820table[i].base_address; … … 61 64 62 65 #ifdef __32_BITS__ 63 /* Ignore physical memory above 4 GB */ 64 if ((base >> 32) != 0) 66 /* 67 * XXX FIXME: 68 * 69 * Ignore zones which start above PHYSMEM_LIMIT32 70 * or clip zones which go beyond PHYSMEM_LIMIT32. 71 * 72 * The PHYSMEM_LIMIT32 (2 GB - 64 MB) is a rather 73 * arbitrary constant which allows to have at 74 * least 64 MB in the kernel address space to 75 * map hardware resources. 76 * 77 * The kernel uses fixed 1:1 identity mapping 78 * of the physical memory with 2:2 GB split. 79 * This is a severe limitation of the current 80 * kernel memory management. 81 * 82 */ 83 84 if (base > PHYSMEM_LIMIT32) 65 85 continue; 66 86 67 /* Clip regions above 4 GB */ 68 if (((base + size) >> 32) != 0) 69 size = 0xffffffff - base; 70 #endif 71 72 pfn_t pfn; 73 size_t count; 87 if (base + size > PHYSMEM_LIMIT32) 88 size = PHYSMEM_LIMIT32 - base; 89 #endif 90 91 #ifdef __64_BITS__ 92 /* 93 * XXX FIXME: 94 * 95 * Ignore zones which start above PHYSMEM_LIMIT64 96 * or clip zones which go beyond PHYSMEM_LIMIT64. 97 * 98 * The PHYSMEM_LIMIT64 (8 GB) is the size of the 99 * fixed 1:1 identically mapped physical memory 100 * accessible during the bootstrap process. 101 * This is a severe limitation of the current 102 * kernel memory management. 103 * 104 */ 105 106 if (base > PHYSMEM_LIMIT64) 107 continue; 108 109 if (base + size > PHYSMEM_LIMIT64) 110 size = PHYSMEM_LIMIT64 - base; 111 #endif 74 112 75 113 if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) { 76 /* To be safe, make available zone possibly smaller */ 77 pfn = ADDR2PFN(ALIGN_UP(base, FRAME_SIZE)); 78 count = SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE)); 114 /* To be safe, make the available zone possibly smaller */ 115 uint64_t new_base = ALIGN_UP(base, FRAME_SIZE); 116 uint64_t new_size = ALIGN_DOWN(size - (new_base - base), 117 FRAME_SIZE); 118 119 pfn_t pfn = ADDR2PFN(new_base); 120 size_t count = SIZE2FRAMES(new_size); 79 121 80 122 pfn_t conf; … … 87 129 88 130 // XXX this has to be removed 89 if (last_frame < ALIGN_UP(base + size, FRAME_SIZE)) 90 last_frame = ALIGN_UP(base + size, FRAME_SIZE); 91 } 92 93 if (e820table[i].type == MEMMAP_MEMORY_RESERVED) { 94 /* To be safe, make reserved zone possibly larger */ 95 pfn = ADDR2PFN(ALIGN_DOWN(base, FRAME_SIZE)); 96 count = SIZE2FRAMES(ALIGN_UP(size, FRAME_SIZE)); 97 98 zone_create(pfn, count, 0, ZONE_RESERVED); 99 } 100 101 if (e820table[i].type == MEMMAP_MEMORY_ACPI) { 102 /* To be safe, make firmware zone possibly larger */ 103 pfn = ADDR2PFN(ALIGN_DOWN(base, (uintptr_t) FRAME_SIZE)); 104 count = SIZE2FRAMES(ALIGN_UP(size, (uintptr_t) FRAME_SIZE)); 105 106 zone_create(pfn, count, 0, ZONE_FIRMWARE); 131 if (last_frame < ALIGN_UP(new_base + new_size, FRAME_SIZE)) 132 last_frame = ALIGN_UP(new_base + new_size, FRAME_SIZE); 133 } else if ((e820table[i].type == MEMMAP_MEMORY_ACPI) || 134 (e820table[i].type == MEMMAP_MEMORY_NVS)) { 135 /* To be safe, make the firmware zone possibly larger */ 136 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE); 137 uint64_t new_size = ALIGN_UP(size + (base - new_base), 138 FRAME_SIZE); 139 140 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 141 ZONE_FIRMWARE); 142 } else { 143 /* To be safe, make the reserved zone possibly larger */ 144 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE); 145 uint64_t new_size = ALIGN_UP(size + (base - new_base), 146 FRAME_SIZE); 147 148 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 149 ZONE_RESERVED); 107 150 } 108 151 } … … 121 164 { 122 165 unsigned int i; 123 const char *name;166 printf("[base ] [size ] [name ]\n"); 124 167 125 printf("Base Size Name\n");126 printf("------------------ ------------------ ---------\n");127 128 168 for (i = 0; i < e820counter; i++) { 169 const char *name; 170 129 171 if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE) 130 172 name = e820names[e820table[i].type]; … … 132 174 name = "invalid"; 133 175 134 printf("%# 18llx %#18llx%s\n", e820table[i].base_address,176 printf("%#018" PRIx64 " %#018" PRIx64" %s\n", e820table[i].base_address, 135 177 e820table[i].size, name); 136 178 } … … 150 192 hardcoded_unmapped_kdata_size)); 151 193 #endif 152 194 153 195 init_e820_memory(minconf); 154 196 … … 158 200 #ifdef CONFIG_SMP 159 201 /* Reserve AP real mode bootstrap memory */ 160 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 202 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 161 203 (hardcoded_unmapped_ktext_size + 162 204 hardcoded_unmapped_kdata_size) >> FRAME_WIDTH);
Note:
See TracChangeset
for help on using the changeset viewer.