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