Changes in kernel/arch/ia32/src/mm/frame.c [142084b2:ba4a63b8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/mm/frame.c
r142084b2 rba4a63b8 47 47 #include <print.h> 48 48 49 #define PHYSMEM_LIMIT32 0x07c000000ull50 #define PHYSMEM_LIMIT64 0x200000000ull51 52 49 size_t hardcoded_unmapped_ktext_size = 0; 53 50 size_t hardcoded_unmapped_kdata_size = 0; … … 58 55 { 59 56 unsigned int i; 60 57 61 58 for (i = 0; i < e820counter; i++) { 62 59 uint64_t base = e820table[i].base_address; … … 64 61 65 62 #ifdef __32_BITS__ 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) 63 /* Ignore physical memory above 4 GB */ 64 if ((base >> 32) != 0) 85 65 continue; 86 66 87 if (base + size > PHYSMEM_LIMIT32) 88 size = PHYSMEM_LIMIT32 - base; 67 /* Clip regions above 4 GB */ 68 if (((base + size) >> 32) != 0) 69 size = 0xffffffff - base; 89 70 #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 71 72 pfn_t pfn; 73 size_t count; 112 74 113 75 if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) { 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); 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)); 121 79 122 80 pfn_t conf; … … 129 87 130 88 // XXX this has to be removed 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);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)); 139 97 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);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)); 147 105 148 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 149 ZONE_RESERVED); 106 zone_create(pfn, count, 0, ZONE_FIRMWARE); 150 107 } 151 108 } … … 164 121 { 165 122 unsigned int i; 166 printf("[base ] [size ] [name ]\n");123 const char *name; 167 124 125 printf("Base Size Name\n"); 126 printf("------------------ ------------------ ---------\n"); 127 168 128 for (i = 0; i < e820counter; i++) { 169 const char *name;170 171 129 if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE) 172 130 name = e820names[e820table[i].type]; … … 174 132 name = "invalid"; 175 133 176 printf("%# 018" PRIx64 " %#018" PRIx64"%s\n", e820table[i].base_address,134 printf("%#18llx %#18llx %s\n", e820table[i].base_address, 177 135 e820table[i].size, name); 178 136 } … … 192 150 hardcoded_unmapped_kdata_size)); 193 151 #endif 194 152 195 153 init_e820_memory(minconf); 196 154 … … 200 158 #ifdef CONFIG_SMP 201 159 /* Reserve AP real mode bootstrap memory */ 202 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 160 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 203 161 (hardcoded_unmapped_ktext_size + 204 162 hardcoded_unmapped_kdata_size) >> FRAME_WIDTH);
Note:
See TracChangeset
for help on using the changeset viewer.