reduce the size of ppage by 8 bytes using signly linked list
[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         self.companion = self._kstruct["companion"]
13
14     def uninitialized(self):
15         return not (self.flags & 0b10)
16     
17     def reserved(self):
18         return (not self.uninitialized() 
19                 and self.type == 0b1000
20                 and self.ref  == 0xf0f0f0f0)
21     
22     def busy(self):
23         return (not self.uninitialized()
24                 and self.type != 0b1000
25                 and self.ref > 0)
26
27     def lead_page(self):
28         return self.companion == 0 and not self.uninitialized()
29
30     @staticmethod
31     def get_type() -> Type:
32         return lookup_type("struct ppage").pointer()
33