memory detected with multiboot

This commit is contained in:
Jack Halford 2019-06-25 23:09:13 +02:00
parent f3285163e3
commit 33a6b9d323
3 changed files with 28 additions and 10 deletions

View file

@ -9,6 +9,7 @@ start() {
-gdb tcp::${QEMU_GDB_PORT} \
-monitor unix:${QEMU_SOCKET},server,nowait \
-enable-kvm \
-m 547M \
-display curses \
-device virtio-net,netdev=network0 -netdev tap,id=network0,ifname=tap0,script=no,downscript=no \
-kernel ${KERNEL}

View file

@ -10,4 +10,21 @@ pub fn initialize(info: *const MultibootInfo) void {
vga.printf("upper: {x}\n", info.mem_upper);
vga.printf("mmap_l: {}\n", info.mmap_length);
vga.printf("mmap_a: {x}\n", info.mmap_addr);
var map: usize = info.mmap_addr;
while (map < info.mmap_addr + info.mmap_length) {
var entry = @intToPtr(*MultibootMMapEntry, map);
if (entry.type == MULTIBOOT_MEMORY_AVAILABLE) {
vga.printf("AVAILABLE: ");
} else {
vga.printf("NOT AVAILABLE: ");
}
vga.printf("{x} ", entry.addr);
if (entry.len / (1024 * 1024) > 0) {
vga.printf("({} MB)\n", entry.len / (1024 * 1024));
} else {
vga.printf("({} kB)\n", entry.len / (1024));
}
map += entry.size + @sizeOf(@typeOf(entry.size));
}
}

View file

@ -68,19 +68,19 @@ pub const MultibootInfo = packed struct {
////
// Load all the modules passed by the bootloader.
//
pub fn loadModules(self: *const MultibootInfo) void {
const mods = @intToPtr([*]MultibootModule, self.mods_addr)[0..self.mods_count];
// pub fn loadModules(self: *const MultibootInfo) void {
// const mods = @intToPtr([*]MultibootModule, self.mods_addr)[0..self.mods_count];
for (mods) |mod| {
const cmdline = cstr.toSlice(@intToPtr([*]u8, mod.cmdline));
tty.step("Loading \"{}\"", cmdline);
// for (mods) |mod| {
// const cmdline = cstr.toSlice(@intToPtr([*]u8, mod.cmdline));
// tty.step("Loading \"{}\"", cmdline);
_ = Process.create(mod.mod_start, null);
// TODO: deallocate the original memory.
// _ = Process.create(mod.mod_start, null);
// // TODO: deallocate the original memory.
tty.stepOK();
}
}
// tty.stepOK();
// }
// }
};
// Types of memory map entries.