Rev 3972 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3972 | Rev 3973 | ||
---|---|---|---|
Line 48... | Line 48... | ||
48 | 48 | ||
49 | size_t hardcoded_unmapped_ktext_size = 0; |
49 | size_t hardcoded_unmapped_ktext_size = 0; |
50 | size_t hardcoded_unmapped_kdata_size = 0; |
50 | size_t hardcoded_unmapped_kdata_size = 0; |
51 | 51 | ||
52 | uintptr_t last_frame = 0; |
52 | uintptr_t last_frame = 0; |
53 | uintptr_t end_frame = 0; |
- | |
54 | 53 | ||
55 | static void init_e820_memory(pfn_t minconf) |
54 | static void init_e820_memory(pfn_t minconf) |
56 | { |
55 | { |
57 | unsigned int i; |
56 | unsigned int i; |
58 | pfn_t start, conf; |
- | |
59 | size_t size; |
- | |
60 | - | ||
61 | for (i = 0; i < e820counter; i++) { |
57 | for (i = 0; i < e820counter; i++) { |
- | 58 | uint64_t base = e820table[i].base_address; |
|
- | 59 | uint64_t size = e820table[i].size; |
|
- | 60 | ||
- | 61 | #ifdef __32_BITS__ |
|
- | 62 | ||
- | 63 | /* Ignore physical memory above 4 GB */ |
|
- | 64 | if ((base >> 32) != 0) |
|
- | 65 | continue; |
|
- | 66 | ||
- | 67 | /* Clip regions above 4 GB */ |
|
- | 68 | if (((base + size) >> 32) != 0) |
|
- | 69 | size = 0xffffffff - base; |
|
- | 70 | ||
- | 71 | #endif |
|
- | 72 | pfn_t pfn; |
|
- | 73 | count_t count; |
|
- | 74 | ||
62 | if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) { |
75 | if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) { |
- | 76 | /* To be safe, make available zone possibly smaller */ |
|
63 | start = ADDR2PFN(ALIGN_UP(e820table[i].base_address, FRAME_SIZE)); |
77 | pfn = ADDR2PFN(ALIGN_UP(base, FRAME_SIZE)); |
64 | size = SIZE2FRAMES(ALIGN_DOWN(e820table[i].size, FRAME_SIZE)); |
78 | count = SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE)); |
65 | 79 | ||
- | 80 | pfn_t conf; |
|
66 | if ((minconf < start) || (minconf >= start + size)) |
81 | if ((minconf < pfn) || (minconf >= pfn + count)) |
67 | conf = start; |
82 | conf = pfn; |
68 | else |
83 | else |
69 | conf = minconf; |
84 | conf = minconf; |
70 | 85 | ||
71 | zone_create(start, size, conf, 0); |
86 | zone_create(pfn, count, conf, ZONE_AVAILABLE); |
72 | 87 | ||
- | 88 | // XXX this has to be removed |
|
73 | if (last_frame < ALIGN_UP(e820table[i].base_address + |
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)); |
|
74 | e820table[i].size, FRAME_SIZE)) |
96 | count = SIZE2FRAMES(ALIGN_UP(size, FRAME_SIZE)); |
75 | last_frame = |
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 */ |
|
76 | ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE); |
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); |
|
77 | } |
107 | } |
78 | } |
108 | } |
79 | - | ||
80 | end_frame = last_frame; |
- | |
81 | } |
109 | } |
82 | 110 | ||
83 | static char *e820names[] = { |
111 | static char *e820names[] = { |
84 | "invalid", |
112 | "invalid", |
85 | "available", |
113 | "available", |