Changes in kernel/arch/ia32/src/mm/frame.c [64f6ef04:ba4a63b8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/mm/frame.c
r64f6ef04 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);89 if (last_frame < ALIGN_UP(base + size, FRAME_SIZE)) 90 last_frame = ALIGN_UP(base + size, FRAME_SIZE); 133 91 } 134 92 135 93 if (e820table[i].type == MEMMAP_MEMORY_RESERVED) { 136 /* To be safe, make the reserved zone possibly larger */ 137 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE); 138 uint64_t new_size = ALIGN_UP(size + (base - new_base), 139 FRAME_SIZE); 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)); 140 97 141 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 142 ZONE_RESERVED); 98 zone_create(pfn, count, 0, ZONE_RESERVED); 143 99 } 144 100 145 101 if (e820table[i].type == MEMMAP_MEMORY_ACPI) { 146 /* To be safe, make the firmware zone possibly larger */ 147 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE); 148 uint64_t new_size = ALIGN_UP(size + (base - new_base), 149 FRAME_SIZE); 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)); 150 105 151 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 152 ZONE_FIRMWARE); 106 zone_create(pfn, count, 0, ZONE_FIRMWARE); 153 107 } 154 108 } … … 167 121 { 168 122 unsigned int i; 169 printf("[base ] [size ] [name ]\n");123 const char *name; 170 124 125 printf("Base Size Name\n"); 126 printf("------------------ ------------------ ---------\n"); 127 171 128 for (i = 0; i < e820counter; i++) { 172 const char *name;173 174 129 if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE) 175 130 name = e820names[e820table[i].type]; … … 177 132 name = "invalid"; 178 133 179 printf("%# 018" PRIx64 " %#018" PRIx64"%s\n", e820table[i].base_address,134 printf("%#18llx %#18llx %s\n", e820table[i].base_address, 180 135 e820table[i].size, name); 181 136 } … … 195 150 hardcoded_unmapped_kdata_size)); 196 151 #endif 197 152 198 153 init_e820_memory(minconf); 199 154
Note:
See TracChangeset
for help on using the changeset viewer.