blob: 13e1f9868e4cf7bc560613e8c3b2d43cf353c015 [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 {
21 TO_VIRT(mb.mods_addr[i], uint *);
22 }
23
24 return mb;
25}