aboutsummaryrefslogtreecommitdiff
path: root/mirai.old/invocations/os/meminfo.zig
blob: e1f3b3cac60fea62476709d6a3b86ae5ae76d11a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! MEMINFO invocation - Get memory information

const handler = @import("../handler.zig");
const memory = @import("../../common/constants/memory.zig");
const pmm = @import("../../memory/pmm.zig");
const result = @import("../../utils/types/result.zig");

pub fn invoke(ctx: *handler.InvocationContext) void {
    const total_ptr: *u64 = @ptrFromInt(ctx.rdi);
    const used_ptr: *u64 = @ptrFromInt(ctx.rsi);
    const free_ptr: *u64 = @ptrFromInt(ctx.rdx);

    const info = pmm.get_info();

    total_ptr.* = info.total * memory.PAGE_SIZE;
    used_ptr.* = info.used * memory.PAGE_SIZE;
    free_ptr.* = (info.total - info.used) * memory.PAGE_SIZE;

    result.set_ok(ctx);
}