add validator to restrict the flexibility of LConfig
[lunaix-os.git] / lunaix-os / arch / LConfig
1 from . import x86
2
3 @"Platform"
4 def architecture_support():
5     """
6         Config ISA related features
7     """
8
9     @flag
10     def arch_x86_32() -> bool:
11         when(arch is "i386")
12     
13     @flag
14     def arch_x86_64() -> bool:
15         when(arch is "x86_64")
16     
17     @flag
18     def arch_x86() -> bool:
19         when(arch is "i386")
20         when(arch is "x86_64")
21
22     @"Architecture"
23     def arch() -> "i386" | "x86_64":
24         """ 
25             Config ISA support 
26         """
27         _arch = env("ARCH")
28         return _arch if _arch else "x86_64"
29
30     @"Base operand size"
31     @readonly
32     def arch_bits() -> 32 | 64:
33         """ 
34             Defines the base size of a general register of the 
35             current selected ISA.
36
37             This the 'bits' part when we are talking about a CPU
38         """
39
40         match arch.val:
41             case "i386": 
42                 return 32
43             case "aarch64": 
44                 return 64
45             case "rv64": 
46                 return 64
47             case "x86_64": 
48                 return 64
49             case _:
50                 return 32
51