/* $ gcc arm-fpu.c $ ./a.out machdep.fpu_present=1 machdep.fpu_id=0x410120b5 machdep.neon_present=0 FPU model=VFP11 Raspberry Pi 1 */ #include #include #include #include #include int main(int argc, char **argv) { int fpu_present; uint32_t fpu_id; int neon_present; const char *model = NULL; size_t len; len = sizeof(fpu_present); if (sysctlbyname("machdep.fpu_present", &fpu_present, &len, NULL, 0) < 0) abort(); printf("machdep.fpu_present=%d\n", fpu_present); if (fpu_present == 0) return 0; len = sizeof(fpu_id); if (sysctlbyname("machdep.fpu_id", &fpu_id, &len, NULL, 0) < 0) abort(); printf("machdep.fpu_id=%#x\n", fpu_id); len = sizeof(neon_present); if (sysctlbyname("machdep.neon_present", &neon_present, &len, NULL, 0) < 0) abort(); printf("machdep.neon_present=%d\n", neon_present); switch (fpu_id & ~ VFP_FPSID_REV_MSK) { case FPU_VFP10_ARM10E: model = "VFP10 R1"; break; case FPU_VFP11_ARM11: model = "VFP11"; break; case FPU_VFP_MV88SV58XX: model = "VFP3"; break; case FPU_VFP_CORTEXA5: case FPU_VFP_CORTEXA7: case FPU_VFP_CORTEXA8: case FPU_VFP_CORTEXA9: #ifdef FPU_VFP_CORTEXA12 case FPU_VFP_CORTEXA12: #endif case FPU_VFP_CORTEXA15: case FPU_VFP_CORTEXA15_QEMU: #ifdef FPU_VFP_CORTEXA17 case FPU_VFP_CORTEXA17: #endif case FPU_VFP_CORTEXA53: case FPU_VFP_CORTEXA57: if (!neon_present) { model = "VFP 4.0+"; } else { model = "NEON MPE (VFP 3.0+)"; } break; default: model = "unrecognized VFP version"; } printf("FPU model=%s\n", model); return 0; }