swissChili | 9752ab3 | 2021-03-05 11:20:13 -0800 | [diff] [blame] | 1 | #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 |
| 8 | struct 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 | { |
swissChili | 6c0519e | 2021-03-07 19:40:23 -0800 | [diff] [blame^] | 21 | TO_VIRT(mb.mods_addr[i], uchar *); |
swissChili | 9752ab3 | 2021-03-05 11:20:13 -0800 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | return mb; |
| 25 | } |