From 78ce18f5cf9f0a3ed0f38c4b0d74e0b53aca4f89 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Mon, 6 Jan 2020 20:26:52 +0000 Subject: [PATCH] riscos: Add CPU feature detection --- src/cpuinfo/SDL_cpuinfo.c | 51 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 7819f37e73a59..faf4e60ea1c8f 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -90,6 +90,11 @@ #endif #endif +#ifdef __RISCOS__ +#include +#include +#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;