feat: The waitpid family!
[lunaix-os.git] / lunaix-os / includes / hal / cpu.h
index bdb07c467267c56aa911bf3f37795b10b0747fc1..fe633d090fa7f3c7a189d590e9c8655c691ba752 100644 (file)
@@ -20,12 +20,10 @@ typedef struct
 
 typedef struct
 {
-    reg16 ss;
-    reg16 es;
     reg16 ds;
+    reg16 es;
     reg16 fs;
     reg16 gs;
-    reg16 cs;
 } __attribute__((packed)) sg_reg;
 
 void
@@ -39,19 +37,35 @@ cpu_has_apic();
 static inline reg32
 cpu_rcr0()
 {
-    asm("mov %cr0, %eax");
+    uintptr_t val;
+    asm volatile("movl %%cr0,%0" : "=r"(val));
+    return val;
 }
 
 static inline reg32
 cpu_rcr2()
 {
-    asm("mov %cr2, %eax");
+    uintptr_t val;
+    asm volatile("movl %%cr2,%0" : "=r"(val));
+    return val;
 }
 
 static inline reg32
 cpu_rcr3()
 {
-    asm("mov %cr3, %eax");
+    uintptr_t val;
+    asm volatile("movl %%cr3,%0" : "=r"(val));
+    return val;
+}
+
+static inline reg32
+cpu_reflags()
+{
+    uintptr_t val;
+    asm volatile("pushf\n"
+                 "popl %0\n"
+                 : "=r"(val)::);
+    return val;
 }
 #pragma GCC diagnostic pop