File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,32 @@ inline void Paging_Enable(multiboot_info *multibootInfo)
126
126
127
127
// TEMPTEMP: put page directories between 16 - 20 megs
128
128
nextPageDirectory = FOUR_MEGABYTES * 4 ;
129
+
130
+ // Walk through the mem map grub gave us
131
+ // TODO: Assert that grub gave us a memory map
132
+ // TODO: Don't assume we have memory at the beginning of RAM
133
+ // TODO: Use all the entries we get from GRUB
134
+ multiboot_mmap_entry * entry = (multiboot_mmap_entry * )multibootInfo -> mmap_addr ;
135
+
136
+ // examine each mmap entry
137
+ for (uint32_t offset = 0 ; offset <= multibootInfo -> mmap_length && entry -> size ; offset += entry -> size + 4 )
138
+ {
139
+ if (entry -> type == MULTIBOOT_MEMORY_AVAILABLE )
140
+ {
141
+ // If the next page of memory we're assuming we can use resides here
142
+ if (pagingNextAvailableMemory >= entry -> addr && pagingNextAvailableMemory < (entry -> addr + entry -> len ))
143
+ {
144
+ // determine how many pages we really have available
145
+ uint64_t addrEnd = entry -> addr + entry -> len ;
146
+ uint64_t bytesAvailable = addrEnd - pagingNextAvailableMemory ;
147
+ paging4MPagesAvailable = bytesAvailable / FOUR_MEGABYTES ;
148
+ return ;
149
+ }
150
+ }
151
+
152
+ // advance pointer to next entry
153
+ entry = (multiboot_mmap_entry * )((uint32_t )entry + entry -> size + 4 );
154
+ }
129
155
}
130
156
131
157
bool Paging_Print_Page_Table (PAGE_DIRECTORY_ENTRY * thePageDir );
You can’t perform that action at this time.
0 commit comments