bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC] Features patch


From: Samuel Thibault
Subject: [RFC] Features patch
Date: Tue, 19 Dec 2006 11:24:43 +0100
User-agent: Mutt/1.5.11

Hi,

For some reasons (fxsave/rstor, global page bit), we need to know which
features the CPU has.  Here is a patch for adding this support.  Any
comments?

Note: the cpu_features variable is an array because there are several
feature words, I for now only implemented word 0 which contains all we
need for now.

Samuel

2006-12-19  Samuel Thibault  <samuel.thibault@ens-lyon.org>

        Add support for x86 features.

        * i386/i386/locore.h (cpu_features): New variable declaration.
        (CPU_FEATURE_FPU, CPU_FEATURE_VME, CPU_FEATURE_DE,
        CPU_FEATURE_PSE, CPU_FEATURE_TSC, CPU_FEATURE_MSR, CPU_FEATURE_PAE,
        CPU_FEATURE_MCE, CPU_FEATURE_CX8, CPU_FEATURE_APIC, CPU_FEATURE_SEP,
        CPU_FEATURE_MTRR, CPU_FEATURE_PGE, CPU_FEATURE_MCA, CPU_FEATURE_CMOV,
        CPU_FEATURE_PAT, CPU_FEATURE_PSE_36, CPU_FEATURE_PSN,
        CPU_FEATURE_CFLSH, CPU_FEATURE_DS, CPU_FEATURE_ACPI, CPU_FEATURE_MMX,
        CPU_FEATURE_FXSR, CPU_FEATURE_SSE, CPU_FEATURE_SSE2, CPU_FEATURE_SS,
        CPU_FEATURE_HTT, CPU_FEATURE_TM, CPU_FEATURE_PBE, CPU_HAS_FEATURE): New
        macros
        * i386/i386/locore.S (cpu_features): New variable.
        (discover_x86_cpu_type): Record CPUID feature word 0.

Index: i386/i386/locore.h
===================================================================
RCS file: /cvsroot/hurd/gnumach/i386/i386/Attic/locore.h,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 locore.h
--- i386/i386/locore.h  12 Nov 2006 23:45:06 -0000      1.1.2.1
+++ i386/i386/locore.h  19 Dec 2006 10:17:09 -0000
@@ -34,5 +34,39 @@ extern int copyoutmsg (vm_offset_t kerne
 
 extern int call_continuation (continuation_t continuation);
 
+extern unsigned int cpu_features[1];
+
+#define CPU_FEATURE_FPU                 0
+#define CPU_FEATURE_VME                 1
+#define CPU_FEATURE_DE          2
+#define CPU_FEATURE_PSE                 3
+#define CPU_FEATURE_TSC                 4
+#define CPU_FEATURE_MSR                 5
+#define CPU_FEATURE_PAE                 6
+#define CPU_FEATURE_MCE                 7
+#define CPU_FEATURE_CX8                 8
+#define CPU_FEATURE_APIC        9
+#define CPU_FEATURE_SEP                11
+#define CPU_FEATURE_MTRR       12
+#define CPU_FEATURE_PGE                13
+#define CPU_FEATURE_MCA                14
+#define CPU_FEATURE_CMOV       15
+#define CPU_FEATURE_PAT                16
+#define CPU_FEATURE_PSE_36     17
+#define CPU_FEATURE_PSN                18
+#define CPU_FEATURE_CFLSH      19
+#define CPU_FEATURE_DS         21
+#define CPU_FEATURE_ACPI       22
+#define CPU_FEATURE_MMX                23
+#define CPU_FEATURE_FXSR       24
+#define CPU_FEATURE_SSE                25
+#define CPU_FEATURE_SSE2       26
+#define CPU_FEATURE_SS         27
+#define CPU_FEATURE_HTT                28
+#define CPU_FEATURE_TM         29
+#define CPU_FEATURE_PBE                31
+
+#define CPU_HAS_FEATURE(feature) (cpu_feature[(feature) / 32] & (1 << 
((feature) % 32)))
+
 #endif /* _MACHINE__LOCORE_H_ */
 
Index: i386/i386/locore.S
===================================================================
RCS file: /cvsroot/hurd/gnumach/i386/i386/locore.S,v
retrieving revision 1.6.2.6
diff -u -p -r1.6.2.6 locore.S
--- i386/i386/locore.S  5 Nov 2006 19:55:48 -0000       1.6.2.6
+++ i386/i386/locore.S  19 Dec 2006 10:17:09 -0000
@@ -1136,6 +1136,11 @@ syscall_addr:
        jmp     _take_trap              /* treat as a trap */
 
 
+       .data
+DATA(cpu_features)
+       .long   0
+       .text
+
 /* Discover what kind of cpu we have; return the family number
    (3, 4, 5, 6, for 386, 486, 586, 686 respectively).  */
 ENTRY(discover_x86_cpu_type)
@@ -1172,6 +1177,7 @@ ENTRY(discover_x86_cpu_type)
           use it to find out what we are. */
 0:     movl    $1,%eax                 /* Fetch CPU type info ... */
        cpuid                           /*  ... into eax */
+       movl    %edx,cpu_features       /* Keep a copy */
        shrl    $8,%eax                 /* Slide family bits down */
        andl    $15,%eax                /* And select them */
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]