From 8d39bb60cd946b27b824cdb3b0556cd47e67cf98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Mon, 2 Apr 2007 13:57:27 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20d=C3=A9claration=20de=20fonctions=20aya?= =?UTF-8?q?nt=20rapport=20avec=20la=20d=C3=A9tection=20du=20CPU?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/cpuid.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 include/cpuid.h diff --git a/include/cpuid.h b/include/cpuid.h new file mode 100644 index 0000000..bde58ca --- /dev/null +++ b/include/cpuid.h @@ -0,0 +1,24 @@ + +inline bool cansetflag (u32 flag) +{ +u32 r1, r2; +asm("pushfl\n" +"popl %0\n" +"movl %0, %1\n" +"xorl %2, %0\n" +"pushl %0\n" +"popfl\n" +"pushfl\n" +"popl %0\n" +"pushl %1\n" +"popfl\n" +: "=&r" (r1), "=&r" (r2) +: "ir" (flag) +); +return ((r1 ^ r2) & flag) != 0; +} + +inline void cpuid(u32 op, u32 *eax, u32 *ebx,u32 *ecx, u32 *edx) +{ + asm("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (op) : "cc"); +}