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 |
swissChili | da23a91 | 2021-03-12 16:07:50 -0800 | [diff] [blame] | 8 | struct multiboot_info make_multiboot_physical(struct multiboot_info *old) |
swissChili | 9752ab3 | 2021-03-05 11:20:13 -0800 | [diff] [blame] | 9 | { |
swissChili | da23a91 | 2021-03-12 16:07:50 -0800 | [diff] [blame] | 10 | struct multiboot_info mb; |
swissChili | 9752ab3 | 2021-03-05 11:20:13 -0800 | [diff] [blame] | 11 | memcpy(&mb, old, sizeof(mb)); |
| 12 | |
| 13 | // Make modules physical |
swissChili | da23a91 | 2021-03-12 16:07:50 -0800 | [diff] [blame] | 14 | TO_VIRT(mb.mods_addr, uint); |
| 15 | TO_VIRT(mb.cmdline, char); |
swissChili | 9752ab3 | 2021-03-05 11:20:13 -0800 | [diff] [blame] | 16 | |
swissChili | 9bd74de | 2021-06-15 20:30:48 -0700 | [diff] [blame] | 17 | kprintf(DEBUG "mb.mods_addr = %d, 0x%x\n", mb.mods_addr, mb.mods_addr); |
swissChili | cfd3c3c | 2021-04-03 15:04:24 -0700 | [diff] [blame] | 18 | kassert((size_t)mb.mods_addr >= 0xc0000000, "mb.mods_addr PHYSICAL"); |
swissChili | 9752ab3 | 2021-03-05 11:20:13 -0800 | [diff] [blame] | 19 | for (int i = 0; i < mb.mods_count + 1; i++) |
| 20 | { |
swissChili | da23a91 | 2021-03-12 16:07:50 -0800 | [diff] [blame] | 21 | TO_VIRT(*(uint *)(mb.mods_addr+i), uint); |
swissChili | 9752ab3 | 2021-03-05 11:20:13 -0800 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | return mb; |
| 25 | } |