Subversion Repositories HelenOS

Rev

Rev 2787 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2787 Rev 4377
Line 33... Line 33...
33
 */
33
 */
34
 
34
 
35
#ifndef KERN_ia32_CPUID_H_
35
#ifndef KERN_ia32_CPUID_H_
36
#define KERN_ia32_CPUID_H_
36
#define KERN_ia32_CPUID_H_
37
 
37
 
-
 
38
#define INTEL_CPUID_LEVEL     0x00000000
-
 
39
#define INTEL_CPUID_STANDARD  0x00000001
-
 
40
#define INTEL_PSE             3
-
 
41
#define INTEL_SEP             11
-
 
42
 
-
 
43
#ifndef __ASM__
-
 
44
 
38
#include <arch/types.h>
45
#include <arch/types.h>
39
 
46
 
40
typedef struct {
47
typedef struct {
41
    uint32_t cpuid_eax;
48
    uint32_t cpuid_eax;
42
    uint32_t cpuid_ebx;
49
    uint32_t cpuid_ebx;
Line 72... Line 79...
72
static inline uint32_t has_cpuid(void)
79
static inline uint32_t has_cpuid(void)
73
{
80
{
74
    uint32_t val, ret;
81
    uint32_t val, ret;
75
   
82
   
76
    asm volatile (
83
    asm volatile (
77
        "pushf\n"               /* read flags */
84
        "pushf\n"                    /* read flags */
78
        "popl %0\n"
85
        "popl %[ret]\n"
79
        "movl %0, %1\n"
86
        "movl %[ret], %[val]\n"
80
       
87
       
81
        "btcl $21, %1\n"        /* swap the ID bit */
88
        "btcl $21, %[val]\n"         /* swap the ID bit */
82
       
89
       
83
        "pushl %1\n"            /* propagate the change into flags */
90
        "pushl %[val]\n"             /* propagate the change into flags */
84
        "popf\n"
91
        "popf\n"
85
        "pushf\n"
92
        "pushf\n"
86
        "popl %1\n"
93
        "popl %[val]\n"
87
       
94
       
88
        "andl $(1 << 21), %0\n" /* interrested only in ID bit */
95
        "andl $(1 << 21), %[ret]\n"  /* interrested only in ID bit */
89
        "andl $(1 << 21), %1\n"
96
        "andl $(1 << 21), %[val]\n"
90
        "xorl %1, %0\n"
97
        "xorl %[val], %[ret]\n"
91
        : "=r" (ret), "=r" (val)
98
        : [ret] "=r" (ret), [val] "=r" (val)
92
    );
99
    );
93
   
100
   
94
    return ret;
101
    return ret;
95
}
102
}
96
 
103
 
97
static inline void cpuid(uint32_t cmd, cpu_info_t *info)
104
static inline void cpuid(uint32_t cmd, cpu_info_t *info)
98
{
105
{
99
    asm volatile (
106
    asm volatile (
100
        "cpuid\n"
107
        "cpuid\n"
101
        : "=a" (info->cpuid_eax), "=b" (info->cpuid_ebx), "=c" (info->cpuid_ecx), "=d" (info->cpuid_edx)
108
        : "=a" (info->cpuid_eax), "=b" (info->cpuid_ebx),
-
 
109
          "=c" (info->cpuid_ecx), "=d" (info->cpuid_edx)
102
        : "a" (cmd)
110
        : "a" (cmd)
103
    );
111
    );
104
}
112
}
105
 
113
 
-
 
114
#endif /* !def __ASM__ */
106
#endif
115
#endif
107
 
116
 
108
/** @}
117
/** @}
109
 */
118
 */