]> git.corax.cc Git - corax/commitdiff
kernel/arch: Clean up cpu_get_capabilities() implementation
authorMatthias Kruk <m@m10k.eu>
Thu, 5 Nov 2020 04:03:36 +0000 (13:03 +0900)
committerMatthias Kruk <m@m10k.eu>
Thu, 5 Nov 2020 04:03:36 +0000 (13:03 +0900)
Reverse the order of the dwords returned so that the most important
features are in the lower dword and add macros that can be used to
test for feature support on the executing processor.

kernel/arch/cpu32.S
kernel/include/arch.h

index e98f45f8e88d40d437b95a683ae4eada5b1fb1a5..63eb5a35a66f8800e1070af3a94273340a56aab3 100644 (file)
@@ -35,26 +35,27 @@ boot_id:
 .global cpu_get_id
 
 cpu_get_id:
-    movl    $APIC_ID_ADDR, %esi
-    movl    (%esi), %eax
-    shrl    $24, %eax
-    ret
+       movl    $APIC_ID_ADDR, %esi
+       movl    (%esi), %eax
+       shrl    $24, %eax
+       ret
 
 .global cpu_get_capabilities
 
 cpu_get_capabilities:
        pushl   %ebx
-    movl    $1, %eax
-    cpuid
-    movl    %ecx, %eax
+       movl    $1, %eax
+       cpuid
+       movl    %edx, %eax
+       movl    %ecx, %edx
        popl    %ebx
-    ret
+       ret
 
 .global cpu_timestamp
 cpu_timestamp:
-    lfence
-    rdtsc
-    ret
+       lfence
+       rdtsc
+       ret
 
 .global cpu_set_pstate
 
index 9f828a7c0c10793c0f84bbe1c34a4cc4c971b978..a13ffc1e7152443b09bfd6d78791601d1a7e74ec 100644 (file)
@@ -183,6 +183,39 @@ struct region {
 
 typedef struct pagedir pg_dir_t;
 
+#define CPU_CAPABILITY_FPU   (1 << 0)
+#define CPU_CAPABILITY_VME   (1 << 1)
+#define CPU_CAPABILITY_DE    (1 << 2)
+#define CPU_CAPABILITY_PSE   (1 << 3)
+#define CPU_CAPABILITY_TSC   (1 << 4)
+#define CPU_CAPABILITY_MSR   (1 << 5)
+#define CPU_CAPABILITY_PAE   (1 << 6)
+#define CPU_CAPABILITY_MCE   (1 << 7)
+#define CPU_CAPABILITY_CX8   (1 << 8)
+#define CPU_CAPABILITY_APIC  (1 << 9)
+
+#define CPU_CAPABILITY_SEP   (1 << 11)
+#define CPU_CAPABILITY_MTRR  (1 << 12)
+#define CPU_CAPABILITY_PGE   (1 << 13)
+#define CPU_CAPABILITY_MCA   (1 << 14)
+#define CPU_CAPABILITY_CMOV  (1 << 15)
+#define CPU_CAPABILITY_PAT   (1 << 16)
+#define CPU_CAPABILITY_PSE36 (1 << 17)
+#define CPU_CAPABILITY_PSN   (1 << 18)
+#define CPU_CAPABILITY_CLFSH (1 << 19)
+
+#define CPU_CAPABILITY_DS    (1 << 21)
+#define CPU_CAPABILITY_ACPI  (1 << 22)
+#define CPU_CAPABILITY_MMX   (1 << 23)
+#define CPU_CAPABILITY_FXSR  (1 << 24)
+#define CPU_CAPABILITY_SSE   (1 << 25)
+#define CPU_CAPABILITY_SSE2  (1 << 26)
+#define CPU_CAPABILITY_SS    (1 << 27)
+#define CPU_CAPABILITY_HTT   (1 << 28)
+#define CPU_CAPABILITY_TM    (1 << 29)
+
+#define CPU_CAPABILITY_PBE   (1 << 31)
+
 int     cpu_get_id(void);
 u64_t   cpu_get_capabilities(void);
 u64_t   cpu_timestamp(void);