memory detected with multiboot
This commit is contained in:
parent
f3285163e3
commit
33a6b9d323
3 changed files with 28 additions and 10 deletions
1
qemu.sh
1
qemu.sh
|
|
@ -9,6 +9,7 @@ start() {
|
||||||
-gdb tcp::${QEMU_GDB_PORT} \
|
-gdb tcp::${QEMU_GDB_PORT} \
|
||||||
-monitor unix:${QEMU_SOCKET},server,nowait \
|
-monitor unix:${QEMU_SOCKET},server,nowait \
|
||||||
-enable-kvm \
|
-enable-kvm \
|
||||||
|
-m 547M \
|
||||||
-display curses \
|
-display curses \
|
||||||
-device virtio-net,netdev=network0 -netdev tap,id=network0,ifname=tap0,script=no,downscript=no \
|
-device virtio-net,netdev=network0 -netdev tap,id=network0,ifname=tap0,script=no,downscript=no \
|
||||||
-kernel ${KERNEL}
|
-kernel ${KERNEL}
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,21 @@ pub fn initialize(info: *const MultibootInfo) void {
|
||||||
vga.printf("upper: {x}\n", info.mem_upper);
|
vga.printf("upper: {x}\n", info.mem_upper);
|
||||||
vga.printf("mmap_l: {}\n", info.mmap_length);
|
vga.printf("mmap_l: {}\n", info.mmap_length);
|
||||||
vga.printf("mmap_a: {x}\n", info.mmap_addr);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,19 +68,19 @@ pub const MultibootInfo = packed struct {
|
||||||
////
|
////
|
||||||
// Load all the modules passed by the bootloader.
|
// Load all the modules passed by the bootloader.
|
||||||
//
|
//
|
||||||
pub fn loadModules(self: *const MultibootInfo) void {
|
// pub fn loadModules(self: *const MultibootInfo) void {
|
||||||
const mods = @intToPtr([*]MultibootModule, self.mods_addr)[0..self.mods_count];
|
// const mods = @intToPtr([*]MultibootModule, self.mods_addr)[0..self.mods_count];
|
||||||
|
|
||||||
for (mods) |mod| {
|
// for (mods) |mod| {
|
||||||
const cmdline = cstr.toSlice(@intToPtr([*]u8, mod.cmdline));
|
// const cmdline = cstr.toSlice(@intToPtr([*]u8, mod.cmdline));
|
||||||
tty.step("Loading \"{}\"", cmdline);
|
// tty.step("Loading \"{}\"", cmdline);
|
||||||
|
|
||||||
_ = Process.create(mod.mod_start, null);
|
// _ = Process.create(mod.mod_start, null);
|
||||||
// TODO: deallocate the original memory.
|
// // TODO: deallocate the original memory.
|
||||||
|
|
||||||
tty.stepOK();
|
// tty.stepOK();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Types of memory map entries.
|
// Types of memory map entries.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue