提交 c5877911 编写于 作者: P PMheart

User: Fix CPUID on non-x86 platforms

closes https://github.com/acidanthera/bugtracker/issues/1421
上级 98270188
......@@ -45,35 +45,60 @@ EnableInterrupts (
UINT32
AsmCpuid (
UINT32 Index,
UINT32 *Eax,
UINT32 *Ebx,
UINT32 *Ecx,
UINT32 *Edx
IN UINT32 Index,
OUT UINT32 *Eax, OPTIONAL
OUT UINT32 *Ebx, OPTIONAL
OUT UINT32 *Ecx, OPTIONAL
OUT UINT32 *Edx OPTIONAL
)
{
UINT32 eax = 0, ebx = 0, ecx = 0, edx = 0;
#if defined(__i386__) || defined(__x86_64__)
UINT32 EaxVal;
UINT32 EbxVal;
UINT32 EcxVal;
UINT32 EdxVal;
EaxVal = 0;
EbxVal = 0;
EcxVal = 0;
EdxVal = 0;
asm (
"cpuid\n"
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
: "=a" (EaxVal), "=b" (EbxVal), "=c" (EcxVal), "=d" (EdxVal)
: "0" (Index)
);
if (Eax) {
*Eax = eax;
if (Eax != NULL) {
*Eax = EaxVal;
}
if (Ebx) {
*Ebx = ebx;
if (Ebx != NULL) {
*Ebx = EbxVal;
}
if (Ecx) {
*Ecx = ecx;
if (Ecx != NULL) {
*Ecx = EcxVal;
}
if (Edx) {
*Edx = edx;
if (Edx != NULL) {
*Edx = EdxVal;
}
return Index;
#else
if (Eax != NULL) {
*Eax = 0;
}
if (Ebx != NULL) {
*Ebx = 0;
}
if (Ecx != NULL) {
*Ecx = 0;
}
if (Edx != NULL) {
*Edx = 0;
}
return 0;
#endif
}
UINT32
......@@ -86,29 +111,54 @@ AsmCpuidEx (
OUT UINT32 *Edx OPTIONAL
)
{
UINT32 eax = 0, ebx = 0, ecx = 0, edx = 0;
#if defined(__i386__) || defined(__x86_64__)
UINT32 EaxVal;
UINT32 EbxVal;
UINT32 EcxVal;
UINT32 EdxVal;
EaxVal = 0;
EbxVal = 0;
EcxVal = 0;
EdxVal = 0;
asm (
"cpuid\n"
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
: "=a" (EaxVal), "=b" (EbxVal), "=c" (EcxVal), "=d" (EdxVal)
: "0" (Index),
"2" (SubIndex)
);
if (Eax) {
*Eax = eax;
if (Eax != NULL) {
*Eax = EaxVal;
}
if (Ebx) {
*Ebx = ebx;
if (Ebx != NULL) {
*Ebx = EbxVal;
}
if (Ecx) {
*Ecx = ecx;
if (Ecx != NULL) {
*Ecx = EcxVal;
}
if (Edx) {
*Edx = edx;
if (Edx != NULL) {
*Edx = EdxVal;
}
return Index;
#else
if (Eax != NULL) {
*Eax = 0;
}
if (Ebx != NULL) {
*Ebx = 0;
}
if (Ecx != NULL) {
*Ecx = 0;
}
if (Edx != NULL) {
*Edx = 0;
}
return 0;
#endif
}
UINT32
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册