Changes in kernel/arch/ia32/src/mm/frame.c [dc0b964:98000fb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/mm/frame.c
rdc0b964 r98000fb 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 46 47 #include <print.h> 47 48 #define PHYSMEM_LIMIT32 UINT64_C(0x07c000000)49 #define PHYSMEM_LIMIT64 UINT64_C(0x200000000)50 48 51 49 size_t hardcoded_unmapped_ktext_size = 0; … … 57 55 { 58 56 unsigned int i; 59 60 57 for (i = 0; i < e820counter; i++) { 61 58 uint64_t base = e820table[i].base_address; … … 63 60 64 61 #ifdef __32_BITS__ 65 /*66 * XXX FIXME:67 *68 * Ignore zones which start above PHYSMEM_LIMIT3269 * or clip zones which go beyond PHYSMEM_LIMIT32.70 *71 * The PHYSMEM_LIMIT32 (2 GB - 64 MB) is a rather72 * arbitrary constant which allows to have at73 * least 64 MB in the kernel address space to74 * map hardware resources.75 *76 * The kernel uses fixed 1:1 identity mapping77 * of the physical memory with 2:2 GB split.78 * This is a severe limitation of the current79 * kernel memory management.80 *81 */82 62 83 if (base > PHYSMEM_LIMIT32) 63 /* Ignore physical memory above 4 GB */ 64 if ((base >> 32) != 0) 84 65 continue; 85 66 86 if (base + size > PHYSMEM_LIMIT32) 87 size = PHYSMEM_LIMIT32 - base; 67 /* Clip regions above 4 GB */ 68 if (((base + size) >> 32) != 0) 69 size = 0xffffffff - base; 70 88 71 #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 72 pfn_t pfn; 73 size_t count; 111 74 112 75 if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) { 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); 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)); 120 79 121 80 pfn_t conf; … … 128 87 129 88 // XXX this has to be removed 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);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)); 138 97 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);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)); 146 105 147 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 148 ZONE_RESERVED); 106 zone_create(pfn, count, 0, ZONE_FIRMWARE); 149 107 } 150 108 } 151 109 } 152 110 153 static c onst char *e820names[] = {111 static char *e820names[] = { 154 112 "invalid", 155 113 "available", … … 160 118 }; 161 119 120 162 121 void physmem_print(void) 163 122 { 164 123 unsigned int i; 165 printf("[base ] [size ] [name ]\n");124 char *name; 166 125 126 printf("Base Size Name\n"); 127 printf("------------------ ------------------ ---------\n"); 128 167 129 for (i = 0; i < e820counter; i++) { 168 const char *name;169 170 130 if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE) 171 131 name = e820names[e820table[i].type]; … … 173 133 name = "invalid"; 174 134 175 printf("%# 018" PRIx64 " %#018" PRIx64"%s\n", e820table[i].base_address,176 135 printf("%#18llx %#18llx %s\n", e820table[i].base_address, 136 e820table[i].size, name); 177 137 } 178 138 } … … 188 148 #ifdef CONFIG_SMP 189 149 minconf = max(minconf, 190 191 150 ADDR2PFN(AP_BOOT_OFFSET + hardcoded_unmapped_ktext_size + 151 hardcoded_unmapped_kdata_size)); 192 152 #endif 193 194 153 init_e820_memory(minconf); 195 154 … … 199 158 #ifdef CONFIG_SMP 200 159 /* Reserve AP real mode bootstrap memory */ 201 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 202 203 160 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 161 (hardcoded_unmapped_ktext_size + 162 hardcoded_unmapped_kdata_size) >> FRAME_WIDTH); 204 163 #endif 205 164 }
Note:
See TracChangeset
for help on using the changeset viewer.