add validator to restrict the flexibility of LConfig
[lunaix-os.git] / lunaix-os / kernel / mm / LConfig
index 7db89f5c4abdd9781242b20ba564015169853820..fa7c431055201217f09511e6b60ed354f802a5f9 100644 (file)
@@ -1,92 +1,92 @@
 
-@Collection
+@"Memory Management"
+@(parent := kernel_feature)
 def memory_subsystem():
     """ Config the memory subsystem """
 
-    @Collection
+    @"Physical Memory"
     def physical_mm():
         """ Physical memory manager  """
 
-        @Term
-        def pmalloc_method():
+        @flag
+        def pmalloc_method_simple() -> bool:
+            when (pmalloc_method is "simple")
+        
+        @flag
+        def pmalloc_method_buddy() -> bool:
+            when (pmalloc_method is "buddy")
+        
+        @flag
+        def pmalloc_method_ncontig() -> bool:
+            when (pmalloc_method is "ncontig")
+
+        @"Allocation policy"
+        def pmalloc_method() -> "simple" | "buddy" | "ncontig":
             """ Allocation policy for phiscal memory  """
             
-            type(["simple", "buddy", "ncontig"])
-            default("simple")
+            return "simple"
 
-        @Group
+        @"PMalloc Thresholds"
         def pmalloc_simple_po_thresholds():
+
+            require (pmalloc_method_simple)
             
-            @Term
-            def pmalloc_simple_max_po0():
+            @"Maximum cached order-0 free pages"
+            def pmalloc_simple_max_po0() -> int:
                 """ free list capacity for order-0 pages  """
                 
-                type(int)
-                default(4096)
+                return 4096
 
-            @Term
-            def pmalloc_simple_max_po1():
+            @"Maximum cached order-1 free pages"
+            def pmalloc_simple_max_po1() -> int:
                 """ free list capacity for order-1 pages  """
 
-                type(int)
-                default(2048)
+                return 2048
             
-            @Term
-            def pmalloc_simple_max_po2():
+            @"Maximum cached order-2 free pages"
+            def pmalloc_simple_max_po2() -> int:
                 """ free list capacity for order-2 pages  """
 
-                type(int)
-                default(2048)
+                return 2048
             
-            @Term
-            def pmalloc_simple_max_po3():
+            @"Maximum cached order-3 free pages"
+            def pmalloc_simple_max_po3() -> int:
                 """ free list capacity for order-3 pages  """
                 
-                type(int)
-                default(2048)
+                return 2048
             
-            @Term
-            def pmalloc_simple_max_po4():
+            @"Maximum cached order-4 free pages"
+            def pmalloc_simple_max_po4() -> int:
                 """ free list capacity for order-4 pages  """
 
-                type(int)
-                default(512)
+                return 512
             
-            @Term
-            def pmalloc_simple_max_po5():
+            @"Maximum cached order-5 free pages"
+            def pmalloc_simple_max_po5() -> int:
                 """ free list capacity for order-5 pages  """
 
-                type(int)
-                default(512)
+                return 512
             
-            @Term
-            def pmalloc_simple_max_po6():
+            @"Maximum cached order-6 free pages"
+            def pmalloc_simple_max_po6() -> int:
                 """ free list capacity for order-6 pages  """
 
-                type(int)
-                default(128)
+                return 128
             
-            @Term
-            def pmalloc_simple_max_po7():
+            @"Maximum cached order-7 free pages"
+            def pmalloc_simple_max_po7() -> int:
                 """ free list capacity for order-7 pages  """
 
-                type(int)
-                default(128)
+                return 128
             
-            @Term
-            def pmalloc_simple_max_po8():
+            @"Maximum cached order-8 free pages"
+            def pmalloc_simple_max_po8() -> int:
                 """ free list capacity for order-8 pages  """
 
-                type(int)
-                default(64)
+                return 64
             
-            @Term
-            def pmalloc_simple_max_po9():
+            @"Maximum cached order-9 free pages"
+            def pmalloc_simple_max_po9() -> int:
                 """ free list capacity for order-9 pages  """
 
-                type(int)
-                default(32)
-
-            return v(pmalloc_method) == "simple"
-
-    add_to_collection(kernel_feature)
\ No newline at end of file
+                return 32
\ No newline at end of file