blob: 63f6ed1e4c9a9103bcd42fad51c6da54542b7165 [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
8struct multiboot make_multiboot_physical(struct multiboot *old)
9{
10 struct multiboot mb;
11 memcpy(&mb, old, sizeof(mb));
12
13 // Make modules physical
14 TO_VIRT(mb.mods_addr, uint **);
15 TO_VIRT(mb.cmdline, char *);
16
17 kprintf("mb.mods_addr = %d, 0x%x\n", mb.mods_addr, mb.mods_addr);
18 kassert((size_t)mb.mods_addr > 0xc0000000, "mb.mods_addr PHYSICAL");
19 for (int i = 0; i < mb.mods_count + 1; i++)
20 {
swissChili6c0519e2021-03-07 19:40:23 -080021 TO_VIRT(mb.mods_addr[i], uchar *);
swissChili9752ab32021-03-05 11:20:13 -080022 }
23
24 return mb;
25}