riscos: Add CPU feature detection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c
index 7819f37..faf4e60 100644
--- a/src/cpuinfo/SDL_cpuinfo.c
+++ b/src/cpuinfo/SDL_cpuinfo.c
@@ -90,6 +90,11 @@
#endif
#endif
+#ifdef __RISCOS__
+#include <kernel.h>
+#include <swis.h>
+#endif
+
#define CPU_HAS_RDTSC (1 << 0)
#define CPU_HAS_ALTIVEC (1 << 1)
#define CPU_HAS_MMX (1 << 2)
@@ -333,7 +338,7 @@ CPU_haveAltiVec(void)
return altivec;
}
-#if !defined(__ARM_ARCH)
+#if !defined(__arm__)
static int
CPU_haveARMSIMD(void)
{
@@ -373,6 +378,27 @@ CPU_haveARMSIMD(void)
return arm_simd;
}
+#elif defined(__RISCOS__)
+
+static int
+CPU_haveARMSIMD(void)
+{
+ _kernel_swi_regs regs;
+ regs.r[0] = 0;
+ if (_kernel_swi(OS_PlatformFeatures, ®s, ®s) != NULL)
+ return 0;
+
+ if (!(regs.r[0] & (1<<31)))
+ return 0;
+
+ regs.r[0] = 34;
+ regs.r[1] = 29;
+ if (_kernel_swi(OS_PlatformFeatures, ®s, ®s) != NULL)
+ return 0;
+
+ return regs.r[0];
+}
+
#else
static int
CPU_haveARMSIMD(void)
@@ -419,7 +445,7 @@ CPU_haveNEON(void)
# endif
/* All WinRT ARM devices are required to support NEON, but just in case. */
return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
-#elif !defined(__ARM_ARCH)
+#elif !defined(__arm__)
return 0; /* not an ARM CPU at all. */
#elif __ARM_ARCH >= 8
return 1; /* ARMv8 always has non-optional NEON support. */
@@ -446,6 +472,18 @@ CPU_haveNEON(void)
}
return 0;
}
+#elif defined(__RISCOS__)
+ /* Use the VFPSupport_Features SWI to access the MVFR registers */
+ {
+ _kernel_swi_regs regs;
+ regs.r[0] = 0;
+ if (_kernel_swi(VFPSupport_Features, ®s, ®s) == NULL) {
+ if ((regs.r[2] & 0xFFF000) == 0x111000) {
+ return 1;
+ }
+ }
+ return 0;
+ }
#else
#warning SDL_HasNEON is not implemented for this ARM platform. Write me.
return 0;
@@ -871,6 +909,15 @@ SDL_GetSystemRAM(void)
SDL_SystemRAM = (int) (sysram / 0x100000U);
}
#endif
+#ifdef __RISCOS__
+ if (SDL_SystemRAM <= 0) {
+ _kernel_swi_regs regs;
+ regs.r[0] = 0x108;
+ if (_kernel_swi(OS_Memory, ®s, ®s) == NULL) {
+ SDL_SystemRAM = (int)(regs.r[1] * regs.r[2] / (1024 * 1024));
+ }
+ }
+#endif
#endif
}
return SDL_SystemRAM;