270a8979606b1c65a96a383d7295161380ad89d2
[lunaix-os.git] / lunaix-os / arch / i386 / includes / sys / crx.h
1 #ifndef __LUNAIX_CRX_H
2 #define __LUNAIX_CRX_H
3
4 #define CR4_PSE36           ( 1UL << 4  )
5 #define CR4_OSXMMEXCPT      ( 1UL << 10 )
6 #define CR4_OSFXSR          ( 1UL << 9  )
7 #define CR4_PCIDE           ( 1UL << 17 )
8 #define CR4_PGE             ( 1UL << 7  )
9 #define CR4_LA57            ( 1UL << 12 )
10
11 #define CR0_PG              ( 1UL << 31 )
12 #define CR0_WP              ( 1UL << 16 )
13 #define CR0_EM              ( 1UL << 2  )
14 #define CR0_MP              ( 1UL << 1  )
15
16 #define crx_addflag(crx, flag)      \
17     asm(                            \
18         "movl %%" #crx ", %%eax\n"  \
19         "orl  %0,    %%eax\n"       \
20         "movl %%eax, %%" #crx "\n"  \
21         ::"r"(flag)                 \
22         :"eax"                      \
23     );
24
25 #define crx_rmflag(crx, flag)       \
26     asm(                            \
27         "movl %%" #crx ", %%eax\n"  \
28         "andl  %0,    %%eax\n"      \
29         "movl %%eax, %%" #crx "\n"  \
30         ::"r"(~(flag))              \
31         :"eax"                      \
32     );
33
34 static inline void
35 cr4_setfeature(unsigned long feature)
36 {
37     crx_addflag(cr4, feature);
38 }
39
40 static inline void
41 cr0_setfeature(unsigned long feature)
42 {
43     crx_addflag(cr0, feature);
44 }
45
46 static inline void
47 cr0_unsetfeature(unsigned long feature)
48 {
49     crx_rmflag(cr0, feature);
50 }
51
52 #endif /* __LUNAIX_CR4_H */