Unifying the Lunaix's Physical Memory Model (#28)
[lunaix-os.git] / lunaix-os / scripts / gdb / lunadbg / structs / page.py
1 from gdb import Type, Value, lookup_type
2 from . import KernelStruct
3
4 class PageStruct(KernelStruct):
5     def __init__(self, gdb_inferior: Value) -> None:
6         super().__init__(gdb_inferior, PageStruct)
7         self.ref = self._kstruct["refs"]
8         self.type = self._kstruct["type"]
9         self.flags = self._kstruct["flags"]
10         self.order = self._kstruct["order"]
11         self.pool = self._kstruct["pool"]
12
13     def uninitialized(self):
14         return not (self.flags & 0b10)
15     
16     def reserved(self):
17         return (not self.uninitialized() 
18                 and self.type == 0b1000
19                 and self.ref  == 0xf0f0f0f0)
20     
21     def busy(self):
22         return (not self.uninitialized()
23                 and self.ref > 0)
24
25     @staticmethod
26     def get_type() -> Type:
27         return lookup_type("struct ppage").pointer()
28