mm: implement runtime page mapping

This commit is contained in:
anna 2021-09-23 20:51:12 +02:00
parent 17320f2571
commit 3d6258a06e
Signed by: fef
GPG key ID: EC22E476DC2D3D84
6 changed files with 253 additions and 58 deletions

View file

@ -65,8 +65,6 @@ static void fb_init(enum vga_color fg, enum vga_color bg);
static void print_gay_propaganda(void);
/** @brief Translate a physical memory address to a virtual (mapped) one. */
#define phys_to_virt(ptr) ( (typeof(ptr))( (void *)(ptr) + CFG_KERNEL_RELOCATE ) )
static struct mb2_tag *next_tag(struct mb2_tag *tag);
static void handle_tag(struct mb2_tag *tag);
static void handle_mmap_tag(struct mb2_tag_mmap *tag);
@ -85,8 +83,6 @@ void _boot(u32 magic, void *address)
return;
}
//kprintf("%p\n", address);
print_gay_propaganda();
/*
@ -94,7 +90,7 @@ void _boot(u32 magic, void *address)
* so we need to be careful to translate all pointers to virtual
* addresses before accessing them.
*/
address = phys_to_virt(address);
address += CFG_KERNEL_RELOCATE;
for (struct mb2_tag *tag = address + 8; tag != NULL; tag = next_tag(tag))
handle_tag(tag);
@ -126,7 +122,7 @@ static inline void handle_mmap_tag(struct mb2_tag_mmap *tag)
while ((void *)entry < (void *)tag + tag->tag.size) {
kprintf("[%p-%p] %s\n",
(void *)entry->addr,
(void *)entry->len,
(void *)entry->addr + entry->len - 1,
mmap_type_name(entry->type));
if (entry->type == 1 && entry->len > region_len) {
@ -142,10 +138,10 @@ static inline void handle_mmap_tag(struct mb2_tag_mmap *tag)
while (1);
}
// if (kmalloc_init(region, region + region_len) != 0) {
// kprintf("kmalloc_init() failed! Aborting.\n");
// while (1);
// }
if (kmalloc_init(region, region + region_len) != 0) {
kprintf("kmalloc_init() failed! Aborting.\n");
while (1);
}
}
static inline struct mb2_tag *next_tag(struct mb2_tag *tag)