Check for IDIVA/IDIVT correctly. Cortex-A5 parts would have had this set since it supports VFPv4 but not IDIVA. Qualcomm Krait/Krait 300 still doesn't report in the kernel that it supports this.

This commit is contained in:
Ryan Houdek 2013-07-16 01:22:06 -05:00
parent 4c807fa7b4
commit 9123f58bd5

View file

@ -44,6 +44,56 @@ char *GetCPUString()
} }
return cpu_string; return cpu_string;
} }
unsigned char GetCPUImplementer()
{
const char marker[] = "CPU implementer\t: ";
char *implementer_string = 0;
unsigned char implementer = 0;
char buf[1024];
File::IOFile file(procfile, "r");
auto const fp = file.GetHandle();
if (!fp)
return 0;
while (fgets(buf, sizeof(buf), fp))
{
if (strncmp(buf, marker, sizeof(marker) - 1))
continue;
implementer_string = buf + sizeof(marker) - 1;
implementer_string = strndup(implementer_string, strlen(implementer_string) - 1); // Strip the newline
sscanf(implementer_string, "0x%02hhx", &implementer);
break;
}
return implementer;
}
unsigned short GetCPUPart()
{
const char marker[] = "CPU part\t: ";
char *part_string = 0;
unsigned short part = 0;
char buf[1024];
File::IOFile file(procfile, "r");
auto const fp = file.GetHandle();
if (!fp)
return 0;
while (fgets(buf, sizeof(buf), fp))
{
if (strncmp(buf, marker, sizeof(marker) - 1))
continue;
part_string = buf + sizeof(marker) - 1;
part_string = strndup(part_string, strlen(part_string) - 1); // Strip the newline
sscanf(part_string, "0x%03hx", &part);
break;
}
return part;
}
bool CheckCPUFeature(const char *feature) bool CheckCPUFeature(const char *feature)
{ {
const char marker[] = "Features\t: "; const char marker[] = "Features\t: ";
@ -123,9 +173,8 @@ void CPUInfo::Detect()
bIDIVa = CheckCPUFeature("idiva"); bIDIVa = CheckCPUFeature("idiva");
bIDIVt = CheckCPUFeature("idivt"); bIDIVt = CheckCPUFeature("idivt");
// On some buggy kernels(Qualcomm) they show that they support VFPv4 but not IDIVa // Qualcomm Krait supports IDIVA but it doesn't report it. Check for krait.
// All VFPv4 CPUs will support IDIVa if (GetCPUImplementer() == 0x51 && GetCPUPart() == 0x6F) // Krait(300) is 0x6F, Scorpion is 0x4D
if (bVFPv4)
bIDIVa = bIDIVt = true; bIDIVa = bIDIVt = true;
// These two are ARMv8 specific. // These two are ARMv8 specific.