Unifying the Lunaix's Physical Memory Model (#28)
[lunaix-os.git] / lunaix-os / scripts / gdb / lunadbg / structs / page.py
index 01c08b2e0e090b6376d25c9860d9a08a20a6406f..6dc5bf98ff46236cd92f85ceae79895624a3a275 100644 (file)
@@ -4,10 +4,25 @@ from . import KernelStruct
 class PageStruct(KernelStruct):
     def __init__(self, gdb_inferior: Value) -> None:
         super().__init__(gdb_inferior, PageStruct)
-        self.ref = self._kstruct["ref_counts"]
-        self.attr = self._kstruct["attr"]
+        self.ref = self._kstruct["refs"]
+        self.type = self._kstruct["type"]
+        self.flags = self._kstruct["flags"]
+        self.order = self._kstruct["order"]
+        self.pool = self._kstruct["pool"]
+
+    def uninitialized(self):
+        return not (self.flags & 0b10)
+    
+    def reserved(self):
+        return (not self.uninitialized() 
+                and self.type == 0b1000
+                and self.ref  == 0xf0f0f0f0)
+    
+    def busy(self):
+        return (not self.uninitialized()
+                and self.ref > 0)
 
     @staticmethod
     def get_type() -> Type:
-        return lookup_type("struct pp_struct").pointer()
+        return lookup_type("struct ppage").pointer()