riscos: Add CPU feature detection

This commit is contained in:
Cameron Cawley 2020-01-06 20:26:52 +00:00
parent eb3d39bc8b
commit 78ce18f5cf
1 changed files with 49 additions and 2 deletions

View File

@ -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, &regs, &regs) != NULL)
return 0;
if (!(regs.r[0] & (1<<31)))
return 0;
regs.r[0] = 34;
regs.r[1] = 29;
if (_kernel_swi(OS_PlatformFeatures, &regs, &regs) != 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, &regs, &regs) == 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, &regs, &regs) == NULL) {
SDL_SystemRAM = (int)(regs.r[1] * regs.r[2] / (1024 * 1024));
}
}
#endif
#endif
}
return SDL_SystemRAM;