@@ -127,6 +127,42 @@ static inline unsigned int cpuid_edx(unsigned int op)
127
127
return edx ;
128
128
}
129
129
130
+ static inline void __cpuid_read (unsigned int leaf , unsigned int subleaf , u32 * regs )
131
+ {
132
+ regs [CPUID_EAX ] = leaf ;
133
+ regs [CPUID_ECX ] = subleaf ;
134
+ __cpuid (regs + CPUID_EAX , regs + CPUID_EBX , regs + CPUID_ECX , regs + CPUID_EDX );
135
+ }
136
+
137
+ #define cpuid_subleaf (leaf , subleaf , regs ) { \
138
+ static_assert(sizeof(*(regs)) == 16); \
139
+ __cpuid_read(leaf, subleaf, (u32 *)(regs)); \
140
+ }
141
+
142
+ #define cpuid_leaf (leaf , regs ) { \
143
+ static_assert(sizeof(*(regs)) == 16); \
144
+ __cpuid_read(leaf, 0, (u32 *)(regs)); \
145
+ }
146
+
147
+ static inline void __cpuid_read_reg (unsigned int leaf , unsigned int subleaf ,
148
+ enum cpuid_regs_idx regidx , u32 * reg )
149
+ {
150
+ u32 regs [4 ];
151
+
152
+ __cpuid_read (leaf , subleaf , regs );
153
+ * reg = regs [regidx ];
154
+ }
155
+
156
+ #define cpuid_subleaf_reg (leaf , subleaf , regidx , reg ) { \
157
+ static_assert(sizeof(*(reg)) == 4); \
158
+ __cpuid_read_reg(leaf, subleaf, regidx, (u32 *)(reg)); \
159
+ }
160
+
161
+ #define cpuid_leaf_reg (leaf , regidx , reg ) { \
162
+ static_assert(sizeof(*(reg)) == 4); \
163
+ __cpuid_read_reg(leaf, 0, regidx, (u32 *)(reg)); \
164
+ }
165
+
130
166
static __always_inline bool cpuid_function_is_indexed (u32 function )
131
167
{
132
168
switch (function ) {
0 commit comments