blob: 3170472c09129b0b5d6fb56807e2e8f6932f65ff [file] [log] [blame]
swissChili9752ab32021-03-05 11:20:13 -08001#include "multiboot.h"
2#include "io.h"
3#include "log.h"
4
5#define TO_VIRT(val, t) val = (t)((size_t)val + 0xc0000000u)
6
7// old should be a VIRTUAL address
swissChilida23a912021-03-12 16:07:50 -08008struct multiboot_info make_multiboot_physical(struct multiboot_info *old)
swissChili9752ab32021-03-05 11:20:13 -08009{
swissChilida23a912021-03-12 16:07:50 -080010 struct multiboot_info mb;
swissChili9752ab32021-03-05 11:20:13 -080011 memcpy(&mb, old, sizeof(mb));
12
13 // Make modules physical
swissChilida23a912021-03-12 16:07:50 -080014 TO_VIRT(mb.mods_addr, uint);
15 TO_VIRT(mb.cmdline, char);
swissChili9752ab32021-03-05 11:20:13 -080016
swissChili9bd74de2021-06-15 20:30:48 -070017 kprintf(DEBUG "mb.mods_addr = %d, 0x%x\n", mb.mods_addr, mb.mods_addr);
swissChilicfd3c3c2021-04-03 15:04:24 -070018 kassert((size_t)mb.mods_addr >= 0xc0000000, "mb.mods_addr PHYSICAL");
swissChili9752ab32021-03-05 11:20:13 -080019 for (int i = 0; i < mb.mods_count + 1; i++)
20 {
swissChilida23a912021-03-12 16:07:50 -080021 TO_VIRT(*(uint *)(mb.mods_addr+i), uint);
swissChili9752ab32021-03-05 11:20:13 -080022 }
23
24 return mb;
25}