aboutsummaryrefslogtreecommitdiff
path: root/mirai/pmm/types/page.zig
blob: 6928eaaf2142e671d298984260fb64e00ad4e599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Physical Page Type

pub const PhysicalPage = struct {
    frame_number: u64,
    reference_count: u32,
    flags: PageFlags,

    pub const PageFlags = packed struct {
        allocated: bool = false,
        wired: bool = false,
        reserved: bool = false,
        kernel: bool = false,
        padding: u28 = 0,
    };

    pub fn physical_address(self: PhysicalPage) u64 {
        return self.frame_number << 12;
    }

    pub fn from_physical_address(address: u64) PhysicalPage {
        return PhysicalPage{
            .frame_number = address >> 12,
            .reference_count = 0,
            .flags = .{},
        };
    }
};