Add RAM and VRAM footprint
This commit is contained in:
+11
-3
@@ -47,6 +47,7 @@ fn kmain(boot_info: *const BootInfo) noreturn {
|
||||
con.print(" pitch : {d} bytes\n", .{fb.pitch});
|
||||
con.print(" format : {s}\n", .{@tagName(fb.format)});
|
||||
con.print(" framebuffer: 0x{x:0>16}\n", .{fb.base});
|
||||
con.print (" footprint : {d} MiB\n", .{(fb.pitch * fb.height) / (1024 * 1024)});
|
||||
|
||||
// Summarise the physical memory the loader handed us. The array is danos's
|
||||
// own MemoryRegion, so this is a plain slice — no firmware layout in sight.
|
||||
@@ -73,9 +74,9 @@ fn kmain(boot_info: *const BootInfo) noreturn {
|
||||
// Bring up the physical frame allocator over that map, and prove it works:
|
||||
// allocate three frames, then hand them back.
|
||||
pmm.init(boot_info.memory_map);
|
||||
const s = pmm.stats();
|
||||
const s1 = pmm.stats();
|
||||
con.print("\ndanos: frame allocator online\n", .{});
|
||||
con.print(" free frames: {d} ({d} MiB)\n", .{ s.free_frames, mib(s.free_frames) });
|
||||
con.print(" free frames: {d} ({d} MiB)\n", .{ s1.free_frames, mib(s1.free_frames) });
|
||||
const f0 = pmm.alloc();
|
||||
const f1 = pmm.alloc();
|
||||
const f2 = pmm.alloc();
|
||||
@@ -94,10 +95,13 @@ fn kmain(boot_info: *const BootInfo) noreturn {
|
||||
// Bring up the kernel heap (dynamic allocation), built on the VMM.
|
||||
heap.init();
|
||||
con.write("\ndanos: kernel heap online\n");
|
||||
// Measure the amount of resources the kernel is actually using
|
||||
const s2 = pmm.stats();
|
||||
con.print(" Kernel Footprint: {d} KiB\n", .{kib(s1.free_frames - s2.free_frames)});
|
||||
|
||||
// Register the current context as the first task before enabling preemption.
|
||||
sched.init(4);
|
||||
con.write("danos: scheduler online\n");
|
||||
con.write("\ndanos: scheduler online\n");
|
||||
|
||||
// Start the timer and unmask interrupts — the kernel now has a heartbeat, and
|
||||
// the timer preempts among tasks.
|
||||
@@ -122,6 +126,10 @@ fn mib(pages: u64) u64 {
|
||||
return pages * danos.page_size / (1024 * 1024);
|
||||
}
|
||||
|
||||
fn kib(frames: u64) u64 {
|
||||
return frames * danos.page_size / (1024);
|
||||
}
|
||||
|
||||
/// Report a CPU exception in red and halt. There's no fault recovery yet, so any
|
||||
/// exception is terminal — but now it prints what and where instead of silently
|
||||
/// resetting the machine.
|
||||
|
||||
Reference in New Issue
Block a user